cc: Added inline to Tile::IsReadyToDraw
[chromium-blink-merge.git] / ash / root_window_controller.h
blobd57aaf8a1bd97b8bc746478a21b84ea161920551
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_
8 #include <map>
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"
18 class SkBitmap;
20 namespace aura {
21 class EventFilter;
22 class RootWindow;
23 class Window;
26 namespace gfx {
27 class Point;
30 namespace views {
31 class Widget;
33 namespace corewm {
34 class InputMethodEventFilter;
35 class RootWindowEventFilter;
36 class ScopedCaptureClient;
40 namespace keyboard {
41 class KeyboardController;
44 namespace ash {
45 class StackingController;
46 class ShelfWidget;
47 class SystemTray;
48 class ToplevelWindowEventHandler;
50 namespace internal {
52 class AlwaysOnTopController;
53 class AnimatingDesktopController;
54 class DesktopBackgroundWidgetController;
55 class DockedWindowLayoutManager;
56 class PanelLayoutManager;
57 class RootWindowLayoutManager;
58 class ScreenDimmer;
59 class ShelfLayoutManager;
60 class StatusAreaWidget;
61 class SystemBackgroundController;
62 class SystemModalContainerLayoutManager;
63 class TouchHudDebug;
64 class TouchHudProjection;
65 class WorkspaceController;
67 #if defined(USE_X11)
68 class BootSplashScreen;
69 #endif
71 // 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.
76 class ASH_EXPORT RootWindowController : public ShellObserver {
77 public:
78 explicit RootWindowController(aura::RootWindow* root_window);
79 virtual ~RootWindowController();
81 // 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);
87 // Returns a RootWindowController of the window's root window.
88 static RootWindowController* ForWindow(const aura::Window* window);
90 // Returns the RootWindowController of the active root window.
91 static internal::RootWindowController* ForActiveRootWindow();
93 aura::RootWindow* root_window() { return root_window_.get(); }
95 RootWindowLayoutManager* root_window_layout() { return root_window_layout_; }
97 WorkspaceController* workspace_controller() {
98 return workspace_controller_.get();
101 AlwaysOnTopController* always_on_top_controller() {
102 return always_on_top_controller_.get();
105 ScreenDimmer* screen_dimmer() { return screen_dimmer_.get(); }
107 // Access the shelf associated with this root window controller,
108 // NULL if no such shelf exists.
109 ShelfWidget* shelf() { return shelf_.get(); }
111 // Get touch HUDs associated with this root window controller.
112 TouchHudDebug* touch_hud_debug() const {
113 return touch_hud_debug_;
115 TouchHudProjection* touch_hud_projection() const {
116 return touch_hud_projection_;
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;
126 void set_touch_hud_projection(TouchHudProjection* hud) {
127 touch_hud_projection_ = hud;
130 DesktopBackgroundWidgetController* wallpaper_controller() {
131 return wallpaper_controller_.get();
133 void SetWallpaperController(DesktopBackgroundWidgetController* controller);
134 AnimatingDesktopController* animating_wallpaper_controller() {
135 return animating_wallpaper_controller_.get();
137 void SetAnimatingWallpaperController(AnimatingDesktopController* controller);
139 // Access the shelf layout manager associated with this root
140 // window controller, NULL if no such shelf exists.
141 ShelfLayoutManager* GetShelfLayoutManager();
143 // 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();
148 // Shows context menu at the |location_in_screen|. This uses
149 // |ShellDelegate::CreateContextMenu| to define the content of the menu.
150 void ShowContextMenu(const gfx::Point& location_in_screen,
151 ui::MenuSourceType source_type);
153 // 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);
163 aura::Window* GetContainer(int container_id);
164 const aura::Window* GetContainer(int container_id) const;
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);
170 // Show launcher view if it was created hidden (before session has started).
171 void ShowLauncher();
173 // Called when the launcher associated with this root window is created.
174 void OnLauncherCreated();
176 // 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);
180 // 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();
185 // 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);
191 // 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();
197 // Deletes all child windows and performs necessary cleanup.
198 void CloseChildWindows();
200 // Moves child windows to |dest|.
201 void MoveWindowsTo(aura::RootWindow* dest);
203 // Force the shelf to query for it's current visibility state.
204 void UpdateShelfVisibility();
206 // Initialize touch HUDs if necessary.
207 void InitTouchHuds();
209 // Returns the window, if any, which is in fullscreen mode in the active
210 // workspace. Exposed here so clients of Ash don't need to know the details
211 // of workspace management.
212 const aura::Window* GetFullscreenWindow() const;
214 private:
215 void InitLayoutManagers();
217 // Initializes |system_background_| and possibly also |boot_splash_screen_|.
218 // |is_first_run_after_boot| determines the background's initial color.
219 void CreateSystemBackground(bool is_first_run_after_boot);
221 // Creates each of the special window containers that holds windows of various
222 // types in the shell UI.
223 void CreateContainersInRootWindow(aura::RootWindow* root_window);
225 // Initializes the virtual keyboard.
226 void InitKeyboard();
228 // Enables projection touch HUD.
229 void EnableTouchHudProjection();
231 // Disables projection touch HUD.
232 void DisableTouchHudProjection();
234 // Overridden from ShellObserver.
235 virtual void OnLoginStateChanged(user::LoginStatus status) OVERRIDE;
236 virtual void OnTouchHudProjectionToggled(bool enabled) OVERRIDE;
238 scoped_ptr<aura::RootWindow> root_window_;
239 RootWindowLayoutManager* root_window_layout_;
241 scoped_ptr<StackingController> stacking_controller_;
243 scoped_ptr<keyboard::KeyboardController> keyboard_controller_;
245 // The shelf for managing the launcher and the status widget.
246 scoped_ptr<ShelfWidget> shelf_;
248 // 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_;
255 // Manages layout of docked windows. Owned by DockedContainer.
256 DockedWindowLayoutManager* docked_layout_manager_;
258 // Manages layout of panels. Owned by PanelContainer.
259 PanelLayoutManager* panel_layout_manager_;
261 scoped_ptr<SystemBackgroundController> system_background_;
262 #if defined(USE_X11)
263 scoped_ptr<BootSplashScreen> boot_splash_screen_;
264 #endif
266 scoped_ptr<ScreenDimmer> screen_dimmer_;
267 scoped_ptr<WorkspaceController> workspace_controller_;
268 scoped_ptr<AlwaysOnTopController> always_on_top_controller_;
270 // 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_;
275 // 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_;
280 scoped_ptr<ToplevelWindowEventHandler> panel_container_handler_;
281 scoped_ptr<ToplevelWindowEventHandler> docked_container_handler_;
283 scoped_ptr<DesktopBackgroundWidgetController> wallpaper_controller_;
284 scoped_ptr<AnimatingDesktopController> animating_wallpaper_controller_;
285 scoped_ptr<views::corewm::ScopedCaptureClient> capture_client_;
287 DISALLOW_COPY_AND_ASSIGN(RootWindowController);
290 } // namespace internal
291 } // ash
293 #endif // ASH_ROOT_WINDOW_CONTROLLER_H_