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 "ash/ash_export.h"
9 #include "ash/shelf/shelf_types.h"
10 #include "ash/system/user/login_status.h"
11 #include "base/basictypes.h"
12 #include "base/memory/scoped_ptr.h"
28 class InputMethodEventFilter
;
29 class RootWindowEventFilter
;
34 class KeyboardController
;
38 class StackingController
;
41 class ToplevelWindowEventHandler
;
45 class BootSplashScreen
;
46 class PanelLayoutManager
;
47 class RootWindowLayoutManager
;
49 class ShelfLayoutManager
;
50 class StatusAreaWidget
;
51 class SystemBackgroundController
;
52 class SystemModalContainerLayoutManager
;
53 class TouchObserverHUD
;
54 class WorkspaceController
;
56 // This class maintains the per root window state for ash. This class
57 // owns the root window and other dependent objects that should be
58 // deleted upon the deletion of the root window. The RootWindowController
59 // for particular root window is stored as a property and can be obtained
60 // using |GetRootWindowController(aura::RootWindow*)| function.
61 class ASH_EXPORT RootWindowController
{
63 explicit RootWindowController(aura::RootWindow
* root_window
);
64 ~RootWindowController();
66 // Returns a RootWindowController that has a launcher for given
67 // |window|. This returns the RootWindowController for the |window|'s
68 // root window when multiple launcher mode is enabled, or the primary
69 // RootWindowController otherwise.
70 static RootWindowController
* ForLauncher(aura::Window
* window
);
72 // Returns a RootWindowController of the window's root window.
73 static RootWindowController
* ForWindow(const aura::Window
* window
);
75 // Returns the RootWindowController of the active root window.
76 static internal::RootWindowController
* ForActiveRootWindow();
78 aura::RootWindow
* root_window() { return root_window_
.get(); }
80 RootWindowLayoutManager
* root_window_layout() { return root_window_layout_
; }
82 WorkspaceController
* workspace_controller() {
83 return workspace_controller_
.get();
86 ScreenDimmer
* screen_dimmer() { return screen_dimmer_
.get(); }
88 // Access the shelf associated with this root window controller,
89 // NULL if no such shelf exists.
90 ShelfWidget
* shelf() { return shelf_
.get(); }
92 TouchObserverHUD
* touch_observer_hud() { return touch_observer_hud_
; }
94 // Sets the touch HUD. The RootWindowController will not own this HUD; its
95 // lifetime is managed by itself.
96 void set_touch_observer_hud(TouchObserverHUD
* hud
) {
97 touch_observer_hud_
= hud
;
99 // Access the shelf layout manager associated with this root
100 // window controller, NULL if no such shelf exists.
101 ShelfLayoutManager
* GetShelfLayoutManager();
103 // Returns the system tray on this root window. Note that
104 // calling this on the root window that doesn't have a launcher will
106 SystemTray
* GetSystemTray();
108 // Shows context menu at the |location_in_screen|. This uses
109 // |ShellDelegate::CreateContextMenu| to define the content of the menu.
110 void ShowContextMenu(const gfx::Point
& location_in_screen
);
112 // Returns the layout-manager for the appropriate modal-container. If the
113 // window is inside the lockscreen modal container, then the layout manager
114 // for that is returned. Otherwise the layout manager for the default modal
115 // container is returned.
116 // If no window is specified (i.e. |window| is NULL), then the lockscreen
117 // modal container is used if the screen is currently locked. Otherwise, the
118 // default modal container is used.
119 SystemModalContainerLayoutManager
* GetSystemModalLayoutManager(
120 aura::Window
* window
);
122 aura::Window
* GetContainer(int container_id
);
124 void InitLayoutManagers();
125 void CreateContainers();
127 // Initializs the RootWindowController for primary display. This
129 void InitForPrimaryDisplay();
131 // Initializes |system_background_| and possibly also |boot_splash_screen_|.
132 // |is_first_run_after_boot| determines the background's initial color.
133 void CreateSystemBackground(bool is_first_run_after_boot
);
135 // Show launcher view if it was created hidden (before session has started).
138 // Called when the launcher associated with this root window is created.
139 void OnLauncherCreated();
141 // Called when the user logs in.
142 void OnLoginStateChanged(user::LoginStatus status
);
144 // Called when the login status changes after login (such as lock/unlock).
145 // TODO(oshima): Investigate if we can merge this and |OnLoginStateChanged|.
146 void UpdateAfterLoginStatusChange(user::LoginStatus status
);
148 // Called when the brightness/grayscale animation from white to the login
149 // desktop background image has started. Starts |boot_splash_screen_|'s
150 // hiding animation (if the screen is non-NULL).
151 void HandleInitialDesktopBackgroundAnimationStarted();
153 // Called when the login background is fully visible. Updates |background_|
154 // to be black and drops |boot_splash_screen_|.
155 void HandleDesktopBackgroundVisible();
157 // Deletes associated objects and clears the state, but doesn't delete
158 // the root window yet. This is used to delete a secondary displays'
159 // root window safely when the display disconnect signal is received,
160 // which may come while we're in the nested message loop.
163 // Deletes all child windows and performs necessary cleanup.
164 void CloseChildWindows();
166 // Moves child windows to |dest|.
167 void MoveWindowsTo(aura::RootWindow
* dest
);
169 // Force the shelf to query for it's current visibility state.
170 void UpdateShelfVisibility();
172 // Returns true if the active workspace is in immersive mode. Exposed here
173 // so clients of Ash don't need to know the details of workspace management.
174 bool IsImmersiveMode() const;
177 // Creates each of the special window containers that holds windows of various
178 // types in the shell UI.
179 void CreateContainersInRootWindow(aura::RootWindow
* root_window
);
181 // Initializes the virtual keyboard.
184 scoped_ptr
<aura::RootWindow
> root_window_
;
185 RootWindowLayoutManager
* root_window_layout_
;
187 scoped_ptr
<StackingController
> stacking_controller_
;
189 scoped_ptr
<keyboard::KeyboardController
> keyboard_controller_
;
191 // The shelf for managing the launcher and the status widget.
192 scoped_ptr
<ShelfWidget
> shelf_
;
194 // Manages layout of panels. Owned by PanelContainer.
195 PanelLayoutManager
* panel_layout_manager_
;
197 scoped_ptr
<SystemBackgroundController
> system_background_
;
198 scoped_ptr
<BootSplashScreen
> boot_splash_screen_
;
200 scoped_ptr
<ScreenDimmer
> screen_dimmer_
;
201 scoped_ptr
<WorkspaceController
> workspace_controller_
;
203 // Heads-up display for touch events. The RootWindowController does not own
204 // this HUD; its lifetime is managed by itself.
205 TouchObserverHUD
* touch_observer_hud_
;
207 // We need to own event handlers for various containers.
208 scoped_ptr
<ToplevelWindowEventHandler
> default_container_handler_
;
209 scoped_ptr
<ToplevelWindowEventHandler
> always_on_top_container_handler_
;
210 scoped_ptr
<ToplevelWindowEventHandler
> modal_container_handler_
;
211 scoped_ptr
<ToplevelWindowEventHandler
> lock_modal_container_handler_
;
212 scoped_ptr
<ToplevelWindowEventHandler
> panel_container_handler_
;
214 DISALLOW_COPY_AND_ASSIGN(RootWindowController
);
217 } // namespace internal
220 #endif // ASH_ROOT_WINDOW_CONTROLLER_H_