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

Side by Side Diff: ash/common/root_window_controller_common.cc

Issue 2297893002: Merges RootWindowControllerCommon into WmRootWindowController (Closed)
Patch Set: feedback Created 4 years, 3 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
(Empty)
1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "ash/common/root_window_controller_common.h"
6
7 #include "ash/common/shell_window_ids.h"
8 #include "ash/common/wm/root_window_layout_manager.h"
9 #include "ash/common/wm/workspace/workspace_layout_manager.h"
10 #include "ash/common/wm/workspace_controller.h"
11 #include "ash/common/wm_shell.h"
12 #include "ash/common/wm_window.h"
13 #include "base/memory/ptr_util.h"
14
15 namespace ash {
16 namespace {
17
18 // Creates a new window for use as a container.
19 WmWindow* CreateContainer(int window_id, const char* name, WmWindow* parent) {
20 WmWindow* window = WmShell::Get()->NewContainerWindow();
21 window->SetShellWindowId(window_id);
22 window->SetName(name);
23 parent->AddChild(window);
24 if (window_id != kShellWindowId_UnparentedControlContainer)
25 window->Show();
26 return window;
27 }
28
29 } // namespace
30
31 RootWindowControllerCommon::RootWindowControllerCommon(WmWindow* root)
32 : root_(root), root_window_layout_(nullptr) {}
33
34 RootWindowControllerCommon::~RootWindowControllerCommon() {}
35
36 void RootWindowControllerCommon::CreateContainers() {
37 // These containers are just used by PowerButtonController to animate groups
38 // of containers simultaneously without messing up the current transformations
39 // on those containers. These are direct children of the root window; all of
40 // the other containers are their children.
41
42 // The wallpaper container is not part of the lock animation, so it is not
43 // included in those animate groups. When the screen is locked, the wallpaper
44 // is moved to the lock screen wallpaper container (and moved back on unlock).
45 // Ensure that there's an opaque layer occluding the non-lock-screen layers.
46 WmWindow* wallpaper_container = CreateContainer(
47 kShellWindowId_WallpaperContainer, "WallpaperContainer", root_);
48 wallpaper_container->SetChildWindowVisibilityChangesAnimated();
49
50 WmWindow* non_lock_screen_containers =
51 CreateContainer(kShellWindowId_NonLockScreenContainersContainer,
52 "NonLockScreenContainersContainer", root_);
53 // Clip all windows inside this container, as half pixel of the window's
54 // texture may become visible when the screen is scaled. crbug.com/368591.
55 non_lock_screen_containers->SetMasksToBounds(true);
56
57 WmWindow* lock_wallpaper_containers =
58 CreateContainer(kShellWindowId_LockScreenWallpaperContainer,
59 "LockScreenWallpaperContainer", root_);
60 lock_wallpaper_containers->SetChildWindowVisibilityChangesAnimated();
61
62 WmWindow* lock_screen_containers =
63 CreateContainer(kShellWindowId_LockScreenContainersContainer,
64 "LockScreenContainersContainer", root_);
65 WmWindow* lock_screen_related_containers =
66 CreateContainer(kShellWindowId_LockScreenRelatedContainersContainer,
67 "LockScreenRelatedContainersContainer", root_);
68
69 CreateContainer(kShellWindowId_UnparentedControlContainer,
70 "UnparentedControlContainer", non_lock_screen_containers);
71
72 WmWindow* default_container =
73 CreateContainer(kShellWindowId_DefaultContainer, "DefaultContainer",
74 non_lock_screen_containers);
75 default_container->SetChildWindowVisibilityChangesAnimated();
76 default_container->SetSnapsChildrenToPhysicalPixelBoundary();
77 default_container->SetBoundsInScreenBehaviorForChildren(
78 WmWindow::BoundsInScreenBehavior::USE_SCREEN_COORDINATES);
79 default_container->SetChildrenUseExtendedHitRegion();
80
81 WmWindow* always_on_top_container =
82 CreateContainer(kShellWindowId_AlwaysOnTopContainer,
83 "AlwaysOnTopContainer", non_lock_screen_containers);
84 always_on_top_container->SetChildWindowVisibilityChangesAnimated();
85 always_on_top_container->SetSnapsChildrenToPhysicalPixelBoundary();
86 always_on_top_container->SetBoundsInScreenBehaviorForChildren(
87 WmWindow::BoundsInScreenBehavior::USE_SCREEN_COORDINATES);
88
89 WmWindow* docked_container =
90 CreateContainer(kShellWindowId_DockedContainer, "DockedContainer",
91 non_lock_screen_containers);
92 docked_container->SetChildWindowVisibilityChangesAnimated();
93 docked_container->SetSnapsChildrenToPhysicalPixelBoundary();
94 docked_container->SetBoundsInScreenBehaviorForChildren(
95 WmWindow::BoundsInScreenBehavior::USE_SCREEN_COORDINATES);
96 docked_container->SetChildrenUseExtendedHitRegion();
97
98 WmWindow* shelf_container =
99 CreateContainer(kShellWindowId_ShelfContainer, "ShelfContainer",
100 non_lock_screen_containers);
101 shelf_container->SetSnapsChildrenToPhysicalPixelBoundary();
102 shelf_container->SetBoundsInScreenBehaviorForChildren(
103 WmWindow::BoundsInScreenBehavior::USE_SCREEN_COORDINATES);
104 shelf_container->SetDescendantsStayInSameRootWindow(true);
105
106 WmWindow* panel_container =
107 CreateContainer(kShellWindowId_PanelContainer, "PanelContainer",
108 non_lock_screen_containers);
109 panel_container->SetSnapsChildrenToPhysicalPixelBoundary();
110 panel_container->SetBoundsInScreenBehaviorForChildren(
111 WmWindow::BoundsInScreenBehavior::USE_SCREEN_COORDINATES);
112
113 WmWindow* shelf_bubble_container =
114 CreateContainer(kShellWindowId_ShelfBubbleContainer,
115 "ShelfBubbleContainer", non_lock_screen_containers);
116 shelf_bubble_container->SetSnapsChildrenToPhysicalPixelBoundary();
117 shelf_bubble_container->SetBoundsInScreenBehaviorForChildren(
118 WmWindow::BoundsInScreenBehavior::USE_SCREEN_COORDINATES);
119 shelf_bubble_container->SetDescendantsStayInSameRootWindow(true);
120
121 WmWindow* app_list_container =
122 CreateContainer(kShellWindowId_AppListContainer, "AppListContainer",
123 non_lock_screen_containers);
124 app_list_container->SetSnapsChildrenToPhysicalPixelBoundary();
125 app_list_container->SetBoundsInScreenBehaviorForChildren(
126 WmWindow::BoundsInScreenBehavior::USE_SCREEN_COORDINATES);
127
128 WmWindow* modal_container =
129 CreateContainer(kShellWindowId_SystemModalContainer,
130 "SystemModalContainer", non_lock_screen_containers);
131 modal_container->SetSnapsChildrenToPhysicalPixelBoundary();
132 modal_container->SetChildWindowVisibilityChangesAnimated();
133 modal_container->SetBoundsInScreenBehaviorForChildren(
134 WmWindow::BoundsInScreenBehavior::USE_SCREEN_COORDINATES);
135 modal_container->SetChildrenUseExtendedHitRegion();
136
137 // TODO(beng): Figure out if we can make this use
138 // SystemModalContainerEventFilter instead of stops_event_propagation.
139 WmWindow* lock_container =
140 CreateContainer(kShellWindowId_LockScreenContainer, "LockScreenContainer",
141 lock_screen_containers);
142 lock_container->SetSnapsChildrenToPhysicalPixelBoundary();
143 lock_container->SetBoundsInScreenBehaviorForChildren(
144 WmWindow::BoundsInScreenBehavior::USE_SCREEN_COORDINATES);
145 // TODO(beng): stopsevents
146
147 WmWindow* lock_modal_container =
148 CreateContainer(kShellWindowId_LockSystemModalContainer,
149 "LockSystemModalContainer", lock_screen_containers);
150 lock_modal_container->SetSnapsChildrenToPhysicalPixelBoundary();
151 lock_modal_container->SetChildWindowVisibilityChangesAnimated();
152 lock_modal_container->SetBoundsInScreenBehaviorForChildren(
153 WmWindow::BoundsInScreenBehavior::USE_SCREEN_COORDINATES);
154 lock_modal_container->SetChildrenUseExtendedHitRegion();
155
156 WmWindow* status_container =
157 CreateContainer(kShellWindowId_StatusContainer, "StatusContainer",
158 lock_screen_related_containers);
159 status_container->SetSnapsChildrenToPhysicalPixelBoundary();
160 status_container->SetBoundsInScreenBehaviorForChildren(
161 WmWindow::BoundsInScreenBehavior::USE_SCREEN_COORDINATES);
162 status_container->SetDescendantsStayInSameRootWindow(true);
163
164 WmWindow* settings_bubble_container =
165 CreateContainer(kShellWindowId_SettingBubbleContainer,
166 "SettingBubbleContainer", lock_screen_related_containers);
167 settings_bubble_container->SetChildWindowVisibilityChangesAnimated();
168 settings_bubble_container->SetSnapsChildrenToPhysicalPixelBoundary();
169 settings_bubble_container->SetBoundsInScreenBehaviorForChildren(
170 WmWindow::BoundsInScreenBehavior::USE_SCREEN_COORDINATES);
171 settings_bubble_container->SetDescendantsStayInSameRootWindow(true);
172
173 WmWindow* virtual_keyboard_parent_container = CreateContainer(
174 kShellWindowId_ImeWindowParentContainer, "VirtualKeyboardParentContainer",
175 lock_screen_related_containers);
176 virtual_keyboard_parent_container->SetSnapsChildrenToPhysicalPixelBoundary();
177 virtual_keyboard_parent_container->SetBoundsInScreenBehaviorForChildren(
178 WmWindow::BoundsInScreenBehavior::USE_SCREEN_COORDINATES);
179
180 WmWindow* menu_container =
181 CreateContainer(kShellWindowId_MenuContainer, "MenuContainer",
182 lock_screen_related_containers);
183 menu_container->SetChildWindowVisibilityChangesAnimated();
184 menu_container->SetSnapsChildrenToPhysicalPixelBoundary();
185 menu_container->SetBoundsInScreenBehaviorForChildren(
186 WmWindow::BoundsInScreenBehavior::USE_SCREEN_COORDINATES);
187
188 WmWindow* drag_drop_container = CreateContainer(
189 kShellWindowId_DragImageAndTooltipContainer,
190 "DragImageAndTooltipContainer", lock_screen_related_containers);
191 drag_drop_container->SetChildWindowVisibilityChangesAnimated();
192 drag_drop_container->SetSnapsChildrenToPhysicalPixelBoundary();
193 drag_drop_container->SetBoundsInScreenBehaviorForChildren(
194 WmWindow::BoundsInScreenBehavior::USE_SCREEN_COORDINATES);
195
196 WmWindow* overlay_container =
197 CreateContainer(kShellWindowId_OverlayContainer, "OverlayContainer",
198 lock_screen_related_containers);
199 overlay_container->SetSnapsChildrenToPhysicalPixelBoundary();
200 overlay_container->SetBoundsInScreenBehaviorForChildren(
201 WmWindow::BoundsInScreenBehavior::USE_SCREEN_COORDINATES);
202
203 #if defined(OS_CHROMEOS)
204 WmWindow* mouse_cursor_container = CreateContainer(
205 kShellWindowId_MouseCursorContainer, "MouseCursorContainer", root_);
206 mouse_cursor_container->SetBoundsInScreenBehaviorForChildren(
207 WmWindow::BoundsInScreenBehavior::USE_SCREEN_COORDINATES);
208 #endif
209
210 CreateContainer(kShellWindowId_PowerButtonAnimationContainer,
211 "PowerButtonAnimationContainer", root_);
212 }
213
214 void RootWindowControllerCommon::CreateLayoutManagers() {
215 root_window_layout_ = new wm::RootWindowLayoutManager(root_);
216 root_->SetLayoutManager(base::WrapUnique(root_window_layout_));
217
218 WmWindow* default_container =
219 root_->GetChildByShellWindowId(kShellWindowId_DefaultContainer);
220 workspace_controller_.reset(new WorkspaceController(default_container));
221 }
222
223 void RootWindowControllerCommon::DeleteWorkspaceController() {
224 workspace_controller_.reset();
225 }
226
227 } // namespace ash
OLDNEW
« no previous file with comments | « ash/common/root_window_controller_common.h ('k') | ash/common/wm/maximize_mode/maximize_mode_window_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698