blob: 3a7fdd04d834de69a394cdf82d685728125d3873 [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
18class SkBitmap;
19
20namespace aura {
21class EventFilter;
[email protected]d90b8392012-06-13 09:34:5622class Window;
[email protected]4a59e4e2012-11-12 21:15:4023}
24
25namespace gfx {
26class Point;
27}
28
[email protected]86459e2c2013-04-10 13:39:2429namespace keyboard {
30class KeyboardController;
31}
32
[email protected]3537d472014-01-15 05:45:3133namespace ui {
34class EventHandler;
35}
36
[email protected]e319c7e2014-03-14 19:56:1437namespace views {
38class Widget;
39}
40
41namespace wm {
42class InputMethodEventFilter;
43class RootWindowEventFilter;
44class ScopedCaptureClient;
45}
46
[email protected]d90b8392012-06-13 09:34:5647namespace ash {
[email protected]f5c9dbc2014-04-11 08:13:4548class AshWindowTreeHost;
[email protected]beb4e5c2013-06-18 15:37:0749class DockedWindowLayoutManager;
mswb2416052016-06-24 21:23:4550enum class LoginStatus;
[email protected]e74aaf0a2012-10-12 18:42:2851class PanelLayoutManager;
[email protected]e74aaf0a2012-10-12 18:42:2852class ShelfLayoutManager;
[email protected]093b8d642014-04-03 20:59:2853class StackingController;
[email protected]e74aaf0a2012-10-12 18:42:2854class StatusAreaWidget;
[email protected]c0ce80e2012-10-05 23:28:2755class SystemModalContainerLayoutManager;
[email protected]093b8d642014-04-03 20:59:2856class SystemTray;
msw607227f82016-08-30 17:22:3957class SystemWallpaperController;
[email protected]2b8a9bb2013-07-01 22:43:4058class TouchHudDebug;
59class TouchHudProjection;
skyd053905c2016-08-30 22:37:3560class WmRootWindowControllerAura;
jamescookbe6ed822016-06-06 20:08:5561class WmShelfAura;
sky0702b272016-06-03 22:10:4162class WmWindow;
[email protected]d90b8392012-06-13 09:34:5663class WorkspaceController;
64
[email protected]438cbdf02013-10-07 23:41:0965#if defined(OS_CHROMEOS)
[email protected]252eb232013-08-14 22:09:2766class BootSplashScreen;
[email protected]7d487592014-07-24 03:54:5067class AshTouchExplorationManager;
[email protected]252eb232013-08-14 22:09:2768#endif
69
[email protected]d90b8392012-06-13 09:34:5670// This class maintains the per root window state for ash. This class
71// owns the root window and other dependent objects that should be
[email protected]a273d33a2013-10-17 12:41:2172// deleted upon the deletion of the root window. This object is
oshimae2818922015-07-28 01:18:5273// indirectly owned and deleted by |WindowTreeHostManager|.
[email protected]a273d33a2013-10-17 12:41:2174// The RootWindowController for particular root window is stored in
75// its property (RootWindowSettings) and can be obtained using
[email protected]056ce052014-02-21 05:19:3276// |GetRootWindowController(aura::WindowEventDispatcher*)| function.
jamescook2a5ffa212016-04-29 17:44:0277//
78// NOTE: In classic ash there is one RootWindow per display, so every RootWindow
79// has a RootWindowController. In mus/mash there is one RootWindow per top-level
80// Widget, so not all RootWindows have a RootWindowController.
[email protected]d141b922013-07-09 08:13:1781class ASH_EXPORT RootWindowController : public ShellObserver {
[email protected]d90b8392012-06-13 09:34:5682 public:
[email protected]a273d33a2013-10-17 12:41:2183 // Creates and Initialize the RootWindowController for primary display.
[email protected]f5c9dbc2014-04-11 08:13:4584 static void CreateForPrimaryDisplay(AshWindowTreeHost* host);
[email protected]a273d33a2013-10-17 12:41:2185
86 // Creates and Initialize the RootWindowController for secondary displays.
[email protected]f5c9dbc2014-04-11 08:13:4587 static void CreateForSecondaryDisplay(AshWindowTreeHost* host);
[email protected]d90b8392012-06-13 09:34:5688
[email protected]a0afeb12012-12-10 22:57:0989 // Returns a RootWindowController of the window's root window.
[email protected]ccff3d72013-02-06 04:26:2890 static RootWindowController* ForWindow(const aura::Window* window);
[email protected]a0afeb12012-12-10 22:57:0991
[email protected]d17642d2013-09-12 23:44:3892 // Returns the RootWindowController of the target root window.
[email protected]093b8d642014-04-03 20:59:2893 static RootWindowController* ForTargetRootWindow();
[email protected]a0afeb12012-12-10 22:57:0994
dcheng1f4538e2014-10-27 23:57:0595 ~RootWindowController() override;
[email protected]a273d33a2013-10-17 12:41:2196
[email protected]f5c9dbc2014-04-11 08:13:4597 AshWindowTreeHost* ash_host() { return ash_host_.get(); }
98 const AshWindowTreeHost* ash_host() const { return ash_host_.get(); }
99
100 aura::WindowTreeHost* GetHost();
101 const aura::WindowTreeHost* GetHost() const;
102 aura::Window* GetRootWindow();
103 const aura::Window* GetRootWindow() const;
[email protected]d90b8392012-06-13 09:34:56104
skyf71e6c92016-08-30 18:49:19105 WorkspaceController* workspace_controller();
[email protected]d90b8392012-06-13 09:34:56106
jamescookbe6ed822016-06-06 20:08:55107 WmShelfAura* wm_shelf_aura() const { return wm_shelf_aura_.get(); }
108
sky8d971a0a2016-09-21 23:37:57109 WmRootWindowControllerAura* wm_root_window_controller() {
110 return wm_root_window_controller_;
111 }
112
[email protected]2b8a9bb2013-07-01 22:43:40113 // Get touch HUDs associated with this root window controller.
jamescookb8dcef522016-06-25 14:42:55114 TouchHudDebug* touch_hud_debug() const { return touch_hud_debug_; }
[email protected]2b8a9bb2013-07-01 22:43:40115 TouchHudProjection* touch_hud_projection() const {
116 return touch_hud_projection_;
117 }
118
119 // Set touch HUDs for this root window controller. The root window controller
120 // will not own the HUDs; their lifetimes are managed by themselves. Whenever
121 // the widget showing a HUD is being destroyed (e.g. because of detaching a
122 // display), the HUD deletes itself.
jamescookb8dcef522016-06-25 14:42:55123 void set_touch_hud_debug(TouchHudDebug* hud) { touch_hud_debug_ = hud; }
[email protected]2b8a9bb2013-07-01 22:43:40124 void set_touch_hud_projection(TouchHudProjection* hud) {
125 touch_hud_projection_ = hud;
126 }
127
[email protected]478c6c32013-03-09 02:50:58128 // Access the shelf layout manager associated with this root
129 // window controller, NULL if no such shelf exists.
130 ShelfLayoutManager* GetShelfLayoutManager();
[email protected]d90b8392012-06-13 09:34:56131
jamescookb551aba2016-09-01 01:00:16132 // May return null, for example for a secondary monitor at the login screen.
133 StatusAreaWidget* GetStatusAreaWidget();
134
[email protected]a0afeb12012-12-10 22:57:09135 // Returns the system tray on this root window. Note that
[email protected]864b58552013-12-19 04:19:38136 // calling this on the root window that doesn't have a shelf will
[email protected]a0afeb12012-12-10 22:57:09137 // lead to a crash.
138 SystemTray* GetSystemTray();
139
oshima9a61ecf2016-06-18 10:43:05140 // True if the window can receive events on this root window.
141 bool CanWindowReceiveEvents(aura::Window* window);
142
[email protected]d90b8392012-06-13 09:34:56143 aura::Window* GetContainer(int container_id);
[email protected]d8a24952013-08-05 20:05:05144 const aura::Window* GetContainer(int container_id) const;
[email protected]d90b8392012-06-13 09:34:56145
[email protected]bca9a7e2012-11-10 06:25:49146 // Called when the brightness/grayscale animation from white to the login
msw607227f82016-08-30 17:22:39147 // wallpaper image has started. Starts |boot_splash_screen_|'s hiding
148 // animation (if the screen is non-NULL).
msw3f439af2016-09-08 22:35:26149 void OnInitialWallpaperAnimationStarted();
[email protected]bca9a7e2012-11-10 06:25:49150
msw607227f82016-08-30 17:22:39151 // Called when the wallpaper animation is finished. Updates
152 // |system_wallpaper_| to be black and drops |boot_splash_screen_| and moves
153 // the wallpaper controller into the root window controller. |widget| holds
154 // the wallpaper image, or NULL if the wallpaper is a solid color.
[email protected]0bf61732013-07-02 04:35:10155 void OnWallpaperAnimationFinished(views::Widget* widget);
[email protected]d90b8392012-06-13 09:34:56156
[email protected]6675e1c2012-09-11 09:15:45157 // Deletes associated objects and clears the state, but doesn't delete
158 // the root window yet. This is used to delete a secondary displays'
159 // root window safely when the display disconnect signal is received,
160 // which may come while we're in the nested message loop.
161 void Shutdown();
162
[email protected]d90b8392012-06-13 09:34:56163 // Deletes all child windows and performs necessary cleanup.
164 void CloseChildWindows();
165
[email protected]f1853122012-06-27 16:21:26166 // Moves child windows to |dest|.
[email protected]bf9cdb362013-10-25 19:22:45167 void MoveWindowsTo(aura::Window* dest);
[email protected]f1853122012-06-27 16:21:26168
[email protected]e74aaf0a2012-10-12 18:42:28169 // Force the shelf to query for it's current visibility state.
170 void UpdateShelfVisibility();
171
[email protected]2b8a9bb2013-07-01 22:43:40172 // Initialize touch HUDs if necessary.
173 void InitTouchHuds();
174
[email protected]2c9171d22013-12-10 21:55:10175 // Returns the topmost window or one of its transient parents, if any of them
176 // are in fullscreen mode.
varkhad99fa94f2015-06-29 22:35:46177 aura::Window* GetWindowForFullscreenMode();
[email protected]2ee2f5d2013-01-10 23:37:16178
[email protected]b6ba05d902013-10-04 21:38:45179 // Activate virtual keyboard on current root window controller.
180 void ActivateKeyboard(keyboard::KeyboardController* keyboard_controller);
181
182 // Deactivate virtual keyboard on current root window controller.
183 void DeactivateKeyboard(keyboard::KeyboardController* keyboard_controller);
184
[email protected]602022b2014-03-31 17:07:31185 // Tests if a window is associated with the virtual keyboard.
186 bool IsVirtualKeyboardWindow(aura::Window* window);
187
dmazzoniff86e3472016-06-03 19:52:32188 // If touch exploration is enabled, update the touch exploration
189 // controller so that synthesized touch events are anchored at this point.
190 void SetTouchAccessibilityAnchorPoint(const gfx::Point& anchor_point);
191
[email protected]431552c2012-10-23 00:38:33192 private:
[email protected]f5c9dbc2014-04-11 08:13:45193 explicit RootWindowController(AshWindowTreeHost* host);
jamescookb8dcef522016-06-25 14:42:55194 enum RootWindowType { PRIMARY, SECONDARY };
[email protected]a273d33a2013-10-17 12:41:21195
jamescookfda159002016-10-21 18:48:57196 // Initializes the RootWindowController based on |root_window_type|.
197 void Init(RootWindowType root_window_type);
[email protected]a273d33a2013-10-17 12:41:21198
[email protected]756bda12013-07-03 08:17:06199 void InitLayoutManagers();
200
msw607227f82016-08-30 17:22:39201 // Initializes |system_wallpaper_| and possibly also |boot_splash_screen_|.
jamescookfda159002016-10-21 18:48:57202 // The initial color is determined by the |root_window_type| and whether or
203 // not this is the first boot.
204 void CreateSystemWallpaper(RootWindowType root_window_type);
[email protected]756bda12013-07-03 08:17:06205
[email protected]d141b922013-07-09 08:13:17206 // Enables projection touch HUD.
207 void EnableTouchHudProjection();
208
209 // Disables projection touch HUD.
210 void DisableTouchHudProjection();
211
sky8d971a0a2016-09-21 23:37:57212 DockedWindowLayoutManager* docked_window_layout_manager();
213 PanelLayoutManager* panel_layout_manager();
214
[email protected]d141b922013-07-09 08:13:17215 // Overridden from ShellObserver.
skye79274a2016-06-08 05:39:02216 void OnLoginStateChanged(LoginStatus status) override;
dcheng1f4538e2014-10-27 23:57:05217 void OnTouchHudProjectionToggled(bool enabled) override;
[email protected]d141b922013-07-09 08:13:17218
dchenga94547472016-04-08 08:41:11219 std::unique_ptr<AshWindowTreeHost> ash_host_;
skyee78dde2016-06-01 01:21:43220
skyd053905c2016-08-30 22:37:35221 // Owned by the root window.
222 WmRootWindowControllerAura* wm_root_window_controller_ = nullptr;
skyee78dde2016-06-01 01:21:43223
dchenga94547472016-04-08 08:41:11224 std::unique_ptr<StackingController> stacking_controller_;
[email protected]2a2caa02013-01-22 20:50:36225
jamescookbe6ed822016-06-06 20:08:55226 // The shelf controller for this root window. Exists for the entire lifetime
227 // of the RootWindowController so that it is safe for observers to be added
228 // to it during construction of the shelf widget and status tray.
229 std::unique_ptr<WmShelfAura> wm_shelf_aura_;
230
msw607227f82016-08-30 17:22:39231 std::unique_ptr<SystemWallpaperController> system_wallpaper_;
[email protected]a825e8312014-05-05 22:05:01232
[email protected]438cbdf02013-10-07 23:41:09233#if defined(OS_CHROMEOS)
dchenga94547472016-04-08 08:41:11234 std::unique_ptr<BootSplashScreen> boot_splash_screen_;
[email protected]a825e8312014-05-05 22:05:01235 // Responsible for initializing TouchExplorationController when spoken
236 // feedback is on.
dchenga94547472016-04-08 08:41:11237 std::unique_ptr<AshTouchExplorationManager> touch_exploration_manager_;
[email protected]252eb232013-08-14 22:09:27238#endif
[email protected]697f04c2012-10-03 01:15:10239
[email protected]2b8a9bb2013-07-01 22:43:40240 // Heads-up displays for touch events. These HUDs are not owned by the root
241 // window controller and manage their own lifetimes.
242 TouchHudDebug* touch_hud_debug_;
243 TouchHudProjection* touch_hud_projection_;
[email protected]58175042013-04-01 19:27:13244
[email protected]3537d472014-01-15 05:45:31245 // Handles double clicks on the panel window header.
dchenga94547472016-04-08 08:41:11246 std::unique_ptr<ui::EventHandler> panel_container_handler_;
[email protected]a4cd6d32012-09-12 03:42:13247
dchenga94547472016-04-08 08:41:11248 std::unique_ptr<::wm::ScopedCaptureClient> capture_client_;
[email protected]0bf61732013-07-02 04:35:10249
[email protected]d90b8392012-06-13 09:34:56250 DISALLOW_COPY_AND_ASSIGN(RootWindowController);
251};
252
jamescook5d74ac02016-05-12 19:57:12253// On classic ash, returns the RootWindowController for the given |root_window|.
254// On mus ash, returns the RootWindowController for the primary display.
255// See RootWindowController class comment above.
[email protected]6b2d4a0b2013-09-06 06:29:54256ASH_EXPORT RootWindowController* GetRootWindowController(
[email protected]bf9cdb362013-10-25 19:22:45257 const aura::Window* root_window);
[email protected]6b2d4a0b2013-09-06 06:29:54258
[email protected]76bc4632014-06-16 19:07:46259} // namespace ash
[email protected]d90b8392012-06-13 09:34:56260
[email protected]76bc4632014-06-16 19:07:46261#endif // ASH_ROOT_WINDOW_CONTROLLER_H_