blob: 8a18f48d840d7cee44a4dd6445cb710230d1b2fc [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;
[email protected]e74aaf0a2012-10-12 18:42:2858class ShelfLayoutManager;
[email protected]093b8d642014-04-03 20:59:2859class StackingController;
[email protected]e74aaf0a2012-10-12 18:42:2860class StatusAreaWidget;
[email protected]c0ce80e2012-10-05 23:28:2761class SystemModalContainerLayoutManager;
[email protected]093b8d642014-04-03 20:59:2862class SystemTray;
msw607227f82016-08-30 17:22:3963class SystemWallpaperController;
[email protected]2b8a9bb2013-07-01 22:43:4064class TouchHudDebug;
65class TouchHudProjection;
msw607227f82016-08-30 17:22:3966class WallpaperWidgetController;
skyd053905c2016-08-30 22:37:3567class WmRootWindowControllerAura;
jamescookbe6ed822016-06-06 20:08:5568class WmShelfAura;
sky0702b272016-06-03 22:10:4169class WmWindow;
[email protected]d90b8392012-06-13 09:34:5670class WorkspaceController;
71
[email protected]438cbdf02013-10-07 23:41:0972#if defined(OS_CHROMEOS)
[email protected]252eb232013-08-14 22:09:2773class BootSplashScreen;
[email protected]7d487592014-07-24 03:54:5074class AshTouchExplorationManager;
[email protected]252eb232013-08-14 22:09:2775#endif
76
[email protected]d90b8392012-06-13 09:34:5677// This class maintains the per root window state for ash. This class
78// owns the root window and other dependent objects that should be
[email protected]a273d33a2013-10-17 12:41:2179// deleted upon the deletion of the root window. This object is
oshimae2818922015-07-28 01:18:5280// indirectly owned and deleted by |WindowTreeHostManager|.
[email protected]a273d33a2013-10-17 12:41:2181// The RootWindowController for particular root window is stored in
82// its property (RootWindowSettings) and can be obtained using
[email protected]056ce052014-02-21 05:19:3283// |GetRootWindowController(aura::WindowEventDispatcher*)| function.
jamescook2a5ffa212016-04-29 17:44:0284//
85// NOTE: In classic ash there is one RootWindow per display, so every RootWindow
86// has a RootWindowController. In mus/mash there is one RootWindow per top-level
87// Widget, so not all RootWindows have a RootWindowController.
[email protected]d141b922013-07-09 08:13:1788class ASH_EXPORT RootWindowController : public ShellObserver {
[email protected]d90b8392012-06-13 09:34:5689 public:
[email protected]a273d33a2013-10-17 12:41:2190 // Creates and Initialize the RootWindowController for primary display.
[email protected]f5c9dbc2014-04-11 08:13:4591 static void CreateForPrimaryDisplay(AshWindowTreeHost* host);
[email protected]a273d33a2013-10-17 12:41:2192
93 // Creates and Initialize the RootWindowController for secondary displays.
[email protected]f5c9dbc2014-04-11 08:13:4594 static void CreateForSecondaryDisplay(AshWindowTreeHost* host);
[email protected]d90b8392012-06-13 09:34:5695
[email protected]a0afeb12012-12-10 22:57:0996 // Returns a RootWindowController of the window's root window.
[email protected]ccff3d72013-02-06 04:26:2897 static RootWindowController* ForWindow(const aura::Window* window);
[email protected]a0afeb12012-12-10 22:57:0998
[email protected]d17642d2013-09-12 23:44:3899 // Returns the RootWindowController of the target root window.
[email protected]093b8d642014-04-03 20:59:28100 static RootWindowController* ForTargetRootWindow();
[email protected]a0afeb12012-12-10 22:57:09101
dcheng1f4538e2014-10-27 23:57:05102 ~RootWindowController() override;
[email protected]a273d33a2013-10-17 12:41:21103
[email protected]f5c9dbc2014-04-11 08:13:45104 AshWindowTreeHost* ash_host() { return ash_host_.get(); }
105 const AshWindowTreeHost* ash_host() const { return ash_host_.get(); }
106
107 aura::WindowTreeHost* GetHost();
108 const aura::WindowTreeHost* GetHost() const;
109 aura::Window* GetRootWindow();
110 const aura::Window* GetRootWindow() const;
[email protected]d90b8392012-06-13 09:34:56111
skyf71e6c92016-08-30 18:49:19112 WorkspaceController* workspace_controller();
[email protected]d90b8392012-06-13 09:34:56113
[email protected]80549c152013-07-02 01:42:47114 AlwaysOnTopController* always_on_top_controller() {
115 return always_on_top_controller_.get();
116 }
117
jamescookbe6ed822016-06-06 20:08:55118 WmShelfAura* wm_shelf_aura() const { return wm_shelf_aura_.get(); }
119
[email protected]2b8a9bb2013-07-01 22:43:40120 // Get touch HUDs associated with this root window controller.
jamescookb8dcef522016-06-25 14:42:55121 TouchHudDebug* touch_hud_debug() const { return touch_hud_debug_; }
[email protected]2b8a9bb2013-07-01 22:43:40122 TouchHudProjection* touch_hud_projection() const {
123 return touch_hud_projection_;
124 }
125
126 // Set touch HUDs for this root window controller. The root window controller
127 // will not own the HUDs; their lifetimes are managed by themselves. Whenever
128 // the widget showing a HUD is being destroyed (e.g. because of detaching a
129 // display), the HUD deletes itself.
jamescookb8dcef522016-06-25 14:42:55130 void set_touch_hud_debug(TouchHudDebug* hud) { touch_hud_debug_ = hud; }
[email protected]2b8a9bb2013-07-01 22:43:40131 void set_touch_hud_projection(TouchHudProjection* hud) {
132 touch_hud_projection_ = hud;
133 }
134
msw607227f82016-08-30 17:22:39135 WallpaperWidgetController* wallpaper_widget_controller() {
136 return wallpaper_widget_controller_.get();
[email protected]0bf61732013-07-02 04:35:10137 }
msw607227f82016-08-30 17:22:39138 void SetWallpaperWidgetController(WallpaperWidgetController* controller);
139 AnimatingWallpaperWidgetController* animating_wallpaper_widget_controller() {
140 return animating_wallpaper_widget_controller_.get();
[email protected]0bf61732013-07-02 04:35:10141 }
msw607227f82016-08-30 17:22:39142 void SetAnimatingWallpaperWidgetController(
143 AnimatingWallpaperWidgetController* controller);
[email protected]0bf61732013-07-02 04:35:10144
[email protected]478c6c32013-03-09 02:50:58145 // Access the shelf layout manager associated with this root
146 // window controller, NULL if no such shelf exists.
147 ShelfLayoutManager* GetShelfLayoutManager();
[email protected]d90b8392012-06-13 09:34:56148
jamescookb551aba2016-09-01 01:00:16149 // May return null, for example for a secondary monitor at the login screen.
150 StatusAreaWidget* GetStatusAreaWidget();
151
[email protected]a0afeb12012-12-10 22:57:09152 // Returns the system tray on this root window. Note that
[email protected]864b58552013-12-19 04:19:38153 // calling this on the root window that doesn't have a shelf will
[email protected]a0afeb12012-12-10 22:57:09154 // lead to a crash.
155 SystemTray* GetSystemTray();
156
[email protected]431552c2012-10-23 00:38:33157 // Shows context menu at the |location_in_screen|. This uses
158 // |ShellDelegate::CreateContextMenu| to define the content of the menu.
[email protected]940fb1c2013-06-18 16:54:28159 void ShowContextMenu(const gfx::Point& location_in_screen,
160 ui::MenuSourceType source_type);
[email protected]431552c2012-10-23 00:38:33161
oshima9a61ecf2016-06-18 10:43:05162 // True if the window can receive events on this root window.
163 bool CanWindowReceiveEvents(aura::Window* window);
164
[email protected]8674b312012-10-12 19:02:44165 // Returns the layout-manager for the appropriate modal-container. If the
166 // window is inside the lockscreen modal container, then the layout manager
167 // for that is returned. Otherwise the layout manager for the default modal
168 // container is returned.
169 // If no window is specified (i.e. |window| is NULL), then the lockscreen
170 // modal container is used if the screen is currently locked. Otherwise, the
171 // default modal container is used.
172 SystemModalContainerLayoutManager* GetSystemModalLayoutManager(
173 aura::Window* window);
[email protected]c0ce80e2012-10-05 23:28:27174
[email protected]d90b8392012-06-13 09:34:56175 aura::Window* GetContainer(int container_id);
[email protected]d8a24952013-08-05 20:05:05176 const aura::Window* GetContainer(int container_id) const;
[email protected]d90b8392012-06-13 09:34:56177
[email protected]864b58552013-12-19 04:19:38178 // Show shelf view if it was created hidden (before session has started).
jamescook6afad6d2016-06-01 00:35:01179 // TODO(jamescook): Eliminate this and handle show via Shelf.
[email protected]864b58552013-12-19 04:19:38180 void ShowShelf();
[email protected]e74aaf0a2012-10-12 18:42:28181
jamescook6500ad132016-05-27 06:15:54182 // Creates the shelf for this root window and notifies observers.
183 void CreateShelf();
[email protected]478c6c32013-03-09 02:50:58184
[email protected]16059276d2012-10-22 18:59:50185 // Called when the login status changes after login (such as lock/unlock).
186 // TODO(oshima): Investigate if we can merge this and |OnLoginStateChanged|.
skye79274a2016-06-08 05:39:02187 void UpdateAfterLoginStatusChange(LoginStatus status);
[email protected]16059276d2012-10-22 18:59:50188
[email protected]bca9a7e2012-11-10 06:25:49189 // Called when the brightness/grayscale animation from white to the login
msw607227f82016-08-30 17:22:39190 // wallpaper image has started. Starts |boot_splash_screen_|'s hiding
191 // animation (if the screen is non-NULL).
192 void HandleInitialWallpaperAnimationStarted();
[email protected]bca9a7e2012-11-10 06:25:49193
msw607227f82016-08-30 17:22:39194 // Called when the wallpaper animation is finished. Updates
195 // |system_wallpaper_| to be black and drops |boot_splash_screen_| and moves
196 // the wallpaper controller into the root window controller. |widget| holds
197 // the wallpaper image, or NULL if the wallpaper is a solid color.
[email protected]0bf61732013-07-02 04:35:10198 void OnWallpaperAnimationFinished(views::Widget* widget);
[email protected]d90b8392012-06-13 09:34:56199
[email protected]6675e1c2012-09-11 09:15:45200 // Deletes associated objects and clears the state, but doesn't delete
201 // the root window yet. This is used to delete a secondary displays'
202 // root window safely when the display disconnect signal is received,
203 // which may come while we're in the nested message loop.
204 void Shutdown();
205
[email protected]d90b8392012-06-13 09:34:56206 // Deletes all child windows and performs necessary cleanup.
207 void CloseChildWindows();
208
[email protected]f1853122012-06-27 16:21:26209 // Moves child windows to |dest|.
[email protected]bf9cdb362013-10-25 19:22:45210 void MoveWindowsTo(aura::Window* dest);
[email protected]f1853122012-06-27 16:21:26211
[email protected]e74aaf0a2012-10-12 18:42:28212 // Force the shelf to query for it's current visibility state.
213 void UpdateShelfVisibility();
214
[email protected]2b8a9bb2013-07-01 22:43:40215 // Initialize touch HUDs if necessary.
216 void InitTouchHuds();
217
[email protected]2c9171d22013-12-10 21:55:10218 // Returns the topmost window or one of its transient parents, if any of them
219 // are in fullscreen mode.
varkhad99fa94f2015-06-29 22:35:46220 aura::Window* GetWindowForFullscreenMode();
[email protected]2ee2f5d2013-01-10 23:37:16221
[email protected]b6ba05d902013-10-04 21:38:45222 // Activate virtual keyboard on current root window controller.
223 void ActivateKeyboard(keyboard::KeyboardController* keyboard_controller);
224
225 // Deactivate virtual keyboard on current root window controller.
226 void DeactivateKeyboard(keyboard::KeyboardController* keyboard_controller);
227
[email protected]602022b2014-03-31 17:07:31228 // Tests if a window is associated with the virtual keyboard.
229 bool IsVirtualKeyboardWindow(aura::Window* window);
230
dmazzoniff86e3472016-06-03 19:52:32231 // If touch exploration is enabled, update the touch exploration
232 // controller so that synthesized touch events are anchored at this point.
233 void SetTouchAccessibilityAnchorPoint(const gfx::Point& anchor_point);
234
[email protected]431552c2012-10-23 00:38:33235 private:
[email protected]f5c9dbc2014-04-11 08:13:45236 explicit RootWindowController(AshWindowTreeHost* host);
jamescookb8dcef522016-06-25 14:42:55237 enum RootWindowType { PRIMARY, SECONDARY };
[email protected]a273d33a2013-10-17 12:41:21238
239 // Initializes the RootWindowController. |is_primary| is true if
240 // the controller is for primary display. |first_run_after_boot| is
241 // set to true only for primary root window after boot.
[email protected]608de6c2013-10-29 00:14:28242 void Init(RootWindowType root_window_type, bool first_run_after_boot);
[email protected]a273d33a2013-10-17 12:41:21243
[email protected]756bda12013-07-03 08:17:06244 void InitLayoutManagers();
245
msw607227f82016-08-30 17:22:39246 // Initializes |system_wallpaper_| and possibly also |boot_splash_screen_|.
247 // |is_first_run_after_boot| determines the wallpaper's initial color.
248 void CreateSystemWallpaper(bool is_first_run_after_boot);
[email protected]756bda12013-07-03 08:17:06249
[email protected]d141b922013-07-09 08:13:17250 // Enables projection touch HUD.
251 void EnableTouchHudProjection();
252
253 // Disables projection touch HUD.
254 void DisableTouchHudProjection();
255
jonrossa90d8982016-05-16 18:14:25256 // Callback for MenuModelAdapter.
257 void OnMenuClosed();
258
[email protected]d141b922013-07-09 08:13:17259 // Overridden from ShellObserver.
skye79274a2016-06-08 05:39:02260 void OnLoginStateChanged(LoginStatus status) override;
dcheng1f4538e2014-10-27 23:57:05261 void OnTouchHudProjectionToggled(bool enabled) override;
[email protected]d141b922013-07-09 08:13:17262
dchenga94547472016-04-08 08:41:11263 std::unique_ptr<AshWindowTreeHost> ash_host_;
skyee78dde2016-06-01 01:21:43264
skyd053905c2016-08-30 22:37:35265 // Owned by the root window.
266 WmRootWindowControllerAura* wm_root_window_controller_ = nullptr;
skyee78dde2016-06-01 01:21:43267
dchenga94547472016-04-08 08:41:11268 std::unique_ptr<StackingController> stacking_controller_;
[email protected]2a2caa02013-01-22 20:50:36269
jamescookbe6ed822016-06-06 20:08:55270 // The shelf controller for this root window. Exists for the entire lifetime
271 // of the RootWindowController so that it is safe for observers to be added
272 // to it during construction of the shelf widget and status tray.
273 std::unique_ptr<WmShelfAura> wm_shelf_aura_;
274
[email protected]cf6fea22013-08-07 14:24:01275 // An invisible/empty window used as a event target for
276 // |MouseCursorEventFilter| before a user logs in.
277 // (crbug.com/266987)
msw607227f82016-08-30 17:22:39278 // Its container is |LockScreenWallpaperContainer| and
[email protected]cf6fea22013-08-07 14:24:01279 // this must be deleted before the container is deleted.
dchenga94547472016-04-08 08:41:11280 std::unique_ptr<aura::Window> mouse_event_target_;
[email protected]cf6fea22013-08-07 14:24:01281
[email protected]beb4e5c2013-06-18 15:37:07282 // Manages layout of docked windows. Owned by DockedContainer.
283 DockedWindowLayoutManager* docked_layout_manager_;
284
[email protected]e74aaf0a2012-10-12 18:42:28285 // Manages layout of panels. Owned by PanelContainer.
[email protected]88d71122012-10-18 07:11:01286 PanelLayoutManager* panel_layout_manager_;
[email protected]e74aaf0a2012-10-12 18:42:28287
msw607227f82016-08-30 17:22:39288 std::unique_ptr<SystemWallpaperController> system_wallpaper_;
[email protected]a825e8312014-05-05 22:05:01289
[email protected]438cbdf02013-10-07 23:41:09290#if defined(OS_CHROMEOS)
dchenga94547472016-04-08 08:41:11291 std::unique_ptr<BootSplashScreen> boot_splash_screen_;
[email protected]a825e8312014-05-05 22:05:01292 // Responsible for initializing TouchExplorationController when spoken
293 // feedback is on.
dchenga94547472016-04-08 08:41:11294 std::unique_ptr<AshTouchExplorationManager> touch_exploration_manager_;
[email protected]252eb232013-08-14 22:09:27295#endif
[email protected]697f04c2012-10-03 01:15:10296
dchenga94547472016-04-08 08:41:11297 std::unique_ptr<AlwaysOnTopController> always_on_top_controller_;
[email protected]d90b8392012-06-13 09:34:56298
[email protected]2b8a9bb2013-07-01 22:43:40299 // Heads-up displays for touch events. These HUDs are not owned by the root
300 // window controller and manage their own lifetimes.
301 TouchHudDebug* touch_hud_debug_;
302 TouchHudProjection* touch_hud_projection_;
[email protected]58175042013-04-01 19:27:13303
[email protected]3537d472014-01-15 05:45:31304 // Handles double clicks on the panel window header.
dchenga94547472016-04-08 08:41:11305 std::unique_ptr<ui::EventHandler> panel_container_handler_;
[email protected]a4cd6d32012-09-12 03:42:13306
msw607227f82016-08-30 17:22:39307 std::unique_ptr<WallpaperWidgetController> wallpaper_widget_controller_;
308 std::unique_ptr<AnimatingWallpaperWidgetController>
309 animating_wallpaper_widget_controller_;
dchenga94547472016-04-08 08:41:11310 std::unique_ptr<::wm::ScopedCaptureClient> capture_client_;
[email protected]0bf61732013-07-02 04:35:10311
jonrossa90d8982016-05-16 18:14:25312 // Manages the context menu.
313 std::unique_ptr<ui::MenuModel> menu_model_;
314 std::unique_ptr<views::MenuModelAdapter> menu_model_adapter_;
315 std::unique_ptr<views::MenuRunner> menu_runner_;
316
[email protected]d90b8392012-06-13 09:34:56317 DISALLOW_COPY_AND_ASSIGN(RootWindowController);
318};
319
jamescook5d74ac02016-05-12 19:57:12320// On classic ash, returns the RootWindowController for the given |root_window|.
321// On mus ash, returns the RootWindowController for the primary display.
322// See RootWindowController class comment above.
[email protected]6b2d4a0b2013-09-06 06:29:54323ASH_EXPORT RootWindowController* GetRootWindowController(
[email protected]bf9cdb362013-10-25 19:22:45324 const aura::Window* root_window);
[email protected]6b2d4a0b2013-09-06 06:29:54325
[email protected]76bc4632014-06-16 19:07:46326} // namespace ash
[email protected]d90b8392012-06-13 09:34:56327
[email protected]76bc4632014-06-16 19:07:46328#endif // ASH_ROOT_WINDOW_CONTROLLER_H_