blob: 1494c96f3c114073c635d82a1fdef2ab2cc21374 [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>
9
[email protected]c0ce80e2012-10-05 23:28:2710#include "ash/ash_export.h"
[email protected]478c6c32013-03-09 02:50:5811#include "ash/shelf/shelf_types.h"
[email protected]d141b922013-07-09 08:13:1712#include "ash/shell_observer.h"
[email protected]16059276d2012-10-22 18:59:5013#include "ash/system/user/login_status.h"
[email protected]d90b8392012-06-13 09:34:5614#include "base/basictypes.h"
15#include "base/memory/scoped_ptr.h"
[email protected]f7c05b22013-11-12 21:07:2416#include "ui/aura/window.h"
[email protected]2f2620332014-02-28 10:07:3817#include "ui/aura/window_tree_host.h"
[email protected]940fb1c2013-06-18 16:54:2818#include "ui/base/ui_base_types.h"
[email protected]d90b8392012-06-13 09:34:5619
20class SkBitmap;
21
22namespace aura {
23class EventFilter;
[email protected]d90b8392012-06-13 09:34:5624class Window;
[email protected]4a59e4e2012-11-12 21:15:4025}
26
27namespace gfx {
28class Point;
29}
30
[email protected]86459e2c2013-04-10 13:39:2431namespace keyboard {
32class KeyboardController;
33}
34
[email protected]3537d472014-01-15 05:45:3135namespace ui {
36class EventHandler;
37}
38
[email protected]e319c7e2014-03-14 19:56:1439namespace views {
40class Widget;
41}
42
43namespace wm {
44class InputMethodEventFilter;
45class RootWindowEventFilter;
46class ScopedCaptureClient;
47}
48
[email protected]d90b8392012-06-13 09:34:5649namespace ash {
[email protected]f5c9dbc2014-04-11 08:13:4550class AshWindowTreeHost;
[email protected]80549c152013-07-02 01:42:4751class AlwaysOnTopController;
[email protected]0bf61732013-07-02 04:35:1052class AnimatingDesktopController;
[email protected]0bf61732013-07-02 04:35:1053class DesktopBackgroundWidgetController;
[email protected]beb4e5c2013-06-18 15:37:0754class DockedWindowLayoutManager;
[email protected]e74aaf0a2012-10-12 18:42:2855class PanelLayoutManager;
[email protected]d90b8392012-06-13 09:34:5656class RootWindowLayoutManager;
57class ScreenDimmer;
[email protected]e74aaf0a2012-10-12 18:42:2858class ShelfLayoutManager;
[email protected]093b8d642014-04-03 20:59:2859class ShelfWidget;
60class StackingController;
[email protected]e74aaf0a2012-10-12 18:42:2861class StatusAreaWidget;
62class SystemBackgroundController;
[email protected]c0ce80e2012-10-05 23:28:2763class SystemModalContainerLayoutManager;
[email protected]093b8d642014-04-03 20:59:2864class SystemTray;
[email protected]2b8a9bb2013-07-01 22:43:4065class TouchHudDebug;
66class TouchHudProjection;
[email protected]d90b8392012-06-13 09:34:5667class WorkspaceController;
68
[email protected]438cbdf02013-10-07 23:41:0969#if defined(OS_CHROMEOS)
[email protected]252eb232013-08-14 22:09:2770class BootSplashScreen;
[email protected]7d487592014-07-24 03:54:5071class AshTouchExplorationManager;
[email protected]252eb232013-08-14 22:09:2772#endif
73
[email protected]d90b8392012-06-13 09:34:5674// This class maintains the per root window state for ash. This class
75// owns the root window and other dependent objects that should be
[email protected]a273d33a2013-10-17 12:41:2176// deleted upon the deletion of the root window. This object is
77// indirectly owned and deleted by |DisplayController|.
78// The RootWindowController for particular root window is stored in
79// its property (RootWindowSettings) and can be obtained using
[email protected]056ce052014-02-21 05:19:3280// |GetRootWindowController(aura::WindowEventDispatcher*)| function.
[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]608de6c2013-10-29 00:14:2889 // Creates and Initialize the RootWindowController for virtual
90 // keyboard displays.
[email protected]f5c9dbc2014-04-11 08:13:4591 static void CreateForVirtualKeyboardDisplay(AshWindowTreeHost* host);
[email protected]608de6c2013-10-29 00:14:2892
[email protected]864b58552013-12-19 04:19:3893 // Returns a RootWindowController that has a shelf for given
[email protected]88d71122012-10-18 07:11:0194 // |window|. This returns the RootWindowController for the |window|'s
[email protected]864b58552013-12-19 04:19:3895 // root window when multiple shelf mode is enabled, or the primary
[email protected]88d71122012-10-18 07:11:0196 // RootWindowController otherwise.
[email protected]76bc4632014-06-16 19:07:4697 static RootWindowController* ForShelf(const aura::Window* window);
[email protected]88d71122012-10-18 07:11:0198
[email protected]a0afeb12012-12-10 22:57:0999 // Returns a RootWindowController of the window's root window.
[email protected]ccff3d72013-02-06 04:26:28100 static RootWindowController* ForWindow(const aura::Window* window);
[email protected]a0afeb12012-12-10 22:57:09101
[email protected]d17642d2013-09-12 23:44:38102 // Returns the RootWindowController of the target root window.
[email protected]093b8d642014-04-03 20:59:28103 static RootWindowController* ForTargetRootWindow();
[email protected]a0afeb12012-12-10 22:57:09104
[email protected]a5c78802013-12-12 22:07:01105 // Returns container which contains a given |window|.
106 static aura::Window* GetContainerForWindow(aura::Window* window);
107
dcheng1f4538e2014-10-27 23:57:05108 ~RootWindowController() override;
[email protected]a273d33a2013-10-17 12:41:21109
[email protected]f5c9dbc2014-04-11 08:13:45110 AshWindowTreeHost* ash_host() { return ash_host_.get(); }
111 const AshWindowTreeHost* ash_host() const { return ash_host_.get(); }
112
113 aura::WindowTreeHost* GetHost();
114 const aura::WindowTreeHost* GetHost() const;
115 aura::Window* GetRootWindow();
116 const aura::Window* GetRootWindow() const;
[email protected]d90b8392012-06-13 09:34:56117
[email protected]e74aaf0a2012-10-12 18:42:28118 RootWindowLayoutManager* root_window_layout() { return root_window_layout_; }
[email protected]d90b8392012-06-13 09:34:56119
[email protected]c0ce80e2012-10-05 23:28:27120 WorkspaceController* workspace_controller() {
[email protected]d90b8392012-06-13 09:34:56121 return workspace_controller_.get();
122 }
123
[email protected]80549c152013-07-02 01:42:47124 AlwaysOnTopController* always_on_top_controller() {
125 return always_on_top_controller_.get();
126 }
127
[email protected]e74aaf0a2012-10-12 18:42:28128 ScreenDimmer* screen_dimmer() { return screen_dimmer_.get(); }
129
[email protected]478c6c32013-03-09 02:50:58130 // Access the shelf associated with this root window controller,
131 // NULL if no such shelf exists.
132 ShelfWidget* shelf() { return shelf_.get(); }
[email protected]e74aaf0a2012-10-12 18:42:28133
[email protected]2b8a9bb2013-07-01 22:43:40134 // Get touch HUDs associated with this root window controller.
135 TouchHudDebug* touch_hud_debug() const {
136 return touch_hud_debug_;
[email protected]bff17552013-04-25 04:44:55137 }
[email protected]2b8a9bb2013-07-01 22:43:40138 TouchHudProjection* touch_hud_projection() const {
139 return touch_hud_projection_;
140 }
141
142 // Set touch HUDs for this root window controller. The root window controller
143 // will not own the HUDs; their lifetimes are managed by themselves. Whenever
144 // the widget showing a HUD is being destroyed (e.g. because of detaching a
145 // display), the HUD deletes itself.
146 void set_touch_hud_debug(TouchHudDebug* hud) {
147 touch_hud_debug_ = hud;
148 }
149 void set_touch_hud_projection(TouchHudProjection* hud) {
150 touch_hud_projection_ = hud;
151 }
152
[email protected]0bf61732013-07-02 04:35:10153 DesktopBackgroundWidgetController* wallpaper_controller() {
154 return wallpaper_controller_.get();
155 }
156 void SetWallpaperController(DesktopBackgroundWidgetController* controller);
157 AnimatingDesktopController* animating_wallpaper_controller() {
158 return animating_wallpaper_controller_.get();
159 }
160 void SetAnimatingWallpaperController(AnimatingDesktopController* controller);
161
[email protected]478c6c32013-03-09 02:50:58162 // Access the shelf layout manager associated with this root
163 // window controller, NULL if no such shelf exists.
164 ShelfLayoutManager* GetShelfLayoutManager();
[email protected]d90b8392012-06-13 09:34:56165
[email protected]a0afeb12012-12-10 22:57:09166 // Returns the system tray on this root window. Note that
[email protected]864b58552013-12-19 04:19:38167 // calling this on the root window that doesn't have a shelf will
[email protected]a0afeb12012-12-10 22:57:09168 // lead to a crash.
169 SystemTray* GetSystemTray();
170
[email protected]431552c2012-10-23 00:38:33171 // Shows context menu at the |location_in_screen|. This uses
172 // |ShellDelegate::CreateContextMenu| to define the content of the menu.
[email protected]940fb1c2013-06-18 16:54:28173 void ShowContextMenu(const gfx::Point& location_in_screen,
174 ui::MenuSourceType source_type);
[email protected]431552c2012-10-23 00:38:33175
[email protected]8674b312012-10-12 19:02:44176 // Returns the layout-manager for the appropriate modal-container. If the
177 // window is inside the lockscreen modal container, then the layout manager
178 // for that is returned. Otherwise the layout manager for the default modal
179 // container is returned.
180 // If no window is specified (i.e. |window| is NULL), then the lockscreen
181 // modal container is used if the screen is currently locked. Otherwise, the
182 // default modal container is used.
183 SystemModalContainerLayoutManager* GetSystemModalLayoutManager(
184 aura::Window* window);
[email protected]c0ce80e2012-10-05 23:28:27185
[email protected]d90b8392012-06-13 09:34:56186 aura::Window* GetContainer(int container_id);
[email protected]d8a24952013-08-05 20:05:05187 const aura::Window* GetContainer(int container_id) const;
[email protected]d90b8392012-06-13 09:34:56188
[email protected]864b58552013-12-19 04:19:38189 // Show shelf view if it was created hidden (before session has started).
190 void ShowShelf();
[email protected]e74aaf0a2012-10-12 18:42:28191
[email protected]864b58552013-12-19 04:19:38192 // Called when the shelf associated with this root window is created.
193 void OnShelfCreated();
[email protected]478c6c32013-03-09 02:50:58194
[email protected]16059276d2012-10-22 18:59:50195 // Called when the login status changes after login (such as lock/unlock).
196 // TODO(oshima): Investigate if we can merge this and |OnLoginStateChanged|.
197 void UpdateAfterLoginStatusChange(user::LoginStatus status);
198
[email protected]bca9a7e2012-11-10 06:25:49199 // Called when the brightness/grayscale animation from white to the login
200 // desktop background image has started. Starts |boot_splash_screen_|'s
201 // hiding animation (if the screen is non-NULL).
202 void HandleInitialDesktopBackgroundAnimationStarted();
203
[email protected]0bf61732013-07-02 04:35:10204 // Called when the wallpaper ainmation is finished. Updates |background_|
205 // to be black and drops |boot_splash_screen_| and moves the wallpaper
206 // controller into the root window controller. |widget| holds the wallpaper
207 // image, or NULL if the background is a solid color.
208 void OnWallpaperAnimationFinished(views::Widget* widget);
[email protected]d90b8392012-06-13 09:34:56209
[email protected]6675e1c2012-09-11 09:15:45210 // Deletes associated objects and clears the state, but doesn't delete
211 // the root window yet. This is used to delete a secondary displays'
212 // root window safely when the display disconnect signal is received,
213 // which may come while we're in the nested message loop.
214 void Shutdown();
215
[email protected]d90b8392012-06-13 09:34:56216 // Deletes all child windows and performs necessary cleanup.
217 void CloseChildWindows();
218
[email protected]f1853122012-06-27 16:21:26219 // Moves child windows to |dest|.
[email protected]bf9cdb362013-10-25 19:22:45220 void MoveWindowsTo(aura::Window* dest);
[email protected]f1853122012-06-27 16:21:26221
[email protected]e74aaf0a2012-10-12 18:42:28222 // Force the shelf to query for it's current visibility state.
223 void UpdateShelfVisibility();
224
[email protected]2b8a9bb2013-07-01 22:43:40225 // Initialize touch HUDs if necessary.
226 void InitTouchHuds();
227
[email protected]2c9171d22013-12-10 21:55:10228 // Returns the topmost window or one of its transient parents, if any of them
229 // are in fullscreen mode.
230 const aura::Window* GetWindowForFullscreenMode() const;
[email protected]2ee2f5d2013-01-10 23:37:16231
[email protected]b6ba05d902013-10-04 21:38:45232 // Activate virtual keyboard on current root window controller.
233 void ActivateKeyboard(keyboard::KeyboardController* keyboard_controller);
234
235 // Deactivate virtual keyboard on current root window controller.
236 void DeactivateKeyboard(keyboard::KeyboardController* keyboard_controller);
237
[email protected]602022b2014-03-31 17:07:31238 // Tests if a window is associated with the virtual keyboard.
239 bool IsVirtualKeyboardWindow(aura::Window* window);
240
[email protected]431552c2012-10-23 00:38:33241 private:
[email protected]f5c9dbc2014-04-11 08:13:45242 explicit RootWindowController(AshWindowTreeHost* host);
[email protected]608de6c2013-10-29 00:14:28243 enum RootWindowType {
244 PRIMARY,
bshee1eb0a22014-09-23 21:18:38245 SECONDARY
[email protected]608de6c2013-10-29 00:14:28246 };
[email protected]a273d33a2013-10-17 12:41:21247
248 // Initializes the RootWindowController. |is_primary| is true if
249 // the controller is for primary display. |first_run_after_boot| is
250 // set to true only for primary root window after boot.
[email protected]608de6c2013-10-29 00:14:28251 void Init(RootWindowType root_window_type, bool first_run_after_boot);
[email protected]a273d33a2013-10-17 12:41:21252
[email protected]756bda12013-07-03 08:17:06253 void InitLayoutManagers();
254
255 // Initializes |system_background_| and possibly also |boot_splash_screen_|.
256 // |is_first_run_after_boot| determines the background's initial color.
257 void CreateSystemBackground(bool is_first_run_after_boot);
258
[email protected]a4cd6d32012-09-12 03:42:13259 // Creates each of the special window containers that holds windows of various
260 // types in the shell UI.
[email protected]41baaed2013-11-09 04:18:26261 void CreateContainersInRootWindow(aura::Window* root_window);
[email protected]a4cd6d32012-09-12 03:42:13262
[email protected]d141b922013-07-09 08:13:17263 // Enables projection touch HUD.
264 void EnableTouchHudProjection();
265
266 // Disables projection touch HUD.
267 void DisableTouchHudProjection();
268
269 // Overridden from ShellObserver.
dcheng1f4538e2014-10-27 23:57:05270 void OnLoginStateChanged(user::LoginStatus status) override;
271 void OnTouchHudProjectionToggled(bool enabled) override;
[email protected]d141b922013-07-09 08:13:17272
[email protected]f5c9dbc2014-04-11 08:13:45273 scoped_ptr<AshWindowTreeHost> ash_host_;
[email protected]c0ce80e2012-10-05 23:28:27274 RootWindowLayoutManager* root_window_layout_;
[email protected]d90b8392012-06-13 09:34:56275
[email protected]2a2caa02013-01-22 20:50:36276 scoped_ptr<StackingController> stacking_controller_;
277
[email protected]864b58552013-12-19 04:19:38278 // The shelf for managing the shelf and the status widget.
[email protected]478c6c32013-03-09 02:50:58279 scoped_ptr<ShelfWidget> shelf_;
[email protected]e74aaf0a2012-10-12 18:42:28280
[email protected]cf6fea22013-08-07 14:24:01281 // An invisible/empty window used as a event target for
282 // |MouseCursorEventFilter| before a user logs in.
283 // (crbug.com/266987)
284 // Its container is |LockScreenBackgroundContainer| and
285 // this must be deleted before the container is deleted.
286 scoped_ptr<aura::Window> mouse_event_target_;
287
[email protected]beb4e5c2013-06-18 15:37:07288 // Manages layout of docked windows. Owned by DockedContainer.
289 DockedWindowLayoutManager* docked_layout_manager_;
290
[email protected]e74aaf0a2012-10-12 18:42:28291 // Manages layout of panels. Owned by PanelContainer.
[email protected]88d71122012-10-18 07:11:01292 PanelLayoutManager* panel_layout_manager_;
[email protected]e74aaf0a2012-10-12 18:42:28293
[email protected]e6e41d2f2012-10-29 19:22:19294 scoped_ptr<SystemBackgroundController> system_background_;
[email protected]a825e8312014-05-05 22:05:01295
[email protected]438cbdf02013-10-07 23:41:09296#if defined(OS_CHROMEOS)
[email protected]bca9a7e2012-11-10 06:25:49297 scoped_ptr<BootSplashScreen> boot_splash_screen_;
[email protected]a825e8312014-05-05 22:05:01298 // Responsible for initializing TouchExplorationController when spoken
299 // feedback is on.
[email protected]7d487592014-07-24 03:54:50300 scoped_ptr<AshTouchExplorationManager> touch_exploration_manager_;
[email protected]252eb232013-08-14 22:09:27301#endif
[email protected]697f04c2012-10-03 01:15:10302
[email protected]c0ce80e2012-10-05 23:28:27303 scoped_ptr<ScreenDimmer> screen_dimmer_;
304 scoped_ptr<WorkspaceController> workspace_controller_;
[email protected]80549c152013-07-02 01:42:47305 scoped_ptr<AlwaysOnTopController> always_on_top_controller_;
[email protected]d90b8392012-06-13 09:34:56306
[email protected]2b8a9bb2013-07-01 22:43:40307 // Heads-up displays for touch events. These HUDs are not owned by the root
308 // window controller and manage their own lifetimes.
309 TouchHudDebug* touch_hud_debug_;
310 TouchHudProjection* touch_hud_projection_;
[email protected]58175042013-04-01 19:27:13311
[email protected]3537d472014-01-15 05:45:31312 // Handles double clicks on the panel window header.
313 scoped_ptr<ui::EventHandler> panel_container_handler_;
[email protected]a4cd6d32012-09-12 03:42:13314
[email protected]0bf61732013-07-02 04:35:10315 scoped_ptr<DesktopBackgroundWidgetController> wallpaper_controller_;
316 scoped_ptr<AnimatingDesktopController> animating_wallpaper_controller_;
[email protected]e319c7e2014-03-14 19:56:14317 scoped_ptr< ::wm::ScopedCaptureClient> capture_client_;
[email protected]0bf61732013-07-02 04:35:10318
[email protected]d90b8392012-06-13 09:34:56319 DISALLOW_COPY_AND_ASSIGN(RootWindowController);
320};
321
[email protected]6b2d4a0b2013-09-06 06:29:54322
323// Gets the RootWindowController for |root_window|.
324ASH_EXPORT RootWindowController* GetRootWindowController(
[email protected]bf9cdb362013-10-25 19:22:45325 const aura::Window* root_window);
[email protected]6b2d4a0b2013-09-06 06:29:54326
[email protected]76bc4632014-06-16 19:07:46327} // namespace ash
[email protected]d90b8392012-06-13 09:34:56328
[email protected]76bc4632014-06-16 19:07:46329#endif // ASH_ROOT_WINDOW_CONTROLLER_H_