 Chromium Code Reviews
 Chromium Code Reviews Issue 2814243002:
  Removes a couple more functions from WmWindow  (Closed)
    
  
    Issue 2814243002:
  Removes a couple more functions from WmWindow  (Closed) 
  | 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 // TODO(sky): This should take an aura::Window. http://crbug.com/671246. | 
| 
msw
2017/04/12 22:12:50
nit: remove todo
 
sky
2017/04/12 22:35:04
Done.
 | |
| 205 void ReparentAllWindows(WmWindow* src, WmWindow* dst) { | 205 void ReparentAllWindows(aura::Window* src, aura::Window* dst) { | 
| 206 // Set of windows to move. | 206 // Set of windows to move. | 
| 207 const int kContainerIdsToMove[] = { | 207 const int kContainerIdsToMove[] = { | 
| 208 kShellWindowId_DefaultContainer, | 208 kShellWindowId_DefaultContainer, | 
| 209 kShellWindowId_PanelContainer, | 209 kShellWindowId_PanelContainer, | 
| 210 kShellWindowId_AlwaysOnTopContainer, | 210 kShellWindowId_AlwaysOnTopContainer, | 
| 211 kShellWindowId_SystemModalContainer, | 211 kShellWindowId_SystemModalContainer, | 
| 212 kShellWindowId_LockSystemModalContainer, | 212 kShellWindowId_LockSystemModalContainer, | 
| 213 kShellWindowId_UnparentedControlContainer, | 213 kShellWindowId_UnparentedControlContainer, | 
| 214 kShellWindowId_OverlayContainer, | 214 kShellWindowId_OverlayContainer, | 
| 215 }; | 215 }; | 
| 216 const int kExtraContainerIdsToMoveInUnifiedMode[] = { | 216 const int kExtraContainerIdsToMoveInUnifiedMode[] = { | 
| 217 kShellWindowId_LockScreenContainer, | 217 kShellWindowId_LockScreenContainer, | 
| 218 kShellWindowId_LockScreenWallpaperContainer, | 218 kShellWindowId_LockScreenWallpaperContainer, | 
| 219 }; | 219 }; | 
| 220 std::vector<int> container_ids( | 220 std::vector<int> container_ids( | 
| 221 kContainerIdsToMove, | 221 kContainerIdsToMove, | 
| 222 kContainerIdsToMove + arraysize(kContainerIdsToMove)); | 222 kContainerIdsToMove + arraysize(kContainerIdsToMove)); | 
| 223 // Check the display mode as this is also necessary when trasitioning between | 223 // Check the display mode as this is also necessary when trasitioning between | 
| 224 // mirror and unified mode. | 224 // mirror and unified mode. | 
| 225 if (ShellPort::Get()->IsInUnifiedModeIgnoreMirroring()) { | 225 if (ShellPort::Get()->IsInUnifiedModeIgnoreMirroring()) { | 
| 226 for (int id : kExtraContainerIdsToMoveInUnifiedMode) | 226 for (int id : kExtraContainerIdsToMoveInUnifiedMode) | 
| 227 container_ids.push_back(id); | 227 container_ids.push_back(id); | 
| 228 } | 228 } | 
| 229 | 229 | 
| 230 for (int id : container_ids) { | 230 for (int id : container_ids) { | 
| 231 WmWindow* src_container = src->GetChildByShellWindowId(id); | 231 aura::Window* src_container = src->GetChildById(id); | 
| 232 WmWindow* dst_container = dst->GetChildByShellWindowId(id); | 232 aura::Window* dst_container = dst->GetChildById(id); | 
| 233 while (!src_container->GetChildren().empty()) { | 233 while (!src_container->children().empty()) { | 
| 234 // Restart iteration from the source container windows each time as they | 234 // Restart iteration from the source container windows each time as they | 
| 235 // may change as a result of moving other windows. | 235 // may change as a result of moving other windows. | 
| 236 WmWindow::Windows src_container_children = src_container->GetChildren(); | 236 const aura::Window::Windows& src_container_children = | 
| 237 WmWindow::Windows::const_iterator iter = src_container_children.begin(); | 237 src_container->children(); | 
| 238 auto iter = src_container_children.begin(); | |
| 238 while (iter != src_container_children.end() && | 239 while (iter != src_container_children.end() && | 
| 239 SystemModalContainerLayoutManager::IsModalBackground(*iter)) { | 240 SystemModalContainerLayoutManager::IsModalBackground( | 
| 241 WmWindow::Get(*iter))) { | |
| 240 ++iter; | 242 ++iter; | 
| 241 } | 243 } | 
| 242 // If the entire window list is modal background windows then stop. | 244 // If the entire window list is modal background windows then stop. | 
| 243 if (iter == src_container_children.end()) | 245 if (iter == src_container_children.end()) | 
| 244 break; | 246 break; | 
| 245 ReparentWindow(*iter, dst_container); | 247 ReparentWindow(*iter, dst_container); | 
| 246 } | 248 } | 
| 247 } | 249 } | 
| 248 } | 250 } | 
| 249 | 251 | 
| (...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 382 | 384 | 
| 383 ShelfLayoutManager* RootWindowController::GetShelfLayoutManager() { | 385 ShelfLayoutManager* RootWindowController::GetShelfLayoutManager() { | 
| 384 return wm_shelf_->shelf_layout_manager(); | 386 return wm_shelf_->shelf_layout_manager(); | 
| 385 } | 387 } | 
| 386 | 388 | 
| 387 SystemModalContainerLayoutManager* | 389 SystemModalContainerLayoutManager* | 
| 388 RootWindowController::GetSystemModalLayoutManager(WmWindow* window) { | 390 RootWindowController::GetSystemModalLayoutManager(WmWindow* window) { | 
| 389 WmWindow* modal_container = nullptr; | 391 WmWindow* modal_container = nullptr; | 
| 390 if (window) { | 392 if (window) { | 
| 391 WmWindow* window_container = wm::GetContainerForWindow(window); | 393 WmWindow* window_container = wm::GetContainerForWindow(window); | 
| 392 if (window_container && | 394 if (window_container && window_container->aura_window()->id() >= | 
| 393 window_container->GetShellWindowId() >= | 395 kShellWindowId_LockScreenContainer) { | 
| 394 kShellWindowId_LockScreenContainer) { | |
| 395 modal_container = GetWmContainer(kShellWindowId_LockSystemModalContainer); | 396 modal_container = GetWmContainer(kShellWindowId_LockSystemModalContainer); | 
| 396 } else { | 397 } else { | 
| 397 modal_container = GetWmContainer(kShellWindowId_SystemModalContainer); | 398 modal_container = GetWmContainer(kShellWindowId_SystemModalContainer); | 
| 398 } | 399 } | 
| 399 } else { | 400 } else { | 
| 400 int modal_window_id = | 401 int modal_window_id = | 
| 401 Shell::Get()->session_controller()->IsUserSessionBlocked() | 402 Shell::Get()->session_controller()->IsUserSessionBlocked() | 
| 402 ? kShellWindowId_LockSystemModalContainer | 403 ? kShellWindowId_LockSystemModalContainer | 
| 403 : kShellWindowId_SystemModalContainer; | 404 : kShellWindowId_SystemModalContainer; | 
| 404 modal_container = GetWmContainer(modal_window_id); | 405 modal_container = GetWmContainer(modal_window_id); | 
| (...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 611 if (shelf->IsShelfInitialized()) | 612 if (shelf->IsShelfInitialized()) | 
| 612 shelf->ShutdownShelf(); | 613 shelf->ShutdownShelf(); | 
| 613 | 614 | 
| 614 aura::client::SetDragDropClient(GetRootWindow(), nullptr); | 615 aura::client::SetDragDropClient(GetRootWindow(), nullptr); | 
| 615 aura::client::SetTooltipClient(GetRootWindow(), nullptr); | 616 aura::client::SetTooltipClient(GetRootWindow(), nullptr); | 
| 616 } | 617 } | 
| 617 | 618 | 
| 618 void RootWindowController::MoveWindowsTo(aura::Window* dst) { | 619 void RootWindowController::MoveWindowsTo(aura::Window* dst) { | 
| 619 // Clear the workspace controller, so it doesn't incorrectly update the shelf. | 620 // Clear the workspace controller, so it doesn't incorrectly update the shelf. | 
| 620 workspace_controller_.reset(); | 621 workspace_controller_.reset(); | 
| 621 ReparentAllWindows(GetWindow(), WmWindow::Get(dst)); | 622 ReparentAllWindows(GetRootWindow(), dst); | 
| 622 } | 623 } | 
| 623 | 624 | 
| 624 void RootWindowController::UpdateShelfVisibility() { | 625 void RootWindowController::UpdateShelfVisibility() { | 
| 625 wm_shelf_->UpdateVisibilityState(); | 626 wm_shelf_->UpdateVisibilityState(); | 
| 626 } | 627 } | 
| 627 | 628 | 
| 628 void RootWindowController::InitTouchHuds() { | 629 void RootWindowController::InitTouchHuds() { | 
| 629 if (Shell::GetAshConfig() == Config::MASH) | 630 if (Shell::GetAshConfig() == Config::MASH) | 
| 630 return; | 631 return; | 
| 631 | 632 | 
| (...skipping 469 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1101 EnableTouchHudProjection(); | 1102 EnableTouchHudProjection(); | 
| 1102 else | 1103 else | 
| 1103 DisableTouchHudProjection(); | 1104 DisableTouchHudProjection(); | 
| 1104 } | 1105 } | 
| 1105 | 1106 | 
| 1106 RootWindowController* GetRootWindowController(const aura::Window* root_window) { | 1107 RootWindowController* GetRootWindowController(const aura::Window* root_window) { | 
| 1107 return root_window ? GetRootWindowSettings(root_window)->controller : nullptr; | 1108 return root_window ? GetRootWindowSettings(root_window)->controller : nullptr; | 
| 1108 } | 1109 } | 
| 1109 | 1110 | 
| 1110 } // namespace ash | 1111 } // namespace ash | 
| OLD | NEW |