OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "ash/root_window_controller.h" | 5 #include "ash/root_window_controller.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <queue> | 8 #include <queue> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
11 #include "ash/ash_constants.h" | 11 #include "ash/ash_constants.h" |
12 #include "ash/ash_switches.h" | 12 #include "ash/ash_switches.h" |
13 #include "ash/ash_touch_exploration_manager_chromeos.h" | 13 #include "ash/ash_touch_exploration_manager_chromeos.h" |
14 #include "ash/aura/aura_layout_manager_adapter.h" | 14 #include "ash/aura/aura_layout_manager_adapter.h" |
15 #include "ash/focus_cycler.h" | 15 #include "ash/focus_cycler.h" |
16 #include "ash/high_contrast/high_contrast_controller.h" | 16 #include "ash/high_contrast/high_contrast_controller.h" |
17 #include "ash/host/ash_window_tree_host.h" | 17 #include "ash/host/ash_window_tree_host.h" |
18 #include "ash/login_status.h" | 18 #include "ash/login_status.h" |
19 #include "ash/public/cpp/config.h" | 19 #include "ash/public/cpp/config.h" |
20 #include "ash/public/cpp/shelf_types.h" | 20 #include "ash/public/cpp/shelf_types.h" |
21 #include "ash/public/cpp/shell_window_ids.h" | 21 #include "ash/public/cpp/shell_window_ids.h" |
22 #include "ash/root_window_settings.h" | 22 #include "ash/root_window_settings.h" |
| 23 #include "ash/screen_util.h" |
23 #include "ash/session/session_controller.h" | 24 #include "ash/session/session_controller.h" |
24 #include "ash/shelf/shelf_delegate.h" | 25 #include "ash/shelf/shelf_delegate.h" |
25 #include "ash/shelf/shelf_layout_manager.h" | 26 #include "ash/shelf/shelf_layout_manager.h" |
26 #include "ash/shelf/shelf_widget.h" | 27 #include "ash/shelf/shelf_widget.h" |
27 #include "ash/shelf/shelf_window_targeter.h" | 28 #include "ash/shelf/shelf_window_targeter.h" |
28 #include "ash/shelf/wm_shelf.h" | 29 #include "ash/shelf/wm_shelf.h" |
29 #include "ash/shell.h" | 30 #include "ash/shell.h" |
30 #include "ash/shell_delegate.h" | 31 #include "ash/shell_delegate.h" |
31 #include "ash/shell_port.h" | 32 #include "ash/shell_port.h" |
32 #include "ash/system/status_area_layout_manager.h" | 33 #include "ash/system/status_area_layout_manager.h" |
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
157 void MoveOriginRelativeToSize(const gfx::Size& src_size, | 158 void MoveOriginRelativeToSize(const gfx::Size& src_size, |
158 const gfx::Size& dst_size, | 159 const gfx::Size& dst_size, |
159 gfx::Rect* bounds_in_out) { | 160 gfx::Rect* bounds_in_out) { |
160 gfx::Point origin = bounds_in_out->origin(); | 161 gfx::Point origin = bounds_in_out->origin(); |
161 bounds_in_out->set_origin(gfx::Point( | 162 bounds_in_out->set_origin(gfx::Point( |
162 ToRelativeValue(origin.x(), src_size.width(), dst_size.width()), | 163 ToRelativeValue(origin.x(), src_size.width(), dst_size.width()), |
163 ToRelativeValue(origin.y(), src_size.height(), dst_size.height()))); | 164 ToRelativeValue(origin.y(), src_size.height(), dst_size.height()))); |
164 } | 165 } |
165 | 166 |
166 // Reparents |window| to |new_parent|. | 167 // Reparents |window| to |new_parent|. |
167 // TODO(sky): This should take an aura::Window. http://crbug.com/671246. | 168 void ReparentWindow(aura::Window* window, aura::Window* new_parent) { |
168 void ReparentWindow(WmWindow* window, WmWindow* new_parent) { | 169 const gfx::Size src_size = window->parent()->bounds().size(); |
169 const gfx::Size src_size = window->GetParent()->GetBounds().size(); | 170 const gfx::Size dst_size = new_parent->bounds().size(); |
170 const gfx::Size dst_size = new_parent->GetBounds().size(); | |
171 // Update the restore bounds to make it relative to the display. | 171 // Update the restore bounds to make it relative to the display. |
172 wm::WindowState* state = window->GetWindowState(); | 172 wm::WindowState* state = wm::GetWindowState(window); |
173 gfx::Rect restore_bounds; | 173 gfx::Rect restore_bounds; |
174 const bool has_restore_bounds = state->HasRestoreBounds(); | 174 const bool has_restore_bounds = state->HasRestoreBounds(); |
175 | 175 |
176 const bool update_bounds = state->IsNormalOrSnapped() || state->IsMinimized(); | 176 const bool update_bounds = state->IsNormalOrSnapped() || state->IsMinimized(); |
177 gfx::Rect work_area_in_new_parent = | 177 gfx::Rect work_area_in_new_parent = |
178 wm::GetDisplayWorkAreaBoundsInParent(new_parent); | 178 ScreenUtil::GetDisplayWorkAreaBoundsInParent(new_parent); |
179 | 179 |
180 gfx::Rect local_bounds; | 180 gfx::Rect local_bounds; |
181 if (update_bounds) { | 181 if (update_bounds) { |
182 local_bounds = state->window()->GetBounds(); | 182 local_bounds = state->window()->GetBounds(); |
183 MoveOriginRelativeToSize(src_size, dst_size, &local_bounds); | 183 MoveOriginRelativeToSize(src_size, dst_size, &local_bounds); |
184 local_bounds.AdjustToFit(work_area_in_new_parent); | 184 local_bounds.AdjustToFit(work_area_in_new_parent); |
185 } | 185 } |
186 | 186 |
187 if (has_restore_bounds) { | 187 if (has_restore_bounds) { |
188 restore_bounds = state->GetRestoreBoundsInParent(); | 188 restore_bounds = state->GetRestoreBoundsInParent(); |
189 MoveOriginRelativeToSize(src_size, dst_size, &restore_bounds); | 189 MoveOriginRelativeToSize(src_size, dst_size, &restore_bounds); |
190 restore_bounds.AdjustToFit(work_area_in_new_parent); | 190 restore_bounds.AdjustToFit(work_area_in_new_parent); |
191 } | 191 } |
192 | 192 |
193 new_parent->AddChild(window); | 193 new_parent->AddChild(window); |
194 | 194 |
195 // Docked windows have bounds handled by the layout manager in AddChild(). | 195 // Docked windows have bounds handled by the layout manager in AddChild(). |
196 if (update_bounds) | 196 if (update_bounds) |
197 window->SetBounds(local_bounds); | 197 window->SetBounds(local_bounds); |
198 | 198 |
199 if (has_restore_bounds) | 199 if (has_restore_bounds) |
200 state->SetRestoreBoundsInParent(restore_bounds); | 200 state->SetRestoreBoundsInParent(restore_bounds); |
201 } | 201 } |
202 | 202 |
203 // Reparents the appropriate set of windows from |src| to |dst|. | 203 // Reparents the appropriate set of windows from |src| to |dst|. |
204 // TODO(sky): This should take an aura::Window. http://crbug.com/671246. | 204 void ReparentAllWindows(aura::Window* src, aura::Window* dst) { |
205 void ReparentAllWindows(WmWindow* src, WmWindow* dst) { | |
206 // Set of windows to move. | 205 // Set of windows to move. |
207 const int kContainerIdsToMove[] = { | 206 const int kContainerIdsToMove[] = { |
208 kShellWindowId_DefaultContainer, | 207 kShellWindowId_DefaultContainer, |
209 kShellWindowId_PanelContainer, | 208 kShellWindowId_PanelContainer, |
210 kShellWindowId_AlwaysOnTopContainer, | 209 kShellWindowId_AlwaysOnTopContainer, |
211 kShellWindowId_SystemModalContainer, | 210 kShellWindowId_SystemModalContainer, |
212 kShellWindowId_LockSystemModalContainer, | 211 kShellWindowId_LockSystemModalContainer, |
213 kShellWindowId_UnparentedControlContainer, | 212 kShellWindowId_UnparentedControlContainer, |
214 kShellWindowId_OverlayContainer, | 213 kShellWindowId_OverlayContainer, |
215 }; | 214 }; |
216 const int kExtraContainerIdsToMoveInUnifiedMode[] = { | 215 const int kExtraContainerIdsToMoveInUnifiedMode[] = { |
217 kShellWindowId_LockScreenContainer, | 216 kShellWindowId_LockScreenContainer, |
218 kShellWindowId_LockScreenWallpaperContainer, | 217 kShellWindowId_LockScreenWallpaperContainer, |
219 }; | 218 }; |
220 std::vector<int> container_ids( | 219 std::vector<int> container_ids( |
221 kContainerIdsToMove, | 220 kContainerIdsToMove, |
222 kContainerIdsToMove + arraysize(kContainerIdsToMove)); | 221 kContainerIdsToMove + arraysize(kContainerIdsToMove)); |
223 // Check the display mode as this is also necessary when trasitioning between | 222 // Check the display mode as this is also necessary when trasitioning between |
224 // mirror and unified mode. | 223 // mirror and unified mode. |
225 if (ShellPort::Get()->IsInUnifiedModeIgnoreMirroring()) { | 224 if (ShellPort::Get()->IsInUnifiedModeIgnoreMirroring()) { |
226 for (int id : kExtraContainerIdsToMoveInUnifiedMode) | 225 for (int id : kExtraContainerIdsToMoveInUnifiedMode) |
227 container_ids.push_back(id); | 226 container_ids.push_back(id); |
228 } | 227 } |
229 | 228 |
230 for (int id : container_ids) { | 229 for (int id : container_ids) { |
231 WmWindow* src_container = src->GetChildByShellWindowId(id); | 230 aura::Window* src_container = src->GetChildById(id); |
232 WmWindow* dst_container = dst->GetChildByShellWindowId(id); | 231 aura::Window* dst_container = dst->GetChildById(id); |
233 while (!src_container->GetChildren().empty()) { | 232 while (!src_container->children().empty()) { |
234 // Restart iteration from the source container windows each time as they | 233 // Restart iteration from the source container windows each time as they |
235 // may change as a result of moving other windows. | 234 // may change as a result of moving other windows. |
236 WmWindow::Windows src_container_children = src_container->GetChildren(); | 235 const aura::Window::Windows& src_container_children = |
237 WmWindow::Windows::const_iterator iter = src_container_children.begin(); | 236 src_container->children(); |
| 237 auto iter = src_container_children.begin(); |
238 while (iter != src_container_children.end() && | 238 while (iter != src_container_children.end() && |
239 SystemModalContainerLayoutManager::IsModalBackground(*iter)) { | 239 SystemModalContainerLayoutManager::IsModalBackground( |
| 240 WmWindow::Get(*iter))) { |
240 ++iter; | 241 ++iter; |
241 } | 242 } |
242 // If the entire window list is modal background windows then stop. | 243 // If the entire window list is modal background windows then stop. |
243 if (iter == src_container_children.end()) | 244 if (iter == src_container_children.end()) |
244 break; | 245 break; |
245 ReparentWindow(*iter, dst_container); | 246 ReparentWindow(*iter, dst_container); |
246 } | 247 } |
247 } | 248 } |
248 } | 249 } |
249 | 250 |
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
382 | 383 |
383 ShelfLayoutManager* RootWindowController::GetShelfLayoutManager() { | 384 ShelfLayoutManager* RootWindowController::GetShelfLayoutManager() { |
384 return wm_shelf_->shelf_layout_manager(); | 385 return wm_shelf_->shelf_layout_manager(); |
385 } | 386 } |
386 | 387 |
387 SystemModalContainerLayoutManager* | 388 SystemModalContainerLayoutManager* |
388 RootWindowController::GetSystemModalLayoutManager(WmWindow* window) { | 389 RootWindowController::GetSystemModalLayoutManager(WmWindow* window) { |
389 WmWindow* modal_container = nullptr; | 390 WmWindow* modal_container = nullptr; |
390 if (window) { | 391 if (window) { |
391 WmWindow* window_container = wm::GetContainerForWindow(window); | 392 WmWindow* window_container = wm::GetContainerForWindow(window); |
392 if (window_container && | 393 if (window_container && window_container->aura_window()->id() >= |
393 window_container->GetShellWindowId() >= | 394 kShellWindowId_LockScreenContainer) { |
394 kShellWindowId_LockScreenContainer) { | |
395 modal_container = GetWmContainer(kShellWindowId_LockSystemModalContainer); | 395 modal_container = GetWmContainer(kShellWindowId_LockSystemModalContainer); |
396 } else { | 396 } else { |
397 modal_container = GetWmContainer(kShellWindowId_SystemModalContainer); | 397 modal_container = GetWmContainer(kShellWindowId_SystemModalContainer); |
398 } | 398 } |
399 } else { | 399 } else { |
400 int modal_window_id = | 400 int modal_window_id = |
401 Shell::Get()->session_controller()->IsUserSessionBlocked() | 401 Shell::Get()->session_controller()->IsUserSessionBlocked() |
402 ? kShellWindowId_LockSystemModalContainer | 402 ? kShellWindowId_LockSystemModalContainer |
403 : kShellWindowId_SystemModalContainer; | 403 : kShellWindowId_SystemModalContainer; |
404 modal_container = GetWmContainer(modal_window_id); | 404 modal_container = GetWmContainer(modal_window_id); |
(...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
611 if (shelf->IsShelfInitialized()) | 611 if (shelf->IsShelfInitialized()) |
612 shelf->ShutdownShelf(); | 612 shelf->ShutdownShelf(); |
613 | 613 |
614 aura::client::SetDragDropClient(GetRootWindow(), nullptr); | 614 aura::client::SetDragDropClient(GetRootWindow(), nullptr); |
615 aura::client::SetTooltipClient(GetRootWindow(), nullptr); | 615 aura::client::SetTooltipClient(GetRootWindow(), nullptr); |
616 } | 616 } |
617 | 617 |
618 void RootWindowController::MoveWindowsTo(aura::Window* dst) { | 618 void RootWindowController::MoveWindowsTo(aura::Window* dst) { |
619 // Clear the workspace controller, so it doesn't incorrectly update the shelf. | 619 // Clear the workspace controller, so it doesn't incorrectly update the shelf. |
620 workspace_controller_.reset(); | 620 workspace_controller_.reset(); |
621 ReparentAllWindows(GetWindow(), WmWindow::Get(dst)); | 621 ReparentAllWindows(GetRootWindow(), dst); |
622 } | 622 } |
623 | 623 |
624 void RootWindowController::UpdateShelfVisibility() { | 624 void RootWindowController::UpdateShelfVisibility() { |
625 wm_shelf_->UpdateVisibilityState(); | 625 wm_shelf_->UpdateVisibilityState(); |
626 } | 626 } |
627 | 627 |
628 void RootWindowController::InitTouchHuds() { | 628 void RootWindowController::InitTouchHuds() { |
629 if (Shell::GetAshConfig() == Config::MASH) | 629 if (Shell::GetAshConfig() == Config::MASH) |
630 return; | 630 return; |
631 | 631 |
(...skipping 469 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1101 EnableTouchHudProjection(); | 1101 EnableTouchHudProjection(); |
1102 else | 1102 else |
1103 DisableTouchHudProjection(); | 1103 DisableTouchHudProjection(); |
1104 } | 1104 } |
1105 | 1105 |
1106 RootWindowController* GetRootWindowController(const aura::Window* root_window) { | 1106 RootWindowController* GetRootWindowController(const aura::Window* root_window) { |
1107 return root_window ? GetRootWindowSettings(root_window)->controller : nullptr; | 1107 return root_window ? GetRootWindowSettings(root_window)->controller : nullptr; |
1108 } | 1108 } |
1109 | 1109 |
1110 } // namespace ash | 1110 } // namespace ash |
OLD | NEW |