| 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 <queue> | 7 #include <queue> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "ash/aura/aura_layout_manager_adapter.h" | 10 #include "ash/aura/aura_layout_manager_adapter.h" |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 92 namespace { | 92 namespace { |
| 93 | 93 |
| 94 #if defined(OS_CHROMEOS) | 94 #if defined(OS_CHROMEOS) |
| 95 // Duration for the animation that hides the boot splash screen, in | 95 // Duration for the animation that hides the boot splash screen, in |
| 96 // milliseconds. This should be short enough in relation to | 96 // milliseconds. This should be short enough in relation to |
| 97 // wm/window_animation.cc's brightness/grayscale fade animation that the login | 97 // wm/window_animation.cc's brightness/grayscale fade animation that the login |
| 98 // wallpaper image animation isn't hidden by the splash screen animation. | 98 // wallpaper image animation isn't hidden by the splash screen animation. |
| 99 const int kBootSplashScreenHideDurationMs = 500; | 99 const int kBootSplashScreenHideDurationMs = 500; |
| 100 #endif | 100 #endif |
| 101 | 101 |
| 102 float ToRelativeValue(int value, int src, int dst) { | |
| 103 return static_cast<float>(value) / static_cast<float>(src) * dst; | |
| 104 } | |
| 105 | |
| 106 void MoveOriginRelativeToSize(const gfx::Size& src_size, | |
| 107 const gfx::Size& dst_size, | |
| 108 gfx::Rect* bounds_in_out) { | |
| 109 gfx::Point origin = bounds_in_out->origin(); | |
| 110 bounds_in_out->set_origin(gfx::Point( | |
| 111 ToRelativeValue(origin.x(), src_size.width(), dst_size.width()), | |
| 112 ToRelativeValue(origin.y(), src_size.height(), dst_size.height()))); | |
| 113 } | |
| 114 | |
| 115 // Reparents |window| to |new_parent|. | |
| 116 void ReparentWindow(aura::Window* window, aura::Window* new_parent) { | |
| 117 const gfx::Size src_size = window->parent()->bounds().size(); | |
| 118 const gfx::Size dst_size = new_parent->bounds().size(); | |
| 119 // Update the restore bounds to make it relative to the display. | |
| 120 wm::WindowState* state = wm::GetWindowState(window); | |
| 121 gfx::Rect restore_bounds; | |
| 122 bool has_restore_bounds = state->HasRestoreBounds(); | |
| 123 | |
| 124 bool update_bounds = (state->IsNormalOrSnapped() || state->IsMinimized()) && | |
| 125 new_parent->id() != kShellWindowId_DockedContainer; | |
| 126 gfx::Rect local_bounds; | |
| 127 if (update_bounds) { | |
| 128 local_bounds = WmWindowAura::GetAuraWindow(state->window())->bounds(); | |
| 129 MoveOriginRelativeToSize(src_size, dst_size, &local_bounds); | |
| 130 } | |
| 131 | |
| 132 if (has_restore_bounds) { | |
| 133 restore_bounds = state->GetRestoreBoundsInParent(); | |
| 134 MoveOriginRelativeToSize(src_size, dst_size, &restore_bounds); | |
| 135 } | |
| 136 | |
| 137 new_parent->AddChild(window); | |
| 138 | |
| 139 // Docked windows have bounds handled by the layout manager in AddChild(). | |
| 140 if (update_bounds) | |
| 141 window->SetBounds(local_bounds); | |
| 142 | |
| 143 if (has_restore_bounds) | |
| 144 state->SetRestoreBoundsInParent(restore_bounds); | |
| 145 } | |
| 146 | |
| 147 // Reparents the appropriate set of windows from |src| to |dst|. | |
| 148 void ReparentAllWindows(aura::Window* src, aura::Window* dst) { | |
| 149 // Set of windows to move. | |
| 150 const int kContainerIdsToMove[] = { | |
| 151 kShellWindowId_DefaultContainer, | |
| 152 kShellWindowId_DockedContainer, | |
| 153 kShellWindowId_PanelContainer, | |
| 154 kShellWindowId_AlwaysOnTopContainer, | |
| 155 kShellWindowId_SystemModalContainer, | |
| 156 kShellWindowId_LockSystemModalContainer, | |
| 157 kShellWindowId_UnparentedControlContainer, | |
| 158 kShellWindowId_OverlayContainer, | |
| 159 }; | |
| 160 const int kExtraContainerIdsToMoveInUnifiedMode[] = { | |
| 161 kShellWindowId_LockScreenContainer, | |
| 162 kShellWindowId_LockScreenWallpaperContainer, | |
| 163 }; | |
| 164 std::vector<int> container_ids( | |
| 165 kContainerIdsToMove, | |
| 166 kContainerIdsToMove + arraysize(kContainerIdsToMove)); | |
| 167 // Check the default_multi_display_mode because this is also necessary | |
| 168 // in trasition between mirror <-> unified mode. | |
| 169 if (Shell::GetInstance() | |
| 170 ->display_manager() | |
| 171 ->current_default_multi_display_mode() == DisplayManager::UNIFIED) { | |
| 172 for (int id : kExtraContainerIdsToMoveInUnifiedMode) | |
| 173 container_ids.push_back(id); | |
| 174 } | |
| 175 | |
| 176 for (int id : container_ids) { | |
| 177 aura::Window* src_container = Shell::GetContainer(src, id); | |
| 178 aura::Window* dst_container = Shell::GetContainer(dst, id); | |
| 179 while (!src_container->children().empty()) { | |
| 180 // Restart iteration from the source container windows each time as they | |
| 181 // may change as a result of moving other windows. | |
| 182 aura::Window::Windows::const_iterator iter = | |
| 183 src_container->children().begin(); | |
| 184 while (iter != src_container->children().end() && | |
| 185 SystemModalContainerLayoutManager::IsModalBackground( | |
| 186 WmWindowAura::Get(*iter))) { | |
| 187 ++iter; | |
| 188 } | |
| 189 // If the entire window list is modal background windows then stop. | |
| 190 if (iter == src_container->children().end()) | |
| 191 break; | |
| 192 ReparentWindow(*iter, dst_container); | |
| 193 } | |
| 194 } | |
| 195 } | |
| 196 | |
| 197 bool IsWindowAboveContainer(aura::Window* window, | 102 bool IsWindowAboveContainer(aura::Window* window, |
| 198 aura::Window* blocking_container) { | 103 aura::Window* blocking_container) { |
| 199 std::vector<aura::Window*> target_path; | 104 std::vector<aura::Window*> target_path; |
| 200 std::vector<aura::Window*> blocking_path; | 105 std::vector<aura::Window*> blocking_path; |
| 201 | 106 |
| 202 while (window) { | 107 while (window) { |
| 203 target_path.push_back(window); | 108 target_path.push_back(window); |
| 204 window = window->parent(); | 109 window = window->parent(); |
| 205 } | 110 } |
| 206 | 111 |
| (...skipping 339 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 546 // CloseChildWindows may be called twice during the shutdown of ash unittests. | 451 // CloseChildWindows may be called twice during the shutdown of ash unittests. |
| 547 // Avoid notifying WmShelf that the shelf has been destroyed twice. | 452 // Avoid notifying WmShelf that the shelf has been destroyed twice. |
| 548 if (wm_shelf_aura_->IsShelfInitialized()) | 453 if (wm_shelf_aura_->IsShelfInitialized()) |
| 549 wm_shelf_aura_->ShutdownShelf(); | 454 wm_shelf_aura_->ShutdownShelf(); |
| 550 | 455 |
| 551 aura::client::SetDragDropClient(root_window, nullptr); | 456 aura::client::SetDragDropClient(root_window, nullptr); |
| 552 aura::client::SetTooltipClient(root_window, nullptr); | 457 aura::client::SetTooltipClient(root_window, nullptr); |
| 553 } | 458 } |
| 554 | 459 |
| 555 void RootWindowController::MoveWindowsTo(aura::Window* dst) { | 460 void RootWindowController::MoveWindowsTo(aura::Window* dst) { |
| 556 // Clear the workspace controller, so it doesn't incorrectly update the shelf. | 461 wm_root_window_controller_->MoveWindowsTo(WmWindowAura::Get(dst)); |
| 557 wm_root_window_controller_->DeleteWorkspaceController(); | |
| 558 ReparentAllWindows(GetRootWindow(), dst); | |
| 559 } | 462 } |
| 560 | 463 |
| 561 ShelfLayoutManager* RootWindowController::GetShelfLayoutManager() { | 464 ShelfLayoutManager* RootWindowController::GetShelfLayoutManager() { |
| 562 return wm_shelf_aura_->shelf_layout_manager(); | 465 return wm_shelf_aura_->shelf_layout_manager(); |
| 563 } | 466 } |
| 564 | 467 |
| 565 StatusAreaWidget* RootWindowController::GetStatusAreaWidget() { | 468 StatusAreaWidget* RootWindowController::GetStatusAreaWidget() { |
| 566 ShelfWidget* shelf_widget = wm_shelf_aura_->shelf_widget(); | 469 ShelfWidget* shelf_widget = wm_shelf_aura_->shelf_widget(); |
| 567 return shelf_widget ? shelf_widget->status_area_widget() : nullptr; | 470 return shelf_widget ? shelf_widget->status_area_widget() : nullptr; |
| 568 } | 471 } |
| (...skipping 264 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 833 EnableTouchHudProjection(); | 736 EnableTouchHudProjection(); |
| 834 else | 737 else |
| 835 DisableTouchHudProjection(); | 738 DisableTouchHudProjection(); |
| 836 } | 739 } |
| 837 | 740 |
| 838 RootWindowController* GetRootWindowController(const aura::Window* root_window) { | 741 RootWindowController* GetRootWindowController(const aura::Window* root_window) { |
| 839 return root_window ? GetRootWindowSettings(root_window)->controller : nullptr; | 742 return root_window ? GetRootWindowSettings(root_window)->controller : nullptr; |
| 840 } | 743 } |
| 841 | 744 |
| 842 } // namespace ash | 745 } // namespace ash |
| OLD | NEW |