blob: b0d29a02e267fe109a65a91b65ad668750ea776f [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]b4ddc7a2012-08-07 04:17:329#include "ash/desktop_background/desktop_background_widget_controller.h"
[email protected]8d625fb2012-07-18 16:40:0610#include "ash/display/display_controller.h"
[email protected]6675e1c2012-09-11 09:15:4511#include "ash/display/multi_display_manager.h"
[email protected]e74aaf0a2012-10-12 18:42:2812#include "ash/focus_cycler.h"
[email protected]d90b8392012-06-13 09:34:5613#include "ash/shell.h"
[email protected]e74aaf0a2012-10-12 18:42:2814#include "ash/shell_delegate.h"
[email protected]d90b8392012-06-13 09:34:5615#include "ash/shell_factory.h"
16#include "ash/shell_window_ids.h"
[email protected]e74aaf0a2012-10-12 18:42:2817#include "ash/system/status_area_widget.h"
[email protected]8674b312012-10-12 19:02:4418#include "ash/system/tray/system_tray_delegate.h"
[email protected]d90b8392012-06-13 09:34:5619#include "ash/wm/base_layout_manager.h"
[email protected]e74aaf0a2012-10-12 18:42:2820#include "ash/wm/panel_layout_manager.h"
21#include "ash/wm/panel_window_event_filter.h"
[email protected]d90b8392012-06-13 09:34:5622#include "ash/wm/property_util.h"
23#include "ash/wm/root_window_layout_manager.h"
24#include "ash/wm/screen_dimmer.h"
[email protected]e74aaf0a2012-10-12 18:42:2825#include "ash/wm/shelf_layout_manager.h"
26#include "ash/wm/shelf_types.h"
27#include "ash/wm/status_area_layout_manager.h"
[email protected]d90b8392012-06-13 09:34:5628#include "ash/wm/system_modal_container_layout_manager.h"
[email protected]5dc51db82012-09-11 03:39:0129#include "ash/wm/toplevel_window_event_handler.h"
[email protected]d90b8392012-06-13 09:34:5630#include "ash/wm/visibility_controller.h"
[email protected]8d625fb2012-07-18 16:40:0631#include "ash/wm/window_properties.h"
[email protected]c601e732012-10-11 15:39:3732#include "ash/wm/workspace/colored_window_controller.h"
[email protected]d90b8392012-06-13 09:34:5633#include "ash/wm/workspace_controller.h"
[email protected]f1853122012-06-27 16:21:2634#include "ui/aura/client/activation_client.h"
35#include "ui/aura/client/aura_constants.h"
36#include "ui/aura/client/capture_client.h"
[email protected]d90b8392012-06-13 09:34:5637#include "ui/aura/client/tooltip_client.h"
[email protected]f1853122012-06-27 16:21:2638#include "ui/aura/focus_manager.h"
[email protected]d90b8392012-06-13 09:34:5639#include "ui/aura/root_window.h"
[email protected]f1853122012-06-27 16:21:2640#include "ui/aura/window.h"
41#include "ui/aura/window_observer.h"
[email protected]1d030242012-06-28 18:34:0842#include "ui/aura/window_tracker.h"
[email protected]431552c2012-10-23 00:38:3343#include "ui/base/models/menu_model.h"
[email protected]8d625fb2012-07-18 16:40:0644#include "ui/gfx/display.h"
45#include "ui/gfx/screen.h"
[email protected]431552c2012-10-23 00:38:3346#include "ui/views/controls/menu/menu_model_adapter.h"
47#include "ui/views/controls/menu/menu_runner.h"
48#include "ui/views/view_model.h"
49#include "ui/views/view_model_utils.h"
[email protected]d90b8392012-06-13 09:34:5650
51namespace ash {
52namespace {
53
[email protected]697f04c2012-10-03 01:15:1054#if defined(OS_CHROMEOS)
55// Color initially used for the system background after the system has first
56// booted.
57const SkColor kBootSystemBackgroundColor = 0xFFFEFEFE;
58#endif
59
[email protected]d90b8392012-06-13 09:34:5660// Creates a new window for use as a container.
61aura::Window* CreateContainer(int window_id,
62 const char* name,
63 aura::Window* parent) {
64 aura::Window* container = new aura::Window(NULL);
65 container->set_id(window_id);
66 container->SetName(name);
67 container->Init(ui::LAYER_NOT_DRAWN);
68 parent->AddChild(container);
69 if (window_id != internal::kShellWindowId_UnparentedControlContainer)
70 container->Show();
71 return container;
72}
73
[email protected]95058572012-08-20 14:57:2974// Returns all the children of the workspace windows, eg the standard top-level
75// windows.
76std::vector<aura::Window*> GetWorkspaceWindows(aura::RootWindow* root) {
77 using aura::Window;
78
79 std::vector<Window*> windows;
80 Window* container = Shell::GetContainer(
81 root, internal::kShellWindowId_DefaultContainer);
82 for (Window::Windows::const_reverse_iterator i =
83 container->children().rbegin();
84 i != container->children().rend(); ++i) {
85 Window* workspace_window = *i;
86 if (workspace_window->id() == internal::kShellWindowId_WorkspaceContainer) {
87 windows.insert(windows.end(), workspace_window->children().begin(),
88 workspace_window->children().end());
89 }
90 }
91 return windows;
92}
93
94// Reparents |window| to |new_parent|.
95void ReparentWindow(aura::Window* window, aura::Window* new_parent) {
96 // Update the restore bounds to make it relative to the display.
97 gfx::Rect restore_bounds(GetRestoreBoundsInParent(window));
98 new_parent->AddChild(window);
99 if (!restore_bounds.IsEmpty())
100 SetRestoreBoundsInParent(window, restore_bounds);
101}
102
103// Reparents the appropriate set of windows from |src| to |dst|.
104void ReparentAllWindows(aura::RootWindow* src, aura::RootWindow* dst) {
105 // Set of windows to move.
[email protected]f1853122012-06-27 16:21:26106 const int kContainerIdsToMove[] = {
107 internal::kShellWindowId_DefaultContainer,
108 internal::kShellWindowId_AlwaysOnTopContainer,
109 internal::kShellWindowId_SystemModalContainer,
110 internal::kShellWindowId_LockSystemModalContainer,
[email protected]6274d312012-10-04 22:06:41111 internal::kShellWindowId_InputMethodContainer,
[email protected]f1853122012-06-27 16:21:26112 };
[email protected]95058572012-08-20 14:57:29113 // For Workspace2 we need to manually reparent the windows. This way
114 // Workspace2 can move the windows to the appropriate workspace.
[email protected]c96b9812012-10-17 16:04:04115 std::vector<aura::Window*> windows(GetWorkspaceWindows(src));
116 internal::WorkspaceController* workspace_controller =
117 GetRootWindowController(dst)->workspace_controller();
118 for (size_t i = 0; i < windows.size(); ++i) {
119 aura::Window* new_parent =
120 workspace_controller->GetParentForNewWindow(windows[i]);
121 ReparentWindow(windows[i], new_parent);
[email protected]95058572012-08-20 14:57:29122 }
[email protected]f1853122012-06-27 16:21:26123 for (size_t i = 0; i < arraysize(kContainerIdsToMove); i++) {
124 int id = kContainerIdsToMove[i];
[email protected]c96b9812012-10-17 16:04:04125 if (id == internal::kShellWindowId_DefaultContainer)
[email protected]95058572012-08-20 14:57:29126 continue;
127
[email protected]f1853122012-06-27 16:21:26128 aura::Window* src_container = Shell::GetContainer(src, id);
129 aura::Window* dst_container = Shell::GetContainer(dst, id);
130 aura::Window::Windows children = src_container->children();
131 for (aura::Window::Windows::iterator iter = children.begin();
132 iter != children.end(); ++iter) {
133 aura::Window* window = *iter;
134 // Don't move modal screen.
[email protected]c0ce80e2012-10-05 23:28:27135 if (internal::SystemModalContainerLayoutManager::IsModalBackground(
136 window))
[email protected]f1853122012-06-27 16:21:26137 continue;
[email protected]f059c6942012-07-21 14:27:57138
[email protected]95058572012-08-20 14:57:29139 ReparentWindow(window, dst_container);
[email protected]f1853122012-06-27 16:21:26140 }
141 }
142}
143
[email protected]8d625fb2012-07-18 16:40:06144// Mark the container window so that a widget added to this container will
145// use the virtual screeen coordinates instead of parent.
146void SetUsesScreenCoordinates(aura::Window* container) {
147 container->SetProperty(internal::kUsesScreenCoordinatesKey, true);
148}
149
[email protected]d90b8392012-06-13 09:34:56150} // namespace
151
152namespace internal {
153
154RootWindowController::RootWindowController(aura::RootWindow* root_window)
[email protected]e74aaf0a2012-10-12 18:42:28155 : root_window_(root_window),
156 root_window_layout_(NULL),
157 status_area_widget_(NULL),
158 shelf_(NULL),
159 panel_layout_manager_(NULL) {
[email protected]d90b8392012-06-13 09:34:56160 SetRootWindowController(root_window, this);
[email protected]c0ce80e2012-10-05 23:28:27161 screen_dimmer_.reset(new ScreenDimmer(root_window));
[email protected]d90b8392012-06-13 09:34:56162}
163
164RootWindowController::~RootWindowController() {
[email protected]6675e1c2012-09-11 09:15:45165 Shutdown();
166 root_window_.reset();
167}
168
[email protected]88d71122012-10-18 07:11:01169// static
170internal::RootWindowController*
171RootWindowController::ForLauncher(aura::Window* window) {
172 if (Shell::IsLauncherPerDisplayEnabled())
173 return GetRootWindowController(window->GetRootWindow());
174 else
175 return Shell::GetPrimaryRootWindowController();
176}
177
[email protected]6675e1c2012-09-11 09:15:45178void RootWindowController::Shutdown() {
179 CloseChildWindows();
[email protected]f634dd32012-07-23 22:49:07180 if (Shell::GetActiveRootWindow() == root_window_.get()) {
181 Shell::GetInstance()->set_active_root_window(
182 Shell::GetPrimaryRootWindow() == root_window_.get() ?
183 NULL : Shell::GetPrimaryRootWindow());
184 }
[email protected]d90b8392012-06-13 09:34:56185 SetRootWindowController(root_window_.get(), NULL);
[email protected]d90b8392012-06-13 09:34:56186 screen_dimmer_.reset();
187 workspace_controller_.reset();
[email protected]6675e1c2012-09-11 09:15:45188 // Forget with the display ID so that display lookup
189 // ends up with invalid display.
190 root_window_->ClearProperty(kDisplayIdKey);
191 // And this root window should no longer process events.
192 root_window_->PrepareForShutdown();
[email protected]e74aaf0a2012-10-12 18:42:28193
194 // Launcher widget has an InputMethodBridge that references to
195 // |input_method_filter_|'s |input_method_|. So explicitly release
196 // |launcher_| before |input_method_filter_|. And this needs to be
197 // after we delete all containers in case there are still live
198 // browser windows which access LauncherModel during close.
199 launcher_.reset();
[email protected]d90b8392012-06-13 09:34:56200}
201
[email protected]c0ce80e2012-10-05 23:28:27202SystemModalContainerLayoutManager*
[email protected]8674b312012-10-12 19:02:44203RootWindowController::GetSystemModalLayoutManager(aura::Window* window) {
204 aura::Window* container = NULL;
205 if (window) {
206 container = GetContainer(
207 kShellWindowId_LockSystemModalContainer);
208 if (!container->Contains(window))
209 container = GetContainer(kShellWindowId_SystemModalContainer);
210 } else {
211 user::LoginStatus login = Shell::GetInstance()->tray_delegate() ?
212 Shell::GetInstance()->tray_delegate()->GetUserLoginStatus() :
213 user::LOGGED_IN_NONE;
214 int modal_window_id = (login == user::LOGGED_IN_LOCKED ||
215 login == user::LOGGED_IN_NONE) ?
216 kShellWindowId_LockSystemModalContainer :
217 kShellWindowId_SystemModalContainer;
218 container = GetContainer(modal_window_id);
219 }
[email protected]c0ce80e2012-10-05 23:28:27220 return static_cast<SystemModalContainerLayoutManager*>(
[email protected]8674b312012-10-12 19:02:44221 container->layout_manager());
[email protected]c0ce80e2012-10-05 23:28:27222}
223
[email protected]d90b8392012-06-13 09:34:56224aura::Window* RootWindowController::GetContainer(int container_id) {
225 return root_window_->GetChildById(container_id);
226}
227
228void RootWindowController::InitLayoutManagers() {
229 root_window_layout_ =
[email protected]c0ce80e2012-10-05 23:28:27230 new RootWindowLayoutManager(root_window_.get());
[email protected]d90b8392012-06-13 09:34:56231 root_window_->SetLayoutManager(root_window_layout_);
232
233 aura::Window* default_container =
[email protected]c0ce80e2012-10-05 23:28:27234 GetContainer(kShellWindowId_DefaultContainer);
[email protected]d90b8392012-06-13 09:34:56235 // Workspace manager has its own layout managers.
236 workspace_controller_.reset(
[email protected]c0ce80e2012-10-05 23:28:27237 new WorkspaceController(default_container));
[email protected]d90b8392012-06-13 09:34:56238
239 aura::Window* always_on_top_container =
[email protected]c0ce80e2012-10-05 23:28:27240 GetContainer(kShellWindowId_AlwaysOnTopContainer);
[email protected]d90b8392012-06-13 09:34:56241 always_on_top_container->SetLayoutManager(
[email protected]c0ce80e2012-10-05 23:28:27242 new BaseLayoutManager(
[email protected]d90b8392012-06-13 09:34:56243 always_on_top_container->GetRootWindow()));
244}
245
[email protected]e74aaf0a2012-10-12 18:42:28246void RootWindowController::InitForPrimaryDisplay() {
247 DCHECK(!status_area_widget_);
248 ShellDelegate* delegate = Shell::GetInstance()->delegate();
[email protected]16059276d2012-10-22 18:59:50249 aura::Window* status_container =
250 GetContainer(ash::internal::kShellWindowId_StatusContainer);
[email protected]e74aaf0a2012-10-12 18:42:28251 // Initialize Primary RootWindow specific items.
[email protected]16059276d2012-10-22 18:59:50252 status_area_widget_ = new internal::StatusAreaWidget(status_container);
[email protected]e74aaf0a2012-10-12 18:42:28253 status_area_widget_->CreateTrayViews(delegate);
254 // Login screen manages status area visibility by itself.
255 if (delegate && delegate->IsSessionStarted())
256 status_area_widget_->Show();
257
258 Shell::GetInstance()->focus_cycler()->AddWidget(status_area_widget_);
259
260 internal::ShelfLayoutManager* shelf_layout_manager =
261 new internal::ShelfLayoutManager(status_area_widget_);
262 GetContainer(internal::kShellWindowId_LauncherContainer)->
263 SetLayoutManager(shelf_layout_manager);
264 shelf_ = shelf_layout_manager;
265
266 internal::StatusAreaLayoutManager* status_area_layout_manager =
267 new internal::StatusAreaLayoutManager(shelf_layout_manager);
268 GetContainer(internal::kShellWindowId_StatusContainer)->
269 SetLayoutManager(status_area_layout_manager);
270
271 shelf_layout_manager->set_workspace_controller(
272 workspace_controller());
273
274 workspace_controller()->SetShelf(shelf_);
275
276 // Create Panel layout manager
277 aura::Window* panel_container = GetContainer(
278 internal::kShellWindowId_PanelContainer);
279 panel_layout_manager_ =
280 new internal::PanelLayoutManager(panel_container);
281 panel_container->SetEventFilter(
282 new internal::PanelWindowEventFilter(
283 panel_container, panel_layout_manager_));
284 panel_container->SetLayoutManager(panel_layout_manager_);
285
286 if (!delegate || delegate->IsUserLoggedIn())
287 CreateLauncher();
288}
289
[email protected]d90b8392012-06-13 09:34:56290void RootWindowController::CreateContainers() {
291 CreateContainersInRootWindow(root_window_.get());
292}
293
[email protected]697f04c2012-10-03 01:15:10294void RootWindowController::CreateSystemBackground(
295 bool is_first_run_after_boot) {
296 SkColor color = SK_ColorBLACK;
297#if defined(OS_CHROMEOS)
298 if (is_first_run_after_boot)
299 color = kBootSystemBackgroundColor;
300#endif
[email protected]c601e732012-10-11 15:39:37301 background_.reset(new ColoredWindowController(
302 root_window_->GetChildById(kShellWindowId_SystemBackgroundContainer),
303 "SystemBackground"));
304 background_->SetColor(color);
305 background_->GetWidget()->Show();
[email protected]697f04c2012-10-03 01:15:10306}
307
[email protected]e74aaf0a2012-10-12 18:42:28308void RootWindowController::CreateLauncher() {
309 if (launcher_.get())
310 return;
311
312 aura::Window* default_container =
313 GetContainer(internal::kShellWindowId_DefaultContainer);
314 launcher_.reset(new Launcher(default_container, shelf_));
315
316 launcher_->SetFocusCycler(Shell::GetInstance()->focus_cycler());
317 shelf_->SetLauncher(launcher_.get());
318
319 if (panel_layout_manager_)
320 panel_layout_manager_->SetLauncher(launcher_.get());
321
322 ShellDelegate* delegate = Shell::GetInstance()->delegate();
323 if (delegate)
324 launcher_->SetVisible(delegate->IsSessionStarted());
325 launcher_->widget()->Show();
326}
327
328void RootWindowController::ShowLauncher() {
329 if (!launcher_.get())
330 return;
331 launcher_->SetVisible(true);
332}
333
[email protected]16059276d2012-10-22 18:59:50334void RootWindowController::OnLoginStateChanged(user::LoginStatus status) {
335 // TODO(oshima): remove if when launcher per display is enabled by
336 // default.
337 if (shelf_)
338 shelf_->UpdateVisibilityState();
339}
340
341void RootWindowController::UpdateAfterLoginStatusChange(
342 user::LoginStatus status) {
343 if (status_area_widget_)
344 status_area_widget_->UpdateAfterLoginStatusChange(status);
345}
346
[email protected]697f04c2012-10-03 01:15:10347void RootWindowController::HandleDesktopBackgroundVisible() {
348 if (background_.get())
349 background_->SetColor(SK_ColorBLACK);
350}
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.
475 // Desktop and lock screen background containers are not part of the
476 // lock animation so they are not included in those animate groups.
477 // When screen is locked desktop background is moved to lock screen background
478 // container (moved back on unlock). We want to make sure that there's an
479 // opaque layer occluding the non-lock-screen layers.
480
[email protected]c0ce80e2012-10-05 23:28:27481 CreateContainer(kShellWindowId_SystemBackgroundContainer,
[email protected]a4cd6d32012-09-12 03:42:13482 "SystemBackgroundContainer", root_window);
483
484 aura::Window* desktop_background_containers = CreateContainer(
[email protected]c0ce80e2012-10-05 23:28:27485 kShellWindowId_DesktopBackgroundContainer,
[email protected]a4cd6d32012-09-12 03:42:13486 "DesktopBackgroundContainer",
487 root_window);
488 SetChildWindowVisibilityChangesAnimated(desktop_background_containers);
489
490 aura::Window* non_lock_screen_containers = CreateContainer(
[email protected]c0ce80e2012-10-05 23:28:27491 kShellWindowId_NonLockScreenContainersContainer,
[email protected]a4cd6d32012-09-12 03:42:13492 "NonLockScreenContainersContainer",
493 root_window);
494
495 aura::Window* lock_background_containers = CreateContainer(
[email protected]c0ce80e2012-10-05 23:28:27496 kShellWindowId_LockScreenBackgroundContainer,
[email protected]a4cd6d32012-09-12 03:42:13497 "LockScreenBackgroundContainer",
498 root_window);
499 SetChildWindowVisibilityChangesAnimated(lock_background_containers);
500
501 aura::Window* lock_screen_containers = CreateContainer(
[email protected]c0ce80e2012-10-05 23:28:27502 kShellWindowId_LockScreenContainersContainer,
[email protected]a4cd6d32012-09-12 03:42:13503 "LockScreenContainersContainer",
504 root_window);
505 aura::Window* lock_screen_related_containers = CreateContainer(
[email protected]c0ce80e2012-10-05 23:28:27506 kShellWindowId_LockScreenRelatedContainersContainer,
[email protected]a4cd6d32012-09-12 03:42:13507 "LockScreenRelatedContainersContainer",
508 root_window);
509
[email protected]c0ce80e2012-10-05 23:28:27510 CreateContainer(kShellWindowId_UnparentedControlContainer,
[email protected]a4cd6d32012-09-12 03:42:13511 "UnparentedControlContainer",
512 non_lock_screen_containers);
513
514 aura::Window* default_container = CreateContainer(
[email protected]c0ce80e2012-10-05 23:28:27515 kShellWindowId_DefaultContainer,
[email protected]a4cd6d32012-09-12 03:42:13516 "DefaultContainer",
517 non_lock_screen_containers);
[email protected]a4cd6d32012-09-12 03:42:13518 SetChildWindowVisibilityChangesAnimated(default_container);
519 SetUsesScreenCoordinates(default_container);
520
521 aura::Window* always_on_top_container = CreateContainer(
[email protected]c0ce80e2012-10-05 23:28:27522 kShellWindowId_AlwaysOnTopContainer,
[email protected]a4cd6d32012-09-12 03:42:13523 "AlwaysOnTopContainer",
524 non_lock_screen_containers);
525 always_on_top_container_handler_.reset(
526 new ToplevelWindowEventHandler(always_on_top_container));
[email protected]a4cd6d32012-09-12 03:42:13527 SetChildWindowVisibilityChangesAnimated(always_on_top_container);
528 SetUsesScreenCoordinates(always_on_top_container);
529
530 aura::Window* panel_container = CreateContainer(
[email protected]c0ce80e2012-10-05 23:28:27531 kShellWindowId_PanelContainer,
[email protected]a4cd6d32012-09-12 03:42:13532 "PanelContainer",
533 non_lock_screen_containers);
534 SetUsesScreenCoordinates(panel_container);
535
536 aura::Window* launcher_container =
[email protected]c0ce80e2012-10-05 23:28:27537 CreateContainer(kShellWindowId_LauncherContainer,
[email protected]a4cd6d32012-09-12 03:42:13538 "LauncherContainer",
539 non_lock_screen_containers);
540 SetUsesScreenCoordinates(launcher_container);
541
[email protected]dc851a4e52012-10-03 00:05:55542 aura::Window* app_list_container =
[email protected]c0ce80e2012-10-05 23:28:27543 CreateContainer(kShellWindowId_AppListContainer,
[email protected]dc851a4e52012-10-03 00:05:55544 "AppListContainer",
545 non_lock_screen_containers);
546 SetUsesScreenCoordinates(app_list_container);
[email protected]a4cd6d32012-09-12 03:42:13547
548 aura::Window* modal_container = CreateContainer(
[email protected]c0ce80e2012-10-05 23:28:27549 kShellWindowId_SystemModalContainer,
[email protected]a4cd6d32012-09-12 03:42:13550 "SystemModalContainer",
551 non_lock_screen_containers);
552 modal_container_handler_.reset(
553 new ToplevelWindowEventHandler(modal_container));
[email protected]a4cd6d32012-09-12 03:42:13554 modal_container->SetLayoutManager(
[email protected]c0ce80e2012-10-05 23:28:27555 new SystemModalContainerLayoutManager(modal_container));
[email protected]a4cd6d32012-09-12 03:42:13556 SetChildWindowVisibilityChangesAnimated(modal_container);
557 SetUsesScreenCoordinates(modal_container);
558
559 aura::Window* input_method_container = CreateContainer(
[email protected]c0ce80e2012-10-05 23:28:27560 kShellWindowId_InputMethodContainer,
[email protected]a4cd6d32012-09-12 03:42:13561 "InputMethodContainer",
562 non_lock_screen_containers);
563 SetUsesScreenCoordinates(input_method_container);
564
565 // TODO(beng): Figure out if we can make this use
566 // SystemModalContainerEventFilter instead of stops_event_propagation.
567 aura::Window* lock_container = CreateContainer(
[email protected]c0ce80e2012-10-05 23:28:27568 kShellWindowId_LockScreenContainer,
[email protected]a4cd6d32012-09-12 03:42:13569 "LockScreenContainer",
570 lock_screen_containers);
571 lock_container->SetLayoutManager(
[email protected]c0ce80e2012-10-05 23:28:27572 new BaseLayoutManager(root_window));
[email protected]a4cd6d32012-09-12 03:42:13573 SetUsesScreenCoordinates(lock_container);
574 // TODO(beng): stopsevents
575
576 aura::Window* lock_modal_container = CreateContainer(
[email protected]c0ce80e2012-10-05 23:28:27577 kShellWindowId_LockSystemModalContainer,
[email protected]a4cd6d32012-09-12 03:42:13578 "LockSystemModalContainer",
579 lock_screen_containers);
580 lock_modal_container_handler_.reset(
581 new ToplevelWindowEventHandler(lock_modal_container));
[email protected]a4cd6d32012-09-12 03:42:13582 lock_modal_container->SetLayoutManager(
[email protected]c0ce80e2012-10-05 23:28:27583 new SystemModalContainerLayoutManager(lock_modal_container));
[email protected]a4cd6d32012-09-12 03:42:13584 SetChildWindowVisibilityChangesAnimated(lock_modal_container);
585 SetUsesScreenCoordinates(lock_modal_container);
586
587 aura::Window* status_container =
[email protected]c0ce80e2012-10-05 23:28:27588 CreateContainer(kShellWindowId_StatusContainer,
[email protected]a4cd6d32012-09-12 03:42:13589 "StatusContainer",
590 lock_screen_related_containers);
591 SetUsesScreenCoordinates(status_container);
592
593 aura::Window* settings_bubble_container = CreateContainer(
[email protected]c0ce80e2012-10-05 23:28:27594 kShellWindowId_SettingBubbleContainer,
[email protected]a4cd6d32012-09-12 03:42:13595 "SettingBubbleContainer",
596 lock_screen_related_containers);
597 SetChildWindowVisibilityChangesAnimated(settings_bubble_container);
598 SetUsesScreenCoordinates(settings_bubble_container);
599
600 aura::Window* menu_container = CreateContainer(
[email protected]c0ce80e2012-10-05 23:28:27601 kShellWindowId_MenuContainer,
[email protected]a4cd6d32012-09-12 03:42:13602 "MenuContainer",
603 lock_screen_related_containers);
604 SetChildWindowVisibilityChangesAnimated(menu_container);
605 SetUsesScreenCoordinates(menu_container);
606
607 aura::Window* drag_drop_container = CreateContainer(
[email protected]c0ce80e2012-10-05 23:28:27608 kShellWindowId_DragImageAndTooltipContainer,
[email protected]a4cd6d32012-09-12 03:42:13609 "DragImageAndTooltipContainer",
610 lock_screen_related_containers);
611 SetChildWindowVisibilityChangesAnimated(drag_drop_container);
612 SetUsesScreenCoordinates(drag_drop_container);
613
614 aura::Window* overlay_container = CreateContainer(
[email protected]c0ce80e2012-10-05 23:28:27615 kShellWindowId_OverlayContainer,
[email protected]a4cd6d32012-09-12 03:42:13616 "OverlayContainer",
617 lock_screen_related_containers);
618 SetUsesScreenCoordinates(overlay_container);
619}
620
[email protected]d90b8392012-06-13 09:34:56621} // namespace internal
622} // namespace ash