Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(39)

Side by Side Diff: ash/root_window_controller.cc

Issue 2808723004: Renames WmShell to ShellPort (Closed)
Patch Set: cleanup Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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
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
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
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(ShellPort::HasInstance() &&
316 (WmShell::Get()->IsRunningInMash() || Shell::HasInstance())); 316 (ShellPort::Get()->IsRunningInMash() || Shell::HasInstance()));
James Cook 2017/04/10 22:00:41 nit: ShellPort::HasInstance() && Shell::HasInstanc
sky 2017/04/10 22:16:25 Done.
317 return GetRootWindowController(window->GetRootWindow()); 317 return GetRootWindowController(window->GetRootWindow());
318 } 318 }
319 319
320 // static 320 // static
321 RootWindowController* RootWindowController::ForTargetRootWindow() { 321 RootWindowController* RootWindowController::ForTargetRootWindow() {
322 CHECK(Shell::HasInstance()); 322 CHECK(Shell::HasInstance());
323 return GetRootWindowController(Shell::GetRootWindowForNewWindows()); 323 return GetRootWindowController(Shell::GetRootWindowForNewWindows());
324 } 324 }
325 325
326 void RootWindowController::ConfigureWidgetInitParamsForContainer( 326 void RootWindowController::ConfigureWidgetInitParamsForContainer(
(...skipping 293 matching lines...) Expand 10 before | Expand all | Expand 10 after
620 // 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.
621 workspace_controller_.reset(); 621 workspace_controller_.reset();
622 ReparentAllWindows(GetWindow(), WmWindow::Get(dst)); 622 ReparentAllWindows(GetWindow(), WmWindow::Get(dst));
623 } 623 }
624 624
625 void RootWindowController::UpdateShelfVisibility() { 625 void RootWindowController::UpdateShelfVisibility() {
626 wm_shelf_->UpdateVisibilityState(); 626 wm_shelf_->UpdateVisibilityState();
627 } 627 }
628 628
629 void RootWindowController::InitTouchHuds() { 629 void RootWindowController::InitTouchHuds() {
630 if (WmShell::Get()->IsRunningInMash()) 630 if (ShellPort::Get()->IsRunningInMash())
631 return; 631 return;
632 632
633 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); 633 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess();
634 if (command_line->HasSwitch(switches::kAshTouchHud)) 634 if (command_line->HasSwitch(switches::kAshTouchHud))
635 set_touch_hud_debug(new TouchHudDebug(GetRootWindow())); 635 set_touch_hud_debug(new TouchHudDebug(GetRootWindow()));
636 if (Shell::Get()->is_touch_hud_projection_enabled()) 636 if (Shell::Get()->is_touch_hud_projection_enabled())
637 EnableTouchHudProjection(); 637 EnableTouchHudProjection();
638 } 638 }
639 639
640 aura::Window* RootWindowController::GetWindowForFullscreenMode() { 640 aura::Window* RootWindowController::GetWindowForFullscreenMode() {
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
744 GetRootWindowSettings(root_window)->controller = this; 744 GetRootWindowSettings(root_window)->controller = this;
745 745
746 stacking_controller_.reset(new StackingController); 746 stacking_controller_.reset(new StackingController);
747 aura::client::SetWindowParentingClient(root_window, 747 aura::client::SetWindowParentingClient(root_window,
748 stacking_controller_.get()); 748 stacking_controller_.get());
749 capture_client_.reset(new ::wm::ScopedCaptureClient(root_window)); 749 capture_client_.reset(new ::wm::ScopedCaptureClient(root_window));
750 } 750 }
751 751
752 void RootWindowController::Init(RootWindowType root_window_type) { 752 void RootWindowController::Init(RootWindowType root_window_type) {
753 aura::Window* root_window = GetRootWindow(); 753 aura::Window* root_window = GetRootWindow();
754 WmShell* wm_shell = WmShell::Get(); 754 ShellPort* shell_port = ShellPort::Get();
755 Shell* shell = Shell::Get(); 755 Shell* shell = Shell::Get();
756 shell->InitRootWindow(root_window); 756 shell->InitRootWindow(root_window);
757 757
758 CreateContainers(); 758 CreateContainers();
759 759
760 CreateSystemWallpaper(root_window_type); 760 CreateSystemWallpaper(root_window_type);
761 761
762 InitLayoutManagers(); 762 InitLayoutManagers();
763 InitTouchHuds(); 763 InitTouchHuds();
764 764
765 if (wm_shell->GetPrimaryRootWindowController() 765 if (shell_port->GetPrimaryRootWindowController()
766 ->GetSystemModalLayoutManager(nullptr) 766 ->GetSystemModalLayoutManager(nullptr)
767 ->has_window_dimmer()) { 767 ->has_window_dimmer()) {
768 GetSystemModalLayoutManager(nullptr)->CreateModalBackground(); 768 GetSystemModalLayoutManager(nullptr)->CreateModalBackground();
769 } 769 }
770 770
771 shell->AddShellObserver(this); 771 shell->AddShellObserver(this);
772 772
773 root_window_layout_manager_->OnWindowResized(); 773 root_window_layout_manager_->OnWindowResized();
774 if (root_window_type == RootWindowType::PRIMARY) { 774 if (root_window_type == RootWindowType::PRIMARY) {
775 if (!wm_shell->IsRunningInMash()) 775 if (!shell_port->IsRunningInMash())
776 shell->InitKeyboard(); 776 shell->InitKeyboard();
777 } else { 777 } else {
778 window_tree_host_->Show(); 778 window_tree_host_->Show();
779 779
780 // Create a shelf if a user is already logged in. 780 // Create a shelf if a user is already logged in.
781 if (shell->session_controller()->NumberOfLoggedInUsers()) 781 if (shell->session_controller()->NumberOfLoggedInUsers())
782 CreateShelfView(); 782 CreateShelfView();
783 783
784 // Notify shell observers about new root window. 784 // Notify shell observers about new root window.
785 shell->OnRootWindowAdded(WmWindow::Get(root_window)); 785 shell->OnRootWindowAdded(WmWindow::Get(root_window));
786 } 786 }
787 787
788 // TODO: AshTouchExplorationManager doesn't work with mus. 788 // TODO: AshTouchExplorationManager doesn't work with mus.
789 // http://crbug.com/679782 789 // http://crbug.com/679782
790 if (!base::CommandLine::ForCurrentProcess()->HasSwitch( 790 if (!base::CommandLine::ForCurrentProcess()->HasSwitch(
791 switches::kAshDisableTouchExplorationMode) && 791 switches::kAshDisableTouchExplorationMode) &&
792 !wm_shell->IsRunningInMash()) { 792 !shell_port->IsRunningInMash()) {
793 touch_exploration_manager_.reset(new AshTouchExplorationManager(this)); 793 touch_exploration_manager_.reset(new AshTouchExplorationManager(this));
794 } 794 }
795 } 795 }
796 796
797 void RootWindowController::InitLayoutManagers() { 797 void RootWindowController::InitLayoutManagers() {
798 // Create the shelf and status area widgets. 798 // Create the shelf and status area widgets.
799 DCHECK(!wm_shelf_->shelf_widget()); 799 DCHECK(!wm_shelf_->shelf_widget());
800 GetShelf()->CreateShelfWidget(GetWindow()); 800 GetShelf()->CreateShelfWidget(GetWindow());
801 801
802 WmWindow* root = GetWindow(); 802 WmWindow* root = GetWindow();
(...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after
1073 1073
1074 void RootWindowController::ResetRootForNewWindowsIfNecessary() { 1074 void RootWindowController::ResetRootForNewWindowsIfNecessary() {
1075 // Change the target root window before closing child windows. If any child 1075 // 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 1076 // 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 1077 // window list adding windows from the target root window's containers which
1078 // may have already gone away. 1078 // may have already gone away.
1079 WmWindow* root = GetWindow(); 1079 WmWindow* root = GetWindow();
1080 if (Shell::GetWmRootWindowForNewWindows() == root) { 1080 if (Shell::GetWmRootWindowForNewWindows() == root) {
1081 // The root window for new windows is being destroyed. Switch to the primary 1081 // The root window for new windows is being destroyed. Switch to the primary
1082 // root window if possible. 1082 // root window if possible.
1083 WmWindow* primary_root = WmShell::Get()->GetPrimaryRootWindow(); 1083 WmWindow* primary_root = ShellPort::Get()->GetPrimaryRootWindow();
1084 Shell::Get()->set_root_window_for_new_windows( 1084 Shell::Get()->set_root_window_for_new_windows(
1085 primary_root == root ? nullptr : primary_root); 1085 primary_root == root ? nullptr : primary_root);
1086 } 1086 }
1087 } 1087 }
1088 1088
1089 void RootWindowController::OnMenuClosed() { 1089 void RootWindowController::OnMenuClosed() {
1090 menu_runner_.reset(); 1090 menu_runner_.reset();
1091 menu_model_adapter_.reset(); 1091 menu_model_adapter_.reset();
1092 menu_model_.reset(); 1092 menu_model_.reset();
1093 wm_shelf_->UpdateVisibilityState(); 1093 wm_shelf_->UpdateVisibilityState();
1094 } 1094 }
1095 1095
1096 void RootWindowController::OnLoginStateChanged(LoginStatus status) { 1096 void RootWindowController::OnLoginStateChanged(LoginStatus status) {
1097 wm_shelf_->UpdateVisibilityState(); 1097 wm_shelf_->UpdateVisibilityState();
1098 } 1098 }
1099 1099
1100 void RootWindowController::OnTouchHudProjectionToggled(bool enabled) { 1100 void RootWindowController::OnTouchHudProjectionToggled(bool enabled) {
1101 if (enabled) 1101 if (enabled)
1102 EnableTouchHudProjection(); 1102 EnableTouchHudProjection();
1103 else 1103 else
1104 DisableTouchHudProjection(); 1104 DisableTouchHudProjection();
1105 } 1105 }
1106 1106
1107 RootWindowController* GetRootWindowController(const aura::Window* root_window) { 1107 RootWindowController* GetRootWindowController(const aura::Window* root_window) {
1108 return root_window ? GetRootWindowSettings(root_window)->controller : nullptr; 1108 return root_window ? GetRootWindowSettings(root_window)->controller : nullptr;
1109 } 1109 }
1110 1110
1111 } // namespace ash 1111 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698