[email protected] | d90b839 | 2012-06-13 09:34:56 | [diff] [blame] | 1 | // 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] | d90b839 | 2012-06-13 09:34:56 | [diff] [blame] | 7 | |
[email protected] | 2b8a9bb | 2013-07-01 22:43:40 | [diff] [blame] | 8 | #include <map> |
| 9 | |
[email protected] | c0ce80e | 2012-10-05 23:28:27 | [diff] [blame] | 10 | #include "ash/ash_export.h" |
[email protected] | 478c6c3 | 2013-03-09 02:50:58 | [diff] [blame] | 11 | #include "ash/shelf/shelf_types.h" |
[email protected] | 16059276d | 2012-10-22 18:59:50 | [diff] [blame] | 12 | #include "ash/system/user/login_status.h" |
[email protected] | d90b839 | 2012-06-13 09:34:56 | [diff] [blame] | 13 | #include "base/basictypes.h" |
| 14 | #include "base/memory/scoped_ptr.h" |
[email protected] | 940fb1c | 2013-06-18 16:54:28 | [diff] [blame] | 15 | #include "ui/base/ui_base_types.h" |
[email protected] | d90b839 | 2012-06-13 09:34:56 | [diff] [blame] | 16 | |
| 17 | class SkBitmap; |
| 18 | |
| 19 | namespace aura { |
| 20 | class EventFilter; |
| 21 | class RootWindow; |
| 22 | class Window; |
[email protected] | 4a59e4e | 2012-11-12 21:15:40 | [diff] [blame] | 23 | } |
| 24 | |
| 25 | namespace gfx { |
| 26 | class Point; |
| 27 | } |
| 28 | |
| 29 | namespace views { |
[email protected] | 0bf6173 | 2013-07-02 04:35:10 | [diff] [blame] | 30 | class Widget; |
| 31 | |
[email protected] | 4a59e4e | 2012-11-12 21:15:40 | [diff] [blame] | 32 | namespace corewm { |
[email protected] | d90b839 | 2012-06-13 09:34:56 | [diff] [blame] | 33 | class InputMethodEventFilter; |
| 34 | class RootWindowEventFilter; |
[email protected] | 4a59e4e | 2012-11-12 21:15:40 | [diff] [blame] | 35 | } |
| 36 | } |
[email protected] | d90b839 | 2012-06-13 09:34:56 | [diff] [blame] | 37 | |
[email protected] | 86459e2c | 2013-04-10 13:39:24 | [diff] [blame] | 38 | namespace keyboard { |
| 39 | class KeyboardController; |
| 40 | } |
| 41 | |
[email protected] | d90b839 | 2012-06-13 09:34:56 | [diff] [blame] | 42 | namespace ash { |
[email protected] | 2a2caa0 | 2013-01-22 20:50:36 | [diff] [blame] | 43 | class StackingController; |
[email protected] | 478c6c3 | 2013-03-09 02:50:58 | [diff] [blame] | 44 | class ShelfWidget; |
[email protected] | a0afeb1 | 2012-12-10 22:57:09 | [diff] [blame] | 45 | class SystemTray; |
[email protected] | a4cd6d3 | 2012-09-12 03:42:13 | [diff] [blame] | 46 | class ToplevelWindowEventHandler; |
[email protected] | e74aaf0a | 2012-10-12 18:42:28 | [diff] [blame] | 47 | |
[email protected] | d90b839 | 2012-06-13 09:34:56 | [diff] [blame] | 48 | namespace internal { |
| 49 | |
[email protected] | 80549c15 | 2013-07-02 01:42:47 | [diff] [blame] | 50 | class AlwaysOnTopController; |
[email protected] | 0bf6173 | 2013-07-02 04:35:10 | [diff] [blame] | 51 | class AnimatingDesktopController; |
[email protected] | bca9a7e | 2012-11-10 06:25:49 | [diff] [blame] | 52 | class BootSplashScreen; |
[email protected] | 0bf6173 | 2013-07-02 04:35:10 | [diff] [blame] | 53 | class DesktopBackgroundWidgetController; |
[email protected] | beb4e5c | 2013-06-18 15:37:07 | [diff] [blame] | 54 | class DockedWindowLayoutManager; |
[email protected] | e74aaf0a | 2012-10-12 18:42:28 | [diff] [blame] | 55 | class PanelLayoutManager; |
[email protected] | d90b839 | 2012-06-13 09:34:56 | [diff] [blame] | 56 | class RootWindowLayoutManager; |
| 57 | class ScreenDimmer; |
[email protected] | e74aaf0a | 2012-10-12 18:42:28 | [diff] [blame] | 58 | class ShelfLayoutManager; |
| 59 | class StatusAreaWidget; |
| 60 | class SystemBackgroundController; |
[email protected] | c0ce80e | 2012-10-05 23:28:27 | [diff] [blame] | 61 | class SystemModalContainerLayoutManager; |
[email protected] | 2b8a9bb | 2013-07-01 22:43:40 | [diff] [blame] | 62 | class TouchHudDebug; |
| 63 | class TouchHudProjection; |
[email protected] | d90b839 | 2012-06-13 09:34:56 | [diff] [blame] | 64 | class WorkspaceController; |
| 65 | |
| 66 | // This class maintains the per root window state for ash. This class |
| 67 | // owns the root window and other dependent objects that should be |
| 68 | // deleted upon the deletion of the root window. The RootWindowController |
| 69 | // for particular root window is stored as a property and can be obtained |
| 70 | // using |GetRootWindowController(aura::RootWindow*)| function. |
[email protected] | c0ce80e | 2012-10-05 23:28:27 | [diff] [blame] | 71 | class ASH_EXPORT RootWindowController { |
[email protected] | d90b839 | 2012-06-13 09:34:56 | [diff] [blame] | 72 | public: |
| 73 | explicit RootWindowController(aura::RootWindow* root_window); |
| 74 | ~RootWindowController(); |
| 75 | |
[email protected] | 88d7112 | 2012-10-18 07:11:01 | [diff] [blame] | 76 | // Returns a RootWindowController that has a launcher for given |
| 77 | // |window|. This returns the RootWindowController for the |window|'s |
| 78 | // root window when multiple launcher mode is enabled, or the primary |
| 79 | // RootWindowController otherwise. |
| 80 | static RootWindowController* ForLauncher(aura::Window* window); |
| 81 | |
[email protected] | a0afeb1 | 2012-12-10 22:57:09 | [diff] [blame] | 82 | // Returns a RootWindowController of the window's root window. |
[email protected] | ccff3d7 | 2013-02-06 04:26:28 | [diff] [blame] | 83 | static RootWindowController* ForWindow(const aura::Window* window); |
[email protected] | a0afeb1 | 2012-12-10 22:57:09 | [diff] [blame] | 84 | |
| 85 | // Returns the RootWindowController of the active root window. |
| 86 | static internal::RootWindowController* ForActiveRootWindow(); |
| 87 | |
[email protected] | e74aaf0a | 2012-10-12 18:42:28 | [diff] [blame] | 88 | aura::RootWindow* root_window() { return root_window_.get(); } |
[email protected] | d90b839 | 2012-06-13 09:34:56 | [diff] [blame] | 89 | |
[email protected] | e74aaf0a | 2012-10-12 18:42:28 | [diff] [blame] | 90 | RootWindowLayoutManager* root_window_layout() { return root_window_layout_; } |
[email protected] | d90b839 | 2012-06-13 09:34:56 | [diff] [blame] | 91 | |
[email protected] | c0ce80e | 2012-10-05 23:28:27 | [diff] [blame] | 92 | WorkspaceController* workspace_controller() { |
[email protected] | d90b839 | 2012-06-13 09:34:56 | [diff] [blame] | 93 | return workspace_controller_.get(); |
| 94 | } |
| 95 | |
[email protected] | 80549c15 | 2013-07-02 01:42:47 | [diff] [blame] | 96 | AlwaysOnTopController* always_on_top_controller() { |
| 97 | return always_on_top_controller_.get(); |
| 98 | } |
| 99 | |
[email protected] | e74aaf0a | 2012-10-12 18:42:28 | [diff] [blame] | 100 | ScreenDimmer* screen_dimmer() { return screen_dimmer_.get(); } |
| 101 | |
[email protected] | 478c6c3 | 2013-03-09 02:50:58 | [diff] [blame] | 102 | // Access the shelf associated with this root window controller, |
| 103 | // NULL if no such shelf exists. |
| 104 | ShelfWidget* shelf() { return shelf_.get(); } |
[email protected] | e74aaf0a | 2012-10-12 18:42:28 | [diff] [blame] | 105 | |
[email protected] | 2b8a9bb | 2013-07-01 22:43:40 | [diff] [blame] | 106 | // Get touch HUDs associated with this root window controller. |
| 107 | TouchHudDebug* touch_hud_debug() const { |
| 108 | return touch_hud_debug_; |
[email protected] | bff1755 | 2013-04-25 04:44:55 | [diff] [blame] | 109 | } |
[email protected] | 2b8a9bb | 2013-07-01 22:43:40 | [diff] [blame] | 110 | TouchHudProjection* touch_hud_projection() const { |
| 111 | return touch_hud_projection_; |
| 112 | } |
| 113 | |
| 114 | // Set touch HUDs for this root window controller. The root window controller |
| 115 | // will not own the HUDs; their lifetimes are managed by themselves. Whenever |
| 116 | // the widget showing a HUD is being destroyed (e.g. because of detaching a |
| 117 | // display), the HUD deletes itself. |
| 118 | void set_touch_hud_debug(TouchHudDebug* hud) { |
| 119 | touch_hud_debug_ = hud; |
| 120 | } |
| 121 | void set_touch_hud_projection(TouchHudProjection* hud) { |
| 122 | touch_hud_projection_ = hud; |
| 123 | } |
| 124 | |
| 125 | // Enables projection touch HUD. |
| 126 | void EnableTouchHudProjection(); |
| 127 | |
| 128 | // Disables projection touch HUD. |
| 129 | void DisableTouchHudProjection(); |
| 130 | |
[email protected] | 0bf6173 | 2013-07-02 04:35:10 | [diff] [blame] | 131 | DesktopBackgroundWidgetController* wallpaper_controller() { |
| 132 | return wallpaper_controller_.get(); |
| 133 | } |
| 134 | void SetWallpaperController(DesktopBackgroundWidgetController* controller); |
| 135 | AnimatingDesktopController* animating_wallpaper_controller() { |
| 136 | return animating_wallpaper_controller_.get(); |
| 137 | } |
| 138 | void SetAnimatingWallpaperController(AnimatingDesktopController* controller); |
| 139 | |
[email protected] | 478c6c3 | 2013-03-09 02:50:58 | [diff] [blame] | 140 | // Access the shelf layout manager associated with this root |
| 141 | // window controller, NULL if no such shelf exists. |
| 142 | ShelfLayoutManager* GetShelfLayoutManager(); |
[email protected] | d90b839 | 2012-06-13 09:34:56 | [diff] [blame] | 143 | |
[email protected] | a0afeb1 | 2012-12-10 22:57:09 | [diff] [blame] | 144 | // Returns the system tray on this root window. Note that |
| 145 | // calling this on the root window that doesn't have a launcher will |
| 146 | // lead to a crash. |
| 147 | SystemTray* GetSystemTray(); |
| 148 | |
[email protected] | 431552c | 2012-10-23 00:38:33 | [diff] [blame] | 149 | // Shows context menu at the |location_in_screen|. This uses |
| 150 | // |ShellDelegate::CreateContextMenu| to define the content of the menu. |
[email protected] | 940fb1c | 2013-06-18 16:54:28 | [diff] [blame] | 151 | void ShowContextMenu(const gfx::Point& location_in_screen, |
| 152 | ui::MenuSourceType source_type); |
[email protected] | 431552c | 2012-10-23 00:38:33 | [diff] [blame] | 153 | |
[email protected] | 8674b31 | 2012-10-12 19:02:44 | [diff] [blame] | 154 | // Returns the layout-manager for the appropriate modal-container. If the |
| 155 | // window is inside the lockscreen modal container, then the layout manager |
| 156 | // for that is returned. Otherwise the layout manager for the default modal |
| 157 | // container is returned. |
| 158 | // If no window is specified (i.e. |window| is NULL), then the lockscreen |
| 159 | // modal container is used if the screen is currently locked. Otherwise, the |
| 160 | // default modal container is used. |
| 161 | SystemModalContainerLayoutManager* GetSystemModalLayoutManager( |
| 162 | aura::Window* window); |
[email protected] | c0ce80e | 2012-10-05 23:28:27 | [diff] [blame] | 163 | |
[email protected] | d90b839 | 2012-06-13 09:34:56 | [diff] [blame] | 164 | aura::Window* GetContainer(int container_id); |
| 165 | |
[email protected] | 756bda1 | 2013-07-03 08:17:06 | [diff] [blame^] | 166 | // 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] | 697f04c | 2012-10-03 01:15:10 | [diff] [blame] | 169 | |
[email protected] | e74aaf0a | 2012-10-12 18:42:28 | [diff] [blame] | 170 | // Show launcher view if it was created hidden (before session has started). |
| 171 | void ShowLauncher(); |
| 172 | |
[email protected] | 478c6c3 | 2013-03-09 02:50:58 | [diff] [blame] | 173 | // Called when the launcher associated with this root window is created. |
| 174 | void OnLauncherCreated(); |
| 175 | |
[email protected] | 16059276d | 2012-10-22 18:59:50 | [diff] [blame] | 176 | // Called when the user logs in. |
| 177 | void OnLoginStateChanged(user::LoginStatus status); |
| 178 | |
| 179 | // Called when the login status changes after login (such as lock/unlock). |
| 180 | // TODO(oshima): Investigate if we can merge this and |OnLoginStateChanged|. |
| 181 | void UpdateAfterLoginStatusChange(user::LoginStatus status); |
| 182 | |
[email protected] | bca9a7e | 2012-11-10 06:25:49 | [diff] [blame] | 183 | // Called when the brightness/grayscale animation from white to the login |
| 184 | // desktop background image has started. Starts |boot_splash_screen_|'s |
| 185 | // hiding animation (if the screen is non-NULL). |
| 186 | void HandleInitialDesktopBackgroundAnimationStarted(); |
| 187 | |
[email protected] | 0bf6173 | 2013-07-02 04:35:10 | [diff] [blame] | 188 | // Called when the wallpaper ainmation is finished. Updates |background_| |
| 189 | // to be black and drops |boot_splash_screen_| and moves the wallpaper |
| 190 | // controller into the root window controller. |widget| holds the wallpaper |
| 191 | // image, or NULL if the background is a solid color. |
| 192 | void OnWallpaperAnimationFinished(views::Widget* widget); |
[email protected] | d90b839 | 2012-06-13 09:34:56 | [diff] [blame] | 193 | |
[email protected] | 6675e1c | 2012-09-11 09:15:45 | [diff] [blame] | 194 | // Deletes associated objects and clears the state, but doesn't delete |
| 195 | // the root window yet. This is used to delete a secondary displays' |
| 196 | // root window safely when the display disconnect signal is received, |
| 197 | // which may come while we're in the nested message loop. |
| 198 | void Shutdown(); |
| 199 | |
[email protected] | d90b839 | 2012-06-13 09:34:56 | [diff] [blame] | 200 | // Deletes all child windows and performs necessary cleanup. |
| 201 | void CloseChildWindows(); |
| 202 | |
[email protected] | f185312 | 2012-06-27 16:21:26 | [diff] [blame] | 203 | // Moves child windows to |dest|. |
| 204 | void MoveWindowsTo(aura::RootWindow* dest); |
| 205 | |
[email protected] | e74aaf0a | 2012-10-12 18:42:28 | [diff] [blame] | 206 | // Force the shelf to query for it's current visibility state. |
| 207 | void UpdateShelfVisibility(); |
| 208 | |
[email protected] | 2b8a9bb | 2013-07-01 22:43:40 | [diff] [blame] | 209 | // Initialize touch HUDs if necessary. |
| 210 | void InitTouchHuds(); |
| 211 | |
[email protected] | 700849f | 2013-04-30 17:49:20 | [diff] [blame] | 212 | // Returns the window, if any, which is in fullscreen mode in the active |
| 213 | // workspace. Exposed here so clients of Ash don't need to know the details |
| 214 | // of workspace management. |
| 215 | aura::Window* GetFullscreenWindow() const; |
[email protected] | 2ee2f5d | 2013-01-10 23:37:16 | [diff] [blame] | 216 | |
[email protected] | 431552c | 2012-10-23 00:38:33 | [diff] [blame] | 217 | private: |
[email protected] | 756bda1 | 2013-07-03 08:17:06 | [diff] [blame^] | 218 | void InitLayoutManagers(); |
| 219 | |
| 220 | // Initializes |system_background_| and possibly also |boot_splash_screen_|. |
| 221 | // |is_first_run_after_boot| determines the background's initial color. |
| 222 | void CreateSystemBackground(bool is_first_run_after_boot); |
| 223 | |
[email protected] | a4cd6d3 | 2012-09-12 03:42:13 | [diff] [blame] | 224 | // Creates each of the special window containers that holds windows of various |
| 225 | // types in the shell UI. |
| 226 | void CreateContainersInRootWindow(aura::RootWindow* root_window); |
| 227 | |
[email protected] | 86459e2c | 2013-04-10 13:39:24 | [diff] [blame] | 228 | // Initializes the virtual keyboard. |
| 229 | void InitKeyboard(); |
| 230 | |
[email protected] | d90b839 | 2012-06-13 09:34:56 | [diff] [blame] | 231 | scoped_ptr<aura::RootWindow> root_window_; |
[email protected] | c0ce80e | 2012-10-05 23:28:27 | [diff] [blame] | 232 | RootWindowLayoutManager* root_window_layout_; |
[email protected] | d90b839 | 2012-06-13 09:34:56 | [diff] [blame] | 233 | |
[email protected] | 2a2caa0 | 2013-01-22 20:50:36 | [diff] [blame] | 234 | scoped_ptr<StackingController> stacking_controller_; |
| 235 | |
[email protected] | 86459e2c | 2013-04-10 13:39:24 | [diff] [blame] | 236 | scoped_ptr<keyboard::KeyboardController> keyboard_controller_; |
| 237 | |
[email protected] | e74aaf0a | 2012-10-12 18:42:28 | [diff] [blame] | 238 | // The shelf for managing the launcher and the status widget. |
[email protected] | 478c6c3 | 2013-03-09 02:50:58 | [diff] [blame] | 239 | scoped_ptr<ShelfWidget> shelf_; |
[email protected] | e74aaf0a | 2012-10-12 18:42:28 | [diff] [blame] | 240 | |
[email protected] | beb4e5c | 2013-06-18 15:37:07 | [diff] [blame] | 241 | // Manages layout of docked windows. Owned by DockedContainer. |
| 242 | DockedWindowLayoutManager* docked_layout_manager_; |
| 243 | |
[email protected] | e74aaf0a | 2012-10-12 18:42:28 | [diff] [blame] | 244 | // Manages layout of panels. Owned by PanelContainer. |
[email protected] | 88d7112 | 2012-10-18 07:11:01 | [diff] [blame] | 245 | PanelLayoutManager* panel_layout_manager_; |
[email protected] | e74aaf0a | 2012-10-12 18:42:28 | [diff] [blame] | 246 | |
[email protected] | e6e41d2f | 2012-10-29 19:22:19 | [diff] [blame] | 247 | scoped_ptr<SystemBackgroundController> system_background_; |
[email protected] | bca9a7e | 2012-11-10 06:25:49 | [diff] [blame] | 248 | scoped_ptr<BootSplashScreen> boot_splash_screen_; |
[email protected] | 697f04c | 2012-10-03 01:15:10 | [diff] [blame] | 249 | |
[email protected] | c0ce80e | 2012-10-05 23:28:27 | [diff] [blame] | 250 | scoped_ptr<ScreenDimmer> screen_dimmer_; |
| 251 | scoped_ptr<WorkspaceController> workspace_controller_; |
[email protected] | 80549c15 | 2013-07-02 01:42:47 | [diff] [blame] | 252 | scoped_ptr<AlwaysOnTopController> always_on_top_controller_; |
[email protected] | d90b839 | 2012-06-13 09:34:56 | [diff] [blame] | 253 | |
[email protected] | 2b8a9bb | 2013-07-01 22:43:40 | [diff] [blame] | 254 | // Heads-up displays for touch events. These HUDs are not owned by the root |
| 255 | // window controller and manage their own lifetimes. |
| 256 | TouchHudDebug* touch_hud_debug_; |
| 257 | TouchHudProjection* touch_hud_projection_; |
[email protected] | 5817504 | 2013-04-01 19:27:13 | [diff] [blame] | 258 | |
[email protected] | a4cd6d3 | 2012-09-12 03:42:13 | [diff] [blame] | 259 | // We need to own event handlers for various containers. |
| 260 | scoped_ptr<ToplevelWindowEventHandler> default_container_handler_; |
| 261 | scoped_ptr<ToplevelWindowEventHandler> always_on_top_container_handler_; |
| 262 | scoped_ptr<ToplevelWindowEventHandler> modal_container_handler_; |
| 263 | scoped_ptr<ToplevelWindowEventHandler> lock_modal_container_handler_; |
[email protected] | 58202205 | 2013-02-20 15:19:04 | [diff] [blame] | 264 | scoped_ptr<ToplevelWindowEventHandler> panel_container_handler_; |
[email protected] | beb4e5c | 2013-06-18 15:37:07 | [diff] [blame] | 265 | scoped_ptr<ToplevelWindowEventHandler> docked_container_handler_; |
[email protected] | a4cd6d3 | 2012-09-12 03:42:13 | [diff] [blame] | 266 | |
[email protected] | 0bf6173 | 2013-07-02 04:35:10 | [diff] [blame] | 267 | scoped_ptr<DesktopBackgroundWidgetController> wallpaper_controller_; |
| 268 | scoped_ptr<AnimatingDesktopController> animating_wallpaper_controller_; |
| 269 | |
[email protected] | d90b839 | 2012-06-13 09:34:56 | [diff] [blame] | 270 | DISALLOW_COPY_AND_ASSIGN(RootWindowController); |
| 271 | }; |
| 272 | |
| 273 | } // namespace internal |
| 274 | } // ash |
| 275 | |
| 276 | #endif // ASH_ROOT_WINDOW_CONTROLLER_H_ |