blob: 2c00a5b0ab4655e38225fa4e90398608ccc39707 [file] [log] [blame]
[email protected]d90b8392012-06-13 09:34:561// 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#include "ash/root_window_controller.h"
6
[email protected]8d625fb2012-07-18 16:40:067#include <vector>
8
[email protected]e6e41d2f2012-10-29 19:22:199#include "ash/ash_switches.h"
[email protected]b4ddc7a2012-08-07 04:17:3210#include "ash/desktop_background/desktop_background_widget_controller.h"
[email protected]8d625fb2012-07-18 16:40:0611#include "ash/display/display_controller.h"
[email protected]6675e1c2012-09-11 09:15:4512#include "ash/display/multi_display_manager.h"
[email protected]e74aaf0a2012-10-12 18:42:2813#include "ash/focus_cycler.h"
[email protected]d90b8392012-06-13 09:34:5614#include "ash/shell.h"
[email protected]e74aaf0a2012-10-12 18:42:2815#include "ash/shell_delegate.h"
[email protected]d90b8392012-06-13 09:34:5616#include "ash/shell_factory.h"
17#include "ash/shell_window_ids.h"
[email protected]e74aaf0a2012-10-12 18:42:2818#include "ash/system/status_area_widget.h"
[email protected]8674b312012-10-12 19:02:4419#include "ash/system/tray/system_tray_delegate.h"
[email protected]d90b8392012-06-13 09:34:5620#include "ash/wm/base_layout_manager.h"
[email protected]e74aaf0a2012-10-12 18:42:2821#include "ash/wm/panel_layout_manager.h"
22#include "ash/wm/panel_window_event_filter.h"
[email protected]d90b8392012-06-13 09:34:5623#include "ash/wm/property_util.h"
24#include "ash/wm/root_window_layout_manager.h"
25#include "ash/wm/screen_dimmer.h"
[email protected]e74aaf0a2012-10-12 18:42:2826#include "ash/wm/shelf_layout_manager.h"
27#include "ash/wm/shelf_types.h"
28#include "ash/wm/status_area_layout_manager.h"
[email protected]e6e41d2f2012-10-29 19:22:1929#include "ash/wm/system_background_controller.h"
[email protected]d90b8392012-06-13 09:34:5630#include "ash/wm/system_modal_container_layout_manager.h"
[email protected]5dc51db82012-09-11 03:39:0131#include "ash/wm/toplevel_window_event_handler.h"
[email protected]d90b8392012-06-13 09:34:5632#include "ash/wm/visibility_controller.h"
[email protected]8d625fb2012-07-18 16:40:0633#include "ash/wm/window_properties.h"
[email protected]d90b8392012-06-13 09:34:5634#include "ash/wm/workspace_controller.h"
[email protected]e6e41d2f2012-10-29 19:22:1935#include "base/command_line.h"
[email protected]f1853122012-06-27 16:21:2636#include "ui/aura/client/activation_client.h"
37#include "ui/aura/client/aura_constants.h"
38#include "ui/aura/client/capture_client.h"
[email protected]d90b8392012-06-13 09:34:5639#include "ui/aura/client/tooltip_client.h"
[email protected]f1853122012-06-27 16:21:2640#include "ui/aura/focus_manager.h"
[email protected]d90b8392012-06-13 09:34:5641#include "ui/aura/root_window.h"
[email protected]f1853122012-06-27 16:21:2642#include "ui/aura/window.h"
43#include "ui/aura/window_observer.h"
[email protected]1d030242012-06-28 18:34:0844#include "ui/aura/window_tracker.h"
[email protected]431552c2012-10-23 00:38:3345#include "ui/base/models/menu_model.h"
[email protected]8d625fb2012-07-18 16:40:0646#include "ui/gfx/display.h"
47#include "ui/gfx/screen.h"
[email protected]431552c2012-10-23 00:38:3348#include "ui/views/controls/menu/menu_model_adapter.h"
49#include "ui/views/controls/menu/menu_runner.h"
50#include "ui/views/view_model.h"
51#include "ui/views/view_model_utils.h"
[email protected]d90b8392012-06-13 09:34:5652
53namespace ash {
54namespace {
55
56// Creates a new window for use as a container.
57aura::Window* CreateContainer(int window_id,
58 const char* name,
59 aura::Window* parent) {
60 aura::Window* container = new aura::Window(NULL);
61 container->set_id(window_id);
62 container->SetName(name);
63 container->Init(ui::LAYER_NOT_DRAWN);
64 parent->AddChild(container);
65 if (window_id != internal::kShellWindowId_UnparentedControlContainer)
66 container->Show();
67 return container;
68}
69
[email protected]95058572012-08-20 14:57:2970// Returns all the children of the workspace windows, eg the standard top-level
71// windows.
72std::vector<aura::Window*> GetWorkspaceWindows(aura::RootWindow* root) {
73 using aura::Window;
74
75 std::vector<Window*> windows;
76 Window* container = Shell::GetContainer(
77 root, internal::kShellWindowId_DefaultContainer);
78 for (Window::Windows::const_reverse_iterator i =
79 container->children().rbegin();
80 i != container->children().rend(); ++i) {
81 Window* workspace_window = *i;
82 if (workspace_window->id() == internal::kShellWindowId_WorkspaceContainer) {
83 windows.insert(windows.end(), workspace_window->children().begin(),
84 workspace_window->children().end());
85 }
86 }
87 return windows;
88}
89
90// Reparents |window| to |new_parent|.
91void ReparentWindow(aura::Window* window, aura::Window* new_parent) {
92 // Update the restore bounds to make it relative to the display.
93 gfx::Rect restore_bounds(GetRestoreBoundsInParent(window));
94 new_parent->AddChild(window);
95 if (!restore_bounds.IsEmpty())
96 SetRestoreBoundsInParent(window, restore_bounds);
97}
98
99// Reparents the appropriate set of windows from |src| to |dst|.
100void ReparentAllWindows(aura::RootWindow* src, aura::RootWindow* dst) {
101 // Set of windows to move.
[email protected]f1853122012-06-27 16:21:26102 const int kContainerIdsToMove[] = {
103 internal::kShellWindowId_DefaultContainer,
104 internal::kShellWindowId_AlwaysOnTopContainer,
105 internal::kShellWindowId_SystemModalContainer,
106 internal::kShellWindowId_LockSystemModalContainer,
[email protected]6274d312012-10-04 22:06:41107 internal::kShellWindowId_InputMethodContainer,
[email protected]f1853122012-06-27 16:21:26108 };
[email protected]95058572012-08-20 14:57:29109 // For Workspace2 we need to manually reparent the windows. This way
110 // Workspace2 can move the windows to the appropriate workspace.
[email protected]c96b9812012-10-17 16:04:04111 std::vector<aura::Window*> windows(GetWorkspaceWindows(src));
112 internal::WorkspaceController* workspace_controller =
113 GetRootWindowController(dst)->workspace_controller();
114 for (size_t i = 0; i < windows.size(); ++i) {
115 aura::Window* new_parent =
116 workspace_controller->GetParentForNewWindow(windows[i]);
117 ReparentWindow(windows[i], new_parent);
[email protected]95058572012-08-20 14:57:29118 }
[email protected]f1853122012-06-27 16:21:26119 for (size_t i = 0; i < arraysize(kContainerIdsToMove); i++) {
120 int id = kContainerIdsToMove[i];
[email protected]c96b9812012-10-17 16:04:04121 if (id == internal::kShellWindowId_DefaultContainer)
[email protected]95058572012-08-20 14:57:29122 continue;
123
[email protected]f1853122012-06-27 16:21:26124 aura::Window* src_container = Shell::GetContainer(src, id);
125 aura::Window* dst_container = Shell::GetContainer(dst, id);
126 aura::Window::Windows children = src_container->children();
127 for (aura::Window::Windows::iterator iter = children.begin();
128 iter != children.end(); ++iter) {
129 aura::Window* window = *iter;
130 // Don't move modal screen.
[email protected]c0ce80e2012-10-05 23:28:27131 if (internal::SystemModalContainerLayoutManager::IsModalBackground(
132 window))
[email protected]f1853122012-06-27 16:21:26133 continue;
[email protected]f059c6942012-07-21 14:27:57134
[email protected]95058572012-08-20 14:57:29135 ReparentWindow(window, dst_container);
[email protected]f1853122012-06-27 16:21:26136 }
137 }
138}
139
[email protected]8d625fb2012-07-18 16:40:06140// Mark the container window so that a widget added to this container will
141// use the virtual screeen coordinates instead of parent.
142void SetUsesScreenCoordinates(aura::Window* container) {
143 container->SetProperty(internal::kUsesScreenCoordinatesKey, true);
144}
145
[email protected]d90b8392012-06-13 09:34:56146} // namespace
147
148namespace internal {
149
150RootWindowController::RootWindowController(aura::RootWindow* root_window)
[email protected]e74aaf0a2012-10-12 18:42:28151 : root_window_(root_window),
152 root_window_layout_(NULL),
153 status_area_widget_(NULL),
154 shelf_(NULL),
155 panel_layout_manager_(NULL) {
[email protected]d90b8392012-06-13 09:34:56156 SetRootWindowController(root_window, this);
[email protected]c0ce80e2012-10-05 23:28:27157 screen_dimmer_.reset(new ScreenDimmer(root_window));
[email protected]d90b8392012-06-13 09:34:56158}
159
160RootWindowController::~RootWindowController() {
[email protected]6675e1c2012-09-11 09:15:45161 Shutdown();
162 root_window_.reset();
163}
164
[email protected]88d71122012-10-18 07:11:01165// static
166internal::RootWindowController*
167RootWindowController::ForLauncher(aura::Window* window) {
168 if (Shell::IsLauncherPerDisplayEnabled())
169 return GetRootWindowController(window->GetRootWindow());
170 else
171 return Shell::GetPrimaryRootWindowController();
172}
173
[email protected]6675e1c2012-09-11 09:15:45174void RootWindowController::Shutdown() {
175 CloseChildWindows();
[email protected]f634dd32012-07-23 22:49:07176 if (Shell::GetActiveRootWindow() == root_window_.get()) {
177 Shell::GetInstance()->set_active_root_window(
178 Shell::GetPrimaryRootWindow() == root_window_.get() ?
179 NULL : Shell::GetPrimaryRootWindow());
180 }
[email protected]d90b8392012-06-13 09:34:56181 SetRootWindowController(root_window_.get(), NULL);
[email protected]d90b8392012-06-13 09:34:56182 screen_dimmer_.reset();
183 workspace_controller_.reset();
[email protected]6675e1c2012-09-11 09:15:45184 // Forget with the display ID so that display lookup
185 // ends up with invalid display.
186 root_window_->ClearProperty(kDisplayIdKey);
187 // And this root window should no longer process events.
188 root_window_->PrepareForShutdown();
[email protected]e74aaf0a2012-10-12 18:42:28189
190 // Launcher widget has an InputMethodBridge that references to
191 // |input_method_filter_|'s |input_method_|. So explicitly release
192 // |launcher_| before |input_method_filter_|. And this needs to be
193 // after we delete all containers in case there are still live
194 // browser windows which access LauncherModel during close.
195 launcher_.reset();
[email protected]d90b8392012-06-13 09:34:56196}
197
[email protected]c0ce80e2012-10-05 23:28:27198SystemModalContainerLayoutManager*
[email protected]8674b312012-10-12 19:02:44199RootWindowController::GetSystemModalLayoutManager(aura::Window* window) {
200 aura::Window* container = NULL;
201 if (window) {
202 container = GetContainer(
203 kShellWindowId_LockSystemModalContainer);
204 if (!container->Contains(window))
205 container = GetContainer(kShellWindowId_SystemModalContainer);
206 } else {
207 user::LoginStatus login = Shell::GetInstance()->tray_delegate() ?
208 Shell::GetInstance()->tray_delegate()->GetUserLoginStatus() :
209 user::LOGGED_IN_NONE;
210 int modal_window_id = (login == user::LOGGED_IN_LOCKED ||
211 login == user::LOGGED_IN_NONE) ?
212 kShellWindowId_LockSystemModalContainer :
213 kShellWindowId_SystemModalContainer;
214 container = GetContainer(modal_window_id);
215 }
[email protected]c0ce80e2012-10-05 23:28:27216 return static_cast<SystemModalContainerLayoutManager*>(
[email protected]8674b312012-10-12 19:02:44217 container->layout_manager());
[email protected]c0ce80e2012-10-05 23:28:27218}
219
[email protected]d90b8392012-06-13 09:34:56220aura::Window* RootWindowController::GetContainer(int container_id) {
221 return root_window_->GetChildById(container_id);
222}
223
224void RootWindowController::InitLayoutManagers() {
225 root_window_layout_ =
[email protected]c0ce80e2012-10-05 23:28:27226 new RootWindowLayoutManager(root_window_.get());
[email protected]d90b8392012-06-13 09:34:56227 root_window_->SetLayoutManager(root_window_layout_);
228
229 aura::Window* default_container =
[email protected]c0ce80e2012-10-05 23:28:27230 GetContainer(kShellWindowId_DefaultContainer);
[email protected]d90b8392012-06-13 09:34:56231 // Workspace manager has its own layout managers.
232 workspace_controller_.reset(
[email protected]c0ce80e2012-10-05 23:28:27233 new WorkspaceController(default_container));
[email protected]d90b8392012-06-13 09:34:56234
235 aura::Window* always_on_top_container =
[email protected]c0ce80e2012-10-05 23:28:27236 GetContainer(kShellWindowId_AlwaysOnTopContainer);
[email protected]d90b8392012-06-13 09:34:56237 always_on_top_container->SetLayoutManager(
[email protected]c0ce80e2012-10-05 23:28:27238 new BaseLayoutManager(
[email protected]d90b8392012-06-13 09:34:56239 always_on_top_container->GetRootWindow()));
240}
241
[email protected]e74aaf0a2012-10-12 18:42:28242void RootWindowController::InitForPrimaryDisplay() {
243 DCHECK(!status_area_widget_);
244 ShellDelegate* delegate = Shell::GetInstance()->delegate();
[email protected]16059276d2012-10-22 18:59:50245 aura::Window* status_container =
246 GetContainer(ash::internal::kShellWindowId_StatusContainer);
[email protected]e74aaf0a2012-10-12 18:42:28247 // Initialize Primary RootWindow specific items.
[email protected]16059276d2012-10-22 18:59:50248 status_area_widget_ = new internal::StatusAreaWidget(status_container);
[email protected]e74aaf0a2012-10-12 18:42:28249 status_area_widget_->CreateTrayViews(delegate);
250 // Login screen manages status area visibility by itself.
251 if (delegate && delegate->IsSessionStarted())
252 status_area_widget_->Show();
253
254 Shell::GetInstance()->focus_cycler()->AddWidget(status_area_widget_);
255
256 internal::ShelfLayoutManager* shelf_layout_manager =
257 new internal::ShelfLayoutManager(status_area_widget_);
258 GetContainer(internal::kShellWindowId_LauncherContainer)->
259 SetLayoutManager(shelf_layout_manager);
260 shelf_ = shelf_layout_manager;
261
262 internal::StatusAreaLayoutManager* status_area_layout_manager =
263 new internal::StatusAreaLayoutManager(shelf_layout_manager);
264 GetContainer(internal::kShellWindowId_StatusContainer)->
265 SetLayoutManager(status_area_layout_manager);
266
267 shelf_layout_manager->set_workspace_controller(
268 workspace_controller());
269
270 workspace_controller()->SetShelf(shelf_);
271
272 // Create Panel layout manager
273 aura::Window* panel_container = GetContainer(
274 internal::kShellWindowId_PanelContainer);
275 panel_layout_manager_ =
276 new internal::PanelLayoutManager(panel_container);
277 panel_container->SetEventFilter(
278 new internal::PanelWindowEventFilter(
279 panel_container, panel_layout_manager_));
280 panel_container->SetLayoutManager(panel_layout_manager_);
281
282 if (!delegate || delegate->IsUserLoggedIn())
283 CreateLauncher();
284}
285
[email protected]d90b8392012-06-13 09:34:56286void RootWindowController::CreateContainers() {
287 CreateContainersInRootWindow(root_window_.get());
288}
289
[email protected]697f04c2012-10-03 01:15:10290void RootWindowController::CreateSystemBackground(
291 bool is_first_run_after_boot) {
[email protected]e6e41d2f2012-10-29 19:22:19292 SystemBackgroundController::Content initial_content =
293 SystemBackgroundController::CONTENT_BLACK;
[email protected]697f04c2012-10-03 01:15:10294#if defined(OS_CHROMEOS)
[email protected]e6e41d2f2012-10-29 19:22:19295 if (is_first_run_after_boot) {
296 if (CommandLine::ForCurrentProcess()->HasSwitch(
297 switches::kAshCopyHostBackgroundAtBoot)) {
298 initial_content = SystemBackgroundController::CONTENT_COPY_FROM_HOST;
299 } else {
300 initial_content =
301 SystemBackgroundController::CONTENT_CHROME_OS_BOOT_COLOR;
302 }
303 }
[email protected]697f04c2012-10-03 01:15:10304#endif
[email protected]e6e41d2f2012-10-29 19:22:19305 system_background_.reset(
306 new SystemBackgroundController(root_window_.get(), initial_content));
[email protected]697f04c2012-10-03 01:15:10307}
308
[email protected]e74aaf0a2012-10-12 18:42:28309void RootWindowController::CreateLauncher() {
310 if (launcher_.get())
311 return;
312
313 aura::Window* default_container =
314 GetContainer(internal::kShellWindowId_DefaultContainer);
315 launcher_.reset(new Launcher(default_container, shelf_));
316
317 launcher_->SetFocusCycler(Shell::GetInstance()->focus_cycler());
318 shelf_->SetLauncher(launcher_.get());
319
320 if (panel_layout_manager_)
321 panel_layout_manager_->SetLauncher(launcher_.get());
322
323 ShellDelegate* delegate = Shell::GetInstance()->delegate();
324 if (delegate)
325 launcher_->SetVisible(delegate->IsSessionStarted());
326 launcher_->widget()->Show();
327}
328
329void RootWindowController::ShowLauncher() {
330 if (!launcher_.get())
331 return;
332 launcher_->SetVisible(true);
333}
334
[email protected]16059276d2012-10-22 18:59:50335void RootWindowController::OnLoginStateChanged(user::LoginStatus status) {
336 // TODO(oshima): remove if when launcher per display is enabled by
337 // default.
338 if (shelf_)
339 shelf_->UpdateVisibilityState();
340}
341
342void RootWindowController::UpdateAfterLoginStatusChange(
343 user::LoginStatus status) {
344 if (status_area_widget_)
345 status_area_widget_->UpdateAfterLoginStatusChange(status);
346}
347
[email protected]697f04c2012-10-03 01:15:10348void RootWindowController::HandleDesktopBackgroundVisible() {
[email protected]e6e41d2f2012-10-29 19:22:19349 system_background_->SetContent(SystemBackgroundController::CONTENT_BLACK);
[email protected]697f04c2012-10-03 01:15:10350}
351
[email protected]d90b8392012-06-13 09:34:56352void RootWindowController::CloseChildWindows() {
[email protected]e74aaf0a2012-10-12 18:42:28353 // The status area needs to be shut down before the windows are destroyed.
[email protected]8674b312012-10-12 19:02:44354 if (status_area_widget_) {
[email protected]e74aaf0a2012-10-12 18:42:28355 status_area_widget_->Shutdown();
[email protected]8674b312012-10-12 19:02:44356 status_area_widget_ = NULL;
357 }
[email protected]e74aaf0a2012-10-12 18:42:28358
359 // Closing the windows frees the workspace controller.
360 if (shelf_)
361 shelf_->set_workspace_controller(NULL);
362
[email protected]d90b8392012-06-13 09:34:56363 // Close background widget first as it depends on tooltip.
[email protected]d86de6b22012-10-05 19:32:58364 root_window_->SetProperty(kDesktopController,
[email protected]b4ddc7a2012-08-07 04:17:32365 static_cast<DesktopBackgroundWidgetController*>(NULL));
[email protected]d86de6b22012-10-05 19:32:58366 root_window_->SetProperty(kAnimatingDesktopController,
367 static_cast<AnimatingDesktopController*>(NULL));
[email protected]b4ddc7a2012-08-07 04:17:32368
[email protected]d90b8392012-06-13 09:34:56369 workspace_controller_.reset();
370 aura::client::SetTooltipClient(root_window_.get(), NULL);
371
372 while (!root_window_->children().empty()) {
373 aura::Window* child = root_window_->children()[0];
374 delete child;
375 }
[email protected]e74aaf0a2012-10-12 18:42:28376
377 // All containers are deleted, so reset shelf_.
378 shelf_ = NULL;
[email protected]d90b8392012-06-13 09:34:56379}
380
[email protected]f1853122012-06-27 16:21:26381void RootWindowController::MoveWindowsTo(aura::RootWindow* dst) {
382 aura::Window* focused = dst->GetFocusManager()->GetFocusedWindow();
[email protected]dbf835d82012-09-11 18:23:09383 aura::WindowTracker tracker;
384 if (focused)
385 tracker.Add(focused);
[email protected]f1853122012-06-27 16:21:26386 aura::client::ActivationClient* activation_client =
387 aura::client::GetActivationClient(dst);
388 aura::Window* active = activation_client->GetActiveWindow();
[email protected]dbf835d82012-09-11 18:23:09389 if (active && focused != active)
390 tracker.Add(active);
[email protected]f1853122012-06-27 16:21:26391 // Deactivate the window to close menu / bubble windows.
392 activation_client->DeactivateWindow(active);
393 // Release capture if any.
394 aura::client::GetCaptureClient(root_window_.get())->
395 SetCapture(NULL);
[email protected]dbf835d82012-09-11 18:23:09396 // Clear the focused window if any. This is necessary because a
397 // window may be deleted when losing focus (fullscreen flash for
398 // example). If the focused window is still alive after move, it'll
399 // be re-focused below.
400 dst->GetFocusManager()->SetFocusedWindow(NULL, NULL);
[email protected]f1853122012-06-27 16:21:26401
[email protected]95058572012-08-20 14:57:29402 ReparentAllWindows(root_window_.get(), dst);
[email protected]f1853122012-06-27 16:21:26403
404 // Restore focused or active window if it's still alive.
[email protected]1d030242012-06-28 18:34:08405 if (focused && tracker.Contains(focused) && dst->Contains(focused)) {
[email protected]f1853122012-06-27 16:21:26406 dst->GetFocusManager()->SetFocusedWindow(focused, NULL);
[email protected]1d030242012-06-28 18:34:08407 } else if (active && tracker.Contains(active) && dst->Contains(active)) {
[email protected]f1853122012-06-27 16:21:26408 activation_client->ActivateWindow(active);
409 }
410}
411
[email protected]431552c2012-10-23 00:38:33412void RootWindowController::ShowContextMenu(
413 const gfx::Point& location_in_screen) {
414 aura::RootWindow* target = Shell::IsLauncherPerDisplayEnabled() ?
415 root_window() : Shell::GetPrimaryRootWindow();
416 DCHECK(Shell::GetInstance()->delegate());
417 scoped_ptr<ui::MenuModel> menu_model(
418 Shell::GetInstance()->delegate()->CreateContextMenu(target));
419
420 views::MenuModelAdapter menu_model_adapter(menu_model.get());
421 views::MenuRunner menu_runner(menu_model_adapter.CreateMenu());
422 views::Widget* widget =
423 root_window_->GetProperty(kDesktopController)->widget();
424
425 if (menu_runner.RunMenuAt(
426 widget, NULL, gfx::Rect(location_in_screen, gfx::Size()),
427 views::MenuItemView::TOPLEFT, views::MenuRunner::CONTEXT_MENU) ==
428 views::MenuRunner::MENU_DELETED)
429 return;
430
431 Shell::GetInstance()->UpdateShelfVisibility();
432}
433
[email protected]e74aaf0a2012-10-12 18:42:28434void RootWindowController::UpdateShelfVisibility() {
435 shelf_->UpdateVisibilityState();
436}
437
438void RootWindowController::SetShelfAutoHideBehavior(
439 ShelfAutoHideBehavior behavior) {
440 shelf_->SetAutoHideBehavior(behavior);
441}
442
443ShelfAutoHideBehavior RootWindowController::GetShelfAutoHideBehavior() const {
444 return shelf_->auto_hide_behavior();
445}
446
447bool RootWindowController::SetShelfAlignment(ShelfAlignment alignment) {
448 return shelf_->SetAlignment(alignment);
449}
450
451ShelfAlignment RootWindowController::GetShelfAlignment() {
452 return shelf_->alignment();
453}
454
[email protected]431552c2012-10-23 00:38:33455bool RootWindowController::IsShelfAutoHideMenuHideChecked() {
456 return GetShelfAutoHideBehavior() == ash::SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS;
457}
458
459ShelfAutoHideBehavior
460RootWindowController::GetToggledShelfAutoHideBehavior() {
461 return IsShelfAutoHideMenuHideChecked() ?
462 ash::SHELF_AUTO_HIDE_BEHAVIOR_NEVER :
463 ash::SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS;
464}
465
[email protected]a4cd6d32012-09-12 03:42:13466////////////////////////////////////////////////////////////////////////////////
467// RootWindowController, private:
468
469void RootWindowController::CreateContainersInRootWindow(
470 aura::RootWindow* root_window) {
471 // These containers are just used by PowerButtonController to animate groups
472 // of containers simultaneously without messing up the current transformations
473 // on those containers. These are direct children of the root window; all of
474 // the other containers are their children.
[email protected]e6e41d2f2012-10-29 19:22:19475
476 // The desktop background container is not part of the lock animation, so it
477 // is not included in those animate groups.
[email protected]a4cd6d32012-09-12 03:42:13478 // When screen is locked desktop background is moved to lock screen background
479 // container (moved back on unlock). We want to make sure that there's an
480 // opaque layer occluding the non-lock-screen layers.
[email protected]e6e41d2f2012-10-29 19:22:19481 aura::Window* desktop_background_container = CreateContainer(
[email protected]c0ce80e2012-10-05 23:28:27482 kShellWindowId_DesktopBackgroundContainer,
[email protected]a4cd6d32012-09-12 03:42:13483 "DesktopBackgroundContainer",
484 root_window);
[email protected]e6e41d2f2012-10-29 19:22:19485 SetChildWindowVisibilityChangesAnimated(desktop_background_container);
[email protected]a4cd6d32012-09-12 03:42:13486
487 aura::Window* non_lock_screen_containers = CreateContainer(
[email protected]c0ce80e2012-10-05 23:28:27488 kShellWindowId_NonLockScreenContainersContainer,
[email protected]a4cd6d32012-09-12 03:42:13489 "NonLockScreenContainersContainer",
490 root_window);
491
492 aura::Window* lock_background_containers = CreateContainer(
[email protected]c0ce80e2012-10-05 23:28:27493 kShellWindowId_LockScreenBackgroundContainer,
[email protected]a4cd6d32012-09-12 03:42:13494 "LockScreenBackgroundContainer",
495 root_window);
496 SetChildWindowVisibilityChangesAnimated(lock_background_containers);
497
498 aura::Window* lock_screen_containers = CreateContainer(
[email protected]c0ce80e2012-10-05 23:28:27499 kShellWindowId_LockScreenContainersContainer,
[email protected]a4cd6d32012-09-12 03:42:13500 "LockScreenContainersContainer",
501 root_window);
502 aura::Window* lock_screen_related_containers = CreateContainer(
[email protected]c0ce80e2012-10-05 23:28:27503 kShellWindowId_LockScreenRelatedContainersContainer,
[email protected]a4cd6d32012-09-12 03:42:13504 "LockScreenRelatedContainersContainer",
505 root_window);
506
[email protected]c0ce80e2012-10-05 23:28:27507 CreateContainer(kShellWindowId_UnparentedControlContainer,
[email protected]a4cd6d32012-09-12 03:42:13508 "UnparentedControlContainer",
509 non_lock_screen_containers);
510
511 aura::Window* default_container = CreateContainer(
[email protected]c0ce80e2012-10-05 23:28:27512 kShellWindowId_DefaultContainer,
[email protected]a4cd6d32012-09-12 03:42:13513 "DefaultContainer",
514 non_lock_screen_containers);
[email protected]a4cd6d32012-09-12 03:42:13515 SetChildWindowVisibilityChangesAnimated(default_container);
516 SetUsesScreenCoordinates(default_container);
517
518 aura::Window* always_on_top_container = CreateContainer(
[email protected]c0ce80e2012-10-05 23:28:27519 kShellWindowId_AlwaysOnTopContainer,
[email protected]a4cd6d32012-09-12 03:42:13520 "AlwaysOnTopContainer",
521 non_lock_screen_containers);
522 always_on_top_container_handler_.reset(
523 new ToplevelWindowEventHandler(always_on_top_container));
[email protected]a4cd6d32012-09-12 03:42:13524 SetChildWindowVisibilityChangesAnimated(always_on_top_container);
525 SetUsesScreenCoordinates(always_on_top_container);
526
527 aura::Window* panel_container = CreateContainer(
[email protected]c0ce80e2012-10-05 23:28:27528 kShellWindowId_PanelContainer,
[email protected]a4cd6d32012-09-12 03:42:13529 "PanelContainer",
530 non_lock_screen_containers);
531 SetUsesScreenCoordinates(panel_container);
532
533 aura::Window* launcher_container =
[email protected]c0ce80e2012-10-05 23:28:27534 CreateContainer(kShellWindowId_LauncherContainer,
[email protected]a4cd6d32012-09-12 03:42:13535 "LauncherContainer",
536 non_lock_screen_containers);
537 SetUsesScreenCoordinates(launcher_container);
538
[email protected]dc851a4e52012-10-03 00:05:55539 aura::Window* app_list_container =
[email protected]c0ce80e2012-10-05 23:28:27540 CreateContainer(kShellWindowId_AppListContainer,
[email protected]dc851a4e52012-10-03 00:05:55541 "AppListContainer",
542 non_lock_screen_containers);
543 SetUsesScreenCoordinates(app_list_container);
[email protected]a4cd6d32012-09-12 03:42:13544
545 aura::Window* modal_container = CreateContainer(
[email protected]c0ce80e2012-10-05 23:28:27546 kShellWindowId_SystemModalContainer,
[email protected]a4cd6d32012-09-12 03:42:13547 "SystemModalContainer",
548 non_lock_screen_containers);
549 modal_container_handler_.reset(
550 new ToplevelWindowEventHandler(modal_container));
[email protected]a4cd6d32012-09-12 03:42:13551 modal_container->SetLayoutManager(
[email protected]c0ce80e2012-10-05 23:28:27552 new SystemModalContainerLayoutManager(modal_container));
[email protected]a4cd6d32012-09-12 03:42:13553 SetChildWindowVisibilityChangesAnimated(modal_container);
554 SetUsesScreenCoordinates(modal_container);
555
556 aura::Window* input_method_container = CreateContainer(
[email protected]c0ce80e2012-10-05 23:28:27557 kShellWindowId_InputMethodContainer,
[email protected]a4cd6d32012-09-12 03:42:13558 "InputMethodContainer",
559 non_lock_screen_containers);
560 SetUsesScreenCoordinates(input_method_container);
561
562 // TODO(beng): Figure out if we can make this use
563 // SystemModalContainerEventFilter instead of stops_event_propagation.
564 aura::Window* lock_container = CreateContainer(
[email protected]c0ce80e2012-10-05 23:28:27565 kShellWindowId_LockScreenContainer,
[email protected]a4cd6d32012-09-12 03:42:13566 "LockScreenContainer",
567 lock_screen_containers);
568 lock_container->SetLayoutManager(
[email protected]c0ce80e2012-10-05 23:28:27569 new BaseLayoutManager(root_window));
[email protected]a4cd6d32012-09-12 03:42:13570 SetUsesScreenCoordinates(lock_container);
571 // TODO(beng): stopsevents
572
573 aura::Window* lock_modal_container = CreateContainer(
[email protected]c0ce80e2012-10-05 23:28:27574 kShellWindowId_LockSystemModalContainer,
[email protected]a4cd6d32012-09-12 03:42:13575 "LockSystemModalContainer",
576 lock_screen_containers);
577 lock_modal_container_handler_.reset(
578 new ToplevelWindowEventHandler(lock_modal_container));
[email protected]a4cd6d32012-09-12 03:42:13579 lock_modal_container->SetLayoutManager(
[email protected]c0ce80e2012-10-05 23:28:27580 new SystemModalContainerLayoutManager(lock_modal_container));
[email protected]a4cd6d32012-09-12 03:42:13581 SetChildWindowVisibilityChangesAnimated(lock_modal_container);
582 SetUsesScreenCoordinates(lock_modal_container);
583
584 aura::Window* status_container =
[email protected]c0ce80e2012-10-05 23:28:27585 CreateContainer(kShellWindowId_StatusContainer,
[email protected]a4cd6d32012-09-12 03:42:13586 "StatusContainer",
587 lock_screen_related_containers);
588 SetUsesScreenCoordinates(status_container);
589
590 aura::Window* settings_bubble_container = CreateContainer(
[email protected]c0ce80e2012-10-05 23:28:27591 kShellWindowId_SettingBubbleContainer,
[email protected]a4cd6d32012-09-12 03:42:13592 "SettingBubbleContainer",
593 lock_screen_related_containers);
594 SetChildWindowVisibilityChangesAnimated(settings_bubble_container);
595 SetUsesScreenCoordinates(settings_bubble_container);
596
597 aura::Window* menu_container = CreateContainer(
[email protected]c0ce80e2012-10-05 23:28:27598 kShellWindowId_MenuContainer,
[email protected]a4cd6d32012-09-12 03:42:13599 "MenuContainer",
600 lock_screen_related_containers);
601 SetChildWindowVisibilityChangesAnimated(menu_container);
602 SetUsesScreenCoordinates(menu_container);
603
604 aura::Window* drag_drop_container = CreateContainer(
[email protected]c0ce80e2012-10-05 23:28:27605 kShellWindowId_DragImageAndTooltipContainer,
[email protected]a4cd6d32012-09-12 03:42:13606 "DragImageAndTooltipContainer",
607 lock_screen_related_containers);
608 SetChildWindowVisibilityChangesAnimated(drag_drop_container);
609 SetUsesScreenCoordinates(drag_drop_container);
610
611 aura::Window* overlay_container = CreateContainer(
[email protected]c0ce80e2012-10-05 23:28:27612 kShellWindowId_OverlayContainer,
[email protected]a4cd6d32012-09-12 03:42:13613 "OverlayContainer",
614 lock_screen_related_containers);
615 SetUsesScreenCoordinates(overlay_container);
[email protected]a07615f2012-10-24 08:23:08616
617 CreateContainer(kShellWindowId_PowerButtonAnimationContainer,
618 "PowerButtonAnimationContainer", root_window) ;
[email protected]a4cd6d32012-09-12 03:42:13619}
620
[email protected]d90b8392012-06-13 09:34:56621} // namespace internal
622} // namespace ash