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.
5 #ifndef ASH_ROOT_WINDOW_CONTROLLER_H_
6 #define ASH_ROOT_WINDOW_CONTROLLER_H_
10 #include "ash/ash_export.h"
11 #include "ash/shelf/shelf_types.h"
12 #include "ash/shell_observer.h"
13 #include "ash/system/user/login_status.h"
14 #include "base/basictypes.h"
15 #include "base/memory/scoped_ptr.h"
16 #include "ui/base/ui_base_types.h"
34 class InputMethodEventFilter
;
35 class RootWindowEventFilter
;
40 class KeyboardController
;
44 class StackingController
;
47 class ToplevelWindowEventHandler
;
51 class AlwaysOnTopController
;
52 class AnimatingDesktopController
;
53 class BootSplashScreen
;
54 class DesktopBackgroundWidgetController
;
55 class DockedWindowLayoutManager
;
56 class PanelLayoutManager
;
57 class RootWindowLayoutManager
;
59 class ShelfLayoutManager
;
60 class StatusAreaWidget
;
61 class SystemBackgroundController
;
62 class SystemModalContainerLayoutManager
;
64 class TouchHudProjection
;
65 class WorkspaceController
;
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.
72 class ASH_EXPORT RootWindowController
: public ShellObserver
{
74 explicit RootWindowController(aura::RootWindow
* root_window
);
75 virtual ~RootWindowController();
77 // 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
);
83 // Returns a RootWindowController of the window's root window.
84 static RootWindowController
* ForWindow(const aura::Window
* window
);
86 // Returns the RootWindowController of the active root window.
87 static internal::RootWindowController
* ForActiveRootWindow();
89 aura::RootWindow
* root_window() { return root_window_
.get(); }
91 RootWindowLayoutManager
* root_window_layout() { return root_window_layout_
; }
93 WorkspaceController
* workspace_controller() {
94 return workspace_controller_
.get();
97 AlwaysOnTopController
* always_on_top_controller() {
98 return always_on_top_controller_
.get();
101 ScreenDimmer
* screen_dimmer() { return screen_dimmer_
.get(); }
103 // Access the shelf associated with this root window controller,
104 // NULL if no such shelf exists.
105 ShelfWidget
* shelf() { return shelf_
.get(); }
107 // Get touch HUDs associated with this root window controller.
108 TouchHudDebug
* touch_hud_debug() const {
109 return touch_hud_debug_
;
111 TouchHudProjection
* touch_hud_projection() const {
112 return touch_hud_projection_
;
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
;
122 void set_touch_hud_projection(TouchHudProjection
* hud
) {
123 touch_hud_projection_
= hud
;
126 DesktopBackgroundWidgetController
* wallpaper_controller() {
127 return wallpaper_controller_
.get();
129 void SetWallpaperController(DesktopBackgroundWidgetController
* controller
);
130 AnimatingDesktopController
* animating_wallpaper_controller() {
131 return animating_wallpaper_controller_
.get();
133 void SetAnimatingWallpaperController(AnimatingDesktopController
* controller
);
135 // Access the shelf layout manager associated with this root
136 // window controller, NULL if no such shelf exists.
137 ShelfLayoutManager
* GetShelfLayoutManager();
139 // Returns the system tray on this root window. Note that
140 // calling this on the root window that doesn't have a launcher will
142 SystemTray
* GetSystemTray();
144 // Shows context menu at the |location_in_screen|. This uses
145 // |ShellDelegate::CreateContextMenu| to define the content of the menu.
146 void ShowContextMenu(const gfx::Point
& location_in_screen
,
147 ui::MenuSourceType source_type
);
149 // 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
);
159 aura::Window
* GetContainer(int container_id
);
161 // Initializes the RootWindowController. |first_run_after_boot| is
162 // set to true only for primary root window after boot.
163 void Init(bool first_run_after_boot
);
165 // Show launcher view if it was created hidden (before session has started).
168 // Called when the launcher associated with this root window is created.
169 void OnLauncherCreated();
171 // Called when the login status changes after login (such as lock/unlock).
172 // TODO(oshima): Investigate if we can merge this and |OnLoginStateChanged|.
173 void UpdateAfterLoginStatusChange(user::LoginStatus status
);
175 // Called when the brightness/grayscale animation from white to the login
176 // desktop background image has started. Starts |boot_splash_screen_|'s
177 // hiding animation (if the screen is non-NULL).
178 void HandleInitialDesktopBackgroundAnimationStarted();
180 // Called when the wallpaper ainmation is finished. Updates |background_|
181 // to be black and drops |boot_splash_screen_| and moves the wallpaper
182 // controller into the root window controller. |widget| holds the wallpaper
183 // image, or NULL if the background is a solid color.
184 void OnWallpaperAnimationFinished(views::Widget
* widget
);
186 // Deletes associated objects and clears the state, but doesn't delete
187 // the root window yet. This is used to delete a secondary displays'
188 // root window safely when the display disconnect signal is received,
189 // which may come while we're in the nested message loop.
192 // Deletes all child windows and performs necessary cleanup.
193 void CloseChildWindows();
195 // Moves child windows to |dest|.
196 void MoveWindowsTo(aura::RootWindow
* dest
);
198 // Force the shelf to query for it's current visibility state.
199 void UpdateShelfVisibility();
201 // Initialize touch HUDs if necessary.
202 void InitTouchHuds();
204 // Returns the window, if any, which is in fullscreen mode in the active
205 // workspace. Exposed here so clients of Ash don't need to know the details
206 // of workspace management.
207 aura::Window
* GetFullscreenWindow() const;
210 void InitLayoutManagers();
212 // Initializes |system_background_| and possibly also |boot_splash_screen_|.
213 // |is_first_run_after_boot| determines the background's initial color.
214 void CreateSystemBackground(bool is_first_run_after_boot
);
216 // Creates each of the special window containers that holds windows of various
217 // types in the shell UI.
218 void CreateContainersInRootWindow(aura::RootWindow
* root_window
);
220 // Initializes the virtual keyboard.
223 // Enables projection touch HUD.
224 void EnableTouchHudProjection();
226 // Disables projection touch HUD.
227 void DisableTouchHudProjection();
229 // Overridden from ShellObserver.
230 virtual void OnLoginStateChanged(user::LoginStatus status
) OVERRIDE
;
231 virtual void OnTouchHudProjectionToggled(bool enabled
) OVERRIDE
;
233 scoped_ptr
<aura::RootWindow
> root_window_
;
234 RootWindowLayoutManager
* root_window_layout_
;
236 scoped_ptr
<StackingController
> stacking_controller_
;
238 scoped_ptr
<keyboard::KeyboardController
> keyboard_controller_
;
240 // The shelf for managing the launcher and the status widget.
241 scoped_ptr
<ShelfWidget
> shelf_
;
243 // Manages layout of docked windows. Owned by DockedContainer.
244 DockedWindowLayoutManager
* docked_layout_manager_
;
246 // Manages layout of panels. Owned by PanelContainer.
247 PanelLayoutManager
* panel_layout_manager_
;
249 scoped_ptr
<SystemBackgroundController
> system_background_
;
250 scoped_ptr
<BootSplashScreen
> boot_splash_screen_
;
252 scoped_ptr
<ScreenDimmer
> screen_dimmer_
;
253 scoped_ptr
<WorkspaceController
> workspace_controller_
;
254 scoped_ptr
<AlwaysOnTopController
> always_on_top_controller_
;
256 // Heads-up displays for touch events. These HUDs are not owned by the root
257 // window controller and manage their own lifetimes.
258 TouchHudDebug
* touch_hud_debug_
;
259 TouchHudProjection
* touch_hud_projection_
;
261 // We need to own event handlers for various containers.
262 scoped_ptr
<ToplevelWindowEventHandler
> default_container_handler_
;
263 scoped_ptr
<ToplevelWindowEventHandler
> always_on_top_container_handler_
;
264 scoped_ptr
<ToplevelWindowEventHandler
> modal_container_handler_
;
265 scoped_ptr
<ToplevelWindowEventHandler
> lock_modal_container_handler_
;
266 scoped_ptr
<ToplevelWindowEventHandler
> panel_container_handler_
;
267 scoped_ptr
<ToplevelWindowEventHandler
> docked_container_handler_
;
269 scoped_ptr
<DesktopBackgroundWidgetController
> wallpaper_controller_
;
270 scoped_ptr
<AnimatingDesktopController
> animating_wallpaper_controller_
;
272 DISALLOW_COPY_AND_ASSIGN(RootWindowController
);
275 } // namespace internal
278 #endif // ASH_ROOT_WINDOW_CONTROLLER_H_