blob: 980bf1e618c5160c9f7a48b22cd4f2b7cd93ddce [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]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
30namespace views {
[email protected]0bf61732013-07-02 04:35:1031class Widget;
32
[email protected]4a59e4e2012-11-12 21:15:4033namespace corewm {
[email protected]d90b8392012-06-13 09:34:5634class InputMethodEventFilter;
35class RootWindowEventFilter;
[email protected]23a2dc8d2013-08-22 15:04:2236class ScopedCaptureClient;
[email protected]4a59e4e2012-11-12 21:15:4037}
38}
[email protected]d90b8392012-06-13 09:34:5639
[email protected]86459e2c2013-04-10 13:39:2440namespace keyboard {
41class KeyboardController;
42}
43
[email protected]d90b8392012-06-13 09:34:5644namespace ash {
[email protected]2a2caa02013-01-22 20:50:3645class StackingController;
[email protected]478c6c32013-03-09 02:50:5846class ShelfWidget;
[email protected]a0afeb12012-12-10 22:57:0947class SystemTray;
[email protected]a4cd6d32012-09-12 03:42:1348class ToplevelWindowEventHandler;
[email protected]e74aaf0a2012-10-12 18:42:2849
[email protected]d90b8392012-06-13 09:34:5650namespace internal {
51
[email protected]80549c152013-07-02 01:42:4752class AlwaysOnTopController;
[email protected]0bf61732013-07-02 04:35:1053class AnimatingDesktopController;
[email protected]0bf61732013-07-02 04:35:1054class DesktopBackgroundWidgetController;
[email protected]beb4e5c2013-06-18 15:37:0755class DockedWindowLayoutManager;
[email protected]e74aaf0a2012-10-12 18:42:2856class PanelLayoutManager;
[email protected]d90b8392012-06-13 09:34:5657class RootWindowLayoutManager;
58class ScreenDimmer;
[email protected]e74aaf0a2012-10-12 18:42:2859class ShelfLayoutManager;
60class StatusAreaWidget;
61class SystemBackgroundController;
[email protected]c0ce80e2012-10-05 23:28:2762class SystemModalContainerLayoutManager;
[email protected]2b8a9bb2013-07-01 22:43:4063class TouchHudDebug;
64class TouchHudProjection;
[email protected]d90b8392012-06-13 09:34:5665class WorkspaceController;
66
[email protected]438cbdf02013-10-07 23:41:0967#if defined(OS_CHROMEOS)
[email protected]252eb232013-08-14 22:09:2768class BootSplashScreen;
69#endif
70
[email protected]d90b8392012-06-13 09:34:5671// This class maintains the per root window state for ash. This class
72// owns the root window and other dependent objects that should be
[email protected]a273d33a2013-10-17 12:41:2173// deleted upon the deletion of the root window. This object is
74// indirectly owned and deleted by |DisplayController|.
75// The RootWindowController for particular root window is stored in
76// its property (RootWindowSettings) and can be obtained using
77// |GetRootWindowController(aura::RootWindow*)| function.
[email protected]d141b922013-07-09 08:13:1778class ASH_EXPORT RootWindowController : public ShellObserver {
[email protected]d90b8392012-06-13 09:34:5679 public:
[email protected]a273d33a2013-10-17 12:41:2180
81 // Creates and Initialize the RootWindowController for primary display.
82 static void CreateForPrimaryDisplay(aura::RootWindow* root_window);
83
84 // Creates and Initialize the RootWindowController for secondary displays.
85 static void CreateForSecondaryDisplay(aura::RootWindow* root_window);
[email protected]d90b8392012-06-13 09:34:5686
[email protected]608de6c2013-10-29 00:14:2887 // Creates and Initialize the RootWindowController for virtual
88 // keyboard displays.
89 static void CreateForVirtualKeyboardDisplay(aura::RootWindow* root_window);
90
[email protected]88d71122012-10-18 07:11:0191 // Returns a RootWindowController that has a launcher for given
92 // |window|. This returns the RootWindowController for the |window|'s
93 // root window when multiple launcher mode is enabled, or the primary
94 // RootWindowController otherwise.
95 static RootWindowController* ForLauncher(aura::Window* window);
96
[email protected]a0afeb12012-12-10 22:57:0997 // Returns a RootWindowController of the window's root window.
[email protected]ccff3d72013-02-06 04:26:2898 static RootWindowController* ForWindow(const aura::Window* window);
[email protected]a0afeb12012-12-10 22:57:0999
[email protected]d17642d2013-09-12 23:44:38100 // Returns the RootWindowController of the target root window.
101 static internal::RootWindowController* ForTargetRootWindow();
[email protected]a0afeb12012-12-10 22:57:09102
[email protected]a273d33a2013-10-17 12:41:21103 virtual ~RootWindowController();
104
[email protected]41baaed2013-11-09 04:18:26105 aura::Window* root_window() { return dispatcher()->window(); }
106 aura::WindowEventDispatcher* dispatcher() { return root_window_.get(); }
[email protected]d90b8392012-06-13 09:34:56107
[email protected]e74aaf0a2012-10-12 18:42:28108 RootWindowLayoutManager* root_window_layout() { return root_window_layout_; }
[email protected]d90b8392012-06-13 09:34:56109
[email protected]c0ce80e2012-10-05 23:28:27110 WorkspaceController* workspace_controller() {
[email protected]d90b8392012-06-13 09:34:56111 return workspace_controller_.get();
112 }
113
[email protected]80549c152013-07-02 01:42:47114 AlwaysOnTopController* always_on_top_controller() {
115 return always_on_top_controller_.get();
116 }
117
[email protected]e74aaf0a2012-10-12 18:42:28118 ScreenDimmer* screen_dimmer() { return screen_dimmer_.get(); }
119
[email protected]478c6c32013-03-09 02:50:58120 // Access the shelf associated with this root window controller,
121 // NULL if no such shelf exists.
122 ShelfWidget* shelf() { return shelf_.get(); }
[email protected]e74aaf0a2012-10-12 18:42:28123
[email protected]2b8a9bb2013-07-01 22:43:40124 // Get touch HUDs associated with this root window controller.
125 TouchHudDebug* touch_hud_debug() const {
126 return touch_hud_debug_;
[email protected]bff17552013-04-25 04:44:55127 }
[email protected]2b8a9bb2013-07-01 22:43:40128 TouchHudProjection* touch_hud_projection() const {
129 return touch_hud_projection_;
130 }
131
132 // Set touch HUDs for this root window controller. The root window controller
133 // will not own the HUDs; their lifetimes are managed by themselves. Whenever
134 // the widget showing a HUD is being destroyed (e.g. because of detaching a
135 // display), the HUD deletes itself.
136 void set_touch_hud_debug(TouchHudDebug* hud) {
137 touch_hud_debug_ = hud;
138 }
139 void set_touch_hud_projection(TouchHudProjection* hud) {
140 touch_hud_projection_ = hud;
141 }
142
[email protected]0bf61732013-07-02 04:35:10143 DesktopBackgroundWidgetController* wallpaper_controller() {
144 return wallpaper_controller_.get();
145 }
146 void SetWallpaperController(DesktopBackgroundWidgetController* controller);
147 AnimatingDesktopController* animating_wallpaper_controller() {
148 return animating_wallpaper_controller_.get();
149 }
150 void SetAnimatingWallpaperController(AnimatingDesktopController* controller);
151
[email protected]478c6c32013-03-09 02:50:58152 // Access the shelf layout manager associated with this root
153 // window controller, NULL if no such shelf exists.
154 ShelfLayoutManager* GetShelfLayoutManager();
[email protected]d90b8392012-06-13 09:34:56155
[email protected]a0afeb12012-12-10 22:57:09156 // Returns the system tray on this root window. Note that
157 // calling this on the root window that doesn't have a launcher will
158 // lead to a crash.
159 SystemTray* GetSystemTray();
160
[email protected]431552c2012-10-23 00:38:33161 // Shows context menu at the |location_in_screen|. This uses
162 // |ShellDelegate::CreateContextMenu| to define the content of the menu.
[email protected]940fb1c2013-06-18 16:54:28163 void ShowContextMenu(const gfx::Point& location_in_screen,
164 ui::MenuSourceType source_type);
[email protected]431552c2012-10-23 00:38:33165
[email protected]8674b312012-10-12 19:02:44166 // Returns the layout-manager for the appropriate modal-container. If the
167 // window is inside the lockscreen modal container, then the layout manager
168 // for that is returned. Otherwise the layout manager for the default modal
169 // container is returned.
170 // If no window is specified (i.e. |window| is NULL), then the lockscreen
171 // modal container is used if the screen is currently locked. Otherwise, the
172 // default modal container is used.
173 SystemModalContainerLayoutManager* GetSystemModalLayoutManager(
174 aura::Window* window);
[email protected]c0ce80e2012-10-05 23:28:27175
[email protected]d90b8392012-06-13 09:34:56176 aura::Window* GetContainer(int container_id);
[email protected]d8a24952013-08-05 20:05:05177 const aura::Window* GetContainer(int container_id) const;
[email protected]d90b8392012-06-13 09:34:56178
[email protected]e74aaf0a2012-10-12 18:42:28179 // Show launcher view if it was created hidden (before session has started).
180 void ShowLauncher();
181
[email protected]478c6c32013-03-09 02:50:58182 // Called when the launcher associated with this root window is created.
183 void OnLauncherCreated();
184
[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|.
187 void UpdateAfterLoginStatusChange(user::LoginStatus status);
188
[email protected]bca9a7e2012-11-10 06:25:49189 // Called when the brightness/grayscale animation from white to the login
190 // desktop background image has started. Starts |boot_splash_screen_|'s
191 // hiding animation (if the screen is non-NULL).
192 void HandleInitialDesktopBackgroundAnimationStarted();
193
[email protected]0bf61732013-07-02 04:35:10194 // Called when the wallpaper ainmation is finished. Updates |background_|
195 // to be black and drops |boot_splash_screen_| and moves the wallpaper
196 // controller into the root window controller. |widget| holds the wallpaper
197 // image, or NULL if the background is a solid color.
198 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]e3bc88e2013-09-06 06:22:06218 // Returns the window, if any, which is in fullscreen mode. If multiple
219 // windows are in fullscreen state, the topmost one is preferred.
220 const aura::Window* GetTopmostFullscreenWindow() const;
[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]431552c2012-10-23 00:38:33228 private:
[email protected]a273d33a2013-10-17 12:41:21229 explicit RootWindowController(aura::RootWindow* root_window);
[email protected]608de6c2013-10-29 00:14:28230 enum RootWindowType {
231 PRIMARY,
232 SECONDARY,
233 VIRTUAL_KEYBOARD
234 };
[email protected]a273d33a2013-10-17 12:41:21235
236 // Initializes the RootWindowController. |is_primary| is true if
237 // the controller is for primary display. |first_run_after_boot| is
238 // set to true only for primary root window after boot.
[email protected]608de6c2013-10-29 00:14:28239 void Init(RootWindowType root_window_type, bool first_run_after_boot);
[email protected]a273d33a2013-10-17 12:41:21240
[email protected]756bda12013-07-03 08:17:06241 void InitLayoutManagers();
242
243 // Initializes |system_background_| and possibly also |boot_splash_screen_|.
244 // |is_first_run_after_boot| determines the background's initial color.
245 void CreateSystemBackground(bool is_first_run_after_boot);
246
[email protected]a4cd6d32012-09-12 03:42:13247 // Creates each of the special window containers that holds windows of various
248 // types in the shell UI.
[email protected]41baaed2013-11-09 04:18:26249 void CreateContainersInRootWindow(aura::Window* root_window);
[email protected]a4cd6d32012-09-12 03:42:13250
[email protected]d141b922013-07-09 08:13:17251 // Enables projection touch HUD.
252 void EnableTouchHudProjection();
253
254 // Disables projection touch HUD.
255 void DisableTouchHudProjection();
256
257 // Overridden from ShellObserver.
258 virtual void OnLoginStateChanged(user::LoginStatus status) OVERRIDE;
259 virtual void OnTouchHudProjectionToggled(bool enabled) OVERRIDE;
260
[email protected]d90b8392012-06-13 09:34:56261 scoped_ptr<aura::RootWindow> root_window_;
[email protected]c0ce80e2012-10-05 23:28:27262 RootWindowLayoutManager* root_window_layout_;
[email protected]d90b8392012-06-13 09:34:56263
[email protected]2a2caa02013-01-22 20:50:36264 scoped_ptr<StackingController> stacking_controller_;
265
[email protected]e74aaf0a2012-10-12 18:42:28266 // The shelf for managing the launcher and the status widget.
[email protected]478c6c32013-03-09 02:50:58267 scoped_ptr<ShelfWidget> shelf_;
[email protected]e74aaf0a2012-10-12 18:42:28268
[email protected]cf6fea22013-08-07 14:24:01269 // An invisible/empty window used as a event target for
270 // |MouseCursorEventFilter| before a user logs in.
271 // (crbug.com/266987)
272 // Its container is |LockScreenBackgroundContainer| and
273 // this must be deleted before the container is deleted.
274 scoped_ptr<aura::Window> mouse_event_target_;
275
[email protected]beb4e5c2013-06-18 15:37:07276 // Manages layout of docked windows. Owned by DockedContainer.
277 DockedWindowLayoutManager* docked_layout_manager_;
278
[email protected]e74aaf0a2012-10-12 18:42:28279 // Manages layout of panels. Owned by PanelContainer.
[email protected]88d71122012-10-18 07:11:01280 PanelLayoutManager* panel_layout_manager_;
[email protected]e74aaf0a2012-10-12 18:42:28281
[email protected]e6e41d2f2012-10-29 19:22:19282 scoped_ptr<SystemBackgroundController> system_background_;
[email protected]438cbdf02013-10-07 23:41:09283#if defined(OS_CHROMEOS)
[email protected]bca9a7e2012-11-10 06:25:49284 scoped_ptr<BootSplashScreen> boot_splash_screen_;
[email protected]252eb232013-08-14 22:09:27285#endif
[email protected]697f04c2012-10-03 01:15:10286
[email protected]c0ce80e2012-10-05 23:28:27287 scoped_ptr<ScreenDimmer> screen_dimmer_;
288 scoped_ptr<WorkspaceController> workspace_controller_;
[email protected]80549c152013-07-02 01:42:47289 scoped_ptr<AlwaysOnTopController> always_on_top_controller_;
[email protected]d90b8392012-06-13 09:34:56290
[email protected]2b8a9bb2013-07-01 22:43:40291 // Heads-up displays for touch events. These HUDs are not owned by the root
292 // window controller and manage their own lifetimes.
293 TouchHudDebug* touch_hud_debug_;
294 TouchHudProjection* touch_hud_projection_;
[email protected]58175042013-04-01 19:27:13295
[email protected]a4cd6d32012-09-12 03:42:13296 // We need to own event handlers for various containers.
297 scoped_ptr<ToplevelWindowEventHandler> default_container_handler_;
298 scoped_ptr<ToplevelWindowEventHandler> always_on_top_container_handler_;
299 scoped_ptr<ToplevelWindowEventHandler> modal_container_handler_;
300 scoped_ptr<ToplevelWindowEventHandler> lock_modal_container_handler_;
[email protected]582022052013-02-20 15:19:04301 scoped_ptr<ToplevelWindowEventHandler> panel_container_handler_;
[email protected]beb4e5c2013-06-18 15:37:07302 scoped_ptr<ToplevelWindowEventHandler> docked_container_handler_;
[email protected]a4cd6d32012-09-12 03:42:13303
[email protected]0bf61732013-07-02 04:35:10304 scoped_ptr<DesktopBackgroundWidgetController> wallpaper_controller_;
305 scoped_ptr<AnimatingDesktopController> animating_wallpaper_controller_;
[email protected]23a2dc8d2013-08-22 15:04:22306 scoped_ptr<views::corewm::ScopedCaptureClient> capture_client_;
[email protected]0bf61732013-07-02 04:35:10307
[email protected]d90b8392012-06-13 09:34:56308 DISALLOW_COPY_AND_ASSIGN(RootWindowController);
309};
310
[email protected]6b2d4a0b2013-09-06 06:29:54311
312// Gets the RootWindowController for |root_window|.
313ASH_EXPORT RootWindowController* GetRootWindowController(
[email protected]bf9cdb362013-10-25 19:22:45314 const aura::Window* root_window);
[email protected]6b2d4a0b2013-09-06 06:29:54315
[email protected]d90b8392012-06-13 09:34:56316} // namespace internal
317} // ash
318
319#endif // ASH_ROOT_WINDOW_CONTROLLER_H_