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

Side by Side Diff: ash/root_window_controller.cc

Issue 2700523004: Remove docked windows entirely in M59. (Closed)
Patch Set: Rebase Created 3 years, 9 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
« no previous file with comments | « ash/root_window_controller.h ('k') | ash/shell_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
11 #include "ash/ash_touch_exploration_manager_chromeos.h" 11 #include "ash/ash_touch_exploration_manager_chromeos.h"
12 #include "ash/aura/aura_layout_manager_adapter.h" 12 #include "ash/aura/aura_layout_manager_adapter.h"
13 #include "ash/common/ash_constants.h" 13 #include "ash/common/ash_constants.h"
14 #include "ash/common/ash_switches.h" 14 #include "ash/common/ash_switches.h"
15 #include "ash/common/focus_cycler.h" 15 #include "ash/common/focus_cycler.h"
16 #include "ash/common/login_status.h" 16 #include "ash/common/login_status.h"
17 #include "ash/common/session/session_controller.h" 17 #include "ash/common/session/session_controller.h"
18 #include "ash/common/shelf/shelf_delegate.h" 18 #include "ash/common/shelf/shelf_delegate.h"
19 #include "ash/common/shelf/shelf_layout_manager.h" 19 #include "ash/common/shelf/shelf_layout_manager.h"
20 #include "ash/common/shelf/shelf_widget.h" 20 #include "ash/common/shelf/shelf_widget.h"
21 #include "ash/common/shelf/wm_shelf.h" 21 #include "ash/common/shelf/wm_shelf.h"
22 #include "ash/common/shell_delegate.h" 22 #include "ash/common/shell_delegate.h"
23 #include "ash/common/system/status_area_layout_manager.h" 23 #include "ash/common/system/status_area_layout_manager.h"
24 #include "ash/common/system/status_area_widget.h" 24 #include "ash/common/system/status_area_widget.h"
25 #include "ash/common/system/tray/system_tray_delegate.h" 25 #include "ash/common/system/tray/system_tray_delegate.h"
26 #include "ash/common/wallpaper/wallpaper_delegate.h" 26 #include "ash/common/wallpaper/wallpaper_delegate.h"
27 #include "ash/common/wallpaper/wallpaper_widget_controller.h" 27 #include "ash/common/wallpaper/wallpaper_widget_controller.h"
28 #include "ash/common/wm/always_on_top_controller.h" 28 #include "ash/common/wm/always_on_top_controller.h"
29 #include "ash/common/wm/container_finder.h" 29 #include "ash/common/wm/container_finder.h"
30 #include "ash/common/wm/dock/docked_window_layout_manager.h"
31 #include "ash/common/wm/fullscreen_window_finder.h" 30 #include "ash/common/wm/fullscreen_window_finder.h"
32 #include "ash/common/wm/lock_layout_manager.h" 31 #include "ash/common/wm/lock_layout_manager.h"
33 #include "ash/common/wm/panels/panel_layout_manager.h" 32 #include "ash/common/wm/panels/panel_layout_manager.h"
34 #include "ash/common/wm/root_window_layout_manager.h" 33 #include "ash/common/wm/root_window_layout_manager.h"
35 #include "ash/common/wm/switchable_windows.h" 34 #include "ash/common/wm/switchable_windows.h"
36 #include "ash/common/wm/system_modal_container_layout_manager.h" 35 #include "ash/common/wm/system_modal_container_layout_manager.h"
37 #include "ash/common/wm/window_state.h" 36 #include "ash/common/wm/window_state.h"
38 #include "ash/common/wm/wm_screen_util.h" 37 #include "ash/common/wm/wm_screen_util.h"
39 #include "ash/common/wm/workspace/workspace_layout_manager.h" 38 #include "ash/common/wm/workspace/workspace_layout_manager.h"
40 #include "ash/common/wm/workspace_controller.h" 39 #include "ash/common/wm/workspace_controller.h"
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
164 } 163 }
165 164
166 // Reparents |window| to |new_parent|. 165 // Reparents |window| to |new_parent|.
167 // TODO(sky): This should take an aura::Window. http://crbug.com/671246. 166 // TODO(sky): This should take an aura::Window. http://crbug.com/671246.
168 void ReparentWindow(WmWindow* window, WmWindow* new_parent) { 167 void ReparentWindow(WmWindow* window, WmWindow* new_parent) {
169 const gfx::Size src_size = window->GetParent()->GetBounds().size(); 168 const gfx::Size src_size = window->GetParent()->GetBounds().size();
170 const gfx::Size dst_size = new_parent->GetBounds().size(); 169 const gfx::Size dst_size = new_parent->GetBounds().size();
171 // Update the restore bounds to make it relative to the display. 170 // Update the restore bounds to make it relative to the display.
172 wm::WindowState* state = window->GetWindowState(); 171 wm::WindowState* state = window->GetWindowState();
173 gfx::Rect restore_bounds; 172 gfx::Rect restore_bounds;
174 bool has_restore_bounds = state->HasRestoreBounds(); 173 const bool has_restore_bounds = state->HasRestoreBounds();
175 174
176 bool update_bounds = 175 const bool update_bounds = state->IsNormalOrSnapped() || state->IsMinimized();
177 (state->IsNormalOrSnapped() || state->IsMinimized()) &&
178 new_parent->GetShellWindowId() != kShellWindowId_DockedContainer;
179 gfx::Rect work_area_in_new_parent = 176 gfx::Rect work_area_in_new_parent =
180 wm::GetDisplayWorkAreaBoundsInParent(new_parent); 177 wm::GetDisplayWorkAreaBoundsInParent(new_parent);
181 178
182 gfx::Rect local_bounds; 179 gfx::Rect local_bounds;
183 if (update_bounds) { 180 if (update_bounds) {
184 local_bounds = state->window()->GetBounds(); 181 local_bounds = state->window()->GetBounds();
185 MoveOriginRelativeToSize(src_size, dst_size, &local_bounds); 182 MoveOriginRelativeToSize(src_size, dst_size, &local_bounds);
186 local_bounds.AdjustToFit(work_area_in_new_parent); 183 local_bounds.AdjustToFit(work_area_in_new_parent);
187 } 184 }
188 185
(...skipping 12 matching lines...) Expand all
201 if (has_restore_bounds) 198 if (has_restore_bounds)
202 state->SetRestoreBoundsInParent(restore_bounds); 199 state->SetRestoreBoundsInParent(restore_bounds);
203 } 200 }
204 201
205 // Reparents the appropriate set of windows from |src| to |dst|. 202 // Reparents the appropriate set of windows from |src| to |dst|.
206 // TODO(sky): This should take an aura::Window. http://crbug.com/671246. 203 // TODO(sky): This should take an aura::Window. http://crbug.com/671246.
207 void ReparentAllWindows(WmWindow* src, WmWindow* dst) { 204 void ReparentAllWindows(WmWindow* src, WmWindow* dst) {
208 // Set of windows to move. 205 // Set of windows to move.
209 const int kContainerIdsToMove[] = { 206 const int kContainerIdsToMove[] = {
210 kShellWindowId_DefaultContainer, 207 kShellWindowId_DefaultContainer,
211 kShellWindowId_DockedContainer,
212 kShellWindowId_PanelContainer, 208 kShellWindowId_PanelContainer,
213 kShellWindowId_AlwaysOnTopContainer, 209 kShellWindowId_AlwaysOnTopContainer,
214 kShellWindowId_SystemModalContainer, 210 kShellWindowId_SystemModalContainer,
215 kShellWindowId_LockSystemModalContainer, 211 kShellWindowId_LockSystemModalContainer,
216 kShellWindowId_UnparentedControlContainer, 212 kShellWindowId_UnparentedControlContainer,
217 kShellWindowId_OverlayContainer, 213 kShellWindowId_OverlayContainer,
218 }; 214 };
219 const int kExtraContainerIdsToMoveInUnifiedMode[] = { 215 const int kExtraContainerIdsToMoveInUnifiedMode[] = {
220 kShellWindowId_LockScreenContainer, 216 kShellWindowId_LockScreenContainer,
221 kShellWindowId_LockScreenWallpaperContainer, 217 kShellWindowId_LockScreenWallpaperContainer,
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after
368 364
369 void RootWindowController::CreateShelfView() { 365 void RootWindowController::CreateShelfView() {
370 if (wm_shelf_->IsShelfInitialized()) 366 if (wm_shelf_->IsShelfInitialized())
371 return; 367 return;
372 wm_shelf_->CreateShelfView(); 368 wm_shelf_->CreateShelfView();
373 369
374 // TODO(jamescook): Pass |wm_shelf_| into the constructors for these layout 370 // TODO(jamescook): Pass |wm_shelf_| into the constructors for these layout
375 // managers. 371 // managers.
376 if (panel_layout_manager_) 372 if (panel_layout_manager_)
377 panel_layout_manager_->SetShelf(wm_shelf_.get()); 373 panel_layout_manager_->SetShelf(wm_shelf_.get());
378 if (docked_window_layout_manager_) {
379 docked_window_layout_manager_->SetShelf(wm_shelf_.get());
380 if (wm_shelf_->shelf_layout_manager())
381 docked_window_layout_manager_->AddObserver(
382 wm_shelf_->shelf_layout_manager());
383 }
384 374
385 // Notify shell observers that the shelf has been created. 375 // Notify shell observers that the shelf has been created.
386 // TODO(jamescook): Move this into WmShelf::InitializeShelf(). This will 376 // TODO(jamescook): Move this into WmShelf::InitializeShelf(). This will
387 // require changing AttachedPanelWidgetTargeter's access to WmShelf. 377 // require changing AttachedPanelWidgetTargeter's access to WmShelf.
388 Shell::GetInstance()->NotifyShelfCreatedForRootWindow( 378 Shell::GetInstance()->NotifyShelfCreatedForRootWindow(
389 WmWindow::Get(GetRootWindow())); 379 WmWindow::Get(GetRootWindow()));
390 380
391 wm_shelf_->shelf_widget()->PostCreateShelf(); 381 wm_shelf_->shelf_widget()->PostCreateShelf();
392 } 382 }
393 383
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after
565 if (ash_host_) 555 if (ash_host_)
566 ash_host_->PrepareForShutdown(); 556 ash_host_->PrepareForShutdown();
567 557
568 system_wallpaper_.reset(); 558 system_wallpaper_.reset();
569 aura::client::SetScreenPositionClient(root_window, nullptr); 559 aura::client::SetScreenPositionClient(root_window, nullptr);
570 } 560 }
571 561
572 void RootWindowController::CloseChildWindows() { 562 void RootWindowController::CloseChildWindows() {
573 // NOTE: this may be called multiple times. 563 // NOTE: this may be called multiple times.
574 564
575 // Remove observer as deactivating keyboard causes
576 // docked_window_layout_manager() to fire notifications.
577 if (docked_window_layout_manager() && wm_shelf_->shelf_layout_manager()) {
578 docked_window_layout_manager()->RemoveObserver(
579 wm_shelf_->shelf_layout_manager());
580 }
581
582 // Deactivate keyboard container before closing child windows and shutting 565 // Deactivate keyboard container before closing child windows and shutting
583 // down associated layout managers. 566 // down associated layout managers.
584 DeactivateKeyboard(keyboard::KeyboardController::GetInstance()); 567 DeactivateKeyboard(keyboard::KeyboardController::GetInstance());
585 568
586 // |panel_layout_manager_| needs to be shut down before windows are destroyed. 569 // |panel_layout_manager_| needs to be shut down before windows are destroyed.
587 if (panel_layout_manager_) { 570 if (panel_layout_manager_) {
588 panel_layout_manager_->Shutdown(); 571 panel_layout_manager_->Shutdown();
589 panel_layout_manager_ = nullptr; 572 panel_layout_manager_ = nullptr;
590 } 573 }
591 574
592 // |docked_window_layout_manager_| needs to be shut down before windows are
593 // destroyed.
594 if (docked_window_layout_manager_) {
595 docked_window_layout_manager_->Shutdown();
596 docked_window_layout_manager_ = nullptr;
597 }
598
599 WmShelf* shelf = GetShelf(); 575 WmShelf* shelf = GetShelf();
600 shelf->ShutdownShelfWidget(); 576 shelf->ShutdownShelfWidget();
601 577
602 workspace_controller_.reset(); 578 workspace_controller_.reset();
603 579
604 // Explicitly destroy top level windows. We do this because such windows may 580 // Explicitly destroy top level windows. We do this because such windows may
605 // query the RootWindow for state. 581 // query the RootWindow for state.
606 aura::WindowTracker non_toplevel_windows; 582 aura::WindowTracker non_toplevel_windows;
607 WmWindow* root = GetWindow(); 583 WmWindow* root = GetWindow();
608 non_toplevel_windows.Add(root->aura_window()); 584 non_toplevel_windows.Add(root->aura_window());
(...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after
848 DCHECK(lock_container); 824 DCHECK(lock_container);
849 lock_container->SetLayoutManager( 825 lock_container->SetLayoutManager(
850 base::MakeUnique<LockLayoutManager>(lock_container)); 826 base::MakeUnique<LockLayoutManager>(lock_container));
851 827
852 WmWindow* always_on_top_container = 828 WmWindow* always_on_top_container =
853 GetWmContainer(kShellWindowId_AlwaysOnTopContainer); 829 GetWmContainer(kShellWindowId_AlwaysOnTopContainer);
854 DCHECK(always_on_top_container); 830 DCHECK(always_on_top_container);
855 always_on_top_controller_ = 831 always_on_top_controller_ =
856 base::MakeUnique<AlwaysOnTopController>(always_on_top_container); 832 base::MakeUnique<AlwaysOnTopController>(always_on_top_container);
857 833
858 // Create Docked windows layout manager
859 WmWindow* docked_container = GetWmContainer(kShellWindowId_DockedContainer);
860 docked_window_layout_manager_ =
861 new DockedWindowLayoutManager(docked_container);
862 docked_container->SetLayoutManager(
863 base::WrapUnique(docked_window_layout_manager_));
864
865 // Create Panel layout manager 834 // Create Panel layout manager
866 WmWindow* wm_panel_container = GetWmContainer(kShellWindowId_PanelContainer); 835 WmWindow* wm_panel_container = GetWmContainer(kShellWindowId_PanelContainer);
867 panel_layout_manager_ = new PanelLayoutManager(wm_panel_container); 836 panel_layout_manager_ = new PanelLayoutManager(wm_panel_container);
868 wm_panel_container->aura_window()->SetLayoutManager(panel_layout_manager_); 837 wm_panel_container->aura_window()->SetLayoutManager(panel_layout_manager_);
869 838
870 wm::WmSnapToPixelLayoutManager::InstallOnContainers(root); 839 wm::WmSnapToPixelLayoutManager::InstallOnContainers(root);
871 840
872 // Make it easier to resize windows that partially overlap the shelf. Must 841 // Make it easier to resize windows that partially overlap the shelf. Must
873 // occur after the ShelfLayoutManager is constructed by ShelfWidget. 842 // occur after the ShelfLayoutManager is constructed by ShelfWidget.
874 aura::Window* shelf_container = GetContainer(kShellWindowId_ShelfContainer); 843 aura::Window* shelf_container = GetContainer(kShellWindowId_ShelfContainer);
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
944 default_container->SetChildrenUseExtendedHitRegion(); 913 default_container->SetChildrenUseExtendedHitRegion();
945 914
946 WmWindow* always_on_top_container = 915 WmWindow* always_on_top_container =
947 CreateContainer(kShellWindowId_AlwaysOnTopContainer, 916 CreateContainer(kShellWindowId_AlwaysOnTopContainer,
948 "AlwaysOnTopContainer", non_lock_screen_containers); 917 "AlwaysOnTopContainer", non_lock_screen_containers);
949 always_on_top_container->SetChildWindowVisibilityChangesAnimated(); 918 always_on_top_container->SetChildWindowVisibilityChangesAnimated();
950 always_on_top_container->SetSnapsChildrenToPhysicalPixelBoundary(); 919 always_on_top_container->SetSnapsChildrenToPhysicalPixelBoundary();
951 always_on_top_container->SetBoundsInScreenBehaviorForChildren( 920 always_on_top_container->SetBoundsInScreenBehaviorForChildren(
952 WmWindow::BoundsInScreenBehavior::USE_SCREEN_COORDINATES); 921 WmWindow::BoundsInScreenBehavior::USE_SCREEN_COORDINATES);
953 922
954 WmWindow* docked_container =
955 CreateContainer(kShellWindowId_DockedContainer, "DockedContainer",
956 non_lock_screen_containers);
957 docked_container->SetChildWindowVisibilityChangesAnimated();
958 docked_container->SetSnapsChildrenToPhysicalPixelBoundary();
959 docked_container->SetBoundsInScreenBehaviorForChildren(
960 WmWindow::BoundsInScreenBehavior::USE_SCREEN_COORDINATES);
961 docked_container->SetChildrenUseExtendedHitRegion();
962
963 WmWindow* shelf_container = 923 WmWindow* shelf_container =
964 CreateContainer(kShellWindowId_ShelfContainer, "ShelfContainer", 924 CreateContainer(kShellWindowId_ShelfContainer, "ShelfContainer",
965 non_lock_screen_containers); 925 non_lock_screen_containers);
966 shelf_container->SetSnapsChildrenToPhysicalPixelBoundary(); 926 shelf_container->SetSnapsChildrenToPhysicalPixelBoundary();
967 shelf_container->SetBoundsInScreenBehaviorForChildren( 927 shelf_container->SetBoundsInScreenBehaviorForChildren(
968 WmWindow::BoundsInScreenBehavior::USE_SCREEN_COORDINATES); 928 WmWindow::BoundsInScreenBehavior::USE_SCREEN_COORDINATES);
969 shelf_container->SetLockedToRoot(true); 929 shelf_container->SetLockedToRoot(true);
970 930
971 WmWindow* panel_container = 931 WmWindow* panel_container =
972 CreateContainer(kShellWindowId_PanelContainer, "PanelContainer", 932 CreateContainer(kShellWindowId_PanelContainer, "PanelContainer",
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after
1142 EnableTouchHudProjection(); 1102 EnableTouchHudProjection();
1143 else 1103 else
1144 DisableTouchHudProjection(); 1104 DisableTouchHudProjection();
1145 } 1105 }
1146 1106
1147 RootWindowController* GetRootWindowController(const aura::Window* root_window) { 1107 RootWindowController* GetRootWindowController(const aura::Window* root_window) {
1148 return root_window ? GetRootWindowSettings(root_window)->controller : nullptr; 1108 return root_window ? GetRootWindowSettings(root_window)->controller : nullptr;
1149 } 1109 }
1150 1110
1151 } // namespace ash 1111 } // namespace ash
OLDNEW
« no previous file with comments | « ash/root_window_controller.h ('k') | ash/shell_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698