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

Side by Side Diff: ash/root_window_controller_common.cc

Issue 2025413002: Moves RootWindowControllerCommon and LayoutManager to common (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@use_root_window_controller_common
Patch Set: merge Created 4 years, 6 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_common.h ('k') | ash/root_window_controller_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
(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/root_window_controller_common.h"
6
7 #include "ash/common/wm/wm_globals.h"
8 #include "ash/common/wm/wm_window.h"
9 #include "ash/shell_window_ids.h"
10 #include "ash/wm/root_window_layout_manager.h"
11 #include "base/memory/ptr_util.h"
12
13 namespace ash {
14 namespace {
15
16 // Creates a new window for use as a container.
17 wm::WmWindow* CreateContainer(int window_id,
18 const char* name,
19 wm::WmWindow* parent) {
20 wm::WmWindow* window = wm::WmGlobals::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(wm::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 desktop background container is not part of the lock animation, so it
43 // is not included in those animate groups.
44 // When screen is locked desktop background is moved to lock screen background
45 // container (moved back on unlock). We want to make sure that there's an
46 // opaque layer occluding the non-lock-screen layers.
47 wm::WmWindow* desktop_background_container =
48 CreateContainer(kShellWindowId_DesktopBackgroundContainer,
49 "DesktopBackgroundContainer", root_);
50 desktop_background_container->SetChildWindowVisibilityChangesAnimated();
51
52 wm::WmWindow* non_lock_screen_containers =
53 CreateContainer(kShellWindowId_NonLockScreenContainersContainer,
54 "NonLockScreenContainersContainer", root_);
55 // Clip all windows inside this container, as half pixel of the window's
56 // texture may become visible when the screen is scaled. crbug.com/368591.
57 non_lock_screen_containers->SetMasksToBounds(true);
58
59 wm::WmWindow* lock_background_containers =
60 CreateContainer(kShellWindowId_LockScreenBackgroundContainer,
61 "LockScreenBackgroundContainer", root_);
62 lock_background_containers->SetChildWindowVisibilityChangesAnimated();
63
64 wm::WmWindow* lock_screen_containers =
65 CreateContainer(kShellWindowId_LockScreenContainersContainer,
66 "LockScreenContainersContainer", root_);
67 wm::WmWindow* lock_screen_related_containers =
68 CreateContainer(kShellWindowId_LockScreenRelatedContainersContainer,
69 "LockScreenRelatedContainersContainer", root_);
70
71 CreateContainer(kShellWindowId_UnparentedControlContainer,
72 "UnparentedControlContainer", non_lock_screen_containers);
73
74 wm::WmWindow* default_container =
75 CreateContainer(kShellWindowId_DefaultContainer, "DefaultContainer",
76 non_lock_screen_containers);
77 default_container->SetChildWindowVisibilityChangesAnimated();
78 default_container->SetSnapsChildrenToPhysicalPixelBoundary();
79 default_container->SetBoundsInScreenBehaviorForChildren(
80 wm::WmWindow::BoundsInScreenBehavior::USE_SCREEN_COORDINATES);
81 default_container->SetChildrenUseExtendedHitRegion();
82
83 wm::WmWindow* always_on_top_container =
84 CreateContainer(kShellWindowId_AlwaysOnTopContainer,
85 "AlwaysOnTopContainer", non_lock_screen_containers);
86 always_on_top_container->SetChildWindowVisibilityChangesAnimated();
87 always_on_top_container->SetSnapsChildrenToPhysicalPixelBoundary();
88 always_on_top_container->SetBoundsInScreenBehaviorForChildren(
89 wm::WmWindow::BoundsInScreenBehavior::USE_SCREEN_COORDINATES);
90
91 wm::WmWindow* docked_container =
92 CreateContainer(kShellWindowId_DockedContainer, "DockedContainer",
93 non_lock_screen_containers);
94 docked_container->SetChildWindowVisibilityChangesAnimated();
95 docked_container->SetSnapsChildrenToPhysicalPixelBoundary();
96 docked_container->SetBoundsInScreenBehaviorForChildren(
97 wm::WmWindow::BoundsInScreenBehavior::USE_SCREEN_COORDINATES);
98 docked_container->SetChildrenUseExtendedHitRegion();
99
100 wm::WmWindow* shelf_container =
101 CreateContainer(kShellWindowId_ShelfContainer, "ShelfContainer",
102 non_lock_screen_containers);
103 shelf_container->SetSnapsChildrenToPhysicalPixelBoundary();
104 shelf_container->SetBoundsInScreenBehaviorForChildren(
105 wm::WmWindow::BoundsInScreenBehavior::USE_SCREEN_COORDINATES);
106 shelf_container->SetDescendantsStayInSameRootWindow(true);
107
108 wm::WmWindow* panel_container =
109 CreateContainer(kShellWindowId_PanelContainer, "PanelContainer",
110 non_lock_screen_containers);
111 panel_container->SetSnapsChildrenToPhysicalPixelBoundary();
112 panel_container->SetBoundsInScreenBehaviorForChildren(
113 wm::WmWindow::BoundsInScreenBehavior::USE_SCREEN_COORDINATES);
114
115 wm::WmWindow* shelf_bubble_container =
116 CreateContainer(kShellWindowId_ShelfBubbleContainer,
117 "ShelfBubbleContainer", non_lock_screen_containers);
118 shelf_bubble_container->SetSnapsChildrenToPhysicalPixelBoundary();
119 shelf_bubble_container->SetBoundsInScreenBehaviorForChildren(
120 wm::WmWindow::BoundsInScreenBehavior::USE_SCREEN_COORDINATES);
121 shelf_bubble_container->SetDescendantsStayInSameRootWindow(true);
122
123 wm::WmWindow* app_list_container =
124 CreateContainer(kShellWindowId_AppListContainer, "AppListContainer",
125 non_lock_screen_containers);
126 app_list_container->SetSnapsChildrenToPhysicalPixelBoundary();
127 app_list_container->SetBoundsInScreenBehaviorForChildren(
128 wm::WmWindow::BoundsInScreenBehavior::USE_SCREEN_COORDINATES);
129
130 wm::WmWindow* modal_container =
131 CreateContainer(kShellWindowId_SystemModalContainer,
132 "SystemModalContainer", non_lock_screen_containers);
133 modal_container->SetSnapsChildrenToPhysicalPixelBoundary();
134 modal_container->SetChildWindowVisibilityChangesAnimated();
135 modal_container->SetBoundsInScreenBehaviorForChildren(
136 wm::WmWindow::BoundsInScreenBehavior::USE_SCREEN_COORDINATES);
137 modal_container->SetChildrenUseExtendedHitRegion();
138
139 // TODO(beng): Figure out if we can make this use
140 // SystemModalContainerEventFilter instead of stops_event_propagation.
141 wm::WmWindow* lock_container =
142 CreateContainer(kShellWindowId_LockScreenContainer, "LockScreenContainer",
143 lock_screen_containers);
144 lock_container->SetSnapsChildrenToPhysicalPixelBoundary();
145 lock_container->SetBoundsInScreenBehaviorForChildren(
146 wm::WmWindow::BoundsInScreenBehavior::USE_SCREEN_COORDINATES);
147 // TODO(beng): stopsevents
148
149 wm::WmWindow* lock_modal_container =
150 CreateContainer(kShellWindowId_LockSystemModalContainer,
151 "LockSystemModalContainer", lock_screen_containers);
152 lock_modal_container->SetSnapsChildrenToPhysicalPixelBoundary();
153 lock_modal_container->SetChildWindowVisibilityChangesAnimated();
154 lock_modal_container->SetBoundsInScreenBehaviorForChildren(
155 wm::WmWindow::BoundsInScreenBehavior::USE_SCREEN_COORDINATES);
156 lock_modal_container->SetChildrenUseExtendedHitRegion();
157
158 wm::WmWindow* status_container =
159 CreateContainer(kShellWindowId_StatusContainer, "StatusContainer",
160 lock_screen_related_containers);
161 status_container->SetSnapsChildrenToPhysicalPixelBoundary();
162 status_container->SetBoundsInScreenBehaviorForChildren(
163 wm::WmWindow::BoundsInScreenBehavior::USE_SCREEN_COORDINATES);
164 status_container->SetDescendantsStayInSameRootWindow(true);
165
166 wm::WmWindow* settings_bubble_container =
167 CreateContainer(kShellWindowId_SettingBubbleContainer,
168 "SettingBubbleContainer", lock_screen_related_containers);
169 settings_bubble_container->SetChildWindowVisibilityChangesAnimated();
170 settings_bubble_container->SetSnapsChildrenToPhysicalPixelBoundary();
171 settings_bubble_container->SetBoundsInScreenBehaviorForChildren(
172 wm::WmWindow::BoundsInScreenBehavior::USE_SCREEN_COORDINATES);
173 settings_bubble_container->SetDescendantsStayInSameRootWindow(true);
174
175 wm::WmWindow* virtual_keyboard_parent_container = CreateContainer(
176 kShellWindowId_ImeWindowParentContainer, "VirtualKeyboardParentContainer",
177 lock_screen_related_containers);
178 virtual_keyboard_parent_container->SetSnapsChildrenToPhysicalPixelBoundary();
179 virtual_keyboard_parent_container->SetBoundsInScreenBehaviorForChildren(
180 wm::WmWindow::BoundsInScreenBehavior::USE_SCREEN_COORDINATES);
181
182 wm::WmWindow* menu_container =
183 CreateContainer(kShellWindowId_MenuContainer, "MenuContainer",
184 lock_screen_related_containers);
185 menu_container->SetChildWindowVisibilityChangesAnimated();
186 menu_container->SetSnapsChildrenToPhysicalPixelBoundary();
187 menu_container->SetBoundsInScreenBehaviorForChildren(
188 wm::WmWindow::BoundsInScreenBehavior::USE_SCREEN_COORDINATES);
189
190 wm::WmWindow* drag_drop_container = CreateContainer(
191 kShellWindowId_DragImageAndTooltipContainer,
192 "DragImageAndTooltipContainer", lock_screen_related_containers);
193 drag_drop_container->SetChildWindowVisibilityChangesAnimated();
194 drag_drop_container->SetSnapsChildrenToPhysicalPixelBoundary();
195 drag_drop_container->SetBoundsInScreenBehaviorForChildren(
196 wm::WmWindow::BoundsInScreenBehavior::USE_SCREEN_COORDINATES);
197
198 wm::WmWindow* overlay_container =
199 CreateContainer(kShellWindowId_OverlayContainer, "OverlayContainer",
200 lock_screen_related_containers);
201 overlay_container->SetSnapsChildrenToPhysicalPixelBoundary();
202 overlay_container->SetBoundsInScreenBehaviorForChildren(
203 wm::WmWindow::BoundsInScreenBehavior::USE_SCREEN_COORDINATES);
204
205 #if defined(OS_CHROMEOS)
206 wm::WmWindow* mouse_cursor_container = CreateContainer(
207 kShellWindowId_MouseCursorContainer, "MouseCursorContainer", root_);
208 mouse_cursor_container->SetBoundsInScreenBehaviorForChildren(
209 wm::WmWindow::BoundsInScreenBehavior::USE_SCREEN_COORDINATES);
210 #endif
211
212 CreateContainer(kShellWindowId_PowerButtonAnimationContainer,
213 "PowerButtonAnimationContainer", root_);
214 }
215
216 void RootWindowControllerCommon::CreateLayoutManagers() {
217 root_window_layout_ = new wm::RootWindowLayoutManager(root_);
218 root_->SetLayoutManager(base::WrapUnique(root_window_layout_));
219 }
220
221 } // namespace ash
OLDNEW
« no previous file with comments | « ash/root_window_controller_common.h ('k') | ash/root_window_controller_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698