| 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 |
| (...skipping 10 matching lines...) Expand all Loading... |
| 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/session/session_controller.h" | 23 #include "ash/session/session_controller.h" |
| 24 #include "ash/shelf/shelf_delegate.h" | 24 #include "ash/shelf/shelf_delegate.h" |
| 25 #include "ash/shelf/shelf_layout_manager.h" | 25 #include "ash/shelf/shelf_layout_manager.h" |
| 26 #include "ash/shelf/shelf_widget.h" | 26 #include "ash/shelf/shelf_widget.h" |
| 27 #include "ash/shelf/shelf_window_targeter.h" | 27 #include "ash/shelf/shelf_window_targeter.h" |
| 28 #include "ash/shelf/wm_shelf.h" | 28 #include "ash/shelf/wm_shelf.h" |
| 29 #include "ash/shell.h" | 29 #include "ash/shell.h" |
| 30 #include "ash/shell_delegate.h" | 30 #include "ash/shell_delegate.h" |
| 31 #include "ash/shell_port.h" |
| 31 #include "ash/system/status_area_layout_manager.h" | 32 #include "ash/system/status_area_layout_manager.h" |
| 32 #include "ash/system/status_area_widget.h" | 33 #include "ash/system/status_area_widget.h" |
| 33 #include "ash/system/tray/system_tray_delegate.h" | 34 #include "ash/system/tray/system_tray_delegate.h" |
| 34 #include "ash/touch/touch_hud_debug.h" | 35 #include "ash/touch/touch_hud_debug.h" |
| 35 #include "ash/touch/touch_hud_projection.h" | 36 #include "ash/touch/touch_hud_projection.h" |
| 36 #include "ash/touch/touch_observer_hud.h" | 37 #include "ash/touch/touch_observer_hud.h" |
| 37 #include "ash/wallpaper/wallpaper_delegate.h" | 38 #include "ash/wallpaper/wallpaper_delegate.h" |
| 38 #include "ash/wallpaper/wallpaper_widget_controller.h" | 39 #include "ash/wallpaper/wallpaper_widget_controller.h" |
| 39 #include "ash/wm/always_on_top_controller.h" | 40 #include "ash/wm/always_on_top_controller.h" |
| 40 #include "ash/wm/boot_splash_screen_chromeos.h" | 41 #include "ash/wm/boot_splash_screen_chromeos.h" |
| 41 #include "ash/wm/container_finder.h" | 42 #include "ash/wm/container_finder.h" |
| 42 #include "ash/wm/fullscreen_window_finder.h" | 43 #include "ash/wm/fullscreen_window_finder.h" |
| 43 #include "ash/wm/lock_layout_manager.h" | 44 #include "ash/wm/lock_layout_manager.h" |
| 44 #include "ash/wm/panels/attached_panel_window_targeter.h" | 45 #include "ash/wm/panels/attached_panel_window_targeter.h" |
| 45 #include "ash/wm/panels/panel_layout_manager.h" | 46 #include "ash/wm/panels/panel_layout_manager.h" |
| 46 #include "ash/wm/panels/panel_window_event_handler.h" | 47 #include "ash/wm/panels/panel_window_event_handler.h" |
| 47 #include "ash/wm/root_window_layout_manager.h" | 48 #include "ash/wm/root_window_layout_manager.h" |
| 48 #include "ash/wm/stacking_controller.h" | 49 #include "ash/wm/stacking_controller.h" |
| 49 #include "ash/wm/switchable_windows.h" | 50 #include "ash/wm/switchable_windows.h" |
| 50 #include "ash/wm/system_modal_container_layout_manager.h" | 51 #include "ash/wm/system_modal_container_layout_manager.h" |
| 51 #include "ash/wm/system_wallpaper_controller.h" | 52 #include "ash/wm/system_wallpaper_controller.h" |
| 52 #include "ash/wm/window_properties.h" | 53 #include "ash/wm/window_properties.h" |
| 53 #include "ash/wm/window_state.h" | 54 #include "ash/wm/window_state.h" |
| 54 #include "ash/wm/window_state_aura.h" | 55 #include "ash/wm/window_state_aura.h" |
| 55 #include "ash/wm/window_util.h" | 56 #include "ash/wm/window_util.h" |
| 56 #include "ash/wm/wm_screen_util.h" | 57 #include "ash/wm/wm_screen_util.h" |
| 57 #include "ash/wm/workspace/workspace_layout_manager.h" | 58 #include "ash/wm/workspace/workspace_layout_manager.h" |
| 58 #include "ash/wm/workspace_controller.h" | 59 #include "ash/wm/workspace_controller.h" |
| 59 #include "ash/wm_shell.h" | |
| 60 #include "ash/wm_window.h" | 60 #include "ash/wm_window.h" |
| 61 #include "base/command_line.h" | 61 #include "base/command_line.h" |
| 62 #include "base/macros.h" | 62 #include "base/macros.h" |
| 63 #include "base/memory/ptr_util.h" | 63 #include "base/memory/ptr_util.h" |
| 64 #include "base/time/time.h" | 64 #include "base/time/time.h" |
| 65 #include "chromeos/chromeos_switches.h" | 65 #include "chromeos/chromeos_switches.h" |
| 66 #include "ui/aura/client/aura_constants.h" | 66 #include "ui/aura/client/aura_constants.h" |
| 67 #include "ui/aura/client/drag_drop_client.h" | 67 #include "ui/aura/client/drag_drop_client.h" |
| 68 #include "ui/aura/client/screen_position_client.h" | 68 #include "ui/aura/client/screen_position_client.h" |
| 69 #include "ui/aura/mus/window_mus.h" | 69 #include "ui/aura/mus/window_mus.h" |
| (...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 (WmShell::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 WmWindow* src_container = src->GetChildByShellWindowId(id); |
| 232 WmWindow* dst_container = dst->GetChildByShellWindowId(id); | 232 WmWindow* dst_container = dst->GetChildByShellWindowId(id); |
| 233 while (!src_container->GetChildren().empty()) { | 233 while (!src_container->GetChildren().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. |
| (...skipping 26 matching lines...) Expand all Loading... |
| 262 if (window_id != kShellWindowId_UnparentedControlContainer) | 262 if (window_id != kShellWindowId_UnparentedControlContainer) |
| 263 window->Show(); | 263 window->Show(); |
| 264 return WmWindow::Get(window); | 264 return WmWindow::Get(window); |
| 265 } | 265 } |
| 266 | 266 |
| 267 // TODO(sky): This should take an aura::Window. http://crbug.com/671246. | 267 // TODO(sky): This should take an aura::Window. http://crbug.com/671246. |
| 268 bool ShouldDestroyWindowInCloseChildWindows(WmWindow* window) { | 268 bool ShouldDestroyWindowInCloseChildWindows(WmWindow* window) { |
| 269 if (!WmWindow::GetAuraWindow(window)->owned_by_parent()) | 269 if (!WmWindow::GetAuraWindow(window)->owned_by_parent()) |
| 270 return false; | 270 return false; |
| 271 | 271 |
| 272 if (!WmShell::Get()->IsRunningInMash()) | 272 if (!ShellPort::Get()->IsRunningInMash()) |
| 273 return true; | 273 return true; |
| 274 | 274 |
| 275 aura::WindowMus* window_mus = | 275 aura::WindowMus* window_mus = |
| 276 aura::WindowMus::Get(WmWindow::GetAuraWindow(window)); | 276 aura::WindowMus::Get(WmWindow::GetAuraWindow(window)); |
| 277 return Shell::window_tree_client()->WasCreatedByThisClient(window_mus) || | 277 return Shell::window_tree_client()->WasCreatedByThisClient(window_mus) || |
| 278 Shell::window_tree_client()->IsRoot(window_mus); | 278 Shell::window_tree_client()->IsRoot(window_mus); |
| 279 } | 279 } |
| 280 | 280 |
| 281 } // namespace | 281 } // namespace |
| 282 | 282 |
| (...skipping 22 matching lines...) Expand all Loading... |
| 305 | 305 |
| 306 void RootWindowController::CreateForSecondaryDisplay(AshWindowTreeHost* host) { | 306 void RootWindowController::CreateForSecondaryDisplay(AshWindowTreeHost* host) { |
| 307 RootWindowController* controller = new RootWindowController(host, nullptr); | 307 RootWindowController* controller = new RootWindowController(host, nullptr); |
| 308 controller->Init(RootWindowType::SECONDARY); | 308 controller->Init(RootWindowType::SECONDARY); |
| 309 } | 309 } |
| 310 | 310 |
| 311 // static | 311 // static |
| 312 RootWindowController* RootWindowController::ForWindow( | 312 RootWindowController* RootWindowController::ForWindow( |
| 313 const aura::Window* window) { | 313 const aura::Window* window) { |
| 314 DCHECK(window); | 314 DCHECK(window); |
| 315 CHECK(WmShell::HasInstance() && | 315 CHECK(Shell::HasInstance()); |
| 316 (WmShell::Get()->IsRunningInMash() || Shell::HasInstance())); | |
| 317 return GetRootWindowController(window->GetRootWindow()); | 316 return GetRootWindowController(window->GetRootWindow()); |
| 318 } | 317 } |
| 319 | 318 |
| 320 // static | 319 // static |
| 321 RootWindowController* RootWindowController::ForTargetRootWindow() { | 320 RootWindowController* RootWindowController::ForTargetRootWindow() { |
| 322 CHECK(Shell::HasInstance()); | 321 CHECK(Shell::HasInstance()); |
| 323 return GetRootWindowController(Shell::GetRootWindowForNewWindows()); | 322 return GetRootWindowController(Shell::GetRootWindowForNewWindows()); |
| 324 } | 323 } |
| 325 | 324 |
| 326 void RootWindowController::ConfigureWidgetInitParamsForContainer( | 325 void RootWindowController::ConfigureWidgetInitParamsForContainer( |
| (...skipping 293 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 620 // 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. |
| 621 workspace_controller_.reset(); | 620 workspace_controller_.reset(); |
| 622 ReparentAllWindows(GetWindow(), WmWindow::Get(dst)); | 621 ReparentAllWindows(GetWindow(), WmWindow::Get(dst)); |
| 623 } | 622 } |
| 624 | 623 |
| 625 void RootWindowController::UpdateShelfVisibility() { | 624 void RootWindowController::UpdateShelfVisibility() { |
| 626 wm_shelf_->UpdateVisibilityState(); | 625 wm_shelf_->UpdateVisibilityState(); |
| 627 } | 626 } |
| 628 | 627 |
| 629 void RootWindowController::InitTouchHuds() { | 628 void RootWindowController::InitTouchHuds() { |
| 630 if (WmShell::Get()->IsRunningInMash()) | 629 if (ShellPort::Get()->IsRunningInMash()) |
| 631 return; | 630 return; |
| 632 | 631 |
| 633 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); | 632 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); |
| 634 if (command_line->HasSwitch(switches::kAshTouchHud)) | 633 if (command_line->HasSwitch(switches::kAshTouchHud)) |
| 635 set_touch_hud_debug(new TouchHudDebug(GetRootWindow())); | 634 set_touch_hud_debug(new TouchHudDebug(GetRootWindow())); |
| 636 if (Shell::Get()->is_touch_hud_projection_enabled()) | 635 if (Shell::Get()->is_touch_hud_projection_enabled()) |
| 637 EnableTouchHudProjection(); | 636 EnableTouchHudProjection(); |
| 638 } | 637 } |
| 639 | 638 |
| 640 aura::Window* RootWindowController::GetWindowForFullscreenMode() { | 639 aura::Window* RootWindowController::GetWindowForFullscreenMode() { |
| (...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 744 GetRootWindowSettings(root_window)->controller = this; | 743 GetRootWindowSettings(root_window)->controller = this; |
| 745 | 744 |
| 746 stacking_controller_.reset(new StackingController); | 745 stacking_controller_.reset(new StackingController); |
| 747 aura::client::SetWindowParentingClient(root_window, | 746 aura::client::SetWindowParentingClient(root_window, |
| 748 stacking_controller_.get()); | 747 stacking_controller_.get()); |
| 749 capture_client_.reset(new ::wm::ScopedCaptureClient(root_window)); | 748 capture_client_.reset(new ::wm::ScopedCaptureClient(root_window)); |
| 750 } | 749 } |
| 751 | 750 |
| 752 void RootWindowController::Init(RootWindowType root_window_type) { | 751 void RootWindowController::Init(RootWindowType root_window_type) { |
| 753 aura::Window* root_window = GetRootWindow(); | 752 aura::Window* root_window = GetRootWindow(); |
| 754 WmShell* wm_shell = WmShell::Get(); | 753 ShellPort* shell_port = ShellPort::Get(); |
| 755 Shell* shell = Shell::Get(); | 754 Shell* shell = Shell::Get(); |
| 756 shell->InitRootWindow(root_window); | 755 shell->InitRootWindow(root_window); |
| 757 | 756 |
| 758 CreateContainers(); | 757 CreateContainers(); |
| 759 | 758 |
| 760 CreateSystemWallpaper(root_window_type); | 759 CreateSystemWallpaper(root_window_type); |
| 761 | 760 |
| 762 InitLayoutManagers(); | 761 InitLayoutManagers(); |
| 763 InitTouchHuds(); | 762 InitTouchHuds(); |
| 764 | 763 |
| 765 if (wm_shell->GetPrimaryRootWindowController() | 764 if (shell_port->GetPrimaryRootWindowController() |
| 766 ->GetSystemModalLayoutManager(nullptr) | 765 ->GetSystemModalLayoutManager(nullptr) |
| 767 ->has_window_dimmer()) { | 766 ->has_window_dimmer()) { |
| 768 GetSystemModalLayoutManager(nullptr)->CreateModalBackground(); | 767 GetSystemModalLayoutManager(nullptr)->CreateModalBackground(); |
| 769 } | 768 } |
| 770 | 769 |
| 771 shell->AddShellObserver(this); | 770 shell->AddShellObserver(this); |
| 772 | 771 |
| 773 root_window_layout_manager_->OnWindowResized(); | 772 root_window_layout_manager_->OnWindowResized(); |
| 774 if (root_window_type == RootWindowType::PRIMARY) { | 773 if (root_window_type == RootWindowType::PRIMARY) { |
| 775 if (!wm_shell->IsRunningInMash()) | 774 if (!shell_port->IsRunningInMash()) |
| 776 shell->InitKeyboard(); | 775 shell->InitKeyboard(); |
| 777 } else { | 776 } else { |
| 778 window_tree_host_->Show(); | 777 window_tree_host_->Show(); |
| 779 | 778 |
| 780 // Create a shelf if a user is already logged in. | 779 // Create a shelf if a user is already logged in. |
| 781 if (shell->session_controller()->NumberOfLoggedInUsers()) | 780 if (shell->session_controller()->NumberOfLoggedInUsers()) |
| 782 CreateShelfView(); | 781 CreateShelfView(); |
| 783 | 782 |
| 784 // Notify shell observers about new root window. | 783 // Notify shell observers about new root window. |
| 785 shell->OnRootWindowAdded(WmWindow::Get(root_window)); | 784 shell->OnRootWindowAdded(WmWindow::Get(root_window)); |
| 786 } | 785 } |
| 787 | 786 |
| 788 // TODO: AshTouchExplorationManager doesn't work with mus. | 787 // TODO: AshTouchExplorationManager doesn't work with mus. |
| 789 // http://crbug.com/679782 | 788 // http://crbug.com/679782 |
| 790 if (!base::CommandLine::ForCurrentProcess()->HasSwitch( | 789 if (!base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 791 switches::kAshDisableTouchExplorationMode) && | 790 switches::kAshDisableTouchExplorationMode) && |
| 792 !wm_shell->IsRunningInMash()) { | 791 !shell_port->IsRunningInMash()) { |
| 793 touch_exploration_manager_.reset(new AshTouchExplorationManager(this)); | 792 touch_exploration_manager_.reset(new AshTouchExplorationManager(this)); |
| 794 } | 793 } |
| 795 } | 794 } |
| 796 | 795 |
| 797 void RootWindowController::InitLayoutManagers() { | 796 void RootWindowController::InitLayoutManagers() { |
| 798 // Create the shelf and status area widgets. | 797 // Create the shelf and status area widgets. |
| 799 DCHECK(!wm_shelf_->shelf_widget()); | 798 DCHECK(!wm_shelf_->shelf_widget()); |
| 800 GetShelf()->CreateShelfWidget(GetWindow()); | 799 GetShelf()->CreateShelfWidget(GetWindow()); |
| 801 | 800 |
| 802 WmWindow* root = GetWindow(); | 801 WmWindow* root = GetWindow(); |
| (...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1073 | 1072 |
| 1074 void RootWindowController::ResetRootForNewWindowsIfNecessary() { | 1073 void RootWindowController::ResetRootForNewWindowsIfNecessary() { |
| 1075 // Change the target root window before closing child windows. If any child | 1074 // Change the target root window before closing child windows. If any child |
| 1076 // being removed triggers a relayout of the shelf it will try to build a | 1075 // being removed triggers a relayout of the shelf it will try to build a |
| 1077 // window list adding windows from the target root window's containers which | 1076 // window list adding windows from the target root window's containers which |
| 1078 // may have already gone away. | 1077 // may have already gone away. |
| 1079 WmWindow* root = GetWindow(); | 1078 WmWindow* root = GetWindow(); |
| 1080 if (Shell::GetWmRootWindowForNewWindows() == root) { | 1079 if (Shell::GetWmRootWindowForNewWindows() == root) { |
| 1081 // The root window for new windows is being destroyed. Switch to the primary | 1080 // The root window for new windows is being destroyed. Switch to the primary |
| 1082 // root window if possible. | 1081 // root window if possible. |
| 1083 WmWindow* primary_root = WmShell::Get()->GetPrimaryRootWindow(); | 1082 WmWindow* primary_root = ShellPort::Get()->GetPrimaryRootWindow(); |
| 1084 Shell::Get()->set_root_window_for_new_windows( | 1083 Shell::Get()->set_root_window_for_new_windows( |
| 1085 primary_root == root ? nullptr : primary_root); | 1084 primary_root == root ? nullptr : primary_root); |
| 1086 } | 1085 } |
| 1087 } | 1086 } |
| 1088 | 1087 |
| 1089 void RootWindowController::OnMenuClosed() { | 1088 void RootWindowController::OnMenuClosed() { |
| 1090 menu_runner_.reset(); | 1089 menu_runner_.reset(); |
| 1091 menu_model_adapter_.reset(); | 1090 menu_model_adapter_.reset(); |
| 1092 menu_model_.reset(); | 1091 menu_model_.reset(); |
| 1093 wm_shelf_->UpdateVisibilityState(); | 1092 wm_shelf_->UpdateVisibilityState(); |
| 1094 } | 1093 } |
| 1095 | 1094 |
| 1096 void RootWindowController::OnLoginStateChanged(LoginStatus status) { | 1095 void RootWindowController::OnLoginStateChanged(LoginStatus status) { |
| 1097 wm_shelf_->UpdateVisibilityState(); | 1096 wm_shelf_->UpdateVisibilityState(); |
| 1098 } | 1097 } |
| 1099 | 1098 |
| 1100 void RootWindowController::OnTouchHudProjectionToggled(bool enabled) { | 1099 void RootWindowController::OnTouchHudProjectionToggled(bool enabled) { |
| 1101 if (enabled) | 1100 if (enabled) |
| 1102 EnableTouchHudProjection(); | 1101 EnableTouchHudProjection(); |
| 1103 else | 1102 else |
| 1104 DisableTouchHudProjection(); | 1103 DisableTouchHudProjection(); |
| 1105 } | 1104 } |
| 1106 | 1105 |
| 1107 RootWindowController* GetRootWindowController(const aura::Window* root_window) { | 1106 RootWindowController* GetRootWindowController(const aura::Window* root_window) { |
| 1108 return root_window ? GetRootWindowSettings(root_window)->controller : nullptr; | 1107 return root_window ? GetRootWindowSettings(root_window)->controller : nullptr; |
| 1109 } | 1108 } |
| 1110 | 1109 |
| 1111 } // namespace ash | 1110 } // namespace ash |
| OLD | NEW |