blob: 849ce070fde1bfd95e95eb168a154b57564d6ce0 [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]41baaed2013-11-09 04:18:2616#include "ui/aura/root_window.h"
[email protected]f7c05b22013-11-12 21:07:2417#include "ui/aura/window.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
31namespace views {
[email protected]0bf61732013-07-02 04:35:1032class Widget;
33
[email protected]4a59e4e2012-11-12 21:15:4034namespace corewm {
[email protected]d90b8392012-06-13 09:34:5635class InputMethodEventFilter;
36class RootWindowEventFilter;
[email protected]23a2dc82013-08-22 15:04:2237class ScopedCaptureClient;
[email protected]4a59e4e2012-11-12 21:15:4038}
39}
[email protected]d90b8392012-06-13 09:34:5640
[email protected]86459e2c2013-04-10 13:39:2441namespace keyboard {
42class KeyboardController;
43}
44
[email protected]3537d472014-01-15 05:45:3145namespace ui {
46class EventHandler;
47}
48
[email protected]d90b8392012-06-13 09:34:5649namespace ash {
[email protected]478c6c32013-03-09 02:50:5850class ShelfWidget;
[email protected]97decb52013-11-14 02:27:5051class StackingController;
[email protected]a0afeb12012-12-10 22:57:0952class SystemTray;
[email protected]e74aaf0a2012-10-12 18:42:2853
[email protected]d90b8392012-06-13 09:34:5654namespace internal {
55
[email protected]80549c152013-07-02 01:42:4756class AlwaysOnTopController;
[email protected]0bf61732013-07-02 04:35:1057class AnimatingDesktopController;
[email protected]0bf61732013-07-02 04:35:1058class DesktopBackgroundWidgetController;
[email protected]beb4e5c2013-06-18 15:37:0759class DockedWindowLayoutManager;
[email protected]e74aaf0a2012-10-12 18:42:2860class PanelLayoutManager;
[email protected]d90b8392012-06-13 09:34:5661class RootWindowLayoutManager;
62class ScreenDimmer;
[email protected]e74aaf0a2012-10-12 18:42:2863class ShelfLayoutManager;
64class StatusAreaWidget;
65class SystemBackgroundController;
[email protected]c0ce80e2012-10-05 23:28:2766class SystemModalContainerLayoutManager;
[email protected]2b8a9bb2013-07-01 22:43:4067class TouchHudDebug;
68class TouchHudProjection;
[email protected]d90b8392012-06-13 09:34:5669class WorkspaceController;
70
[email protected]438cbdf02013-10-07 23:41:0971#if defined(OS_CHROMEOS)
[email protected]252eb232013-08-14 22:09:2772class BootSplashScreen;
73#endif
74
[email protected]d90b8392012-06-13 09:34:5675// This class maintains the per root window state for ash. This class
76// owns the root window and other dependent objects that should be
[email protected]a273d33a2013-10-17 12:41:2177// deleted upon the deletion of the root window. This object is
78// indirectly owned and deleted by |DisplayController|.
79// The RootWindowController for particular root window is stored in
80// its property (RootWindowSettings) and can be obtained using
[email protected]056ce052014-02-21 05:19:3281// |GetRootWindowController(aura::WindowEventDispatcher*)| function.
[email protected]d141b922013-07-09 08:13:1782class ASH_EXPORT RootWindowController : public ShellObserver {
[email protected]d90b8392012-06-13 09:34:5683 public:
[email protected]a273d33a2013-10-17 12:41:2184
85 // Creates and Initialize the RootWindowController for primary display.
[email protected]056ce052014-02-21 05:19:3286 static void CreateForPrimaryDisplay(aura::WindowEventDispatcher* dispatcher);
[email protected]a273d33a2013-10-17 12:41:2187
88 // Creates and Initialize the RootWindowController for secondary displays.
[email protected]056ce052014-02-21 05:19:3289 static void CreateForSecondaryDisplay(
90 aura::WindowEventDispatcher* dispatcher);
[email protected]d90b8392012-06-13 09:34:5691
[email protected]608de6c2013-10-29 00:14:2892 // Creates and Initialize the RootWindowController for virtual
93 // keyboard displays.
[email protected]056ce052014-02-21 05:19:3294 static void CreateForVirtualKeyboardDisplay(
95 aura::WindowEventDispatcher* dispatcher);
[email protected]608de6c2013-10-29 00:14:2896
[email protected]864b58552013-12-19 04:19:3897 // Returns a RootWindowController that has a shelf for given
[email protected]88d71122012-10-18 07:11:0198 // |window|. This returns the RootWindowController for the |window|'s
[email protected]864b58552013-12-19 04:19:3899 // root window when multiple shelf mode is enabled, or the primary
[email protected]88d71122012-10-18 07:11:01100 // RootWindowController otherwise.
[email protected]864b58552013-12-19 04:19:38101 static RootWindowController* ForShelf(aura::Window* window);
[email protected]88d71122012-10-18 07:11:01102
[email protected]a0afeb12012-12-10 22:57:09103 // Returns a RootWindowController of the window's root window.
[email protected]ccff3d72013-02-06 04:26:28104 static RootWindowController* ForWindow(const aura::Window* window);
[email protected]a0afeb12012-12-10 22:57:09105
[email protected]d17642d2013-09-12 23:44:38106 // Returns the RootWindowController of the target root window.
107 static internal::RootWindowController* ForTargetRootWindow();
[email protected]a0afeb12012-12-10 22:57:09108
[email protected]a5c78802013-12-12 22:07:01109 // Returns container which contains a given |window|.
110 static aura::Window* GetContainerForWindow(aura::Window* window);
111
[email protected]a273d33a2013-10-17 12:41:21112 virtual ~RootWindowController();
113
[email protected]41baaed2013-11-09 04:18:26114 aura::Window* root_window() { return dispatcher()->window(); }
[email protected]056ce052014-02-21 05:19:32115 aura::WindowEventDispatcher* dispatcher() { return dispatcher_.get(); }
[email protected]d90b8392012-06-13 09:34:56116
[email protected]e74aaf0a2012-10-12 18:42:28117 RootWindowLayoutManager* root_window_layout() { return root_window_layout_; }
[email protected]d90b8392012-06-13 09:34:56118
[email protected]c0ce80e2012-10-05 23:28:27119 WorkspaceController* workspace_controller() {
[email protected]d90b8392012-06-13 09:34:56120 return workspace_controller_.get();
121 }
122
[email protected]80549c152013-07-02 01:42:47123 AlwaysOnTopController* always_on_top_controller() {
124 return always_on_top_controller_.get();
125 }
126
[email protected]e74aaf0a2012-10-12 18:42:28127 ScreenDimmer* screen_dimmer() { return screen_dimmer_.get(); }
128
[email protected]478c6c32013-03-09 02:50:58129 // Access the shelf associated with this root window controller,
130 // NULL if no such shelf exists.
131 ShelfWidget* shelf() { return shelf_.get(); }
[email protected]e74aaf0a2012-10-12 18:42:28132
[email protected]2b8a9bb2013-07-01 22:43:40133 // Get touch HUDs associated with this root window controller.
134 TouchHudDebug* touch_hud_debug() const {
135 return touch_hud_debug_;
[email protected]bff17552013-04-25 04:44:55136 }
[email protected]2b8a9bb2013-07-01 22:43:40137 TouchHudProjection* touch_hud_projection() const {
138 return touch_hud_projection_;
139 }
140
141 // Set touch HUDs for this root window controller. The root window controller
142 // will not own the HUDs; their lifetimes are managed by themselves. Whenever
143 // the widget showing a HUD is being destroyed (e.g. because of detaching a
144 // display), the HUD deletes itself.
145 void set_touch_hud_debug(TouchHudDebug* hud) {
146 touch_hud_debug_ = hud;
147 }
148 void set_touch_hud_projection(TouchHudProjection* hud) {
149 touch_hud_projection_ = hud;
150 }
151
[email protected]0bf61732013-07-02 04:35:10152 DesktopBackgroundWidgetController* wallpaper_controller() {
153 return wallpaper_controller_.get();
154 }
155 void SetWallpaperController(DesktopBackgroundWidgetController* controller);
156 AnimatingDesktopController* animating_wallpaper_controller() {
157 return animating_wallpaper_controller_.get();
158 }
159 void SetAnimatingWallpaperController(AnimatingDesktopController* controller);
160
[email protected]478c6c32013-03-09 02:50:58161 // Access the shelf layout manager associated with this root
162 // window controller, NULL if no such shelf exists.
163 ShelfLayoutManager* GetShelfLayoutManager();
[email protected]d90b8392012-06-13 09:34:56164
[email protected]a0afeb12012-12-10 22:57:09165 // Returns the system tray on this root window. Note that
[email protected]864b58552013-12-19 04:19:38166 // calling this on the root window that doesn't have a shelf will
[email protected]a0afeb12012-12-10 22:57:09167 // lead to a crash.
168 SystemTray* GetSystemTray();
169
[email protected]431552c2012-10-23 00:38:33170 // Shows context menu at the |location_in_screen|. This uses
171 // |ShellDelegate::CreateContextMenu| to define the content of the menu.
[email protected]940fb1c2013-06-18 16:54:28172 void ShowContextMenu(const gfx::Point& location_in_screen,
173 ui::MenuSourceType source_type);
[email protected]431552c2012-10-23 00:38:33174
[email protected]8674b312012-10-12 19:02:44175 // Returns the layout-manager for the appropriate modal-container. If the
176 // window is inside the lockscreen modal container, then the layout manager
177 // for that is returned. Otherwise the layout manager for the default modal
178 // container is returned.
179 // If no window is specified (i.e. |window| is NULL), then the lockscreen
180 // modal container is used if the screen is currently locked. Otherwise, the
181 // default modal container is used.
182 SystemModalContainerLayoutManager* GetSystemModalLayoutManager(
183 aura::Window* window);
[email protected]c0ce80e2012-10-05 23:28:27184
[email protected]d90b8392012-06-13 09:34:56185 aura::Window* GetContainer(int container_id);
[email protected]d8a24952013-08-05 20:05:05186 const aura::Window* GetContainer(int container_id) const;
[email protected]d90b8392012-06-13 09:34:56187
[email protected]864b58552013-12-19 04:19:38188 // Show shelf view if it was created hidden (before session has started).
189 void ShowShelf();
[email protected]e74aaf0a2012-10-12 18:42:28190
[email protected]864b58552013-12-19 04:19:38191 // Called when the shelf associated with this root window is created.
192 void OnShelfCreated();
[email protected]478c6c32013-03-09 02:50:58193
[email protected]16059276d2012-10-22 18:59:50194 // Called when the login status changes after login (such as lock/unlock).
195 // TODO(oshima): Investigate if we can merge this and |OnLoginStateChanged|.
196 void UpdateAfterLoginStatusChange(user::LoginStatus status);
197
[email protected]bca9a7e2012-11-10 06:25:49198 // Called when the brightness/grayscale animation from white to the login
199 // desktop background image has started. Starts |boot_splash_screen_|'s
200 // hiding animation (if the screen is non-NULL).
201 void HandleInitialDesktopBackgroundAnimationStarted();
202
[email protected]0bf61732013-07-02 04:35:10203 // Called when the wallpaper ainmation is finished. Updates |background_|
204 // to be black and drops |boot_splash_screen_| and moves the wallpaper
205 // controller into the root window controller. |widget| holds the wallpaper
206 // image, or NULL if the background is a solid color.
207 void OnWallpaperAnimationFinished(views::Widget* widget);
[email protected]d90b8392012-06-13 09:34:56208
[email protected]6675e1c2012-09-11 09:15:45209 // Deletes associated objects and clears the state, but doesn't delete
210 // the root window yet. This is used to delete a secondary displays'
211 // root window safely when the display disconnect signal is received,
212 // which may come while we're in the nested message loop.
213 void Shutdown();
214
[email protected]d90b8392012-06-13 09:34:56215 // Deletes all child windows and performs necessary cleanup.
216 void CloseChildWindows();
217
[email protected]f1853122012-06-27 16:21:26218 // Moves child windows to |dest|.
[email protected]bf9cdb362013-10-25 19:22:45219 void MoveWindowsTo(aura::Window* dest);
[email protected]f1853122012-06-27 16:21:26220
[email protected]e74aaf0a2012-10-12 18:42:28221 // Force the shelf to query for it's current visibility state.
222 void UpdateShelfVisibility();
223
[email protected]2b8a9bb2013-07-01 22:43:40224 // Initialize touch HUDs if necessary.
225 void InitTouchHuds();
226
[email protected]2c9171d22013-12-10 21:55:10227 // Returns the topmost window or one of its transient parents, if any of them
228 // are in fullscreen mode.
229 const aura::Window* GetWindowForFullscreenMode() const;
[email protected]2ee2f5d2013-01-10 23:37:16230
[email protected]b6ba05d902013-10-04 21:38:45231 // Activate virtual keyboard on current root window controller.
232 void ActivateKeyboard(keyboard::KeyboardController* keyboard_controller);
233
234 // Deactivate virtual keyboard on current root window controller.
235 void DeactivateKeyboard(keyboard::KeyboardController* keyboard_controller);
236
[email protected]431552c2012-10-23 00:38:33237 private:
[email protected]056ce052014-02-21 05:19:32238 explicit RootWindowController(aura::WindowEventDispatcher* dispatcher);
[email protected]608de6c2013-10-29 00:14:28239 enum RootWindowType {
240 PRIMARY,
241 SECONDARY,
242 VIRTUAL_KEYBOARD
243 };
[email protected]a273d33a2013-10-17 12:41:21244
245 // Initializes the RootWindowController. |is_primary| is true if
246 // the controller is for primary display. |first_run_after_boot| is
247 // set to true only for primary root window after boot.
[email protected]608de6c2013-10-29 00:14:28248 void Init(RootWindowType root_window_type, bool first_run_after_boot);
[email protected]a273d33a2013-10-17 12:41:21249
[email protected]756bda12013-07-03 08:17:06250 void InitLayoutManagers();
251
252 // Initializes |system_background_| and possibly also |boot_splash_screen_|.
253 // |is_first_run_after_boot| determines the background's initial color.
254 void CreateSystemBackground(bool is_first_run_after_boot);
255
[email protected]a4cd6d32012-09-12 03:42:13256 // Creates each of the special window containers that holds windows of various
257 // types in the shell UI.
[email protected]41baaed2013-11-09 04:18:26258 void CreateContainersInRootWindow(aura::Window* root_window);
[email protected]a4cd6d32012-09-12 03:42:13259
[email protected]d141b922013-07-09 08:13:17260 // Enables projection touch HUD.
261 void EnableTouchHudProjection();
262
263 // Disables projection touch HUD.
264 void DisableTouchHudProjection();
265
266 // Overridden from ShellObserver.
267 virtual void OnLoginStateChanged(user::LoginStatus status) OVERRIDE;
268 virtual void OnTouchHudProjectionToggled(bool enabled) OVERRIDE;
269
[email protected]056ce052014-02-21 05:19:32270 scoped_ptr<aura::WindowEventDispatcher> dispatcher_;
[email protected]c0ce80e2012-10-05 23:28:27271 RootWindowLayoutManager* root_window_layout_;
[email protected]d90b8392012-06-13 09:34:56272
[email protected]2a2caa02013-01-22 20:50:36273 scoped_ptr<StackingController> stacking_controller_;
274
[email protected]864b58552013-12-19 04:19:38275 // The shelf for managing the shelf and the status widget.
[email protected]478c6c32013-03-09 02:50:58276 scoped_ptr<ShelfWidget> shelf_;
[email protected]e74aaf0a2012-10-12 18:42:28277
[email protected]cf6fea22013-08-07 14:24:01278 // An invisible/empty window used as a event target for
279 // |MouseCursorEventFilter| before a user logs in.
280 // (crbug.com/266987)
281 // Its container is |LockScreenBackgroundContainer| and
282 // this must be deleted before the container is deleted.
283 scoped_ptr<aura::Window> mouse_event_target_;
284
[email protected]beb4e5c2013-06-18 15:37:07285 // Manages layout of docked windows. Owned by DockedContainer.
286 DockedWindowLayoutManager* docked_layout_manager_;
287
[email protected]e74aaf0a2012-10-12 18:42:28288 // Manages layout of panels. Owned by PanelContainer.
[email protected]88d71122012-10-18 07:11:01289 PanelLayoutManager* panel_layout_manager_;
[email protected]e74aaf0a2012-10-12 18:42:28290
[email protected]e6e41d2f2012-10-29 19:22:19291 scoped_ptr<SystemBackgroundController> system_background_;
[email protected]438cbdf02013-10-07 23:41:09292#if defined(OS_CHROMEOS)
[email protected]bca9a7e2012-11-10 06:25:49293 scoped_ptr<BootSplashScreen> boot_splash_screen_;
[email protected]252eb232013-08-14 22:09:27294#endif
[email protected]697f04c2012-10-03 01:15:10295
[email protected]c0ce80e2012-10-05 23:28:27296 scoped_ptr<ScreenDimmer> screen_dimmer_;
297 scoped_ptr<WorkspaceController> workspace_controller_;
[email protected]80549c152013-07-02 01:42:47298 scoped_ptr<AlwaysOnTopController> always_on_top_controller_;
[email protected]d90b8392012-06-13 09:34:56299
[email protected]2b8a9bb2013-07-01 22:43:40300 // Heads-up displays for touch events. These HUDs are not owned by the root
301 // window controller and manage their own lifetimes.
302 TouchHudDebug* touch_hud_debug_;
303 TouchHudProjection* touch_hud_projection_;
[email protected]58175042013-04-01 19:27:13304
[email protected]3537d472014-01-15 05:45:31305 // Handles double clicks on the panel window header.
306 scoped_ptr<ui::EventHandler> panel_container_handler_;
[email protected]a4cd6d32012-09-12 03:42:13307
[email protected]0bf61732013-07-02 04:35:10308 scoped_ptr<DesktopBackgroundWidgetController> wallpaper_controller_;
309 scoped_ptr<AnimatingDesktopController> animating_wallpaper_controller_;
[email protected]23a2dc82013-08-22 15:04:22310 scoped_ptr<views::corewm::ScopedCaptureClient> capture_client_;
[email protected]0bf61732013-07-02 04:35:10311
[email protected]d90b8392012-06-13 09:34:56312 DISALLOW_COPY_AND_ASSIGN(RootWindowController);
313};
314
[email protected]6b2d4a0b2013-09-06 06:29:54315
316// Gets the RootWindowController for |root_window|.
317ASH_EXPORT RootWindowController* GetRootWindowController(
[email protected]bf9cdb362013-10-25 19:22:45318 const aura::Window* root_window);
[email protected]6b2d4a0b2013-09-06 06:29:54319
[email protected]d90b8392012-06-13 09:34:56320} // namespace internal
321} // ash
322
323#endif // ASH_ROOT_WINDOW_CONTROLLER_H_