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

Side by Side Diff: ash/root_window_controller.h

Issue 2625843002: Folds WmRootWindowController into RootWindowController (Closed)
Patch Set: definition in wm_root_window_controller.cc 2 Created 3 years, 11 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/mus/window_manager.cc ('k') | ash/root_window_controller.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 #ifndef ASH_ROOT_WINDOW_CONTROLLER_H_ 5 #ifndef ASH_ROOT_WINDOW_CONTROLLER_H_
6 #define ASH_ROOT_WINDOW_CONTROLLER_H_ 6 #define ASH_ROOT_WINDOW_CONTROLLER_H_
7 7
8 #include <map> 8 #include <map>
9 #include <memory> 9 #include <memory>
10 10
11 #include "ash/ash_export.h" 11 #include "ash/ash_export.h"
12 #include "ash/common/shell_observer.h" 12 #include "ash/common/shell_observer.h"
13 #include "ash/common/wm/workspace/workspace_types.h"
13 #include "ash/public/cpp/shelf_types.h" 14 #include "ash/public/cpp/shelf_types.h"
14 #include "base/macros.h" 15 #include "base/macros.h"
15 #include "ui/aura/window.h" 16 #include "ui/aura/window.h"
16 #include "ui/aura/window_tree_host.h" 17 #include "ui/aura/window_tree_host.h"
18 #include "ui/views/widget/widget.h"
17 19
18 namespace aura { 20 namespace aura {
19 class Window; 21 class Window;
20 } 22 }
21 23
22 namespace gfx { 24 namespace gfx {
23 class Point; 25 class Point;
24 } 26 }
25 27
26 namespace keyboard { 28 namespace keyboard {
27 class KeyboardController; 29 class KeyboardController;
28 } 30 }
29 31
30 namespace ui { 32 namespace ui {
31 class EventHandler; 33 class EventHandler;
34 class MenuModel;
32 class WindowTreeHost; 35 class WindowTreeHost;
33 } 36 }
34 37
35 namespace views { 38 namespace views {
36 class Widget; 39 class MenuModelAdapter;
40 class MenuRunner;
37 } 41 }
38 42
39 namespace wm { 43 namespace wm {
40 class ScopedCaptureClient; 44 class ScopedCaptureClient;
41 } 45 }
42 46
43 namespace ash { 47 namespace ash {
48 class AlwaysOnTopController;
49 class AnimatingWallpaperWidgetController;
44 class AshTouchExplorationManager; 50 class AshTouchExplorationManager;
45 class AshWindowTreeHost; 51 class AshWindowTreeHost;
46 class BootSplashScreen; 52 class BootSplashScreen;
47 class DockedWindowLayoutManager; 53 class DockedWindowLayoutManager;
48 enum class LoginStatus; 54 enum class LoginStatus;
49 class PanelLayoutManager; 55 class PanelLayoutManager;
50 class ShelfLayoutManager; 56 class ShelfLayoutManager;
51 class StackingController; 57 class StackingController;
52 class StatusAreaWidget; 58 class StatusAreaWidget;
59 class SystemModalContainerLayoutManager;
53 class SystemTray; 60 class SystemTray;
54 class SystemWallpaperController; 61 class SystemWallpaperController;
55 class TouchHudDebug; 62 class TouchHudDebug;
56 class TouchHudProjection; 63 class TouchHudProjection;
57 class WmRootWindowController; 64 class WallpaperWidgetController;
58 class WmShelf; 65 class WmShelf;
59 class WorkspaceController; 66 class WorkspaceController;
60 67
61 namespace mus { 68 namespace mus {
62 class RootWindowController; 69 class RootWindowController;
63 } 70 }
64 71
72 namespace wm {
73 class RootWindowLayoutManager;
74 }
75
65 // This class maintains the per root window state for ash. This class 76 // This class maintains the per root window state for ash. This class
66 // owns the root window and other dependent objects that should be 77 // owns the root window and other dependent objects that should be
67 // deleted upon the deletion of the root window. This object is 78 // deleted upon the deletion of the root window. This object is
68 // indirectly owned and deleted by |WindowTreeHostManager|. 79 // indirectly owned and deleted by |WindowTreeHostManager|.
69 // The RootWindowController for particular root window is stored in 80 // The RootWindowController for particular root window is stored in
70 // its property (RootWindowSettings) and can be obtained using 81 // its property (RootWindowSettings) and can be obtained using
71 // |GetRootWindowController(aura::WindowEventDispatcher*)| function. 82 // |GetRootWindowController(aura::WindowEventDispatcher*)| function.
72 class ASH_EXPORT RootWindowController : public ShellObserver { 83 class ASH_EXPORT RootWindowController : public ShellObserver {
73 public: 84 public:
74 // Enumerates the type of display. If there is only a single display then 85 // Enumerates the type of display. If there is only a single display then
75 // it is primary. In a multi-display environment one monitor is deemed the 86 // it is primary. In a multi-display environment one monitor is deemed the
76 // PRIMARY and all others SECONDARY. 87 // PRIMARY and all others SECONDARY.
77 enum class RootWindowType { PRIMARY, SECONDARY }; 88 enum class RootWindowType { PRIMARY, SECONDARY };
78 89
79 ~RootWindowController() override; 90 ~RootWindowController() override;
80 91
81 // Creates and Initialize the RootWindowController for primary display. 92 // Creates and Initialize the RootWindowController for primary display.
82 static void CreateForPrimaryDisplay(AshWindowTreeHost* host); 93 static void CreateForPrimaryDisplay(AshWindowTreeHost* host);
83 94
84 // Creates and Initialize the RootWindowController for secondary displays. 95 // Creates and Initialize the RootWindowController for secondary displays.
85 static void CreateForSecondaryDisplay(AshWindowTreeHost* host); 96 static void CreateForSecondaryDisplay(AshWindowTreeHost* host);
86 97
87 // Returns a RootWindowController of the window's root window. 98 // Returns a RootWindowController of the window's root window.
88 static RootWindowController* ForWindow(const aura::Window* window); 99 static RootWindowController* ForWindow(const aura::Window* window);
89 100
90 // Returns the RootWindowController of the target root window. 101 // Returns the RootWindowController of the target root window.
91 static RootWindowController* ForTargetRootWindow(); 102 static RootWindowController* ForTargetRootWindow();
92 103
104 // Configures |init_params| prior to initializing |widget|.
105 // |shell_container_id| is the id of the container to parent |widget| to.
106 // TODO(sky): remove this, http://crbug.com/671246.
107 void ConfigureWidgetInitParamsForContainer(
108 views::Widget* widget,
109 int shell_container_id,
110 views::Widget::InitParams* init_params);
111
93 // TODO(sky): move these to a separate class or use AshWindowTreeHost in 112 // TODO(sky): move these to a separate class or use AshWindowTreeHost in
94 // mash. http://crbug.com/671246. 113 // mash. http://crbug.com/671246.
95 AshWindowTreeHost* ash_host() { return ash_host_.get(); } 114 AshWindowTreeHost* ash_host() { return ash_host_.get(); }
96 const AshWindowTreeHost* ash_host() const { return ash_host_.get(); } 115 const AshWindowTreeHost* ash_host() const { return ash_host_.get(); }
97 116
98 aura::WindowTreeHost* GetHost(); 117 aura::WindowTreeHost* GetHost();
99 const aura::WindowTreeHost* GetHost() const; 118 const aura::WindowTreeHost* GetHost() const;
100 aura::Window* GetRootWindow(); 119 aura::Window* GetRootWindow();
101 const aura::Window* GetRootWindow() const; 120 const aura::Window* GetRootWindow() const;
102 121
103 WorkspaceController* workspace_controller(); 122 // TODO(sky): remove these. http://crbug.com/671246.
123 WmWindow* GetWindow() {
124 return const_cast<WmWindow*>(
125 const_cast<const RootWindowController*>(this)->GetWindow());
126 }
127 const WmWindow* GetWindow() const;
128
129 WorkspaceController* workspace_controller() {
130 return workspace_controller_.get();
131 }
132
133 wm::WorkspaceWindowState GetWorkspaceWindowState();
104 134
105 WmShelf* wm_shelf() const { return wm_shelf_.get(); } 135 WmShelf* wm_shelf() const { return wm_shelf_.get(); }
106 136
107 WmRootWindowController* wm_root_window_controller() { 137 bool HasShelf();
108 return wm_root_window_controller_.get(); 138
109 } 139 WmShelf* GetShelf();
140
141 // Creates the shelf for this root window and notifies observers.
142 void CreateShelf();
143
144 // Show shelf view if it was created hidden (before session has started).
145 // TODO(jamescook): Eliminate this and handle show via Shelf.
146 void ShowShelf();
110 147
111 // Get touch HUDs associated with this root window controller. 148 // Get touch HUDs associated with this root window controller.
112 TouchHudDebug* touch_hud_debug() const { return touch_hud_debug_; } 149 TouchHudDebug* touch_hud_debug() const { return touch_hud_debug_; }
113 TouchHudProjection* touch_hud_projection() const { 150 TouchHudProjection* touch_hud_projection() const {
114 return touch_hud_projection_; 151 return touch_hud_projection_;
115 } 152 }
116 153
117 // Set touch HUDs for this root window controller. The root window controller 154 // Set touch HUDs for this root window controller. The root window controller
118 // will not own the HUDs; their lifetimes are managed by themselves. Whenever 155 // will not own the HUDs; their lifetimes are managed by themselves. Whenever
119 // the widget showing a HUD is being destroyed (e.g. because of detaching a 156 // the widget showing a HUD is being destroyed (e.g. because of detaching a
120 // display), the HUD deletes itself. 157 // display), the HUD deletes itself.
121 void set_touch_hud_debug(TouchHudDebug* hud) { touch_hud_debug_ = hud; } 158 void set_touch_hud_debug(TouchHudDebug* hud) { touch_hud_debug_ = hud; }
122 void set_touch_hud_projection(TouchHudProjection* hud) { 159 void set_touch_hud_projection(TouchHudProjection* hud) {
123 touch_hud_projection_ = hud; 160 touch_hud_projection_ = hud;
124 } 161 }
125 162
163 DockedWindowLayoutManager* docked_window_layout_manager() {
164 return docked_window_layout_manager_;
165 }
166
167 PanelLayoutManager* panel_layout_manager() { return panel_layout_manager_; }
168
169 wm::RootWindowLayoutManager* root_window_layout_manager() {
170 return root_window_layout_manager_;
171 }
172
126 // Access the shelf layout manager associated with this root 173 // Access the shelf layout manager associated with this root
127 // window controller, NULL if no such shelf exists. 174 // window controller, NULL if no such shelf exists.
128 ShelfLayoutManager* GetShelfLayoutManager(); 175 ShelfLayoutManager* GetShelfLayoutManager();
129 176
177 // Returns the layout manager for the appropriate modal-container. If the
178 // window is inside the lockscreen modal container, then the layout manager
179 // for that is returned. Otherwise the layout manager for the default modal
180 // container is returned.
181 // If no window is specified (i.e. |window| is null), then the lockscreen
182 // modal container is used if the screen is currently locked. Otherwise, the
183 // default modal container is used.
184 SystemModalContainerLayoutManager* GetSystemModalLayoutManager(
185 WmWindow* window);
186
187 AlwaysOnTopController* always_on_top_controller() {
188 return always_on_top_controller_.get();
189 }
190
130 // May return null, for example for a secondary monitor at the login screen. 191 // May return null, for example for a secondary monitor at the login screen.
131 StatusAreaWidget* GetStatusAreaWidget(); 192 StatusAreaWidget* GetStatusAreaWidget();
132 193
133 // Returns the system tray on this root window. Note that 194 // Returns the system tray on this root window. Note that
134 // calling this on the root window that doesn't have a shelf will 195 // calling this on the root window that doesn't have a shelf will
135 // lead to a crash. 196 // lead to a crash.
136 SystemTray* GetSystemTray(); 197 SystemTray* GetSystemTray();
137 198
138 // True if the window can receive events on this root window. 199 // True if the window can receive events on this root window.
139 bool CanWindowReceiveEvents(aura::Window* window); 200 bool CanWindowReceiveEvents(aura::Window* window);
140 201
202 // Returns the window events will be targeted at for the specified location
203 // (in screen coordinates).
204 //
205 // NOTE: the returned window may not contain the location as resize handles
206 // may extend outside the bounds of the window.
207 WmWindow* FindEventTarget(const gfx::Point& location_in_screen);
208
209 // Gets the last location seen in a mouse event in this root window's
210 // coordinates. This may return a point outside the root window's bounds.
211 gfx::Point GetLastMouseLocationInRoot();
212
141 aura::Window* GetContainer(int container_id); 213 aura::Window* GetContainer(int container_id);
142 const aura::Window* GetContainer(int container_id) const; 214 const aura::Window* GetContainer(int container_id) const;
143 215
216 // TODO(sky): remove these. http://crbug.com/671246.
217 WmWindow* GetWmContainer(int container_id) {
218 return const_cast<WmWindow*>(
219 const_cast<const RootWindowController*>(this)->GetWmContainer(
220 container_id));
221 }
222 const WmWindow* GetWmContainer(int container_id) const;
223
224 WallpaperWidgetController* wallpaper_widget_controller() {
225 return wallpaper_widget_controller_.get();
226 }
227 void SetWallpaperWidgetController(WallpaperWidgetController* controller);
228
229 AnimatingWallpaperWidgetController* animating_wallpaper_widget_controller() {
230 return animating_wallpaper_widget_controller_.get();
231 }
232 void SetAnimatingWallpaperWidgetController(
233 AnimatingWallpaperWidgetController* controller);
234
144 // Called when the brightness/grayscale animation from white to the login 235 // Called when the brightness/grayscale animation from white to the login
145 // wallpaper image has started. Starts |boot_splash_screen_|'s hiding 236 // wallpaper image has started. Starts |boot_splash_screen_|'s hiding
146 // animation (if the screen is non-NULL). 237 // animation (if the screen is non-NULL).
147 void OnInitialWallpaperAnimationStarted(); 238 void OnInitialWallpaperAnimationStarted();
148 239
149 // Called when the wallpaper animation is finished. Updates 240 // Called when the wallpaper animation is finished. Updates
150 // |system_wallpaper_| to be black and drops |boot_splash_screen_| and moves 241 // |system_wallpaper_| to be black and drops |boot_splash_screen_| and moves
151 // the wallpaper controller into the root window controller. |widget| holds 242 // the wallpaper controller into the root window controller. |widget| holds
152 // the wallpaper image, or NULL if the wallpaper is a solid color. 243 // the wallpaper image, or NULL if the wallpaper is a solid color.
153 void OnWallpaperAnimationFinished(views::Widget* widget); 244 void OnWallpaperAnimationFinished(views::Widget* widget);
(...skipping 26 matching lines...) Expand all
180 // Deactivate virtual keyboard on current root window controller. 271 // Deactivate virtual keyboard on current root window controller.
181 void DeactivateKeyboard(keyboard::KeyboardController* keyboard_controller); 272 void DeactivateKeyboard(keyboard::KeyboardController* keyboard_controller);
182 273
183 // Tests if a window is associated with the virtual keyboard. 274 // Tests if a window is associated with the virtual keyboard.
184 bool IsVirtualKeyboardWindow(aura::Window* window); 275 bool IsVirtualKeyboardWindow(aura::Window* window);
185 276
186 // If touch exploration is enabled, update the touch exploration 277 // If touch exploration is enabled, update the touch exploration
187 // controller so that synthesized touch events are anchored at this point. 278 // controller so that synthesized touch events are anchored at this point.
188 void SetTouchAccessibilityAnchorPoint(const gfx::Point& anchor_point); 279 void SetTouchAccessibilityAnchorPoint(const gfx::Point& anchor_point);
189 280
281 // Shows a context menu at the |location_in_screen|.
282 void ShowContextMenu(const gfx::Point& location_in_screen,
283 ui::MenuSourceType source_type);
284
285 // Called when the login status changes after login (such as lock/unlock).
286 // TODO(oshima): Investigate if we can merge this and |OnLoginStateChanged|.
287 void UpdateAfterLoginStatusChange(LoginStatus status);
288
190 private: 289 private:
191 // TODO(sky): remove this. Temporary during ash-mus unification. 290 // TODO(sky): remove this. Temporary during ash-mus unification.
192 // http://crbug.com/671246. 291 // http://crbug.com/671246.
193 friend class mus::RootWindowController; 292 friend class mus::RootWindowController;
194 293
195 // Creates a new RootWindowController with the specified host. Only one of 294 // Creates a new RootWindowController with the specified host. Only one of
196 // |ash_host| or |window_tree_host| should be specified. This takes ownership 295 // |ash_host| or |window_tree_host| should be specified. This takes ownership
197 // of the supplied arguments. 296 // of the supplied arguments.
198 // TODO(sky): mash should create AshWindowTreeHost, http://crbug.com/671246. 297 // TODO(sky): mash should create AshWindowTreeHost, http://crbug.com/671246.
199 RootWindowController(AshWindowTreeHost* ash_host, 298 RootWindowController(AshWindowTreeHost* ash_host,
200 aura::WindowTreeHost* window_tree_host); 299 aura::WindowTreeHost* window_tree_host);
201 300
202 // Initializes the RootWindowController based on |root_window_type|. 301 // Initializes the RootWindowController based on |root_window_type|.
203 void Init(RootWindowType root_window_type); 302 void Init(RootWindowType root_window_type);
204 303
205 void InitLayoutManagers(); 304 void InitLayoutManagers();
206 305
306 // Creates the containers (WmWindows) used by the shell.
307 void CreateContainers();
308
309 // Creates the LayoutManagers for the windows created by CreateContainers().
310 // TODO(sky): merge this with InitLayoutManagers().
311 void CreateLayoutManagers();
312
207 // Initializes |system_wallpaper_| and possibly also |boot_splash_screen_|. 313 // Initializes |system_wallpaper_| and possibly also |boot_splash_screen_|.
208 // The initial color is determined by the |root_window_type| and whether or 314 // The initial color is determined by the |root_window_type| and whether or
209 // not this is the first boot. 315 // not this is the first boot.
210 void CreateSystemWallpaper(RootWindowType root_window_type); 316 void CreateSystemWallpaper(RootWindowType root_window_type);
211 317
212 // Enables projection touch HUD. 318 // Enables projection touch HUD.
213 void EnableTouchHudProjection(); 319 void EnableTouchHudProjection();
214 320
215 // Disables projection touch HUD. 321 // Disables projection touch HUD.
216 void DisableTouchHudProjection(); 322 void DisableTouchHudProjection();
217 323
218 DockedWindowLayoutManager* docked_window_layout_manager(); 324 // Resets WmShell::GetRootWindowForNewWindows() if appropriate. This is called
219 PanelLayoutManager* panel_layout_manager(); 325 // during shutdown to make sure GetRootWindowForNewWindows() isn't referencing
326 // this.
327 void ResetRootForNewWindowsIfNecessary();
328
329 // Callback for MenuModelAdapter.
330 void OnMenuClosed();
220 331
221 // Overridden from ShellObserver. 332 // Overridden from ShellObserver.
222 void OnLoginStateChanged(LoginStatus status) override; 333 void OnLoginStateChanged(LoginStatus status) override;
223 void OnTouchHudProjectionToggled(bool enabled) override; 334 void OnTouchHudProjectionToggled(bool enabled) override;
224 335
336 // TODO(sky): temporary, fold into CloseChildWindows().
337 void CloseChildWindowsImpl();
338
225 std::unique_ptr<AshWindowTreeHost> ash_host_; 339 std::unique_ptr<AshWindowTreeHost> ash_host_;
226 std::unique_ptr<aura::WindowTreeHost> mus_window_tree_host_; 340 std::unique_ptr<aura::WindowTreeHost> mus_window_tree_host_;
227 // This comes from |ash_host_| or |mus_window_tree_host_|. 341 // This comes from |ash_host_| or |mus_window_tree_host_|.
228 aura::WindowTreeHost* window_tree_host_; 342 aura::WindowTreeHost* window_tree_host_;
229 343
230 std::unique_ptr<WmRootWindowController> wm_root_window_controller_; 344 // LayoutManagers are owned by the window they are installed on.
345 DockedWindowLayoutManager* docked_window_layout_manager_ = nullptr;
346 PanelLayoutManager* panel_layout_manager_ = nullptr;
347 wm::RootWindowLayoutManager* root_window_layout_manager_ = nullptr;
348
349 std::unique_ptr<WallpaperWidgetController> wallpaper_widget_controller_;
350 std::unique_ptr<AnimatingWallpaperWidgetController>
351 animating_wallpaper_widget_controller_;
352 std::unique_ptr<WorkspaceController> workspace_controller_;
353
354 std::unique_ptr<AlwaysOnTopController> always_on_top_controller_;
355
356 // Manages the context menu.
357 std::unique_ptr<ui::MenuModel> menu_model_;
358 std::unique_ptr<views::MenuModelAdapter> menu_model_adapter_;
359 std::unique_ptr<views::MenuRunner> menu_runner_;
231 360
232 std::unique_ptr<StackingController> stacking_controller_; 361 std::unique_ptr<StackingController> stacking_controller_;
233 362
234 // The shelf controller for this root window. Exists for the entire lifetime 363 // The shelf controller for this root window. Exists for the entire lifetime
235 // of the RootWindowController so that it is safe for observers to be added 364 // of the RootWindowController so that it is safe for observers to be added
236 // to it during construction of the shelf widget and status tray. 365 // to it during construction of the shelf widget and status tray.
237 std::unique_ptr<WmShelf> wm_shelf_; 366 std::unique_ptr<WmShelf> wm_shelf_;
238 367
239 std::unique_ptr<SystemWallpaperController> system_wallpaper_; 368 std::unique_ptr<SystemWallpaperController> system_wallpaper_;
240 369
(...skipping 17 matching lines...) Expand all
258 387
259 // On classic ash, returns the RootWindowController for the given |root_window|. 388 // On classic ash, returns the RootWindowController for the given |root_window|.
260 // On mus ash, returns the RootWindowController for the primary display. 389 // On mus ash, returns the RootWindowController for the primary display.
261 // See RootWindowController class comment above. 390 // See RootWindowController class comment above.
262 ASH_EXPORT RootWindowController* GetRootWindowController( 391 ASH_EXPORT RootWindowController* GetRootWindowController(
263 const aura::Window* root_window); 392 const aura::Window* root_window);
264 393
265 } // namespace ash 394 } // namespace ash
266 395
267 #endif // ASH_ROOT_WINDOW_CONTROLLER_H_ 396 #endif // ASH_ROOT_WINDOW_CONTROLLER_H_
OLDNEW
« no previous file with comments | « ash/mus/window_manager.cc ('k') | ash/root_window_controller.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698