blob: 740d0802083fd91f3f2b2808949effa88ec2f419 [file] [log] [blame]
[email protected]d90b8392012-06-13 09:34:561// 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
3// found in the LICENSE file.
4
5#ifndef ASH_ROOT_WINDOW_CONTROLLER_H_
6#define ASH_ROOT_WINDOW_CONTROLLER_H_
[email protected]d90b8392012-06-13 09:34:567
[email protected]2b8a9bb2013-07-01 22:43:408#include <map>
dchenga94547472016-04-08 08:41:119#include <memory>
[email protected]2b8a9bb2013-07-01 22:43:4010
[email protected]c0ce80e2012-10-05 23:28:2711#include "ash/ash_export.h"
jamescook1b474d6a2016-06-04 05:56:0012#include "ash/common/shelf/shelf_types.h"
sky529ff5d2016-06-08 17:00:5213#include "ash/common/shell_observer.h"
avidb567a8a2015-12-20 17:07:2414#include "base/macros.h"
[email protected]f7c05b22013-11-12 21:07:2415#include "ui/aura/window.h"
[email protected]2f2620332014-02-28 10:07:3816#include "ui/aura/window_tree_host.h"
[email protected]940fb1c2013-06-18 16:54:2817#include "ui/base/ui_base_types.h"
[email protected]d90b8392012-06-13 09:34:5618
19class SkBitmap;
20
21namespace aura {
22class EventFilter;
[email protected]d90b8392012-06-13 09:34:5623class Window;
[email protected]4a59e4e2012-11-12 21:15:4024}
25
26namespace gfx {
27class Point;
28}
29
[email protected]86459e2c2013-04-10 13:39:2430namespace keyboard {
31class KeyboardController;
32}
33
[email protected]3537d472014-01-15 05:45:3134namespace ui {
35class EventHandler;
jonrossa90d8982016-05-16 18:14:2536class MenuModel;
[email protected]3537d472014-01-15 05:45:3137}
38
[email protected]e319c7e2014-03-14 19:56:1439namespace views {
jonrossa90d8982016-05-16 18:14:2540class MenuModelAdapter;
41class MenuRunner;
[email protected]e319c7e2014-03-14 19:56:1442class Widget;
43}
44
45namespace wm {
46class InputMethodEventFilter;
47class RootWindowEventFilter;
48class ScopedCaptureClient;
49}
50
[email protected]d90b8392012-06-13 09:34:5651namespace ash {
[email protected]f5c9dbc2014-04-11 08:13:4552class AshWindowTreeHost;
[email protected]80549c152013-07-02 01:42:4753class AlwaysOnTopController;
msw607227f82016-08-30 17:22:3954class AnimatingWallpaperWidgetController;
[email protected]beb4e5c2013-06-18 15:37:0755class DockedWindowLayoutManager;
mswb2416052016-06-24 21:23:4556enum class LoginStatus;
[email protected]e74aaf0a2012-10-12 18:42:2857class PanelLayoutManager;
skyee78dde2016-06-01 01:21:4358class RootWindowControllerCommon;
jamescook6afad6d2016-06-01 00:35:0159class Shelf;
[email protected]e74aaf0a2012-10-12 18:42:2860class ShelfLayoutManager;
[email protected]093b8d642014-04-03 20:59:2861class ShelfWidget;
62class StackingController;
[email protected]e74aaf0a2012-10-12 18:42:2863class StatusAreaWidget;
[email protected]c0ce80e2012-10-05 23:28:2764class SystemModalContainerLayoutManager;
[email protected]093b8d642014-04-03 20:59:2865class SystemTray;
msw607227f82016-08-30 17:22:3966class SystemWallpaperController;
[email protected]2b8a9bb2013-07-01 22:43:4067class TouchHudDebug;
68class TouchHudProjection;
msw607227f82016-08-30 17:22:3969class WallpaperWidgetController;
jamescookbe6ed822016-06-06 20:08:5570class WmShelfAura;
sky0702b272016-06-03 22:10:4171class WmWindow;
[email protected]d90b8392012-06-13 09:34:5672class WorkspaceController;
73
[email protected]438cbdf02013-10-07 23:41:0974#if defined(OS_CHROMEOS)
[email protected]252eb232013-08-14 22:09:2775class BootSplashScreen;
[email protected]7d487592014-07-24 03:54:5076class AshTouchExplorationManager;
[email protected]252eb232013-08-14 22:09:2777#endif
78
[email protected]d90b8392012-06-13 09:34:5679// This class maintains the per root window state for ash. This class
80// owns the root window and other dependent objects that should be
[email protected]a273d33a2013-10-17 12:41:2181// deleted upon the deletion of the root window. This object is
oshimae2818922015-07-28 01:18:5282// indirectly owned and deleted by |WindowTreeHostManager|.
[email protected]a273d33a2013-10-17 12:41:2183// The RootWindowController for particular root window is stored in
84// its property (RootWindowSettings) and can be obtained using
[email protected]056ce052014-02-21 05:19:3285// |GetRootWindowController(aura::WindowEventDispatcher*)| function.
jamescook2a5ffa212016-04-29 17:44:0286//
87// NOTE: In classic ash there is one RootWindow per display, so every RootWindow
88// has a RootWindowController. In mus/mash there is one RootWindow per top-level
89// Widget, so not all RootWindows have a RootWindowController.
[email protected]d141b922013-07-09 08:13:1790class ASH_EXPORT RootWindowController : public ShellObserver {
[email protected]d90b8392012-06-13 09:34:5691 public:
[email protected]a273d33a2013-10-17 12:41:2192 // Creates and Initialize the RootWindowController for primary display.
[email protected]f5c9dbc2014-04-11 08:13:4593 static void CreateForPrimaryDisplay(AshWindowTreeHost* host);
[email protected]a273d33a2013-10-17 12:41:2194
95 // Creates and Initialize the RootWindowController for secondary displays.
[email protected]f5c9dbc2014-04-11 08:13:4596 static void CreateForSecondaryDisplay(AshWindowTreeHost* host);
[email protected]d90b8392012-06-13 09:34:5697
[email protected]a0afeb12012-12-10 22:57:0998 // Returns a RootWindowController of the window's root window.
[email protected]ccff3d72013-02-06 04:26:2899 static RootWindowController* ForWindow(const aura::Window* window);
[email protected]a0afeb12012-12-10 22:57:09100
[email protected]d17642d2013-09-12 23:44:38101 // Returns the RootWindowController of the target root window.
[email protected]093b8d642014-04-03 20:59:28102 static RootWindowController* ForTargetRootWindow();
[email protected]a0afeb12012-12-10 22:57:09103
dcheng1f4538e2014-10-27 23:57:05104 ~RootWindowController() override;
[email protected]a273d33a2013-10-17 12:41:21105
[email protected]f5c9dbc2014-04-11 08:13:45106 AshWindowTreeHost* ash_host() { return ash_host_.get(); }
107 const AshWindowTreeHost* ash_host() const { return ash_host_.get(); }
108
109 aura::WindowTreeHost* GetHost();
110 const aura::WindowTreeHost* GetHost() const;
111 aura::Window* GetRootWindow();
112 const aura::Window* GetRootWindow() const;
[email protected]d90b8392012-06-13 09:34:56113
skyf71e6c92016-08-30 18:49:19114 WorkspaceController* workspace_controller();
[email protected]d90b8392012-06-13 09:34:56115
[email protected]80549c152013-07-02 01:42:47116 AlwaysOnTopController* always_on_top_controller() {
117 return always_on_top_controller_.get();
118 }
119
jamescookbe6ed822016-06-06 20:08:55120 WmShelfAura* wm_shelf_aura() const { return wm_shelf_aura_.get(); }
121
jamescook612205f2016-05-26 06:02:11122 // Access the shelf widget associated with this root window controller,
[email protected]478c6c32013-03-09 02:50:58123 // NULL if no such shelf exists.
jamescook6afad6d2016-06-01 00:35:01124 // DEPRECATED: Prefer GetShelf()->shelf_widget().
jamescook612205f2016-05-26 06:02:11125 ShelfWidget* shelf_widget() { return shelf_widget_.get(); }
[email protected]e74aaf0a2012-10-12 18:42:28126
[email protected]2b8a9bb2013-07-01 22:43:40127 // Get touch HUDs associated with this root window controller.
jamescookb8dcef522016-06-25 14:42:55128 TouchHudDebug* touch_hud_debug() const { return touch_hud_debug_; }
[email protected]2b8a9bb2013-07-01 22:43:40129 TouchHudProjection* touch_hud_projection() const {
130 return touch_hud_projection_;
131 }
132
133 // Set touch HUDs for this root window controller. The root window controller
134 // will not own the HUDs; their lifetimes are managed by themselves. Whenever
135 // the widget showing a HUD is being destroyed (e.g. because of detaching a
136 // display), the HUD deletes itself.
jamescookb8dcef522016-06-25 14:42:55137 void set_touch_hud_debug(TouchHudDebug* hud) { touch_hud_debug_ = hud; }
[email protected]2b8a9bb2013-07-01 22:43:40138 void set_touch_hud_projection(TouchHudProjection* hud) {
139 touch_hud_projection_ = hud;
140 }
141
msw607227f82016-08-30 17:22:39142 WallpaperWidgetController* wallpaper_widget_controller() {
143 return wallpaper_widget_controller_.get();
[email protected]0bf61732013-07-02 04:35:10144 }
msw607227f82016-08-30 17:22:39145 void SetWallpaperWidgetController(WallpaperWidgetController* controller);
146 AnimatingWallpaperWidgetController* animating_wallpaper_widget_controller() {
147 return animating_wallpaper_widget_controller_.get();
[email protected]0bf61732013-07-02 04:35:10148 }
msw607227f82016-08-30 17:22:39149 void SetAnimatingWallpaperWidgetController(
150 AnimatingWallpaperWidgetController* controller);
[email protected]0bf61732013-07-02 04:35:10151
[email protected]478c6c32013-03-09 02:50:58152 // Access the shelf layout manager associated with this root
153 // window controller, NULL if no such shelf exists.
154 ShelfLayoutManager* GetShelfLayoutManager();
[email protected]d90b8392012-06-13 09:34:56155
[email protected]a0afeb12012-12-10 22:57:09156 // Returns the system tray on this root window. Note that
[email protected]864b58552013-12-19 04:19:38157 // calling this on the root window that doesn't have a shelf will
[email protected]a0afeb12012-12-10 22:57:09158 // lead to a crash.
159 SystemTray* GetSystemTray();
160
[email protected]431552c2012-10-23 00:38:33161 // Shows context menu at the |location_in_screen|. This uses
162 // |ShellDelegate::CreateContextMenu| to define the content of the menu.
[email protected]940fb1c2013-06-18 16:54:28163 void ShowContextMenu(const gfx::Point& location_in_screen,
164 ui::MenuSourceType source_type);
[email protected]431552c2012-10-23 00:38:33165
oshima9a61ecf2016-06-18 10:43:05166 // True if the window can receive events on this root window.
167 bool CanWindowReceiveEvents(aura::Window* window);
168
[email protected]8674b312012-10-12 19:02:44169 // Returns the layout-manager for the appropriate modal-container. If the
170 // window is inside the lockscreen modal container, then the layout manager
171 // for that is returned. Otherwise the layout manager for the default modal
172 // container is returned.
173 // If no window is specified (i.e. |window| is NULL), then the lockscreen
174 // modal container is used if the screen is currently locked. Otherwise, the
175 // default modal container is used.
176 SystemModalContainerLayoutManager* GetSystemModalLayoutManager(
177 aura::Window* window);
[email protected]c0ce80e2012-10-05 23:28:27178
[email protected]d90b8392012-06-13 09:34:56179 aura::Window* GetContainer(int container_id);
[email protected]d8a24952013-08-05 20:05:05180 const aura::Window* GetContainer(int container_id) const;
[email protected]d90b8392012-06-13 09:34:56181
[email protected]864b58552013-12-19 04:19:38182 // Show shelf view if it was created hidden (before session has started).
jamescook6afad6d2016-06-01 00:35:01183 // TODO(jamescook): Eliminate this and handle show via Shelf.
[email protected]864b58552013-12-19 04:19:38184 void ShowShelf();
[email protected]e74aaf0a2012-10-12 18:42:28185
jamescook6500ad132016-05-27 06:15:54186 // Creates the shelf for this root window and notifies observers.
187 void CreateShelf();
[email protected]478c6c32013-03-09 02:50:58188
jamescook6afad6d2016-06-01 00:35:01189 // Returns the shelf controller for this root window.
jamescookbe6ed822016-06-06 20:08:55190 // TODO(jamescook): Remove this and use WmRootWindowController::GetShelf().
jamescook6afad6d2016-06-01 00:35:01191 Shelf* GetShelf() const;
192
[email protected]16059276d2012-10-22 18:59:50193 // Called when the login status changes after login (such as lock/unlock).
194 // TODO(oshima): Investigate if we can merge this and |OnLoginStateChanged|.
skye79274a2016-06-08 05:39:02195 void UpdateAfterLoginStatusChange(LoginStatus status);
[email protected]16059276d2012-10-22 18:59:50196
[email protected]bca9a7e2012-11-10 06:25:49197 // Called when the brightness/grayscale animation from white to the login
msw607227f82016-08-30 17:22:39198 // wallpaper image has started. Starts |boot_splash_screen_|'s hiding
199 // animation (if the screen is non-NULL).
200 void HandleInitialWallpaperAnimationStarted();
[email protected]bca9a7e2012-11-10 06:25:49201
msw607227f82016-08-30 17:22:39202 // Called when the wallpaper animation is finished. Updates
203 // |system_wallpaper_| to be black and drops |boot_splash_screen_| and moves
204 // the wallpaper controller into the root window controller. |widget| holds
205 // the wallpaper image, or NULL if the wallpaper is a solid color.
[email protected]0bf61732013-07-02 04:35:10206 void OnWallpaperAnimationFinished(views::Widget* widget);
[email protected]d90b8392012-06-13 09:34:56207
[email protected]6675e1c2012-09-11 09:15:45208 // Deletes associated objects and clears the state, but doesn't delete
209 // the root window yet. This is used to delete a secondary displays'
210 // root window safely when the display disconnect signal is received,
211 // which may come while we're in the nested message loop.
212 void Shutdown();
213
[email protected]d90b8392012-06-13 09:34:56214 // Deletes all child windows and performs necessary cleanup.
215 void CloseChildWindows();
216
[email protected]f1853122012-06-27 16:21:26217 // Moves child windows to |dest|.
[email protected]bf9cdb362013-10-25 19:22:45218 void MoveWindowsTo(aura::Window* dest);
[email protected]f1853122012-06-27 16:21:26219
[email protected]e74aaf0a2012-10-12 18:42:28220 // Force the shelf to query for it's current visibility state.
221 void UpdateShelfVisibility();
222
[email protected]2b8a9bb2013-07-01 22:43:40223 // Initialize touch HUDs if necessary.
224 void InitTouchHuds();
225
[email protected]2c9171d22013-12-10 21:55:10226 // Returns the topmost window or one of its transient parents, if any of them
227 // are in fullscreen mode.
varkhad99fa94f2015-06-29 22:35:46228 aura::Window* GetWindowForFullscreenMode();
[email protected]2ee2f5d2013-01-10 23:37:16229
[email protected]b6ba05d902013-10-04 21:38:45230 // Activate virtual keyboard on current root window controller.
231 void ActivateKeyboard(keyboard::KeyboardController* keyboard_controller);
232
233 // Deactivate virtual keyboard on current root window controller.
234 void DeactivateKeyboard(keyboard::KeyboardController* keyboard_controller);
235
[email protected]602022b2014-03-31 17:07:31236 // Tests if a window is associated with the virtual keyboard.
237 bool IsVirtualKeyboardWindow(aura::Window* window);
238
dmazzoniff86e3472016-06-03 19:52:32239 // If touch exploration is enabled, update the touch exploration
240 // controller so that synthesized touch events are anchored at this point.
241 void SetTouchAccessibilityAnchorPoint(const gfx::Point& anchor_point);
242
[email protected]431552c2012-10-23 00:38:33243 private:
[email protected]f5c9dbc2014-04-11 08:13:45244 explicit RootWindowController(AshWindowTreeHost* host);
jamescookb8dcef522016-06-25 14:42:55245 enum RootWindowType { PRIMARY, SECONDARY };
[email protected]a273d33a2013-10-17 12:41:21246
247 // Initializes the RootWindowController. |is_primary| is true if
248 // the controller is for primary display. |first_run_after_boot| is
249 // set to true only for primary root window after boot.
[email protected]608de6c2013-10-29 00:14:28250 void Init(RootWindowType root_window_type, bool first_run_after_boot);
[email protected]a273d33a2013-10-17 12:41:21251
[email protected]756bda12013-07-03 08:17:06252 void InitLayoutManagers();
253
msw607227f82016-08-30 17:22:39254 // Initializes |system_wallpaper_| and possibly also |boot_splash_screen_|.
255 // |is_first_run_after_boot| determines the wallpaper's initial color.
256 void CreateSystemWallpaper(bool is_first_run_after_boot);
[email protected]756bda12013-07-03 08:17:06257
[email protected]d141b922013-07-09 08:13:17258 // Enables projection touch HUD.
259 void EnableTouchHudProjection();
260
261 // Disables projection touch HUD.
262 void DisableTouchHudProjection();
263
jonrossa90d8982016-05-16 18:14:25264 // Callback for MenuModelAdapter.
265 void OnMenuClosed();
266
[email protected]d141b922013-07-09 08:13:17267 // Overridden from ShellObserver.
skye79274a2016-06-08 05:39:02268 void OnLoginStateChanged(LoginStatus status) override;
dcheng1f4538e2014-10-27 23:57:05269 void OnTouchHudProjectionToggled(bool enabled) override;
[email protected]d141b922013-07-09 08:13:17270
dchenga94547472016-04-08 08:41:11271 std::unique_ptr<AshWindowTreeHost> ash_host_;
skyee78dde2016-06-01 01:21:43272
273 std::unique_ptr<RootWindowControllerCommon> root_window_controller_common_;
274
dchenga94547472016-04-08 08:41:11275 std::unique_ptr<StackingController> stacking_controller_;
[email protected]2a2caa02013-01-22 20:50:36276
jamescookbe6ed822016-06-06 20:08:55277 // The shelf controller for this root window. Exists for the entire lifetime
278 // of the RootWindowController so that it is safe for observers to be added
279 // to it during construction of the shelf widget and status tray.
280 std::unique_ptr<WmShelfAura> wm_shelf_aura_;
281
jamescook361185a22016-08-13 00:12:09282 // Legacy shelf controller. Only present after shelf is created (post-login).
283 std::unique_ptr<Shelf> shelf_;
284
jamescook612205f2016-05-26 06:02:11285 // The shelf widget for this root window.
286 std::unique_ptr<ShelfWidget> shelf_widget_;
[email protected]e74aaf0a2012-10-12 18:42:28287
[email protected]cf6fea22013-08-07 14:24:01288 // An invisible/empty window used as a event target for
289 // |MouseCursorEventFilter| before a user logs in.
290 // (crbug.com/266987)
msw607227f82016-08-30 17:22:39291 // Its container is |LockScreenWallpaperContainer| and
[email protected]cf6fea22013-08-07 14:24:01292 // this must be deleted before the container is deleted.
dchenga94547472016-04-08 08:41:11293 std::unique_ptr<aura::Window> mouse_event_target_;
[email protected]cf6fea22013-08-07 14:24:01294
[email protected]beb4e5c2013-06-18 15:37:07295 // Manages layout of docked windows. Owned by DockedContainer.
296 DockedWindowLayoutManager* docked_layout_manager_;
297
[email protected]e74aaf0a2012-10-12 18:42:28298 // Manages layout of panels. Owned by PanelContainer.
[email protected]88d71122012-10-18 07:11:01299 PanelLayoutManager* panel_layout_manager_;
[email protected]e74aaf0a2012-10-12 18:42:28300
msw607227f82016-08-30 17:22:39301 std::unique_ptr<SystemWallpaperController> system_wallpaper_;
[email protected]a825e8312014-05-05 22:05:01302
[email protected]438cbdf02013-10-07 23:41:09303#if defined(OS_CHROMEOS)
dchenga94547472016-04-08 08:41:11304 std::unique_ptr<BootSplashScreen> boot_splash_screen_;
[email protected]a825e8312014-05-05 22:05:01305 // Responsible for initializing TouchExplorationController when spoken
306 // feedback is on.
dchenga94547472016-04-08 08:41:11307 std::unique_ptr<AshTouchExplorationManager> touch_exploration_manager_;
[email protected]252eb232013-08-14 22:09:27308#endif
[email protected]697f04c2012-10-03 01:15:10309
dchenga94547472016-04-08 08:41:11310 std::unique_ptr<AlwaysOnTopController> always_on_top_controller_;
[email protected]d90b8392012-06-13 09:34:56311
[email protected]2b8a9bb2013-07-01 22:43:40312 // Heads-up displays for touch events. These HUDs are not owned by the root
313 // window controller and manage their own lifetimes.
314 TouchHudDebug* touch_hud_debug_;
315 TouchHudProjection* touch_hud_projection_;
[email protected]58175042013-04-01 19:27:13316
[email protected]3537d472014-01-15 05:45:31317 // Handles double clicks on the panel window header.
dchenga94547472016-04-08 08:41:11318 std::unique_ptr<ui::EventHandler> panel_container_handler_;
[email protected]a4cd6d32012-09-12 03:42:13319
msw607227f82016-08-30 17:22:39320 std::unique_ptr<WallpaperWidgetController> wallpaper_widget_controller_;
321 std::unique_ptr<AnimatingWallpaperWidgetController>
322 animating_wallpaper_widget_controller_;
dchenga94547472016-04-08 08:41:11323 std::unique_ptr<::wm::ScopedCaptureClient> capture_client_;
[email protected]0bf61732013-07-02 04:35:10324
jonrossa90d8982016-05-16 18:14:25325 // Manages the context menu.
326 std::unique_ptr<ui::MenuModel> menu_model_;
327 std::unique_ptr<views::MenuModelAdapter> menu_model_adapter_;
328 std::unique_ptr<views::MenuRunner> menu_runner_;
329
[email protected]d90b8392012-06-13 09:34:56330 DISALLOW_COPY_AND_ASSIGN(RootWindowController);
331};
332
jamescook5d74ac02016-05-12 19:57:12333// On classic ash, returns the RootWindowController for the given |root_window|.
334// On mus ash, returns the RootWindowController for the primary display.
335// See RootWindowController class comment above.
[email protected]6b2d4a0b2013-09-06 06:29:54336ASH_EXPORT RootWindowController* GetRootWindowController(
[email protected]bf9cdb362013-10-25 19:22:45337 const aura::Window* root_window);
[email protected]6b2d4a0b2013-09-06 06:29:54338
[email protected]76bc4632014-06-16 19:07:46339} // namespace ash
[email protected]d90b8392012-06-13 09:34:56340
[email protected]76bc4632014-06-16 19:07:46341#endif // ASH_ROOT_WINDOW_CONTROLLER_H_