OLD | NEW |
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 enum class RootWindowType { PRIMARY, SECONDARY }; | 85 enum class RootWindowType { PRIMARY, SECONDARY }; |
75 | 86 |
76 ~RootWindowController() override; | 87 ~RootWindowController() override; |
77 | 88 |
78 // Creates and Initialize the RootWindowController for primary display. | 89 // Creates and Initialize the RootWindowController for primary display. |
79 static void CreateForPrimaryDisplay(AshWindowTreeHost* host); | 90 static void CreateForPrimaryDisplay(AshWindowTreeHost* host); |
80 | 91 |
81 // Creates and Initialize the RootWindowController for secondary displays. | 92 // Creates and Initialize the RootWindowController for secondary displays. |
82 static void CreateForSecondaryDisplay(AshWindowTreeHost* host); | 93 static void CreateForSecondaryDisplay(AshWindowTreeHost* host); |
83 | 94 |
84 // Returns a RootWindowController of the window's root window. | 95 // Returns a RootWindowController of the window's root window. |
85 static RootWindowController* ForWindow(const aura::Window* window); | 96 static RootWindowController* ForWindow(const aura::Window* window); |
86 | 97 |
87 // Returns the RootWindowController of the target root window. | 98 // Returns the RootWindowController of the target root window. |
88 static RootWindowController* ForTargetRootWindow(); | 99 static RootWindowController* ForTargetRootWindow(); |
89 | 100 |
| 101 // Configures |init_params| prior to initializing |widget|. |
| 102 // |shell_container_id| is the id of the container to parent |widget| to. |
| 103 // TODO(sky): remove this, http://crbug.com/671246. |
| 104 void ConfigureWidgetInitParamsForContainer( |
| 105 views::Widget* widget, |
| 106 int shell_container_id, |
| 107 views::Widget::InitParams* init_params); |
| 108 |
90 // TODO(sky): move these to a separate class or use AshWindowTreeHost in | 109 // TODO(sky): move these to a separate class or use AshWindowTreeHost in |
91 // mash. http://crbug.com/671246. | 110 // mash. http://crbug.com/671246. |
92 AshWindowTreeHost* ash_host() { return ash_host_.get(); } | 111 AshWindowTreeHost* ash_host() { return ash_host_.get(); } |
93 const AshWindowTreeHost* ash_host() const { return ash_host_.get(); } | 112 const AshWindowTreeHost* ash_host() const { return ash_host_.get(); } |
94 | 113 |
95 aura::WindowTreeHost* GetHost(); | 114 aura::WindowTreeHost* GetHost(); |
96 const aura::WindowTreeHost* GetHost() const; | 115 const aura::WindowTreeHost* GetHost() const; |
97 aura::Window* GetRootWindow(); | 116 aura::Window* GetRootWindow(); |
98 const aura::Window* GetRootWindow() const; | 117 const aura::Window* GetRootWindow() const; |
99 | 118 |
100 WorkspaceController* workspace_controller(); | 119 // TODO(sky): remove these. http://crbug.com/671246. |
| 120 WmWindow* GetWindow() { |
| 121 return const_cast<WmWindow*>( |
| 122 const_cast<const RootWindowController*>(this)->GetWindow()); |
| 123 } |
| 124 const WmWindow* GetWindow() const; |
| 125 |
| 126 WorkspaceController* workspace_controller() { |
| 127 return workspace_controller_.get(); |
| 128 } |
| 129 |
| 130 wm::WorkspaceWindowState GetWorkspaceWindowState(); |
101 | 131 |
102 WmShelf* wm_shelf() const { return wm_shelf_.get(); } | 132 WmShelf* wm_shelf() const { return wm_shelf_.get(); } |
103 | 133 |
104 WmRootWindowController* wm_root_window_controller() { | 134 bool HasShelf(); |
105 return wm_root_window_controller_.get(); | 135 |
106 } | 136 WmShelf* GetShelf(); |
| 137 |
| 138 // Creates the shelf for this root window and notifies observers. |
| 139 void CreateShelf(); |
| 140 |
| 141 // Show shelf view if it was created hidden (before session has started). |
| 142 // TODO(jamescook): Eliminate this and handle show via Shelf. |
| 143 void ShowShelf(); |
107 | 144 |
108 // Get touch HUDs associated with this root window controller. | 145 // Get touch HUDs associated with this root window controller. |
109 TouchHudDebug* touch_hud_debug() const { return touch_hud_debug_; } | 146 TouchHudDebug* touch_hud_debug() const { return touch_hud_debug_; } |
110 TouchHudProjection* touch_hud_projection() const { | 147 TouchHudProjection* touch_hud_projection() const { |
111 return touch_hud_projection_; | 148 return touch_hud_projection_; |
112 } | 149 } |
113 | 150 |
114 // Set touch HUDs for this root window controller. The root window controller | 151 // Set touch HUDs for this root window controller. The root window controller |
115 // will not own the HUDs; their lifetimes are managed by themselves. Whenever | 152 // will not own the HUDs; their lifetimes are managed by themselves. Whenever |
116 // the widget showing a HUD is being destroyed (e.g. because of detaching a | 153 // the widget showing a HUD is being destroyed (e.g. because of detaching a |
117 // display), the HUD deletes itself. | 154 // display), the HUD deletes itself. |
118 void set_touch_hud_debug(TouchHudDebug* hud) { touch_hud_debug_ = hud; } | 155 void set_touch_hud_debug(TouchHudDebug* hud) { touch_hud_debug_ = hud; } |
119 void set_touch_hud_projection(TouchHudProjection* hud) { | 156 void set_touch_hud_projection(TouchHudProjection* hud) { |
120 touch_hud_projection_ = hud; | 157 touch_hud_projection_ = hud; |
121 } | 158 } |
122 | 159 |
| 160 DockedWindowLayoutManager* docked_window_layout_manager() { |
| 161 return docked_window_layout_manager_; |
| 162 } |
| 163 |
| 164 PanelLayoutManager* panel_layout_manager() { return panel_layout_manager_; } |
| 165 |
| 166 wm::RootWindowLayoutManager* root_window_layout_manager() { |
| 167 return root_window_layout_manager_; |
| 168 } |
| 169 |
123 // Access the shelf layout manager associated with this root | 170 // Access the shelf layout manager associated with this root |
124 // window controller, NULL if no such shelf exists. | 171 // window controller, NULL if no such shelf exists. |
125 ShelfLayoutManager* GetShelfLayoutManager(); | 172 ShelfLayoutManager* GetShelfLayoutManager(); |
126 | 173 |
| 174 // Returns the layout manager for the appropriate modal-container. If the |
| 175 // window is inside the lockscreen modal container, then the layout manager |
| 176 // for that is returned. Otherwise the layout manager for the default modal |
| 177 // container is returned. |
| 178 // If no window is specified (i.e. |window| is null), then the lockscreen |
| 179 // modal container is used if the screen is currently locked. Otherwise, the |
| 180 // default modal container is used. |
| 181 SystemModalContainerLayoutManager* GetSystemModalLayoutManager( |
| 182 WmWindow* window); |
| 183 |
| 184 AlwaysOnTopController* always_on_top_controller() { |
| 185 return always_on_top_controller_.get(); |
| 186 } |
| 187 |
127 // May return null, for example for a secondary monitor at the login screen. | 188 // May return null, for example for a secondary monitor at the login screen. |
128 StatusAreaWidget* GetStatusAreaWidget(); | 189 StatusAreaWidget* GetStatusAreaWidget(); |
129 | 190 |
130 // Returns the system tray on this root window. Note that | 191 // Returns the system tray on this root window. Note that |
131 // calling this on the root window that doesn't have a shelf will | 192 // calling this on the root window that doesn't have a shelf will |
132 // lead to a crash. | 193 // lead to a crash. |
133 SystemTray* GetSystemTray(); | 194 SystemTray* GetSystemTray(); |
134 | 195 |
135 // True if the window can receive events on this root window. | 196 // True if the window can receive events on this root window. |
136 bool CanWindowReceiveEvents(aura::Window* window); | 197 bool CanWindowReceiveEvents(aura::Window* window); |
137 | 198 |
| 199 // Returns the window events will be targeted at for the specified location |
| 200 // (in screen coordinates). |
| 201 // |
| 202 // NOTE: the returned window may not contain the location as resize handles |
| 203 // may extend outside the bounds of the window. |
| 204 WmWindow* FindEventTarget(const gfx::Point& location_in_screen); |
| 205 |
| 206 // Gets the last location seen in a mouse event in this root window's |
| 207 // coordinates. This may return a point outside the root window's bounds. |
| 208 gfx::Point GetLastMouseLocationInRoot(); |
| 209 |
138 aura::Window* GetContainer(int container_id); | 210 aura::Window* GetContainer(int container_id); |
139 const aura::Window* GetContainer(int container_id) const; | 211 const aura::Window* GetContainer(int container_id) const; |
140 | 212 |
| 213 // TODO(sky): remove these. http://crbug.com/671246. |
| 214 WmWindow* GetWmContainer(int container_id) { |
| 215 return const_cast<WmWindow*>( |
| 216 const_cast<const RootWindowController*>(this)->GetWmContainer( |
| 217 container_id)); |
| 218 } |
| 219 const WmWindow* GetWmContainer(int container_id) const; |
| 220 |
| 221 WallpaperWidgetController* wallpaper_widget_controller() { |
| 222 return wallpaper_widget_controller_.get(); |
| 223 } |
| 224 void SetWallpaperWidgetController(WallpaperWidgetController* controller); |
| 225 |
| 226 AnimatingWallpaperWidgetController* animating_wallpaper_widget_controller() { |
| 227 return animating_wallpaper_widget_controller_.get(); |
| 228 } |
| 229 void SetAnimatingWallpaperWidgetController( |
| 230 AnimatingWallpaperWidgetController* controller); |
| 231 |
141 // Called when the brightness/grayscale animation from white to the login | 232 // Called when the brightness/grayscale animation from white to the login |
142 // wallpaper image has started. Starts |boot_splash_screen_|'s hiding | 233 // wallpaper image has started. Starts |boot_splash_screen_|'s hiding |
143 // animation (if the screen is non-NULL). | 234 // animation (if the screen is non-NULL). |
144 void OnInitialWallpaperAnimationStarted(); | 235 void OnInitialWallpaperAnimationStarted(); |
145 | 236 |
146 // Called when the wallpaper animation is finished. Updates | 237 // Called when the wallpaper animation is finished. Updates |
147 // |system_wallpaper_| to be black and drops |boot_splash_screen_| and moves | 238 // |system_wallpaper_| to be black and drops |boot_splash_screen_| and moves |
148 // the wallpaper controller into the root window controller. |widget| holds | 239 // the wallpaper controller into the root window controller. |widget| holds |
149 // the wallpaper image, or NULL if the wallpaper is a solid color. | 240 // the wallpaper image, or NULL if the wallpaper is a solid color. |
150 void OnWallpaperAnimationFinished(views::Widget* widget); | 241 void OnWallpaperAnimationFinished(views::Widget* widget); |
(...skipping 26 matching lines...) Expand all Loading... |
177 // Deactivate virtual keyboard on current root window controller. | 268 // Deactivate virtual keyboard on current root window controller. |
178 void DeactivateKeyboard(keyboard::KeyboardController* keyboard_controller); | 269 void DeactivateKeyboard(keyboard::KeyboardController* keyboard_controller); |
179 | 270 |
180 // Tests if a window is associated with the virtual keyboard. | 271 // Tests if a window is associated with the virtual keyboard. |
181 bool IsVirtualKeyboardWindow(aura::Window* window); | 272 bool IsVirtualKeyboardWindow(aura::Window* window); |
182 | 273 |
183 // If touch exploration is enabled, update the touch exploration | 274 // If touch exploration is enabled, update the touch exploration |
184 // controller so that synthesized touch events are anchored at this point. | 275 // controller so that synthesized touch events are anchored at this point. |
185 void SetTouchAccessibilityAnchorPoint(const gfx::Point& anchor_point); | 276 void SetTouchAccessibilityAnchorPoint(const gfx::Point& anchor_point); |
186 | 277 |
| 278 // Shows a context menu at the |location_in_screen|. |
| 279 void ShowContextMenu(const gfx::Point& location_in_screen, |
| 280 ui::MenuSourceType source_type); |
| 281 |
| 282 // Called when the login status changes after login (such as lock/unlock). |
| 283 // TODO(oshima): Investigate if we can merge this and |OnLoginStateChanged|. |
| 284 void UpdateAfterLoginStatusChange(LoginStatus status); |
| 285 |
187 private: | 286 private: |
188 // TODO(sky): remove this. Temporary during ash-mus unification. | 287 // TODO(sky): remove this. Temporary during ash-mus unification. |
189 // http://crbug.com/671246. | 288 // http://crbug.com/671246. |
190 friend class mus::RootWindowController; | 289 friend class mus::RootWindowController; |
191 | 290 |
192 // Creates a new RootWindowController with the specified host. Only one of | 291 // Creates a new RootWindowController with the specified host. Only one of |
193 // |ash_host| or |window_tree_host| should be specified. This takes ownership | 292 // |ash_host| or |window_tree_host| should be specified. This takes ownership |
194 // of the supplied arguments. | 293 // of the supplied arguments. |
195 // TODO(sky): mash should create AshWindowTreeHost, http://crbug.com/671246. | 294 // TODO(sky): mash should create AshWindowTreeHost, http://crbug.com/671246. |
196 RootWindowController(AshWindowTreeHost* ash_host, | 295 RootWindowController(AshWindowTreeHost* ash_host, |
197 aura::WindowTreeHost* window_tree_host); | 296 aura::WindowTreeHost* window_tree_host); |
198 | 297 |
199 // Initializes the RootWindowController based on |root_window_type|. | 298 // Initializes the RootWindowController based on |root_window_type|. |
200 void Init(RootWindowType root_window_type); | 299 void Init(RootWindowType root_window_type); |
201 | 300 |
202 void InitLayoutManagers(); | 301 void InitLayoutManagers(); |
203 | 302 |
| 303 // Creates the containers (WmWindows) used by the shell. |
| 304 void CreateContainers(); |
| 305 |
| 306 // Creates the LayoutManagers for the windows created by CreateContainers(). |
| 307 // TODO(sky): merge this with InitLayoutManagers(). |
| 308 void CreateLayoutManagers(); |
| 309 |
204 // Initializes |system_wallpaper_| and possibly also |boot_splash_screen_|. | 310 // Initializes |system_wallpaper_| and possibly also |boot_splash_screen_|. |
205 // The initial color is determined by the |root_window_type| and whether or | 311 // The initial color is determined by the |root_window_type| and whether or |
206 // not this is the first boot. | 312 // not this is the first boot. |
207 void CreateSystemWallpaper(RootWindowType root_window_type); | 313 void CreateSystemWallpaper(RootWindowType root_window_type); |
208 | 314 |
209 // Enables projection touch HUD. | 315 // Enables projection touch HUD. |
210 void EnableTouchHudProjection(); | 316 void EnableTouchHudProjection(); |
211 | 317 |
212 // Disables projection touch HUD. | 318 // Disables projection touch HUD. |
213 void DisableTouchHudProjection(); | 319 void DisableTouchHudProjection(); |
214 | 320 |
215 DockedWindowLayoutManager* docked_window_layout_manager(); | 321 // Resets WmShell::GetRootWindowForNewWindows() if appropriate. This is called |
216 PanelLayoutManager* panel_layout_manager(); | 322 // during shutdown to make sure GetRootWindowForNewWindows() isn't referencing |
| 323 // this. |
| 324 void ResetRootForNewWindowsIfNecessary(); |
| 325 |
| 326 // Callback for MenuModelAdapter. |
| 327 void OnMenuClosed(); |
217 | 328 |
218 // Overridden from ShellObserver. | 329 // Overridden from ShellObserver. |
219 void OnLoginStateChanged(LoginStatus status) override; | 330 void OnLoginStateChanged(LoginStatus status) override; |
220 void OnTouchHudProjectionToggled(bool enabled) override; | 331 void OnTouchHudProjectionToggled(bool enabled) override; |
221 | 332 |
222 std::unique_ptr<AshWindowTreeHost> ash_host_; | 333 std::unique_ptr<AshWindowTreeHost> ash_host_; |
223 std::unique_ptr<aura::WindowTreeHost> owned_window_tree_host_; | 334 std::unique_ptr<aura::WindowTreeHost> owned_window_tree_host_; |
224 // This comes from |ash_host_| or |owned_window_tree_host_|. | 335 // This comes from |ash_host_| or |owned_window_tree_host_|. |
225 aura::WindowTreeHost* window_tree_host_; | 336 aura::WindowTreeHost* window_tree_host_; |
226 | 337 |
227 std::unique_ptr<WmRootWindowController> wm_root_window_controller_; | 338 // LayoutManagers are owned by the window they are installed on. |
| 339 DockedWindowLayoutManager* docked_window_layout_manager_ = nullptr; |
| 340 PanelLayoutManager* panel_layout_manager_ = nullptr; |
| 341 wm::RootWindowLayoutManager* root_window_layout_manager_ = nullptr; |
| 342 |
| 343 std::unique_ptr<WallpaperWidgetController> wallpaper_widget_controller_; |
| 344 std::unique_ptr<AnimatingWallpaperWidgetController> |
| 345 animating_wallpaper_widget_controller_; |
| 346 std::unique_ptr<WorkspaceController> workspace_controller_; |
| 347 |
| 348 std::unique_ptr<AlwaysOnTopController> always_on_top_controller_; |
| 349 |
| 350 // Manages the context menu. |
| 351 std::unique_ptr<ui::MenuModel> menu_model_; |
| 352 std::unique_ptr<views::MenuModelAdapter> menu_model_adapter_; |
| 353 std::unique_ptr<views::MenuRunner> menu_runner_; |
228 | 354 |
229 std::unique_ptr<StackingController> stacking_controller_; | 355 std::unique_ptr<StackingController> stacking_controller_; |
230 | 356 |
231 // The shelf controller for this root window. Exists for the entire lifetime | 357 // The shelf controller for this root window. Exists for the entire lifetime |
232 // of the RootWindowController so that it is safe for observers to be added | 358 // of the RootWindowController so that it is safe for observers to be added |
233 // to it during construction of the shelf widget and status tray. | 359 // to it during construction of the shelf widget and status tray. |
234 std::unique_ptr<WmShelf> wm_shelf_; | 360 std::unique_ptr<WmShelf> wm_shelf_; |
235 | 361 |
236 std::unique_ptr<SystemWallpaperController> system_wallpaper_; | 362 std::unique_ptr<SystemWallpaperController> system_wallpaper_; |
237 | 363 |
(...skipping 17 matching lines...) Expand all Loading... |
255 | 381 |
256 // On classic ash, returns the RootWindowController for the given |root_window|. | 382 // On classic ash, returns the RootWindowController for the given |root_window|. |
257 // On mus ash, returns the RootWindowController for the primary display. | 383 // On mus ash, returns the RootWindowController for the primary display. |
258 // See RootWindowController class comment above. | 384 // See RootWindowController class comment above. |
259 ASH_EXPORT RootWindowController* GetRootWindowController( | 385 ASH_EXPORT RootWindowController* GetRootWindowController( |
260 const aura::Window* root_window); | 386 const aura::Window* root_window); |
261 | 387 |
262 } // namespace ash | 388 } // namespace ash |
263 | 389 |
264 #endif // ASH_ROOT_WINDOW_CONTROLLER_H_ | 390 #endif // ASH_ROOT_WINDOW_CONTROLLER_H_ |
OLD | NEW |