blob: 0ccc1d32e579d805e01acc9693bd252f3b5eb2d6 [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]23a2dc8d2013-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]d90b8392012-06-13 09:34:5645namespace ash {
[email protected]2a2caa02013-01-22 20:50:3646class StackingController;
[email protected]478c6c32013-03-09 02:50:5847class ShelfWidget;
[email protected]a0afeb12012-12-10 22:57:0948class SystemTray;
[email protected]a4cd6d32012-09-12 03:42:1349class ToplevelWindowEventHandler;
[email protected]e74aaf0a2012-10-12 18:42:2850
[email protected]d90b8392012-06-13 09:34:5651namespace internal {
52
[email protected]80549c152013-07-02 01:42:4753class AlwaysOnTopController;
[email protected]0bf61732013-07-02 04:35:1054class AnimatingDesktopController;
[email protected]0bf61732013-07-02 04:35:1055class DesktopBackgroundWidgetController;
[email protected]beb4e5c2013-06-18 15:37:0756class DockedWindowLayoutManager;
[email protected]e74aaf0a2012-10-12 18:42:2857class PanelLayoutManager;
[email protected]d90b8392012-06-13 09:34:5658class RootWindowLayoutManager;
59class ScreenDimmer;
[email protected]e74aaf0a2012-10-12 18:42:2860class ShelfLayoutManager;
61class StatusAreaWidget;
62class SystemBackgroundController;
[email protected]c0ce80e2012-10-05 23:28:2763class SystemModalContainerLayoutManager;
[email protected]2b8a9bb2013-07-01 22:43:4064class TouchHudDebug;
65class TouchHudProjection;
[email protected]d90b8392012-06-13 09:34:5666class WorkspaceController;
67
[email protected]438cbdf02013-10-07 23:41:0968#if defined(OS_CHROMEOS)
[email protected]252eb232013-08-14 22:09:2769class BootSplashScreen;
70#endif
71
[email protected]d90b8392012-06-13 09:34:5672// This class maintains the per root window state for ash. This class
73// owns the root window and other dependent objects that should be
[email protected]a273d33a2013-10-17 12:41:2174// deleted upon the deletion of the root window. This object is
75// indirectly owned and deleted by |DisplayController|.
76// The RootWindowController for particular root window is stored in
77// its property (RootWindowSettings) and can be obtained using
78// |GetRootWindowController(aura::RootWindow*)| function.
[email protected]d141b922013-07-09 08:13:1779class ASH_EXPORT RootWindowController : public ShellObserver {
[email protected]d90b8392012-06-13 09:34:5680 public:
[email protected]a273d33a2013-10-17 12:41:2181
82 // Creates and Initialize the RootWindowController for primary display.
83 static void CreateForPrimaryDisplay(aura::RootWindow* root_window);
84
85 // Creates and Initialize the RootWindowController for secondary displays.
86 static void CreateForSecondaryDisplay(aura::RootWindow* root_window);
[email protected]d90b8392012-06-13 09:34:5687
[email protected]608de6c2013-10-29 00:14:2888 // Creates and Initialize the RootWindowController for virtual
89 // keyboard displays.
90 static void CreateForVirtualKeyboardDisplay(aura::RootWindow* root_window);
91
[email protected]88d71122012-10-18 07:11:0192 // Returns a RootWindowController that has a launcher for given
93 // |window|. This returns the RootWindowController for the |window|'s
94 // root window when multiple launcher mode is enabled, or the primary
95 // RootWindowController otherwise.
96 static RootWindowController* ForLauncher(aura::Window* window);
97
[email protected]a0afeb12012-12-10 22:57:0998 // Returns a RootWindowController of the window's root window.
[email protected]ccff3d72013-02-06 04:26:2899 static RootWindowController* ForWindow(const aura::Window* window);
[email protected]a0afeb12012-12-10 22:57:09100
[email protected]d17642d2013-09-12 23:44:38101 // Returns the RootWindowController of the target root window.
102 static internal::RootWindowController* ForTargetRootWindow();
[email protected]a0afeb12012-12-10 22:57:09103
[email protected]a273d33a2013-10-17 12:41:21104 virtual ~RootWindowController();
105
[email protected]41baaed2013-11-09 04:18:26106 aura::Window* root_window() { return dispatcher()->window(); }
107 aura::WindowEventDispatcher* dispatcher() { return root_window_.get(); }
[email protected]d90b8392012-06-13 09:34:56108
[email protected]e74aaf0a2012-10-12 18:42:28109 RootWindowLayoutManager* root_window_layout() { return root_window_layout_; }
[email protected]d90b8392012-06-13 09:34:56110
[email protected]c0ce80e2012-10-05 23:28:27111 WorkspaceController* workspace_controller() {
[email protected]d90b8392012-06-13 09:34:56112 return workspace_controller_.get();
113 }
114
[email protected]80549c152013-07-02 01:42:47115 AlwaysOnTopController* always_on_top_controller() {
116 return always_on_top_controller_.get();
117 }
118
[email protected]e74aaf0a2012-10-12 18:42:28119 ScreenDimmer* screen_dimmer() { return screen_dimmer_.get(); }
120
[email protected]478c6c32013-03-09 02:50:58121 // Access the shelf associated with this root window controller,
122 // NULL if no such shelf exists.
123 ShelfWidget* shelf() { return shelf_.get(); }
[email protected]e74aaf0a2012-10-12 18:42:28124
[email protected]2b8a9bb2013-07-01 22:43:40125 // Get touch HUDs associated with this root window controller.
126 TouchHudDebug* touch_hud_debug() const {
127 return touch_hud_debug_;
[email protected]bff17552013-04-25 04:44:55128 }
[email protected]2b8a9bb2013-07-01 22:43:40129 TouchHudProjection* touch_hud_projection() const {
130 return touch_hud_projection_;
131 }
132
133 // Set touch HUDs for this root window controller. The root window controller
134 // will not own the HUDs; their lifetimes are managed by themselves. Whenever
135 // the widget showing a HUD is being destroyed (e.g. because of detaching a
136 // display), the HUD deletes itself.
137 void set_touch_hud_debug(TouchHudDebug* hud) {
138 touch_hud_debug_ = hud;
139 }
140 void set_touch_hud_projection(TouchHudProjection* hud) {
141 touch_hud_projection_ = hud;
142 }
143
[email protected]0bf61732013-07-02 04:35:10144 DesktopBackgroundWidgetController* wallpaper_controller() {
145 return wallpaper_controller_.get();
146 }
147 void SetWallpaperController(DesktopBackgroundWidgetController* controller);
148 AnimatingDesktopController* animating_wallpaper_controller() {
149 return animating_wallpaper_controller_.get();
150 }
151 void SetAnimatingWallpaperController(AnimatingDesktopController* controller);
152
[email protected]478c6c32013-03-09 02:50:58153 // Access the shelf layout manager associated with this root
154 // window controller, NULL if no such shelf exists.
155 ShelfLayoutManager* GetShelfLayoutManager();
[email protected]d90b8392012-06-13 09:34:56156
[email protected]a0afeb12012-12-10 22:57:09157 // Returns the system tray on this root window. Note that
158 // calling this on the root window that doesn't have a launcher will
159 // lead to a crash.
160 SystemTray* GetSystemTray();
161
[email protected]431552c2012-10-23 00:38:33162 // Shows context menu at the |location_in_screen|. This uses
163 // |ShellDelegate::CreateContextMenu| to define the content of the menu.
[email protected]940fb1c2013-06-18 16:54:28164 void ShowContextMenu(const gfx::Point& location_in_screen,
165 ui::MenuSourceType source_type);
[email protected]431552c2012-10-23 00:38:33166
[email protected]8674b312012-10-12 19:02:44167 // Returns the layout-manager for the appropriate modal-container. If the
168 // window is inside the lockscreen modal container, then the layout manager
169 // for that is returned. Otherwise the layout manager for the default modal
170 // container is returned.
171 // If no window is specified (i.e. |window| is NULL), then the lockscreen
172 // modal container is used if the screen is currently locked. Otherwise, the
173 // default modal container is used.
174 SystemModalContainerLayoutManager* GetSystemModalLayoutManager(
175 aura::Window* window);
[email protected]c0ce80e2012-10-05 23:28:27176
[email protected]d90b8392012-06-13 09:34:56177 aura::Window* GetContainer(int container_id);
[email protected]d8a24952013-08-05 20:05:05178 const aura::Window* GetContainer(int container_id) const;
[email protected]d90b8392012-06-13 09:34:56179
[email protected]e74aaf0a2012-10-12 18:42:28180 // Show launcher view if it was created hidden (before session has started).
181 void ShowLauncher();
182
[email protected]478c6c32013-03-09 02:50:58183 // Called when the launcher associated with this root window is created.
184 void OnLauncherCreated();
185
[email protected]16059276d2012-10-22 18:59:50186 // Called when the login status changes after login (such as lock/unlock).
187 // TODO(oshima): Investigate if we can merge this and |OnLoginStateChanged|.
188 void UpdateAfterLoginStatusChange(user::LoginStatus status);
189
[email protected]bca9a7e2012-11-10 06:25:49190 // Called when the brightness/grayscale animation from white to the login
191 // desktop background image has started. Starts |boot_splash_screen_|'s
192 // hiding animation (if the screen is non-NULL).
193 void HandleInitialDesktopBackgroundAnimationStarted();
194
[email protected]0bf61732013-07-02 04:35:10195 // Called when the wallpaper ainmation is finished. Updates |background_|
196 // to be black and drops |boot_splash_screen_| and moves the wallpaper
197 // controller into the root window controller. |widget| holds the wallpaper
198 // image, or NULL if the background is a solid color.
199 void OnWallpaperAnimationFinished(views::Widget* widget);
[email protected]d90b8392012-06-13 09:34:56200
[email protected]6675e1c2012-09-11 09:15:45201 // Deletes associated objects and clears the state, but doesn't delete
202 // the root window yet. This is used to delete a secondary displays'
203 // root window safely when the display disconnect signal is received,
204 // which may come while we're in the nested message loop.
205 void Shutdown();
206
[email protected]d90b8392012-06-13 09:34:56207 // Deletes all child windows and performs necessary cleanup.
208 void CloseChildWindows();
209
[email protected]f1853122012-06-27 16:21:26210 // Moves child windows to |dest|.
[email protected]bf9cdb362013-10-25 19:22:45211 void MoveWindowsTo(aura::Window* dest);
[email protected]f1853122012-06-27 16:21:26212
[email protected]e74aaf0a2012-10-12 18:42:28213 // Force the shelf to query for it's current visibility state.
214 void UpdateShelfVisibility();
215
[email protected]2b8a9bb2013-07-01 22:43:40216 // Initialize touch HUDs if necessary.
217 void InitTouchHuds();
218
[email protected]e3bc88e2013-09-06 06:22:06219 // Returns the window, if any, which is in fullscreen mode. If multiple
220 // windows are in fullscreen state, the topmost one is preferred.
221 const aura::Window* GetTopmostFullscreenWindow() const;
[email protected]2ee2f5d2013-01-10 23:37:16222
[email protected]b6ba05d902013-10-04 21:38:45223 // Activate virtual keyboard on current root window controller.
224 void ActivateKeyboard(keyboard::KeyboardController* keyboard_controller);
225
226 // Deactivate virtual keyboard on current root window controller.
227 void DeactivateKeyboard(keyboard::KeyboardController* keyboard_controller);
228
[email protected]431552c2012-10-23 00:38:33229 private:
[email protected]a273d33a2013-10-17 12:41:21230 explicit RootWindowController(aura::RootWindow* root_window);
[email protected]608de6c2013-10-29 00:14:28231 enum RootWindowType {
232 PRIMARY,
233 SECONDARY,
234 VIRTUAL_KEYBOARD
235 };
[email protected]a273d33a2013-10-17 12:41:21236
237 // Initializes the RootWindowController. |is_primary| is true if
238 // the controller is for primary display. |first_run_after_boot| is
239 // set to true only for primary root window after boot.
[email protected]608de6c2013-10-29 00:14:28240 void Init(RootWindowType root_window_type, bool first_run_after_boot);
[email protected]a273d33a2013-10-17 12:41:21241
[email protected]756bda12013-07-03 08:17:06242 void InitLayoutManagers();
243
244 // Initializes |system_background_| and possibly also |boot_splash_screen_|.
245 // |is_first_run_after_boot| determines the background's initial color.
246 void CreateSystemBackground(bool is_first_run_after_boot);
247
[email protected]a4cd6d32012-09-12 03:42:13248 // Creates each of the special window containers that holds windows of various
249 // types in the shell UI.
[email protected]41baaed2013-11-09 04:18:26250 void CreateContainersInRootWindow(aura::Window* root_window);
[email protected]a4cd6d32012-09-12 03:42:13251
[email protected]d141b922013-07-09 08:13:17252 // Enables projection touch HUD.
253 void EnableTouchHudProjection();
254
255 // Disables projection touch HUD.
256 void DisableTouchHudProjection();
257
258 // Overridden from ShellObserver.
259 virtual void OnLoginStateChanged(user::LoginStatus status) OVERRIDE;
260 virtual void OnTouchHudProjectionToggled(bool enabled) OVERRIDE;
261
[email protected]d90b8392012-06-13 09:34:56262 scoped_ptr<aura::RootWindow> root_window_;
[email protected]c0ce80e2012-10-05 23:28:27263 RootWindowLayoutManager* root_window_layout_;
[email protected]d90b8392012-06-13 09:34:56264
[email protected]2a2caa02013-01-22 20:50:36265 scoped_ptr<StackingController> stacking_controller_;
266
[email protected]e74aaf0a2012-10-12 18:42:28267 // The shelf for managing the launcher and the status widget.
[email protected]478c6c32013-03-09 02:50:58268 scoped_ptr<ShelfWidget> shelf_;
[email protected]e74aaf0a2012-10-12 18:42:28269
[email protected]cf6fea22013-08-07 14:24:01270 // An invisible/empty window used as a event target for
271 // |MouseCursorEventFilter| before a user logs in.
272 // (crbug.com/266987)
273 // Its container is |LockScreenBackgroundContainer| and
274 // this must be deleted before the container is deleted.
275 scoped_ptr<aura::Window> mouse_event_target_;
276
[email protected]beb4e5c2013-06-18 15:37:07277 // Manages layout of docked windows. Owned by DockedContainer.
278 DockedWindowLayoutManager* docked_layout_manager_;
279
[email protected]e74aaf0a2012-10-12 18:42:28280 // Manages layout of panels. Owned by PanelContainer.
[email protected]88d71122012-10-18 07:11:01281 PanelLayoutManager* panel_layout_manager_;
[email protected]e74aaf0a2012-10-12 18:42:28282
[email protected]e6e41d2f2012-10-29 19:22:19283 scoped_ptr<SystemBackgroundController> system_background_;
[email protected]438cbdf02013-10-07 23:41:09284#if defined(OS_CHROMEOS)
[email protected]bca9a7e2012-11-10 06:25:49285 scoped_ptr<BootSplashScreen> boot_splash_screen_;
[email protected]252eb232013-08-14 22:09:27286#endif
[email protected]697f04c2012-10-03 01:15:10287
[email protected]c0ce80e2012-10-05 23:28:27288 scoped_ptr<ScreenDimmer> screen_dimmer_;
289 scoped_ptr<WorkspaceController> workspace_controller_;
[email protected]80549c152013-07-02 01:42:47290 scoped_ptr<AlwaysOnTopController> always_on_top_controller_;
[email protected]d90b8392012-06-13 09:34:56291
[email protected]2b8a9bb2013-07-01 22:43:40292 // Heads-up displays for touch events. These HUDs are not owned by the root
293 // window controller and manage their own lifetimes.
294 TouchHudDebug* touch_hud_debug_;
295 TouchHudProjection* touch_hud_projection_;
[email protected]58175042013-04-01 19:27:13296
[email protected]a4cd6d32012-09-12 03:42:13297 // We need to own event handlers for various containers.
298 scoped_ptr<ToplevelWindowEventHandler> default_container_handler_;
299 scoped_ptr<ToplevelWindowEventHandler> always_on_top_container_handler_;
300 scoped_ptr<ToplevelWindowEventHandler> modal_container_handler_;
301 scoped_ptr<ToplevelWindowEventHandler> lock_modal_container_handler_;
[email protected]582022052013-02-20 15:19:04302 scoped_ptr<ToplevelWindowEventHandler> panel_container_handler_;
[email protected]beb4e5c2013-06-18 15:37:07303 scoped_ptr<ToplevelWindowEventHandler> docked_container_handler_;
[email protected]a4cd6d32012-09-12 03:42:13304
[email protected]0bf61732013-07-02 04:35:10305 scoped_ptr<DesktopBackgroundWidgetController> wallpaper_controller_;
306 scoped_ptr<AnimatingDesktopController> animating_wallpaper_controller_;
[email protected]23a2dc8d2013-08-22 15:04:22307 scoped_ptr<views::corewm::ScopedCaptureClient> capture_client_;
[email protected]0bf61732013-07-02 04:35:10308
[email protected]d90b8392012-06-13 09:34:56309 DISALLOW_COPY_AND_ASSIGN(RootWindowController);
310};
311
[email protected]6b2d4a0b2013-09-06 06:29:54312
313// Gets the RootWindowController for |root_window|.
314ASH_EXPORT RootWindowController* GetRootWindowController(
[email protected]bf9cdb362013-10-25 19:22:45315 const aura::Window* root_window);
[email protected]6b2d4a0b2013-09-06 06:29:54316
[email protected]d90b8392012-06-13 09:34:56317} // namespace internal
318} // ash
319
320#endif // ASH_ROOT_WINDOW_CONTROLLER_H_