blob: bbf29ce1e343d84a54bae9059c5577c5706bb5f0 [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]4a59e4e2012-11-12 21:15:4036}
37}
[email protected]d90b8392012-06-13 09:34:5638
[email protected]86459e2c2013-04-10 13:39:2439namespace keyboard {
40class KeyboardController;
41}
42
[email protected]d90b8392012-06-13 09:34:5643namespace ash {
[email protected]2a2caa02013-01-22 20:50:3644class StackingController;
[email protected]478c6c32013-03-09 02:50:5845class ShelfWidget;
[email protected]a0afeb12012-12-10 22:57:0946class SystemTray;
[email protected]a4cd6d32012-09-12 03:42:1347class ToplevelWindowEventHandler;
[email protected]e74aaf0a2012-10-12 18:42:2848
[email protected]d90b8392012-06-13 09:34:5649namespace internal {
50
[email protected]80549c152013-07-02 01:42:4751class AlwaysOnTopController;
[email protected]0bf61732013-07-02 04:35:1052class AnimatingDesktopController;
[email protected]bca9a7e2012-11-10 06:25:4953class BootSplashScreen;
[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
67// This class maintains the per root window state for ash. This class
68// owns the root window and other dependent objects that should be
69// deleted upon the deletion of the root window. The RootWindowController
70// for particular root window is stored as a property and can be obtained
71// using |GetRootWindowController(aura::RootWindow*)| function.
[email protected]d141b922013-07-09 08:13:1772class ASH_EXPORT RootWindowController : public ShellObserver {
[email protected]d90b8392012-06-13 09:34:5673 public:
74 explicit RootWindowController(aura::RootWindow* root_window);
[email protected]d141b922013-07-09 08:13:1775 virtual ~RootWindowController();
[email protected]d90b8392012-06-13 09:34:5676
[email protected]88d71122012-10-18 07:11:0177 // Returns a RootWindowController that has a launcher for given
78 // |window|. This returns the RootWindowController for the |window|'s
79 // root window when multiple launcher mode is enabled, or the primary
80 // RootWindowController otherwise.
81 static RootWindowController* ForLauncher(aura::Window* window);
82
[email protected]a0afeb12012-12-10 22:57:0983 // Returns a RootWindowController of the window's root window.
[email protected]ccff3d72013-02-06 04:26:2884 static RootWindowController* ForWindow(const aura::Window* window);
[email protected]a0afeb12012-12-10 22:57:0985
86 // Returns the RootWindowController of the active root window.
87 static internal::RootWindowController* ForActiveRootWindow();
88
[email protected]e74aaf0a2012-10-12 18:42:2889 aura::RootWindow* root_window() { return root_window_.get(); }
[email protected]d90b8392012-06-13 09:34:5690
[email protected]e74aaf0a2012-10-12 18:42:2891 RootWindowLayoutManager* root_window_layout() { return root_window_layout_; }
[email protected]d90b8392012-06-13 09:34:5692
[email protected]c0ce80e2012-10-05 23:28:2793 WorkspaceController* workspace_controller() {
[email protected]d90b8392012-06-13 09:34:5694 return workspace_controller_.get();
95 }
96
[email protected]80549c152013-07-02 01:42:4797 AlwaysOnTopController* always_on_top_controller() {
98 return always_on_top_controller_.get();
99 }
100
[email protected]e74aaf0a2012-10-12 18:42:28101 ScreenDimmer* screen_dimmer() { return screen_dimmer_.get(); }
102
[email protected]478c6c32013-03-09 02:50:58103 // Access the shelf associated with this root window controller,
104 // NULL if no such shelf exists.
105 ShelfWidget* shelf() { return shelf_.get(); }
[email protected]e74aaf0a2012-10-12 18:42:28106
[email protected]2b8a9bb2013-07-01 22:43:40107 // Get touch HUDs associated with this root window controller.
108 TouchHudDebug* touch_hud_debug() const {
109 return touch_hud_debug_;
[email protected]bff17552013-04-25 04:44:55110 }
[email protected]2b8a9bb2013-07-01 22:43:40111 TouchHudProjection* touch_hud_projection() const {
112 return touch_hud_projection_;
113 }
114
115 // Set touch HUDs for this root window controller. The root window controller
116 // will not own the HUDs; their lifetimes are managed by themselves. Whenever
117 // the widget showing a HUD is being destroyed (e.g. because of detaching a
118 // display), the HUD deletes itself.
119 void set_touch_hud_debug(TouchHudDebug* hud) {
120 touch_hud_debug_ = hud;
121 }
122 void set_touch_hud_projection(TouchHudProjection* hud) {
123 touch_hud_projection_ = hud;
124 }
125
[email protected]0bf61732013-07-02 04:35:10126 DesktopBackgroundWidgetController* wallpaper_controller() {
127 return wallpaper_controller_.get();
128 }
129 void SetWallpaperController(DesktopBackgroundWidgetController* controller);
130 AnimatingDesktopController* animating_wallpaper_controller() {
131 return animating_wallpaper_controller_.get();
132 }
133 void SetAnimatingWallpaperController(AnimatingDesktopController* controller);
134
[email protected]478c6c32013-03-09 02:50:58135 // Access the shelf layout manager associated with this root
136 // window controller, NULL if no such shelf exists.
137 ShelfLayoutManager* GetShelfLayoutManager();
[email protected]d90b8392012-06-13 09:34:56138
[email protected]a0afeb12012-12-10 22:57:09139 // Returns the system tray on this root window. Note that
140 // calling this on the root window that doesn't have a launcher will
141 // lead to a crash.
142 SystemTray* GetSystemTray();
143
[email protected]431552c2012-10-23 00:38:33144 // Shows context menu at the |location_in_screen|. This uses
145 // |ShellDelegate::CreateContextMenu| to define the content of the menu.
[email protected]940fb1c2013-06-18 16:54:28146 void ShowContextMenu(const gfx::Point& location_in_screen,
147 ui::MenuSourceType source_type);
[email protected]431552c2012-10-23 00:38:33148
[email protected]8674b312012-10-12 19:02:44149 // Returns the layout-manager for the appropriate modal-container. If the
150 // window is inside the lockscreen modal container, then the layout manager
151 // for that is returned. Otherwise the layout manager for the default modal
152 // container is returned.
153 // If no window is specified (i.e. |window| is NULL), then the lockscreen
154 // modal container is used if the screen is currently locked. Otherwise, the
155 // default modal container is used.
156 SystemModalContainerLayoutManager* GetSystemModalLayoutManager(
157 aura::Window* window);
[email protected]c0ce80e2012-10-05 23:28:27158
[email protected]d90b8392012-06-13 09:34:56159 aura::Window* GetContainer(int container_id);
[email protected]d8a24952013-08-05 20:05:05160 const aura::Window* GetContainer(int container_id) const;
[email protected]d90b8392012-06-13 09:34:56161
[email protected]756bda12013-07-03 08:17:06162 // Initializes the RootWindowController. |first_run_after_boot| is
163 // set to true only for primary root window after boot.
164 void Init(bool first_run_after_boot);
[email protected]697f04c2012-10-03 01:15:10165
[email protected]e74aaf0a2012-10-12 18:42:28166 // Show launcher view if it was created hidden (before session has started).
167 void ShowLauncher();
168
[email protected]478c6c32013-03-09 02:50:58169 // Called when the launcher associated with this root window is created.
170 void OnLauncherCreated();
171
[email protected]16059276d2012-10-22 18:59:50172 // Called when the login status changes after login (such as lock/unlock).
173 // TODO(oshima): Investigate if we can merge this and |OnLoginStateChanged|.
174 void UpdateAfterLoginStatusChange(user::LoginStatus status);
175
[email protected]bca9a7e2012-11-10 06:25:49176 // Called when the brightness/grayscale animation from white to the login
177 // desktop background image has started. Starts |boot_splash_screen_|'s
178 // hiding animation (if the screen is non-NULL).
179 void HandleInitialDesktopBackgroundAnimationStarted();
180
[email protected]0bf61732013-07-02 04:35:10181 // Called when the wallpaper ainmation is finished. Updates |background_|
182 // to be black and drops |boot_splash_screen_| and moves the wallpaper
183 // controller into the root window controller. |widget| holds the wallpaper
184 // image, or NULL if the background is a solid color.
185 void OnWallpaperAnimationFinished(views::Widget* widget);
[email protected]d90b8392012-06-13 09:34:56186
[email protected]6675e1c2012-09-11 09:15:45187 // Deletes associated objects and clears the state, but doesn't delete
188 // the root window yet. This is used to delete a secondary displays'
189 // root window safely when the display disconnect signal is received,
190 // which may come while we're in the nested message loop.
191 void Shutdown();
192
[email protected]d90b8392012-06-13 09:34:56193 // Deletes all child windows and performs necessary cleanup.
194 void CloseChildWindows();
195
[email protected]f1853122012-06-27 16:21:26196 // Moves child windows to |dest|.
197 void MoveWindowsTo(aura::RootWindow* dest);
198
[email protected]e74aaf0a2012-10-12 18:42:28199 // Force the shelf to query for it's current visibility state.
200 void UpdateShelfVisibility();
201
[email protected]2b8a9bb2013-07-01 22:43:40202 // Initialize touch HUDs if necessary.
203 void InitTouchHuds();
204
[email protected]700849f2013-04-30 17:49:20205 // Returns the window, if any, which is in fullscreen mode in the active
206 // workspace. Exposed here so clients of Ash don't need to know the details
207 // of workspace management.
[email protected]d8a24952013-08-05 20:05:05208 const aura::Window* GetFullscreenWindow() const;
[email protected]2ee2f5d2013-01-10 23:37:16209
[email protected]431552c2012-10-23 00:38:33210 private:
[email protected]756bda12013-07-03 08:17:06211 void InitLayoutManagers();
212
213 // Initializes |system_background_| and possibly also |boot_splash_screen_|.
214 // |is_first_run_after_boot| determines the background's initial color.
215 void CreateSystemBackground(bool is_first_run_after_boot);
216
[email protected]a4cd6d32012-09-12 03:42:13217 // Creates each of the special window containers that holds windows of various
218 // types in the shell UI.
219 void CreateContainersInRootWindow(aura::RootWindow* root_window);
220
[email protected]86459e2c2013-04-10 13:39:24221 // Initializes the virtual keyboard.
222 void InitKeyboard();
223
[email protected]d141b922013-07-09 08:13:17224 // Enables projection touch HUD.
225 void EnableTouchHudProjection();
226
227 // Disables projection touch HUD.
228 void DisableTouchHudProjection();
229
230 // Overridden from ShellObserver.
231 virtual void OnLoginStateChanged(user::LoginStatus status) OVERRIDE;
232 virtual void OnTouchHudProjectionToggled(bool enabled) OVERRIDE;
233
[email protected]d90b8392012-06-13 09:34:56234 scoped_ptr<aura::RootWindow> root_window_;
[email protected]c0ce80e2012-10-05 23:28:27235 RootWindowLayoutManager* root_window_layout_;
[email protected]d90b8392012-06-13 09:34:56236
[email protected]2a2caa02013-01-22 20:50:36237 scoped_ptr<StackingController> stacking_controller_;
238
[email protected]86459e2c2013-04-10 13:39:24239 scoped_ptr<keyboard::KeyboardController> keyboard_controller_;
240
[email protected]e74aaf0a2012-10-12 18:42:28241 // The shelf for managing the launcher and the status widget.
[email protected]478c6c32013-03-09 02:50:58242 scoped_ptr<ShelfWidget> shelf_;
[email protected]e74aaf0a2012-10-12 18:42:28243
[email protected]cf6fea22013-08-07 14:24:01244 // An invisible/empty window used as a event target for
245 // |MouseCursorEventFilter| before a user logs in.
246 // (crbug.com/266987)
247 // Its container is |LockScreenBackgroundContainer| and
248 // this must be deleted before the container is deleted.
249 scoped_ptr<aura::Window> mouse_event_target_;
250
[email protected]beb4e5c2013-06-18 15:37:07251 // Manages layout of docked windows. Owned by DockedContainer.
252 DockedWindowLayoutManager* docked_layout_manager_;
253
[email protected]e74aaf0a2012-10-12 18:42:28254 // Manages layout of panels. Owned by PanelContainer.
[email protected]88d71122012-10-18 07:11:01255 PanelLayoutManager* panel_layout_manager_;
[email protected]e74aaf0a2012-10-12 18:42:28256
[email protected]e6e41d2f2012-10-29 19:22:19257 scoped_ptr<SystemBackgroundController> system_background_;
[email protected]bca9a7e2012-11-10 06:25:49258 scoped_ptr<BootSplashScreen> boot_splash_screen_;
[email protected]697f04c2012-10-03 01:15:10259
[email protected]c0ce80e2012-10-05 23:28:27260 scoped_ptr<ScreenDimmer> screen_dimmer_;
261 scoped_ptr<WorkspaceController> workspace_controller_;
[email protected]80549c152013-07-02 01:42:47262 scoped_ptr<AlwaysOnTopController> always_on_top_controller_;
[email protected]d90b8392012-06-13 09:34:56263
[email protected]2b8a9bb2013-07-01 22:43:40264 // Heads-up displays for touch events. These HUDs are not owned by the root
265 // window controller and manage their own lifetimes.
266 TouchHudDebug* touch_hud_debug_;
267 TouchHudProjection* touch_hud_projection_;
[email protected]58175042013-04-01 19:27:13268
[email protected]a4cd6d32012-09-12 03:42:13269 // We need to own event handlers for various containers.
270 scoped_ptr<ToplevelWindowEventHandler> default_container_handler_;
271 scoped_ptr<ToplevelWindowEventHandler> always_on_top_container_handler_;
272 scoped_ptr<ToplevelWindowEventHandler> modal_container_handler_;
273 scoped_ptr<ToplevelWindowEventHandler> lock_modal_container_handler_;
[email protected]582022052013-02-20 15:19:04274 scoped_ptr<ToplevelWindowEventHandler> panel_container_handler_;
[email protected]beb4e5c2013-06-18 15:37:07275 scoped_ptr<ToplevelWindowEventHandler> docked_container_handler_;
[email protected]a4cd6d32012-09-12 03:42:13276
[email protected]0bf61732013-07-02 04:35:10277 scoped_ptr<DesktopBackgroundWidgetController> wallpaper_controller_;
278 scoped_ptr<AnimatingDesktopController> animating_wallpaper_controller_;
279
[email protected]d90b8392012-06-13 09:34:56280 DISALLOW_COPY_AND_ASSIGN(RootWindowController);
281};
282
283} // namespace internal
284} // ash
285
286#endif // ASH_ROOT_WINDOW_CONTROLLER_H_