blob: 3588097eb45be8ed561c5996c2ea5d1f06d65d03 [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"
sky529ff5d2016-06-08 17:00:5212#include "ash/common/shell_observer.h"
jamescookd4649fa2016-09-30 17:50:0913#include "ash/public/cpp/shelf_types.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]d90b8392012-06-13 09:34:5617
[email protected]d90b8392012-06-13 09:34:5618namespace aura {
[email protected]d90b8392012-06-13 09:34:5619class Window;
[email protected]4a59e4e2012-11-12 21:15:4020}
21
22namespace gfx {
23class Point;
24}
25
[email protected]86459e2c2013-04-10 13:39:2426namespace keyboard {
27class KeyboardController;
28}
29
[email protected]3537d472014-01-15 05:45:3130namespace ui {
31class EventHandler;
32}
33
[email protected]e319c7e2014-03-14 19:56:1434namespace views {
35class Widget;
36}
37
38namespace wm {
[email protected]e319c7e2014-03-14 19:56:1439class ScopedCaptureClient;
40}
41
[email protected]d90b8392012-06-13 09:34:5642namespace ash {
jamescook01bf23e72017-01-09 19:58:1543class AshTouchExplorationManager;
[email protected]f5c9dbc2014-04-11 08:13:4544class AshWindowTreeHost;
jamescook01bf23e72017-01-09 19:58:1545class BootSplashScreen;
[email protected]beb4e5c2013-06-18 15:37:0746class DockedWindowLayoutManager;
mswb2416052016-06-24 21:23:4547enum class LoginStatus;
[email protected]e74aaf0a2012-10-12 18:42:2848class PanelLayoutManager;
[email protected]e74aaf0a2012-10-12 18:42:2849class ShelfLayoutManager;
[email protected]093b8d642014-04-03 20:59:2850class StackingController;
[email protected]e74aaf0a2012-10-12 18:42:2851class StatusAreaWidget;
[email protected]093b8d642014-04-03 20:59:2852class SystemTray;
msw607227f82016-08-30 17:22:3953class SystemWallpaperController;
[email protected]2b8a9bb2013-07-01 22:43:4054class TouchHudDebug;
55class TouchHudProjection;
skyd053905c2016-08-30 22:37:3556class WmRootWindowControllerAura;
jamescookbe6ed822016-06-06 20:08:5557class WmShelfAura;
[email protected]d90b8392012-06-13 09:34:5658class WorkspaceController;
59
60// This class maintains the per root window state for ash. This class
61// owns the root window and other dependent objects that should be
[email protected]a273d33a2013-10-17 12:41:2162// deleted upon the deletion of the root window. This object is
oshimae2818922015-07-28 01:18:5263// indirectly owned and deleted by |WindowTreeHostManager|.
[email protected]a273d33a2013-10-17 12:41:2164// The RootWindowController for particular root window is stored in
65// its property (RootWindowSettings) and can be obtained using
[email protected]056ce052014-02-21 05:19:3266// |GetRootWindowController(aura::WindowEventDispatcher*)| function.
jamescook2a5ffa212016-04-29 17:44:0267//
68// NOTE: In classic ash there is one RootWindow per display, so every RootWindow
69// has a RootWindowController. In mus/mash there is one RootWindow per top-level
70// Widget, so not all RootWindows have a RootWindowController.
[email protected]d141b922013-07-09 08:13:1771class ASH_EXPORT RootWindowController : public ShellObserver {
[email protected]d90b8392012-06-13 09:34:5672 public:
[email protected]a273d33a2013-10-17 12:41:2173 // Creates and Initialize the RootWindowController for primary display.
[email protected]f5c9dbc2014-04-11 08:13:4574 static void CreateForPrimaryDisplay(AshWindowTreeHost* host);
[email protected]a273d33a2013-10-17 12:41:2175
76 // Creates and Initialize the RootWindowController for secondary displays.
[email protected]f5c9dbc2014-04-11 08:13:4577 static void CreateForSecondaryDisplay(AshWindowTreeHost* host);
[email protected]d90b8392012-06-13 09:34:5678
[email protected]a0afeb12012-12-10 22:57:0979 // Returns a RootWindowController of the window's root window.
[email protected]ccff3d72013-02-06 04:26:2880 static RootWindowController* ForWindow(const aura::Window* window);
[email protected]a0afeb12012-12-10 22:57:0981
[email protected]d17642d2013-09-12 23:44:3882 // Returns the RootWindowController of the target root window.
[email protected]093b8d642014-04-03 20:59:2883 static RootWindowController* ForTargetRootWindow();
[email protected]a0afeb12012-12-10 22:57:0984
dcheng1f4538e2014-10-27 23:57:0585 ~RootWindowController() override;
[email protected]a273d33a2013-10-17 12:41:2186
[email protected]f5c9dbc2014-04-11 08:13:4587 AshWindowTreeHost* ash_host() { return ash_host_.get(); }
88 const AshWindowTreeHost* ash_host() const { return ash_host_.get(); }
89
90 aura::WindowTreeHost* GetHost();
91 const aura::WindowTreeHost* GetHost() const;
92 aura::Window* GetRootWindow();
93 const aura::Window* GetRootWindow() const;
[email protected]d90b8392012-06-13 09:34:5694
skyf71e6c92016-08-30 18:49:1995 WorkspaceController* workspace_controller();
[email protected]d90b8392012-06-13 09:34:5696
jamescookbe6ed822016-06-06 20:08:5597 WmShelfAura* wm_shelf_aura() const { return wm_shelf_aura_.get(); }
98
sky8d971a0a2016-09-21 23:37:5799 WmRootWindowControllerAura* wm_root_window_controller() {
100 return wm_root_window_controller_;
101 }
102
[email protected]2b8a9bb2013-07-01 22:43:40103 // Get touch HUDs associated with this root window controller.
jamescookb8dcef522016-06-25 14:42:55104 TouchHudDebug* touch_hud_debug() const { return touch_hud_debug_; }
[email protected]2b8a9bb2013-07-01 22:43:40105 TouchHudProjection* touch_hud_projection() const {
106 return touch_hud_projection_;
107 }
108
109 // Set touch HUDs for this root window controller. The root window controller
110 // will not own the HUDs; their lifetimes are managed by themselves. Whenever
111 // the widget showing a HUD is being destroyed (e.g. because of detaching a
112 // display), the HUD deletes itself.
jamescookb8dcef522016-06-25 14:42:55113 void set_touch_hud_debug(TouchHudDebug* hud) { touch_hud_debug_ = hud; }
[email protected]2b8a9bb2013-07-01 22:43:40114 void set_touch_hud_projection(TouchHudProjection* hud) {
115 touch_hud_projection_ = hud;
116 }
117
[email protected]478c6c32013-03-09 02:50:58118 // Access the shelf layout manager associated with this root
119 // window controller, NULL if no such shelf exists.
120 ShelfLayoutManager* GetShelfLayoutManager();
[email protected]d90b8392012-06-13 09:34:56121
jamescookb551aba2016-09-01 01:00:16122 // May return null, for example for a secondary monitor at the login screen.
123 StatusAreaWidget* GetStatusAreaWidget();
124
[email protected]a0afeb12012-12-10 22:57:09125 // Returns the system tray on this root window. Note that
[email protected]864b58552013-12-19 04:19:38126 // calling this on the root window that doesn't have a shelf will
[email protected]a0afeb12012-12-10 22:57:09127 // lead to a crash.
128 SystemTray* GetSystemTray();
129
oshima9a61ecf2016-06-18 10:43:05130 // True if the window can receive events on this root window.
131 bool CanWindowReceiveEvents(aura::Window* window);
132
[email protected]d90b8392012-06-13 09:34:56133 aura::Window* GetContainer(int container_id);
[email protected]d8a24952013-08-05 20:05:05134 const aura::Window* GetContainer(int container_id) const;
[email protected]d90b8392012-06-13 09:34:56135
[email protected]bca9a7e2012-11-10 06:25:49136 // Called when the brightness/grayscale animation from white to the login
msw607227f82016-08-30 17:22:39137 // wallpaper image has started. Starts |boot_splash_screen_|'s hiding
138 // animation (if the screen is non-NULL).
msw3f439af2016-09-08 22:35:26139 void OnInitialWallpaperAnimationStarted();
[email protected]bca9a7e2012-11-10 06:25:49140
msw607227f82016-08-30 17:22:39141 // Called when the wallpaper animation is finished. Updates
142 // |system_wallpaper_| to be black and drops |boot_splash_screen_| and moves
143 // the wallpaper controller into the root window controller. |widget| holds
144 // the wallpaper image, or NULL if the wallpaper is a solid color.
[email protected]0bf61732013-07-02 04:35:10145 void OnWallpaperAnimationFinished(views::Widget* widget);
[email protected]d90b8392012-06-13 09:34:56146
[email protected]6675e1c2012-09-11 09:15:45147 // Deletes associated objects and clears the state, but doesn't delete
148 // the root window yet. This is used to delete a secondary displays'
149 // root window safely when the display disconnect signal is received,
150 // which may come while we're in the nested message loop.
151 void Shutdown();
152
[email protected]d90b8392012-06-13 09:34:56153 // Deletes all child windows and performs necessary cleanup.
154 void CloseChildWindows();
155
[email protected]f1853122012-06-27 16:21:26156 // Moves child windows to |dest|.
[email protected]bf9cdb362013-10-25 19:22:45157 void MoveWindowsTo(aura::Window* dest);
[email protected]f1853122012-06-27 16:21:26158
[email protected]e74aaf0a2012-10-12 18:42:28159 // Force the shelf to query for it's current visibility state.
160 void UpdateShelfVisibility();
161
[email protected]2b8a9bb2013-07-01 22:43:40162 // Initialize touch HUDs if necessary.
163 void InitTouchHuds();
164
[email protected]2c9171d22013-12-10 21:55:10165 // Returns the topmost window or one of its transient parents, if any of them
166 // are in fullscreen mode.
varkhad99fa94f2015-06-29 22:35:46167 aura::Window* GetWindowForFullscreenMode();
[email protected]2ee2f5d2013-01-10 23:37:16168
[email protected]b6ba05d902013-10-04 21:38:45169 // Activate virtual keyboard on current root window controller.
170 void ActivateKeyboard(keyboard::KeyboardController* keyboard_controller);
171
172 // Deactivate virtual keyboard on current root window controller.
173 void DeactivateKeyboard(keyboard::KeyboardController* keyboard_controller);
174
[email protected]602022b2014-03-31 17:07:31175 // Tests if a window is associated with the virtual keyboard.
176 bool IsVirtualKeyboardWindow(aura::Window* window);
177
dmazzoniff86e3472016-06-03 19:52:32178 // If touch exploration is enabled, update the touch exploration
179 // controller so that synthesized touch events are anchored at this point.
180 void SetTouchAccessibilityAnchorPoint(const gfx::Point& anchor_point);
181
[email protected]431552c2012-10-23 00:38:33182 private:
[email protected]f5c9dbc2014-04-11 08:13:45183 explicit RootWindowController(AshWindowTreeHost* host);
jamescookb8dcef522016-06-25 14:42:55184 enum RootWindowType { PRIMARY, SECONDARY };
[email protected]a273d33a2013-10-17 12:41:21185
jamescookfda159002016-10-21 18:48:57186 // Initializes the RootWindowController based on |root_window_type|.
187 void Init(RootWindowType root_window_type);
[email protected]a273d33a2013-10-17 12:41:21188
[email protected]756bda12013-07-03 08:17:06189 void InitLayoutManagers();
190
msw607227f82016-08-30 17:22:39191 // Initializes |system_wallpaper_| and possibly also |boot_splash_screen_|.
jamescookfda159002016-10-21 18:48:57192 // The initial color is determined by the |root_window_type| and whether or
193 // not this is the first boot.
194 void CreateSystemWallpaper(RootWindowType root_window_type);
[email protected]756bda12013-07-03 08:17:06195
[email protected]d141b922013-07-09 08:13:17196 // Enables projection touch HUD.
197 void EnableTouchHudProjection();
198
199 // Disables projection touch HUD.
200 void DisableTouchHudProjection();
201
sky8d971a0a2016-09-21 23:37:57202 DockedWindowLayoutManager* docked_window_layout_manager();
203 PanelLayoutManager* panel_layout_manager();
204
[email protected]d141b922013-07-09 08:13:17205 // Overridden from ShellObserver.
skye79274a2016-06-08 05:39:02206 void OnLoginStateChanged(LoginStatus status) override;
dcheng1f4538e2014-10-27 23:57:05207 void OnTouchHudProjectionToggled(bool enabled) override;
[email protected]d141b922013-07-09 08:13:17208
dchenga94547472016-04-08 08:41:11209 std::unique_ptr<AshWindowTreeHost> ash_host_;
skyee78dde2016-06-01 01:21:43210
skyd053905c2016-08-30 22:37:35211 // Owned by the root window.
212 WmRootWindowControllerAura* wm_root_window_controller_ = nullptr;
skyee78dde2016-06-01 01:21:43213
dchenga94547472016-04-08 08:41:11214 std::unique_ptr<StackingController> stacking_controller_;
[email protected]2a2caa02013-01-22 20:50:36215
jamescookbe6ed822016-06-06 20:08:55216 // The shelf controller for this root window. Exists for the entire lifetime
217 // of the RootWindowController so that it is safe for observers to be added
218 // to it during construction of the shelf widget and status tray.
219 std::unique_ptr<WmShelfAura> wm_shelf_aura_;
220
msw607227f82016-08-30 17:22:39221 std::unique_ptr<SystemWallpaperController> system_wallpaper_;
[email protected]a825e8312014-05-05 22:05:01222
dchenga94547472016-04-08 08:41:11223 std::unique_ptr<BootSplashScreen> boot_splash_screen_;
[email protected]a825e8312014-05-05 22:05:01224 // Responsible for initializing TouchExplorationController when spoken
225 // feedback is on.
dchenga94547472016-04-08 08:41:11226 std::unique_ptr<AshTouchExplorationManager> touch_exploration_manager_;
[email protected]697f04c2012-10-03 01:15:10227
[email protected]2b8a9bb2013-07-01 22:43:40228 // Heads-up displays for touch events. These HUDs are not owned by the root
229 // window controller and manage their own lifetimes.
230 TouchHudDebug* touch_hud_debug_;
231 TouchHudProjection* touch_hud_projection_;
[email protected]58175042013-04-01 19:27:13232
[email protected]3537d472014-01-15 05:45:31233 // Handles double clicks on the panel window header.
dchenga94547472016-04-08 08:41:11234 std::unique_ptr<ui::EventHandler> panel_container_handler_;
[email protected]a4cd6d32012-09-12 03:42:13235
dchenga94547472016-04-08 08:41:11236 std::unique_ptr<::wm::ScopedCaptureClient> capture_client_;
[email protected]0bf61732013-07-02 04:35:10237
[email protected]d90b8392012-06-13 09:34:56238 DISALLOW_COPY_AND_ASSIGN(RootWindowController);
239};
240
jamescook5d74ac02016-05-12 19:57:12241// On classic ash, returns the RootWindowController for the given |root_window|.
242// On mus ash, returns the RootWindowController for the primary display.
243// See RootWindowController class comment above.
[email protected]6b2d4a0b2013-09-06 06:29:54244ASH_EXPORT RootWindowController* GetRootWindowController(
[email protected]bf9cdb362013-10-25 19:22:45245 const aura::Window* root_window);
[email protected]6b2d4a0b2013-09-06 06:29:54246
[email protected]76bc4632014-06-16 19:07:46247} // namespace ash
[email protected]d90b8392012-06-13 09:34:56248
[email protected]76bc4632014-06-16 19:07:46249#endif // ASH_ROOT_WINDOW_CONTROLLER_H_