blob: f5a67ee0d9eace7a72253b5423c39fe89d2affcc [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]940fb1c2013-06-18 16:54:2816#include "ui/base/ui_base_types.h"
[email protected]d90b8392012-06-13 09:34:5617
18class SkBitmap;
19
20namespace aura {
21class EventFilter;
22class RootWindow;
23class 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]23a2dc82013-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
73// deleted upon the deletion of the root window. The RootWindowController
74// for particular root window is stored as a property and can be obtained
75// using |GetRootWindowController(aura::RootWindow*)| function.
[email protected]d141b922013-07-09 08:13:1776class ASH_EXPORT RootWindowController : public ShellObserver {
[email protected]d90b8392012-06-13 09:34:5677 public:
78 explicit RootWindowController(aura::RootWindow* root_window);
[email protected]d141b922013-07-09 08:13:1779 virtual ~RootWindowController();
[email protected]d90b8392012-06-13 09:34:5680
[email protected]88d71122012-10-18 07:11:0181 // Returns a RootWindowController that has a launcher for given
82 // |window|. This returns the RootWindowController for the |window|'s
83 // root window when multiple launcher mode is enabled, or the primary
84 // RootWindowController otherwise.
85 static RootWindowController* ForLauncher(aura::Window* window);
86
[email protected]a0afeb12012-12-10 22:57:0987 // Returns a RootWindowController of the window's root window.
[email protected]ccff3d72013-02-06 04:26:2888 static RootWindowController* ForWindow(const aura::Window* window);
[email protected]a0afeb12012-12-10 22:57:0989
[email protected]d17642d2013-09-12 23:44:3890 // Returns the RootWindowController of the target root window.
91 static internal::RootWindowController* ForTargetRootWindow();
[email protected]a0afeb12012-12-10 22:57:0992
[email protected]e74aaf0a2012-10-12 18:42:2893 aura::RootWindow* root_window() { return root_window_.get(); }
[email protected]d90b8392012-06-13 09:34:5694
[email protected]e74aaf0a2012-10-12 18:42:2895 RootWindowLayoutManager* root_window_layout() { return root_window_layout_; }
[email protected]d90b8392012-06-13 09:34:5696
[email protected]c0ce80e2012-10-05 23:28:2797 WorkspaceController* workspace_controller() {
[email protected]d90b8392012-06-13 09:34:5698 return workspace_controller_.get();
99 }
100
[email protected]80549c152013-07-02 01:42:47101 AlwaysOnTopController* always_on_top_controller() {
102 return always_on_top_controller_.get();
103 }
104
[email protected]e74aaf0a2012-10-12 18:42:28105 ScreenDimmer* screen_dimmer() { return screen_dimmer_.get(); }
106
[email protected]478c6c32013-03-09 02:50:58107 // Access the shelf associated with this root window controller,
108 // NULL if no such shelf exists.
109 ShelfWidget* shelf() { return shelf_.get(); }
[email protected]e74aaf0a2012-10-12 18:42:28110
[email protected]2b8a9bb2013-07-01 22:43:40111 // Get touch HUDs associated with this root window controller.
112 TouchHudDebug* touch_hud_debug() const {
113 return touch_hud_debug_;
[email protected]bff17552013-04-25 04:44:55114 }
[email protected]2b8a9bb2013-07-01 22:43:40115 TouchHudProjection* touch_hud_projection() const {
116 return touch_hud_projection_;
117 }
118
119 // Set touch HUDs for this root window controller. The root window controller
120 // will not own the HUDs; their lifetimes are managed by themselves. Whenever
121 // the widget showing a HUD is being destroyed (e.g. because of detaching a
122 // display), the HUD deletes itself.
123 void set_touch_hud_debug(TouchHudDebug* hud) {
124 touch_hud_debug_ = hud;
125 }
126 void set_touch_hud_projection(TouchHudProjection* hud) {
127 touch_hud_projection_ = hud;
128 }
129
[email protected]0bf61732013-07-02 04:35:10130 DesktopBackgroundWidgetController* wallpaper_controller() {
131 return wallpaper_controller_.get();
132 }
133 void SetWallpaperController(DesktopBackgroundWidgetController* controller);
134 AnimatingDesktopController* animating_wallpaper_controller() {
135 return animating_wallpaper_controller_.get();
136 }
137 void SetAnimatingWallpaperController(AnimatingDesktopController* controller);
138
[email protected]478c6c32013-03-09 02:50:58139 // Access the shelf layout manager associated with this root
140 // window controller, NULL if no such shelf exists.
141 ShelfLayoutManager* GetShelfLayoutManager();
[email protected]d90b8392012-06-13 09:34:56142
[email protected]a0afeb12012-12-10 22:57:09143 // Returns the system tray on this root window. Note that
144 // calling this on the root window that doesn't have a launcher will
145 // lead to a crash.
146 SystemTray* GetSystemTray();
147
[email protected]431552c2012-10-23 00:38:33148 // Shows context menu at the |location_in_screen|. This uses
149 // |ShellDelegate::CreateContextMenu| to define the content of the menu.
[email protected]940fb1c2013-06-18 16:54:28150 void ShowContextMenu(const gfx::Point& location_in_screen,
151 ui::MenuSourceType source_type);
[email protected]431552c2012-10-23 00:38:33152
[email protected]8674b312012-10-12 19:02:44153 // Returns the layout-manager for the appropriate modal-container. If the
154 // window is inside the lockscreen modal container, then the layout manager
155 // for that is returned. Otherwise the layout manager for the default modal
156 // container is returned.
157 // If no window is specified (i.e. |window| is NULL), then the lockscreen
158 // modal container is used if the screen is currently locked. Otherwise, the
159 // default modal container is used.
160 SystemModalContainerLayoutManager* GetSystemModalLayoutManager(
161 aura::Window* window);
[email protected]c0ce80e2012-10-05 23:28:27162
[email protected]d90b8392012-06-13 09:34:56163 aura::Window* GetContainer(int container_id);
[email protected]d8a24952013-08-05 20:05:05164 const aura::Window* GetContainer(int container_id) const;
[email protected]d90b8392012-06-13 09:34:56165
[email protected]756bda12013-07-03 08:17:06166 // Initializes the RootWindowController. |first_run_after_boot| is
167 // set to true only for primary root window after boot.
168 void Init(bool first_run_after_boot);
[email protected]697f04c2012-10-03 01:15:10169
[email protected]e74aaf0a2012-10-12 18:42:28170 // Show launcher view if it was created hidden (before session has started).
171 void ShowLauncher();
172
[email protected]478c6c32013-03-09 02:50:58173 // Called when the launcher associated with this root window is created.
174 void OnLauncherCreated();
175
[email protected]16059276d2012-10-22 18:59:50176 // Called when the login status changes after login (such as lock/unlock).
177 // TODO(oshima): Investigate if we can merge this and |OnLoginStateChanged|.
178 void UpdateAfterLoginStatusChange(user::LoginStatus status);
179
[email protected]bca9a7e2012-11-10 06:25:49180 // Called when the brightness/grayscale animation from white to the login
181 // desktop background image has started. Starts |boot_splash_screen_|'s
182 // hiding animation (if the screen is non-NULL).
183 void HandleInitialDesktopBackgroundAnimationStarted();
184
[email protected]0bf61732013-07-02 04:35:10185 // Called when the wallpaper ainmation is finished. Updates |background_|
186 // to be black and drops |boot_splash_screen_| and moves the wallpaper
187 // controller into the root window controller. |widget| holds the wallpaper
188 // image, or NULL if the background is a solid color.
189 void OnWallpaperAnimationFinished(views::Widget* widget);
[email protected]d90b8392012-06-13 09:34:56190
[email protected]6675e1c2012-09-11 09:15:45191 // Deletes associated objects and clears the state, but doesn't delete
192 // the root window yet. This is used to delete a secondary displays'
193 // root window safely when the display disconnect signal is received,
194 // which may come while we're in the nested message loop.
195 void Shutdown();
196
[email protected]d90b8392012-06-13 09:34:56197 // Deletes all child windows and performs necessary cleanup.
198 void CloseChildWindows();
199
[email protected]f1853122012-06-27 16:21:26200 // Moves child windows to |dest|.
201 void MoveWindowsTo(aura::RootWindow* dest);
202
[email protected]e74aaf0a2012-10-12 18:42:28203 // Force the shelf to query for it's current visibility state.
204 void UpdateShelfVisibility();
205
[email protected]2b8a9bb2013-07-01 22:43:40206 // Initialize touch HUDs if necessary.
207 void InitTouchHuds();
208
[email protected]e3bc88e2013-09-06 06:22:06209 // Returns the window, if any, which is in fullscreen mode. If multiple
210 // windows are in fullscreen state, the topmost one is preferred.
211 const aura::Window* GetTopmostFullscreenWindow() const;
[email protected]2ee2f5d2013-01-10 23:37:16212
[email protected]b6ba05d902013-10-04 21:38:45213 // Activate virtual keyboard on current root window controller.
214 void ActivateKeyboard(keyboard::KeyboardController* keyboard_controller);
215
216 // Deactivate virtual keyboard on current root window controller.
217 void DeactivateKeyboard(keyboard::KeyboardController* keyboard_controller);
218
[email protected]431552c2012-10-23 00:38:33219 private:
[email protected]756bda12013-07-03 08:17:06220 void InitLayoutManagers();
221
222 // Initializes |system_background_| and possibly also |boot_splash_screen_|.
223 // |is_first_run_after_boot| determines the background's initial color.
224 void CreateSystemBackground(bool is_first_run_after_boot);
225
[email protected]a4cd6d32012-09-12 03:42:13226 // Creates each of the special window containers that holds windows of various
227 // types in the shell UI.
228 void CreateContainersInRootWindow(aura::RootWindow* root_window);
229
[email protected]d141b922013-07-09 08:13:17230 // Enables projection touch HUD.
231 void EnableTouchHudProjection();
232
233 // Disables projection touch HUD.
234 void DisableTouchHudProjection();
235
236 // Overridden from ShellObserver.
237 virtual void OnLoginStateChanged(user::LoginStatus status) OVERRIDE;
238 virtual void OnTouchHudProjectionToggled(bool enabled) OVERRIDE;
239
[email protected]d90b8392012-06-13 09:34:56240 scoped_ptr<aura::RootWindow> root_window_;
[email protected]c0ce80e2012-10-05 23:28:27241 RootWindowLayoutManager* root_window_layout_;
[email protected]d90b8392012-06-13 09:34:56242
[email protected]2a2caa02013-01-22 20:50:36243 scoped_ptr<StackingController> stacking_controller_;
244
[email protected]e74aaf0a2012-10-12 18:42:28245 // The shelf for managing the launcher and the status widget.
[email protected]478c6c32013-03-09 02:50:58246 scoped_ptr<ShelfWidget> shelf_;
[email protected]e74aaf0a2012-10-12 18:42:28247
[email protected]cf6fea22013-08-07 14:24:01248 // An invisible/empty window used as a event target for
249 // |MouseCursorEventFilter| before a user logs in.
250 // (crbug.com/266987)
251 // Its container is |LockScreenBackgroundContainer| and
252 // this must be deleted before the container is deleted.
253 scoped_ptr<aura::Window> mouse_event_target_;
254
[email protected]beb4e5c2013-06-18 15:37:07255 // Manages layout of docked windows. Owned by DockedContainer.
256 DockedWindowLayoutManager* docked_layout_manager_;
257
[email protected]e74aaf0a2012-10-12 18:42:28258 // Manages layout of panels. Owned by PanelContainer.
[email protected]88d71122012-10-18 07:11:01259 PanelLayoutManager* panel_layout_manager_;
[email protected]e74aaf0a2012-10-12 18:42:28260
[email protected]e6e41d2f2012-10-29 19:22:19261 scoped_ptr<SystemBackgroundController> system_background_;
[email protected]438cbdf02013-10-07 23:41:09262#if defined(OS_CHROMEOS)
[email protected]bca9a7e2012-11-10 06:25:49263 scoped_ptr<BootSplashScreen> boot_splash_screen_;
[email protected]252eb232013-08-14 22:09:27264#endif
[email protected]697f04c2012-10-03 01:15:10265
[email protected]c0ce80e2012-10-05 23:28:27266 scoped_ptr<ScreenDimmer> screen_dimmer_;
267 scoped_ptr<WorkspaceController> workspace_controller_;
[email protected]80549c152013-07-02 01:42:47268 scoped_ptr<AlwaysOnTopController> always_on_top_controller_;
[email protected]d90b8392012-06-13 09:34:56269
[email protected]2b8a9bb2013-07-01 22:43:40270 // Heads-up displays for touch events. These HUDs are not owned by the root
271 // window controller and manage their own lifetimes.
272 TouchHudDebug* touch_hud_debug_;
273 TouchHudProjection* touch_hud_projection_;
[email protected]58175042013-04-01 19:27:13274
[email protected]a4cd6d32012-09-12 03:42:13275 // We need to own event handlers for various containers.
276 scoped_ptr<ToplevelWindowEventHandler> default_container_handler_;
277 scoped_ptr<ToplevelWindowEventHandler> always_on_top_container_handler_;
278 scoped_ptr<ToplevelWindowEventHandler> modal_container_handler_;
279 scoped_ptr<ToplevelWindowEventHandler> lock_modal_container_handler_;
[email protected]582022052013-02-20 15:19:04280 scoped_ptr<ToplevelWindowEventHandler> panel_container_handler_;
[email protected]beb4e5c2013-06-18 15:37:07281 scoped_ptr<ToplevelWindowEventHandler> docked_container_handler_;
[email protected]a4cd6d32012-09-12 03:42:13282
[email protected]0bf61732013-07-02 04:35:10283 scoped_ptr<DesktopBackgroundWidgetController> wallpaper_controller_;
284 scoped_ptr<AnimatingDesktopController> animating_wallpaper_controller_;
[email protected]23a2dc82013-08-22 15:04:22285 scoped_ptr<views::corewm::ScopedCaptureClient> capture_client_;
[email protected]0bf61732013-07-02 04:35:10286
[email protected]d90b8392012-06-13 09:34:56287 DISALLOW_COPY_AND_ASSIGN(RootWindowController);
288};
289
[email protected]6b2d4a0b2013-09-06 06:29:54290
291// Gets the RootWindowController for |root_window|.
292ASH_EXPORT RootWindowController* GetRootWindowController(
293 const aura::RootWindow* root_window);
294
[email protected]d90b8392012-06-13 09:34:56295} // namespace internal
296} // ash
297
298#endif // ASH_ROOT_WINDOW_CONTROLLER_H_