[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] | c0ce80e | 2012-10-05 23:28:27 | [diff] [blame] | 8 | #include "ash/ash_export.h" |
[email protected] | ef80e430 | 2012-12-04 19:37:31 | [diff] [blame] | 9 | #include "ash/shelf_types.h" |
[email protected] | 16059276d | 2012-10-22 18:59:50 | [diff] [blame] | 10 | #include "ash/system/user/login_status.h" |
[email protected] | d90b839 | 2012-06-13 09:34:56 | [diff] [blame] | 11 | #include "base/basictypes.h" |
12 | #include "base/memory/scoped_ptr.h" | ||||
13 | |||||
14 | class SkBitmap; | ||||
15 | |||||
16 | namespace aura { | ||||
17 | class EventFilter; | ||||
18 | class RootWindow; | ||||
19 | class Window; | ||||
[email protected] | 4a59e4e | 2012-11-12 21:15:40 | [diff] [blame] | 20 | } |
21 | |||||
22 | namespace gfx { | ||||
23 | class Point; | ||||
24 | } | ||||
25 | |||||
26 | namespace views { | ||||
27 | namespace corewm { | ||||
[email protected] | d90b839 | 2012-06-13 09:34:56 | [diff] [blame] | 28 | class InputMethodEventFilter; |
29 | class RootWindowEventFilter; | ||||
[email protected] | 4a59e4e | 2012-11-12 21:15:40 | [diff] [blame] | 30 | } |
31 | } | ||||
[email protected] | d90b839 | 2012-06-13 09:34:56 | [diff] [blame] | 32 | |
33 | namespace ash { | ||||
[email protected] | e74aaf0a | 2012-10-12 18:42:28 | [diff] [blame] | 34 | class Launcher; |
[email protected] | a0afeb1 | 2012-12-10 22:57:09 | [diff] [blame^] | 35 | class SystemTray; |
[email protected] | a4cd6d3 | 2012-09-12 03:42:13 | [diff] [blame] | 36 | class ToplevelWindowEventHandler; |
[email protected] | e74aaf0a | 2012-10-12 18:42:28 | [diff] [blame] | 37 | |
[email protected] | d90b839 | 2012-06-13 09:34:56 | [diff] [blame] | 38 | namespace internal { |
39 | |||||
[email protected] | bca9a7e | 2012-11-10 06:25:49 | [diff] [blame] | 40 | class BootSplashScreen; |
[email protected] | e74aaf0a | 2012-10-12 18:42:28 | [diff] [blame] | 41 | class PanelLayoutManager; |
[email protected] | d90b839 | 2012-06-13 09:34:56 | [diff] [blame] | 42 | class RootWindowLayoutManager; |
43 | class ScreenDimmer; | ||||
[email protected] | e74aaf0a | 2012-10-12 18:42:28 | [diff] [blame] | 44 | class ShelfLayoutManager; |
45 | class StatusAreaWidget; | ||||
46 | class SystemBackgroundController; | ||||
[email protected] | c0ce80e | 2012-10-05 23:28:27 | [diff] [blame] | 47 | class SystemModalContainerLayoutManager; |
[email protected] | d90b839 | 2012-06-13 09:34:56 | [diff] [blame] | 48 | class WorkspaceController; |
49 | |||||
50 | // This class maintains the per root window state for ash. This class | ||||
51 | // owns the root window and other dependent objects that should be | ||||
52 | // deleted upon the deletion of the root window. The RootWindowController | ||||
53 | // for particular root window is stored as a property and can be obtained | ||||
54 | // using |GetRootWindowController(aura::RootWindow*)| function. | ||||
[email protected] | c0ce80e | 2012-10-05 23:28:27 | [diff] [blame] | 55 | class ASH_EXPORT RootWindowController { |
[email protected] | d90b839 | 2012-06-13 09:34:56 | [diff] [blame] | 56 | public: |
57 | explicit RootWindowController(aura::RootWindow* root_window); | ||||
58 | ~RootWindowController(); | ||||
59 | |||||
[email protected] | 88d7112 | 2012-10-18 07:11:01 | [diff] [blame] | 60 | // Returns a RootWindowController that has a launcher for given |
61 | // |window|. This returns the RootWindowController for the |window|'s | ||||
62 | // root window when multiple launcher mode is enabled, or the primary | ||||
63 | // RootWindowController otherwise. | ||||
64 | static RootWindowController* ForLauncher(aura::Window* window); | ||||
65 | |||||
[email protected] | a0afeb1 | 2012-12-10 22:57:09 | [diff] [blame^] | 66 | // Returns a RootWindowController of the window's root window. |
67 | static RootWindowController* ForWindow(aura::Window* window); | ||||
68 | |||||
69 | // Returns the RootWindowController of the active root window. | ||||
70 | static internal::RootWindowController* ForActiveRootWindow(); | ||||
71 | |||||
[email protected] | e74aaf0a | 2012-10-12 18:42:28 | [diff] [blame] | 72 | aura::RootWindow* root_window() { return root_window_.get(); } |
[email protected] | d90b839 | 2012-06-13 09:34:56 | [diff] [blame] | 73 | |
[email protected] | e74aaf0a | 2012-10-12 18:42:28 | [diff] [blame] | 74 | RootWindowLayoutManager* root_window_layout() { return root_window_layout_; } |
[email protected] | d90b839 | 2012-06-13 09:34:56 | [diff] [blame] | 75 | |
[email protected] | c0ce80e | 2012-10-05 23:28:27 | [diff] [blame] | 76 | WorkspaceController* workspace_controller() { |
[email protected] | d90b839 | 2012-06-13 09:34:56 | [diff] [blame] | 77 | return workspace_controller_.get(); |
78 | } | ||||
79 | |||||
[email protected] | e74aaf0a | 2012-10-12 18:42:28 | [diff] [blame] | 80 | ScreenDimmer* screen_dimmer() { return screen_dimmer_.get(); } |
81 | |||||
82 | Launcher* launcher() { return launcher_.get(); } | ||||
83 | |||||
[email protected] | 88d7112 | 2012-10-18 07:11:01 | [diff] [blame] | 84 | ShelfLayoutManager* shelf() const { return shelf_; } |
[email protected] | e74aaf0a | 2012-10-12 18:42:28 | [diff] [blame] | 85 | |
[email protected] | a0afeb1 | 2012-12-10 22:57:09 | [diff] [blame^] | 86 | StatusAreaWidget* status_area_widget() { |
[email protected] | e74aaf0a | 2012-10-12 18:42:28 | [diff] [blame] | 87 | return status_area_widget_; |
[email protected] | d90b839 | 2012-06-13 09:34:56 | [diff] [blame] | 88 | } |
89 | |||||
[email protected] | a0afeb1 | 2012-12-10 22:57:09 | [diff] [blame^] | 90 | // Returns the system tray on this root window. Note that |
91 | // calling this on the root window that doesn't have a launcher will | ||||
92 | // lead to a crash. | ||||
93 | SystemTray* GetSystemTray(); | ||||
94 | |||||
[email protected] | 431552c | 2012-10-23 00:38:33 | [diff] [blame] | 95 | // Shows context menu at the |location_in_screen|. This uses |
96 | // |ShellDelegate::CreateContextMenu| to define the content of the menu. | ||||
97 | void ShowContextMenu(const gfx::Point& location_in_screen); | ||||
98 | |||||
[email protected] | 8674b31 | 2012-10-12 19:02:44 | [diff] [blame] | 99 | // Returns the layout-manager for the appropriate modal-container. If the |
100 | // window is inside the lockscreen modal container, then the layout manager | ||||
101 | // for that is returned. Otherwise the layout manager for the default modal | ||||
102 | // container is returned. | ||||
103 | // If no window is specified (i.e. |window| is NULL), then the lockscreen | ||||
104 | // modal container is used if the screen is currently locked. Otherwise, the | ||||
105 | // default modal container is used. | ||||
106 | SystemModalContainerLayoutManager* GetSystemModalLayoutManager( | ||||
107 | aura::Window* window); | ||||
[email protected] | c0ce80e | 2012-10-05 23:28:27 | [diff] [blame] | 108 | |
[email protected] | d90b839 | 2012-06-13 09:34:56 | [diff] [blame] | 109 | aura::Window* GetContainer(int container_id); |
110 | |||||
[email protected] | d90b839 | 2012-06-13 09:34:56 | [diff] [blame] | 111 | void InitLayoutManagers(); |
[email protected] | 697f04c | 2012-10-03 01:15:10 | [diff] [blame] | 112 | void CreateContainers(); |
113 | |||||
[email protected] | e74aaf0a | 2012-10-12 18:42:28 | [diff] [blame] | 114 | // Initializs the RootWindowController for primary display. This |
115 | // creates | ||||
116 | void InitForPrimaryDisplay(); | ||||
117 | |||||
[email protected] | bca9a7e | 2012-11-10 06:25:49 | [diff] [blame] | 118 | // Initializes |system_background_| and possibly also |boot_splash_screen_|. |
119 | // |is_first_run_after_boot| determines the background's initial color. | ||||
[email protected] | 697f04c | 2012-10-03 01:15:10 | [diff] [blame] | 120 | void CreateSystemBackground(bool is_first_run_after_boot); |
121 | |||||
[email protected] | e74aaf0a | 2012-10-12 18:42:28 | [diff] [blame] | 122 | // Initializes |launcher_|. Does nothing if it's already initialized. |
123 | void CreateLauncher(); | ||||
124 | |||||
125 | // Show launcher view if it was created hidden (before session has started). | ||||
126 | void ShowLauncher(); | ||||
127 | |||||
[email protected] | 16059276d | 2012-10-22 18:59:50 | [diff] [blame] | 128 | // Called when the user logs in. |
129 | void OnLoginStateChanged(user::LoginStatus status); | ||||
130 | |||||
131 | // Called when the login status changes after login (such as lock/unlock). | ||||
132 | // TODO(oshima): Investigate if we can merge this and |OnLoginStateChanged|. | ||||
133 | void UpdateAfterLoginStatusChange(user::LoginStatus status); | ||||
134 | |||||
[email protected] | bca9a7e | 2012-11-10 06:25:49 | [diff] [blame] | 135 | // Called when the brightness/grayscale animation from white to the login |
136 | // desktop background image has started. Starts |boot_splash_screen_|'s | ||||
137 | // hiding animation (if the screen is non-NULL). | ||||
138 | void HandleInitialDesktopBackgroundAnimationStarted(); | ||||
139 | |||||
140 | // Called when the login background is fully visible. Updates |background_| | ||||
141 | // to be black and drops |boot_splash_screen_|. | ||||
[email protected] | 697f04c | 2012-10-03 01:15:10 | [diff] [blame] | 142 | void HandleDesktopBackgroundVisible(); |
[email protected] | d90b839 | 2012-06-13 09:34:56 | [diff] [blame] | 143 | |
[email protected] | 6675e1c | 2012-09-11 09:15:45 | [diff] [blame] | 144 | // Deletes associated objects and clears the state, but doesn't delete |
145 | // the root window yet. This is used to delete a secondary displays' | ||||
146 | // root window safely when the display disconnect signal is received, | ||||
147 | // which may come while we're in the nested message loop. | ||||
148 | void Shutdown(); | ||||
149 | |||||
[email protected] | d90b839 | 2012-06-13 09:34:56 | [diff] [blame] | 150 | // Deletes all child windows and performs necessary cleanup. |
151 | void CloseChildWindows(); | ||||
152 | |||||
[email protected] | f185312 | 2012-06-27 16:21:26 | [diff] [blame] | 153 | // Moves child windows to |dest|. |
154 | void MoveWindowsTo(aura::RootWindow* dest); | ||||
155 | |||||
[email protected] | e74aaf0a | 2012-10-12 18:42:28 | [diff] [blame] | 156 | // Force the shelf to query for it's current visibility state. |
157 | void UpdateShelfVisibility(); | ||||
158 | |||||
159 | // Sets/gets the shelf auto-hide behavior. | ||||
160 | void SetShelfAutoHideBehavior(ShelfAutoHideBehavior behavior); | ||||
161 | ShelfAutoHideBehavior GetShelfAutoHideBehavior() const; | ||||
162 | |||||
163 | // Sets/gets the shelf alignemnt. | ||||
164 | bool SetShelfAlignment(ShelfAlignment alignment); | ||||
165 | ShelfAlignment GetShelfAlignment(); | ||||
166 | |||||
[email protected] | 431552c | 2012-10-23 00:38:33 | [diff] [blame] | 167 | private: |
[email protected] | a4cd6d3 | 2012-09-12 03:42:13 | [diff] [blame] | 168 | // Creates each of the special window containers that holds windows of various |
169 | // types in the shell UI. | ||||
170 | void CreateContainersInRootWindow(aura::RootWindow* root_window); | ||||
171 | |||||
[email protected] | d90b839 | 2012-06-13 09:34:56 | [diff] [blame] | 172 | scoped_ptr<aura::RootWindow> root_window_; |
[email protected] | c0ce80e | 2012-10-05 23:28:27 | [diff] [blame] | 173 | RootWindowLayoutManager* root_window_layout_; |
[email protected] | d90b839 | 2012-06-13 09:34:56 | [diff] [blame] | 174 | |
[email protected] | e74aaf0a | 2012-10-12 18:42:28 | [diff] [blame] | 175 | // Widget containing system tray. |
[email protected] | 88d7112 | 2012-10-18 07:11:01 | [diff] [blame] | 176 | StatusAreaWidget* status_area_widget_; |
[email protected] | e74aaf0a | 2012-10-12 18:42:28 | [diff] [blame] | 177 | |
178 | // The shelf for managing the launcher and the status widget. | ||||
179 | // RootWindowController does not own the shelf. Instead, it is owned | ||||
180 | // by container of the status area. | ||||
[email protected] | 88d7112 | 2012-10-18 07:11:01 | [diff] [blame] | 181 | ShelfLayoutManager* shelf_; |
[email protected] | e74aaf0a | 2012-10-12 18:42:28 | [diff] [blame] | 182 | |
183 | // Manages layout of panels. Owned by PanelContainer. | ||||
[email protected] | 88d7112 | 2012-10-18 07:11:01 | [diff] [blame] | 184 | PanelLayoutManager* panel_layout_manager_; |
[email protected] | e74aaf0a | 2012-10-12 18:42:28 | [diff] [blame] | 185 | |
186 | scoped_ptr<Launcher> launcher_; | ||||
187 | |||||
[email protected] | e6e41d2f | 2012-10-29 19:22:19 | [diff] [blame] | 188 | scoped_ptr<SystemBackgroundController> system_background_; |
[email protected] | bca9a7e | 2012-11-10 06:25:49 | [diff] [blame] | 189 | scoped_ptr<BootSplashScreen> boot_splash_screen_; |
[email protected] | 697f04c | 2012-10-03 01:15:10 | [diff] [blame] | 190 | |
[email protected] | c0ce80e | 2012-10-05 23:28:27 | [diff] [blame] | 191 | scoped_ptr<ScreenDimmer> screen_dimmer_; |
192 | scoped_ptr<WorkspaceController> workspace_controller_; | ||||
[email protected] | d90b839 | 2012-06-13 09:34:56 | [diff] [blame] | 193 | |
[email protected] | a4cd6d3 | 2012-09-12 03:42:13 | [diff] [blame] | 194 | // We need to own event handlers for various containers. |
195 | scoped_ptr<ToplevelWindowEventHandler> default_container_handler_; | ||||
196 | scoped_ptr<ToplevelWindowEventHandler> always_on_top_container_handler_; | ||||
197 | scoped_ptr<ToplevelWindowEventHandler> modal_container_handler_; | ||||
198 | scoped_ptr<ToplevelWindowEventHandler> lock_modal_container_handler_; | ||||
199 | |||||
[email protected] | d90b839 | 2012-06-13 09:34:56 | [diff] [blame] | 200 | DISALLOW_COPY_AND_ASSIGN(RootWindowController); |
201 | }; | ||||
202 | |||||
203 | } // namespace internal | ||||
204 | } // ash | ||||
205 | |||||
206 | #endif // ASH_ROOT_WINDOW_CONTROLLER_H_ |