OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef ASH_SHELL_H_ | 5 #ifndef ASH_SHELL_H_ |
6 #define ASH_SHELL_H_ | 6 #define ASH_SHELL_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <utility> | 9 #include <utility> |
10 #include <vector> | 10 #include <vector> |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
69 class WorkspaceController; | 69 class WorkspaceController; |
70 } | 70 } |
71 | 71 |
72 // Shell is a singleton object that presents the Shell API and implements the | 72 // Shell is a singleton object that presents the Shell API and implements the |
73 // RootWindow's delegate interface. | 73 // RootWindow's delegate interface. |
74 // | 74 // |
75 // Upon creation, the Shell sets itself as the RootWindow's delegate, which | 75 // Upon creation, the Shell sets itself as the RootWindow's delegate, which |
76 // takes ownership of the Shell. | 76 // takes ownership of the Shell. |
77 class ASH_EXPORT Shell { | 77 class ASH_EXPORT Shell { |
78 public: | 78 public: |
79 // In compact window mode we fill the screen with a single maximized window, | |
80 // similar to ChromeOS R17 and earlier. In managed mode we have overlapping | |
81 // windows arranged by the workspace. | |
82 enum WindowMode { | |
83 MODE_COMPACT, | |
84 MODE_MANAGED, | |
85 }; | |
86 | |
87 enum BackgroundMode { | 79 enum BackgroundMode { |
88 BACKGROUND_IMAGE, | 80 BACKGROUND_IMAGE, |
89 BACKGROUND_SOLID_COLOR | 81 BACKGROUND_SOLID_COLOR |
90 }; | 82 }; |
91 | 83 |
92 enum Direction { | 84 enum Direction { |
93 FORWARD, | 85 FORWARD, |
94 BACKWARD | 86 BACKWARD |
95 }; | 87 }; |
96 | 88 |
97 // Accesses private data from a Shell for testing. | 89 // Accesses private data from a Shell for testing. |
98 class ASH_EXPORT TestApi { | 90 class ASH_EXPORT TestApi { |
99 public: | 91 public: |
100 explicit TestApi(Shell* shell); | 92 explicit TestApi(Shell* shell); |
101 | 93 |
102 WindowMode ComputeWindowMode(CommandLine* cmd) const; | |
103 internal::RootWindowLayoutManager* root_window_layout(); | 94 internal::RootWindowLayoutManager* root_window_layout(); |
104 internal::InputMethodEventFilter* input_method_event_filter(); | 95 internal::InputMethodEventFilter* input_method_event_filter(); |
105 internal::WorkspaceController* workspace_controller(); | 96 internal::WorkspaceController* workspace_controller(); |
106 | 97 |
107 private: | 98 private: |
108 Shell* shell_; // not owned | 99 Shell* shell_; // not owned |
109 | 100 |
110 DISALLOW_COPY_AND_ASSIGN(TestApi); | 101 DISALLOW_COPY_AND_ASSIGN(TestApi); |
111 }; | 102 }; |
112 | 103 |
113 // A shell must be explicitly created so that it can call |Init()| with the | 104 // A shell must be explicitly created so that it can call |Init()| with the |
114 // delegate set. |delegate| can be NULL (if not required for initialization). | 105 // delegate set. |delegate| can be NULL (if not required for initialization). |
115 static Shell* CreateInstance(ShellDelegate* delegate); | 106 static Shell* CreateInstance(ShellDelegate* delegate); |
116 | 107 |
117 // Should never be called before |CreateInstance()|. | 108 // Should never be called before |CreateInstance()|. |
118 static Shell* GetInstance(); | 109 static Shell* GetInstance(); |
119 | 110 |
120 // Returns true if the ash shell has been instantiated. | 111 // Returns true if the ash shell has been instantiated. |
121 static bool HasInstance(); | 112 static bool HasInstance(); |
122 | 113 |
123 static void DeleteInstance(); | 114 static void DeleteInstance(); |
124 | 115 |
125 // Get the singleton RootWindow used by the Shell. | 116 // Get the singleton RootWindow used by the Shell. |
126 static aura::RootWindow* GetRootWindow(); | 117 static aura::RootWindow* GetRootWindow(); |
127 | 118 |
128 const gfx::Size& compact_status_area_offset() const { | |
129 return compact_status_area_offset_; | |
130 } | |
131 | |
132 BackgroundMode desktop_background_mode() const { | 119 BackgroundMode desktop_background_mode() const { |
133 return desktop_background_mode_; | 120 return desktop_background_mode_; |
134 } | 121 } |
135 | 122 |
136 aura::Window* GetContainer(int container_id); | 123 aura::Window* GetContainer(int container_id); |
137 const aura::Window* GetContainer(int container_id) const; | 124 const aura::Window* GetContainer(int container_id) const; |
138 | 125 |
139 // Adds or removes |filter| from the RootWindowEventFilter. | 126 // Adds or removes |filter| from the RootWindowEventFilter. |
140 void AddRootWindowEventFilter(aura::EventFilter* filter); | 127 void AddRootWindowEventFilter(aura::EventFilter* filter); |
141 void RemoveRootWindowEventFilter(aura::EventFilter* filter); | 128 void RemoveRootWindowEventFilter(aura::EventFilter* filter); |
142 size_t GetRootWindowEventFilterCount() const; | 129 size_t GetRootWindowEventFilterCount() const; |
143 | 130 |
144 // Shows the background menu over |widget|. | 131 // Shows the background menu over |widget|. |
145 void ShowBackgroundMenu(views::Widget* widget, const gfx::Point& location); | 132 void ShowBackgroundMenu(views::Widget* widget, const gfx::Point& location); |
146 | 133 |
147 // Toggles app list. | 134 // Toggles app list. |
148 void ToggleAppList(); | 135 void ToggleAppList(); |
149 | 136 |
150 // Sets the desktop background mode. | 137 // Sets the desktop background mode. |
151 void SetDesktopBackgroundMode(BackgroundMode mode); | 138 void SetDesktopBackgroundMode(BackgroundMode mode); |
152 | 139 |
153 // Returns true if the screen is locked. | 140 // Returns true if the screen is locked. |
154 bool IsScreenLocked() const; | 141 bool IsScreenLocked() const; |
155 | 142 |
156 // Returns true if a modal dialog window is currently open. | 143 // Returns true if a modal dialog window is currently open. |
157 bool IsModalWindowOpen() const; | 144 bool IsModalWindowOpen() const; |
158 | 145 |
159 // See enum WindowMode for details. | |
160 bool IsWindowModeCompact() const { return window_mode_ == MODE_COMPACT; } | |
161 | |
162 // Sets the offset between the corner of the status area and the corner of the | |
163 // screen when we're using the compact window mode. | |
164 void SetCompactStatusAreaOffset(gfx::Size& offset); | |
165 | |
166 // Creates a default views::NonClientFrameView for use by windows in the | 146 // Creates a default views::NonClientFrameView for use by windows in the |
167 // Ash environment. | 147 // Ash environment. |
168 views::NonClientFrameView* CreateDefaultNonClientFrameView( | 148 views::NonClientFrameView* CreateDefaultNonClientFrameView( |
169 views::Widget* widget); | 149 views::Widget* widget); |
170 | 150 |
171 // Rotate focus through containers that can recieve focus. | 151 // Rotate focus through containers that can receive focus. |
172 void RotateFocus(Direction direction); | 152 void RotateFocus(Direction direction); |
173 | 153 |
174 #if !defined(OS_MACOSX) | 154 #if !defined(OS_MACOSX) |
175 AcceleratorController* accelerator_controller() { | 155 AcceleratorController* accelerator_controller() { |
176 return accelerator_controller_.get(); | 156 return accelerator_controller_.get(); |
177 } | 157 } |
178 #endif // !defined(OS_MACOSX) | 158 #endif // !defined(OS_MACOSX) |
179 | 159 |
180 internal::RootWindowEventFilter* root_filter() { | 160 internal::RootWindowEventFilter* root_filter() { |
181 return root_filter_; | 161 return root_filter_; |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
230 FRIEND_TEST_ALL_PREFIXES(RootWindowEventFilterTest, MouseEventCursors); | 210 FRIEND_TEST_ALL_PREFIXES(RootWindowEventFilterTest, MouseEventCursors); |
231 FRIEND_TEST_ALL_PREFIXES(RootWindowEventFilterTest, TransformActivate); | 211 FRIEND_TEST_ALL_PREFIXES(RootWindowEventFilterTest, TransformActivate); |
232 | 212 |
233 typedef std::pair<aura::Window*, gfx::Rect> WindowAndBoundsPair; | 213 typedef std::pair<aura::Window*, gfx::Rect> WindowAndBoundsPair; |
234 | 214 |
235 explicit Shell(ShellDelegate* delegate); | 215 explicit Shell(ShellDelegate* delegate); |
236 virtual ~Shell(); | 216 virtual ~Shell(); |
237 | 217 |
238 void Init(); | 218 void Init(); |
239 | 219 |
240 // Returns the appropriate window mode to use based on the |command_line|. | 220 // Initializes the layout managers and event filters. |
241 WindowMode ComputeWindowMode(CommandLine* command_line) const; | 221 void InitLayoutManagers(); |
242 | |
243 // Initializes or re-initializes the layout managers and event filters needed | |
244 // to support a given window mode and cleans up the unneeded ones. | |
245 void SetupCompactWindowMode(); | |
246 void SetupManagedWindowMode(); | |
247 | |
248 // Sets the LayoutManager of the container with the specified id to NULL. This | |
249 // has the effect of deleting the current LayoutManager. | |
250 void ResetLayoutManager(int container_id); | |
251 | 222 |
252 // Disables the workspace grid layout. | 223 // Disables the workspace grid layout. |
253 void DisableWorkspaceGridLayout(); | 224 void DisableWorkspaceGridLayout(); |
254 | 225 |
255 static Shell* instance_; | 226 static Shell* instance_; |
256 | 227 |
257 // If set before the Shell is initialized, the mouse cursor will be hidden | 228 // If set before the Shell is initialized, the mouse cursor will be hidden |
258 // when the screen is initially created. | 229 // when the screen is initially created. |
259 static bool initially_hide_cursor_; | 230 static bool initially_hide_cursor_; |
260 | 231 |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
305 #if !defined(OS_MACOSX) | 276 #if !defined(OS_MACOSX) |
306 // An event filter that pre-handles global accelerators. | 277 // An event filter that pre-handles global accelerators. |
307 scoped_ptr<internal::AcceleratorFilter> accelerator_filter_; | 278 scoped_ptr<internal::AcceleratorFilter> accelerator_filter_; |
308 #endif | 279 #endif |
309 | 280 |
310 // The shelf for managing the launcher and the status widget in non-compact | 281 // The shelf for managing the launcher and the status widget in non-compact |
311 // mode. Shell does not own the shelf. Instead, it is owned by container of | 282 // mode. Shell does not own the shelf. Instead, it is owned by container of |
312 // the status area. | 283 // the status area. |
313 internal::ShelfLayoutManager* shelf_; | 284 internal::ShelfLayoutManager* shelf_; |
314 | 285 |
315 // Does not change after Init(). | |
316 WindowMode window_mode_; | |
317 | |
318 // Can change at runtime. | 286 // Can change at runtime. |
319 BackgroundMode desktop_background_mode_; | 287 BackgroundMode desktop_background_mode_; |
320 | 288 |
321 // Owned by aura::RootWindow, cached here for type safety. | 289 // Owned by aura::RootWindow, cached here for type safety. |
322 internal::RootWindowLayoutManager* root_window_layout_; | 290 internal::RootWindowLayoutManager* root_window_layout_; |
323 | 291 |
324 // Status area with clock, Wi-Fi signal, etc. | 292 // Status area with clock, Wi-Fi signal, etc. |
325 views::Widget* status_widget_; | 293 views::Widget* status_widget_; |
326 | 294 |
327 // System tray with clock, Wi-Fi signal, etc. (a replacement in progress for | 295 // System tray with clock, Wi-Fi signal, etc. (a replacement in progress for |
328 // |status_widget_|). | 296 // |status_widget_|). |
329 scoped_ptr<SystemTray> tray_; | 297 scoped_ptr<SystemTray> tray_; |
330 | 298 |
331 // Offset between the corner of the status area and the corner of the screen | |
332 // when in the compact window mode. | |
333 gfx::Size compact_status_area_offset_; | |
334 | |
335 DISALLOW_COPY_AND_ASSIGN(Shell); | 299 DISALLOW_COPY_AND_ASSIGN(Shell); |
336 }; | 300 }; |
337 | 301 |
338 } // namespace ash | 302 } // namespace ash |
339 | 303 |
340 #endif // ASH_SHELL_H_ | 304 #endif // ASH_SHELL_H_ |
OLD | NEW |