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