Moved chrome/browser/ui/extensions apps code to chrome/browser/ui/apps
[chromium-blink-merge.git] / ash / root_window_controller.cc
blob3f5c80a3d49bced4969c0376259c50a8691d17c2
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.
5 #include "ash/root_window_controller.h"
7 #include <vector>
9 #include "ash/ash_constants.h"
10 #include "ash/ash_switches.h"
11 #include "ash/desktop_background/desktop_background_widget_controller.h"
12 #include "ash/desktop_background/user_wallpaper_delegate.h"
13 #include "ash/display/display_manager.h"
14 #include "ash/focus_cycler.h"
15 #include "ash/session_state_delegate.h"
16 #include "ash/shelf/shelf_layout_manager.h"
17 #include "ash/shelf/shelf_types.h"
18 #include "ash/shelf/shelf_widget.h"
19 #include "ash/shell.h"
20 #include "ash/shell_delegate.h"
21 #include "ash/shell_factory.h"
22 #include "ash/shell_window_ids.h"
23 #include "ash/system/status_area_widget.h"
24 #include "ash/system/tray/system_tray_delegate.h"
25 #include "ash/touch/touch_hud_debug.h"
26 #include "ash/touch/touch_hud_projection.h"
27 #include "ash/touch/touch_observer_hud.h"
28 #include "ash/wm/always_on_top_controller.h"
29 #include "ash/wm/base_layout_manager.h"
30 #include "ash/wm/boot_splash_screen.h"
31 #include "ash/wm/dock/docked_window_layout_manager.h"
32 #include "ash/wm/panels/panel_layout_manager.h"
33 #include "ash/wm/panels/panel_window_event_handler.h"
34 #include "ash/wm/property_util.h"
35 #include "ash/wm/root_window_layout_manager.h"
36 #include "ash/wm/screen_dimmer.h"
37 #include "ash/wm/stacking_controller.h"
38 #include "ash/wm/status_area_layout_manager.h"
39 #include "ash/wm/system_background_controller.h"
40 #include "ash/wm/system_modal_container_layout_manager.h"
41 #include "ash/wm/toplevel_window_event_handler.h"
42 #include "ash/wm/window_properties.h"
43 #include "ash/wm/window_util.h"
44 #include "ash/wm/workspace_controller.h"
45 #include "base/command_line.h"
46 #include "base/time/time.h"
47 #include "ui/aura/client/aura_constants.h"
48 #include "ui/aura/client/tooltip_client.h"
49 #include "ui/aura/root_window.h"
50 #include "ui/aura/window.h"
51 #include "ui/aura/window_delegate.h"
52 #include "ui/aura/window_observer.h"
53 #include "ui/base/hit_test.h"
54 #include "ui/base/models/menu_model.h"
55 #include "ui/gfx/screen.h"
56 #include "ui/keyboard/keyboard_controller.h"
57 #include "ui/keyboard/keyboard_util.h"
58 #include "ui/views/controls/menu/menu_runner.h"
59 #include "ui/views/corewm/visibility_controller.h"
60 #include "ui/views/view_model.h"
61 #include "ui/views/view_model_utils.h"
63 namespace ash {
64 namespace {
66 // Duration for the animation that hides the boot splash screen, in
67 // milliseconds. This should be short enough in relation to
68 // wm/window_animation.cc's brightness/grayscale fade animation that the login
69 // background image animation isn't hidden by the splash screen animation.
70 const int kBootSplashScreenHideDurationMs = 500;
72 // Creates a new window for use as a container.
73 aura::Window* CreateContainer(int window_id,
74 const char* name,
75 aura::Window* parent) {
76 aura::Window* container = new aura::Window(NULL);
77 container->set_id(window_id);
78 container->SetName(name);
79 container->Init(ui::LAYER_NOT_DRAWN);
80 parent->AddChild(container);
81 if (window_id != internal::kShellWindowId_UnparentedControlContainer)
82 container->Show();
83 return container;
86 // Reparents |window| to |new_parent|.
87 void ReparentWindow(aura::Window* window, aura::Window* new_parent) {
88 // Update the restore bounds to make it relative to the display.
89 gfx::Rect restore_bounds(GetRestoreBoundsInParent(window));
90 new_parent->AddChild(window);
91 if (!restore_bounds.IsEmpty())
92 SetRestoreBoundsInParent(window, restore_bounds);
95 // Reparents the appropriate set of windows from |src| to |dst|.
96 void ReparentAllWindows(aura::RootWindow* src, aura::RootWindow* dst) {
97 // Set of windows to move.
98 const int kContainerIdsToMove[] = {
99 internal::kShellWindowId_DefaultContainer,
100 internal::kShellWindowId_DockedContainer,
101 internal::kShellWindowId_PanelContainer,
102 internal::kShellWindowId_AlwaysOnTopContainer,
103 internal::kShellWindowId_SystemModalContainer,
104 internal::kShellWindowId_LockSystemModalContainer,
105 internal::kShellWindowId_InputMethodContainer,
106 internal::kShellWindowId_UnparentedControlContainer,
108 for (size_t i = 0; i < arraysize(kContainerIdsToMove); i++) {
109 int id = kContainerIdsToMove[i];
110 aura::Window* src_container = Shell::GetContainer(src, id);
111 aura::Window* dst_container = Shell::GetContainer(dst, id);
112 while (!src_container->children().empty()) {
113 // Restart iteration from the source container windows each time as they
114 // may change as a result of moving other windows.
115 aura::Window::Windows::const_iterator iter =
116 src_container->children().begin();
117 while (iter != src_container->children().end() &&
118 internal::SystemModalContainerLayoutManager::IsModalBackground(
119 *iter)) {
120 ++iter;
122 // If the entire window list is modal background windows then stop.
123 if (iter == src_container->children().end())
124 break;
125 ReparentWindow(*iter, dst_container);
130 // Mark the container window so that a widget added to this container will
131 // use the virtual screeen coordinates instead of parent.
132 void SetUsesScreenCoordinates(aura::Window* container) {
133 container->SetProperty(internal::kUsesScreenCoordinatesKey, true);
136 // Mark the container window so that a widget added to this container will
137 // say in the same root window regardless of the bounds specified.
138 void DescendantShouldStayInSameRootWindow(aura::Window* container) {
139 container->SetProperty(internal::kStayInSameRootWindowKey, true);
142 // A window delegate which does nothing. Used to create a window that
143 // is a event target, but do nothing.
144 class EmptyWindowDelegate : public aura::WindowDelegate {
145 public:
146 EmptyWindowDelegate() {}
147 virtual ~EmptyWindowDelegate() {}
149 // aura::WindowDelegate overrides:
150 virtual gfx::Size GetMinimumSize() const OVERRIDE {
151 return gfx::Size();
153 virtual gfx::Size GetMaximumSize() const OVERRIDE {
154 return gfx::Size();
156 virtual void OnBoundsChanged(const gfx::Rect& old_bounds,
157 const gfx::Rect& new_bounds) OVERRIDE {
159 virtual gfx::NativeCursor GetCursor(const gfx::Point& point) OVERRIDE {
160 return gfx::kNullCursor;
162 virtual int GetNonClientComponent(
163 const gfx::Point& point) const OVERRIDE {
164 return HTNOWHERE;
166 virtual bool ShouldDescendIntoChildForEventHandling(
167 aura::Window* child,
168 const gfx::Point& location) OVERRIDE {
169 return false;
171 virtual bool CanFocus() OVERRIDE {
172 return false;
174 virtual void OnCaptureLost() OVERRIDE {
176 virtual void OnPaint(gfx::Canvas* canvas) OVERRIDE {
178 virtual void OnDeviceScaleFactorChanged(
179 float device_scale_factor) OVERRIDE {
181 virtual void OnWindowDestroying() OVERRIDE {}
182 virtual void OnWindowDestroyed() OVERRIDE {
183 delete this;
185 virtual void OnWindowTargetVisibilityChanged(bool visible) OVERRIDE {
187 virtual bool HasHitTestMask() const OVERRIDE {
188 return false;
190 virtual void GetHitTestMask(gfx::Path* mask) const OVERRIDE {}
191 virtual scoped_refptr<ui::Texture> CopyTexture() OVERRIDE {
192 NOTREACHED();
193 return scoped_refptr<ui::Texture>();
196 private:
197 DISALLOW_COPY_AND_ASSIGN(EmptyWindowDelegate);
200 } // namespace
202 namespace internal {
204 RootWindowController::RootWindowController(aura::RootWindow* root_window)
205 : root_window_(root_window),
206 root_window_layout_(NULL),
207 docked_layout_manager_(NULL),
208 panel_layout_manager_(NULL),
209 touch_hud_debug_(NULL),
210 touch_hud_projection_(NULL) {
211 SetRootWindowController(root_window, this);
212 screen_dimmer_.reset(new ScreenDimmer(root_window));
214 stacking_controller_.reset(new StackingController);
215 aura::client::SetStackingClient(root_window, stacking_controller_.get());
218 RootWindowController::~RootWindowController() {
219 Shutdown();
220 root_window_.reset();
223 // static
224 RootWindowController* RootWindowController::ForLauncher(aura::Window* window) {
225 return GetRootWindowController(window->GetRootWindow());
228 // static
229 RootWindowController* RootWindowController::ForWindow(
230 const aura::Window* window) {
231 return GetRootWindowController(window->GetRootWindow());
234 // static
235 RootWindowController* RootWindowController::ForActiveRootWindow() {
236 return GetRootWindowController(Shell::GetActiveRootWindow());
239 void RootWindowController::SetWallpaperController(
240 DesktopBackgroundWidgetController* controller) {
241 wallpaper_controller_.reset(controller);
244 void RootWindowController::SetAnimatingWallpaperController(
245 AnimatingDesktopController* controller) {
246 if (animating_wallpaper_controller_.get())
247 animating_wallpaper_controller_->StopAnimating();
248 animating_wallpaper_controller_.reset(controller);
251 void RootWindowController::Shutdown() {
252 Shell::GetInstance()->RemoveShellObserver(this);
254 if (animating_wallpaper_controller_.get())
255 animating_wallpaper_controller_->StopAnimating();
256 wallpaper_controller_.reset();
257 animating_wallpaper_controller_.reset();
259 CloseChildWindows();
260 if (Shell::GetActiveRootWindow() == root_window_) {
261 Shell::GetInstance()->set_active_root_window(
262 Shell::GetPrimaryRootWindow() == root_window_.get() ?
263 NULL : Shell::GetPrimaryRootWindow());
265 SetRootWindowController(root_window_.get(), NULL);
266 screen_dimmer_.reset();
267 workspace_controller_.reset();
268 // Forget with the display ID so that display lookup
269 // ends up with invalid display.
270 root_window_->ClearProperty(kDisplayIdKey);
271 // And this root window should no longer process events.
272 root_window_->PrepareForShutdown();
274 system_background_.reset();
277 SystemModalContainerLayoutManager*
278 RootWindowController::GetSystemModalLayoutManager(aura::Window* window) {
279 aura::Window* container = NULL;
280 if (window) {
281 if (window->parent() &&
282 window->parent()->id() >= kShellWindowId_LockScreenContainer) {
283 container = GetContainer(kShellWindowId_LockSystemModalContainer);
284 } else {
285 container = GetContainer(kShellWindowId_SystemModalContainer);
287 } else {
288 int modal_window_id = Shell::GetInstance()->session_state_delegate()
289 ->IsUserSessionBlocked() ? kShellWindowId_LockSystemModalContainer :
290 kShellWindowId_SystemModalContainer;
291 container = GetContainer(modal_window_id);
293 return container ? static_cast<SystemModalContainerLayoutManager*>(
294 container->layout_manager()) : NULL;
297 aura::Window* RootWindowController::GetContainer(int container_id) {
298 return root_window_->GetChildById(container_id);
301 const aura::Window* RootWindowController::GetContainer(int container_id) const {
302 return root_window_->GetChildById(container_id);
305 void RootWindowController::Init(bool first_run_after_boot) {
306 root_window_->SetCursor(ui::kCursorPointer);
307 CreateContainersInRootWindow(root_window_.get());
308 CreateSystemBackground(first_run_after_boot);
310 InitLayoutManagers();
311 InitKeyboard();
312 InitTouchHuds();
314 if (Shell::GetPrimaryRootWindowController()->
315 GetSystemModalLayoutManager(NULL)->has_modal_background()) {
316 GetSystemModalLayoutManager(NULL)->CreateModalBackground();
319 Shell::GetInstance()->AddShellObserver(this);
322 void RootWindowController::ShowLauncher() {
323 if (!shelf_->launcher())
324 return;
325 shelf_->launcher()->SetVisible(true);
326 shelf_->status_area_widget()->Show();
329 void RootWindowController::OnLauncherCreated() {
330 if (panel_layout_manager_)
331 panel_layout_manager_->SetLauncher(shelf_->launcher());
332 if (docked_layout_manager_) {
333 docked_layout_manager_->SetLauncher(shelf_->launcher());
334 if (shelf_->shelf_layout_manager())
335 docked_layout_manager_->AddObserver(shelf_->shelf_layout_manager());
339 void RootWindowController::UpdateAfterLoginStatusChange(
340 user::LoginStatus status) {
341 if (status != user::LOGGED_IN_NONE)
342 mouse_event_target_.reset();
343 if (shelf_->status_area_widget())
344 shelf_->status_area_widget()->UpdateAfterLoginStatusChange(status);
347 void RootWindowController::HandleInitialDesktopBackgroundAnimationStarted() {
348 if (CommandLine::ForCurrentProcess()->HasSwitch(
349 switches::kAshAnimateFromBootSplashScreen) &&
350 boot_splash_screen_.get()) {
351 // Make the splash screen fade out so it doesn't obscure the desktop
352 // wallpaper's brightness/grayscale animation.
353 boot_splash_screen_->StartHideAnimation(
354 base::TimeDelta::FromMilliseconds(kBootSplashScreenHideDurationMs));
358 void RootWindowController::OnWallpaperAnimationFinished(views::Widget* widget) {
359 // Make sure the wallpaper is visible.
360 system_background_->SetColor(SK_ColorBLACK);
361 boot_splash_screen_.reset();
363 Shell::GetInstance()->user_wallpaper_delegate()->
364 OnWallpaperAnimationFinished();
365 // Only removes old component when wallpaper animation finished. If we
366 // remove the old one before the new wallpaper is done fading in there will
367 // be a white flash during the animation.
368 if (animating_wallpaper_controller()) {
369 DesktopBackgroundWidgetController* controller =
370 animating_wallpaper_controller()->GetController(true);
371 // |desktop_widget_| should be the same animating widget we try to move
372 // to |kDesktopController|. Otherwise, we may close |desktop_widget_|
373 // before move it to |kDesktopController|.
374 DCHECK_EQ(controller->widget(), widget);
375 // Release the old controller and close its background widget.
376 SetWallpaperController(controller);
380 void RootWindowController::CloseChildWindows() {
381 mouse_event_target_.reset();
383 if (!shelf_.get())
384 return;
385 // panel_layout_manager_ needs to be shut down before windows are destroyed.
386 if (panel_layout_manager_) {
387 panel_layout_manager_->Shutdown();
388 panel_layout_manager_ = NULL;
390 // docked_layout_manager_ needs to be shut down before windows are destroyed.
391 if (docked_layout_manager_) {
392 if (shelf_->shelf_layout_manager())
393 docked_layout_manager_->RemoveObserver(shelf_->shelf_layout_manager());
394 docked_layout_manager_->Shutdown();
395 docked_layout_manager_ = NULL;
398 // TODO(harrym): Remove when Status Area Widget is a child view.
399 shelf_->ShutdownStatusAreaWidget();
401 if (shelf_->shelf_layout_manager())
402 shelf_->shelf_layout_manager()->PrepareForShutdown();
404 // Close background widget first as it depends on tooltip.
405 wallpaper_controller_.reset();
406 animating_wallpaper_controller_.reset();
408 workspace_controller_.reset();
409 aura::client::SetTooltipClient(root_window_.get(), NULL);
411 while (!root_window_->children().empty()) {
412 aura::Window* child = root_window_->children()[0];
413 delete child;
416 shelf_.reset(NULL);
419 void RootWindowController::MoveWindowsTo(aura::RootWindow* dst) {
420 // Forget the shelf early so that shelf don't update itself using wrong
421 // display info.
422 workspace_controller_->SetShelf(NULL);
423 ReparentAllWindows(root_window_.get(), dst);
426 ShelfLayoutManager* RootWindowController::GetShelfLayoutManager() {
427 return shelf_->shelf_layout_manager();
430 SystemTray* RootWindowController::GetSystemTray() {
431 // We assume in throughout the code that this will not return NULL. If code
432 // triggers this for valid reasons, it should test status_area_widget first.
433 CHECK(shelf_->status_area_widget());
434 return shelf_->status_area_widget()->system_tray();
437 void RootWindowController::ShowContextMenu(const gfx::Point& location_in_screen,
438 ui::MenuSourceType source_type) {
439 DCHECK(Shell::GetInstance()->delegate());
440 scoped_ptr<ui::MenuModel> menu_model(
441 Shell::GetInstance()->delegate()->CreateContextMenu(root_window()));
442 if (!menu_model)
443 return;
445 // Background controller may not be set yet if user clicked on status are
446 // before initial animation completion. See crbug.com/222218
447 if (!wallpaper_controller_.get())
448 return;
450 views::MenuRunner menu_runner(menu_model.get());
451 if (menu_runner.RunMenuAt(wallpaper_controller_->widget(),
452 NULL, gfx::Rect(location_in_screen, gfx::Size()),
453 views::MenuItemView::TOPLEFT, source_type,
454 views::MenuRunner::CONTEXT_MENU) ==
455 views::MenuRunner::MENU_DELETED) {
456 return;
459 Shell::GetInstance()->UpdateShelfVisibility();
462 void RootWindowController::UpdateShelfVisibility() {
463 shelf_->shelf_layout_manager()->UpdateVisibilityState();
466 const aura::Window* RootWindowController::GetFullscreenWindow() const {
467 const aura::Window* container = GetContainer(kShellWindowId_DefaultContainer);
468 for (size_t i = 0; i < container->children().size(); ++i) {
469 aura::Window* child = container->children()[i];
470 if (wm::IsWindowFullscreen(child))
471 return child;
473 return NULL;
476 void RootWindowController::InitKeyboard() {
477 if (keyboard::IsKeyboardEnabled()) {
478 aura::Window* parent = root_window();
480 keyboard::KeyboardControllerProxy* proxy =
481 Shell::GetInstance()->delegate()->CreateKeyboardControllerProxy();
482 keyboard_controller_.reset(
483 new keyboard::KeyboardController(proxy));
485 keyboard_controller_->AddObserver(shelf()->shelf_layout_manager());
486 keyboard_controller_->AddObserver(panel_layout_manager_);
488 aura::Window* keyboard_container =
489 keyboard_controller_->GetContainerWindow();
490 keyboard_container->set_id(kShellWindowId_VirtualKeyboardContainer);
491 parent->AddChild(keyboard_container);
492 keyboard_container->SetBounds(parent->bounds());
497 ////////////////////////////////////////////////////////////////////////////////
498 // RootWindowController, private:
500 void RootWindowController::InitLayoutManagers() {
501 root_window_layout_ =
502 new RootWindowLayoutManager(root_window_.get());
503 root_window_->SetLayoutManager(root_window_layout_);
505 aura::Window* default_container =
506 GetContainer(kShellWindowId_DefaultContainer);
507 // Workspace manager has its own layout managers.
508 workspace_controller_.reset(
509 new WorkspaceController(default_container));
511 aura::Window* always_on_top_container =
512 GetContainer(kShellWindowId_AlwaysOnTopContainer);
513 always_on_top_container->SetLayoutManager(
514 new BaseLayoutManager(
515 always_on_top_container->GetRootWindow()));
516 always_on_top_controller_.reset(new internal::AlwaysOnTopController);
517 always_on_top_controller_->SetAlwaysOnTopContainer(always_on_top_container);
519 DCHECK(!shelf_.get());
520 aura::Window* shelf_container =
521 GetContainer(internal::kShellWindowId_ShelfContainer);
522 // TODO(harrym): Remove when status area is view.
523 aura::Window* status_container =
524 GetContainer(internal::kShellWindowId_StatusContainer);
525 shelf_.reset(new ShelfWidget(
526 shelf_container, status_container, workspace_controller()));
528 if (!Shell::GetInstance()->session_state_delegate()->
529 IsActiveUserSessionStarted()) {
530 // This window exists only to be a event target on login screen.
531 // It does not have to handle events, nor be visible.
532 mouse_event_target_.reset(new aura::Window(new EmptyWindowDelegate));
533 mouse_event_target_->Init(ui::LAYER_NOT_DRAWN);
535 aura::Window* lock_background_container =
536 GetContainer(internal::kShellWindowId_LockScreenBackgroundContainer);
537 lock_background_container->AddChild(mouse_event_target_.get());
538 mouse_event_target_->Show();
541 // Create Docked windows layout manager
542 aura::Window* docked_container = GetContainer(
543 internal::kShellWindowId_DockedContainer);
544 docked_layout_manager_ =
545 new internal::DockedWindowLayoutManager(docked_container);
546 docked_container_handler_.reset(
547 new ToplevelWindowEventHandler(docked_container));
548 docked_container->SetLayoutManager(docked_layout_manager_);
550 // Create Panel layout manager
551 aura::Window* panel_container = GetContainer(
552 internal::kShellWindowId_PanelContainer);
553 panel_layout_manager_ =
554 new internal::PanelLayoutManager(panel_container);
555 panel_container_handler_.reset(
556 new PanelWindowEventHandler(panel_container));
557 panel_container->SetLayoutManager(panel_layout_manager_);
560 void RootWindowController::InitTouchHuds() {
561 CommandLine* command_line = CommandLine::ForCurrentProcess();
562 if (command_line->HasSwitch(switches::kAshTouchHud))
563 set_touch_hud_debug(new TouchHudDebug(root_window_.get()));
564 if (Shell::GetInstance()->is_touch_hud_projection_enabled())
565 EnableTouchHudProjection();
568 void RootWindowController::CreateSystemBackground(
569 bool is_first_run_after_boot) {
570 SkColor color = SK_ColorBLACK;
571 #if defined(OS_CHROMEOS)
572 if (is_first_run_after_boot)
573 color = kChromeOsBootColor;
574 #endif
575 system_background_.reset(
576 new SystemBackgroundController(root_window_.get(), color));
578 #if defined(OS_CHROMEOS)
579 // Make a copy of the system's boot splash screen so we can composite it
580 // onscreen until the desktop background is ready.
581 if (is_first_run_after_boot &&
582 (CommandLine::ForCurrentProcess()->HasSwitch(
583 switches::kAshCopyHostBackgroundAtBoot) ||
584 CommandLine::ForCurrentProcess()->HasSwitch(
585 switches::kAshAnimateFromBootSplashScreen)))
586 boot_splash_screen_.reset(new BootSplashScreen(root_window_.get()));
587 #endif
590 void RootWindowController::CreateContainersInRootWindow(
591 aura::RootWindow* root_window) {
592 // These containers are just used by PowerButtonController to animate groups
593 // of containers simultaneously without messing up the current transformations
594 // on those containers. These are direct children of the root window; all of
595 // the other containers are their children.
597 // The desktop background container is not part of the lock animation, so it
598 // is not included in those animate groups.
599 // When screen is locked desktop background is moved to lock screen background
600 // container (moved back on unlock). We want to make sure that there's an
601 // opaque layer occluding the non-lock-screen layers.
602 aura::Window* desktop_background_container = CreateContainer(
603 kShellWindowId_DesktopBackgroundContainer,
604 "DesktopBackgroundContainer",
605 root_window);
606 views::corewm::SetChildWindowVisibilityChangesAnimated(
607 desktop_background_container);
609 aura::Window* non_lock_screen_containers = CreateContainer(
610 kShellWindowId_NonLockScreenContainersContainer,
611 "NonLockScreenContainersContainer",
612 root_window);
614 aura::Window* lock_background_containers = CreateContainer(
615 kShellWindowId_LockScreenBackgroundContainer,
616 "LockScreenBackgroundContainer",
617 root_window);
618 views::corewm::SetChildWindowVisibilityChangesAnimated(
619 lock_background_containers);
621 aura::Window* lock_screen_containers = CreateContainer(
622 kShellWindowId_LockScreenContainersContainer,
623 "LockScreenContainersContainer",
624 root_window);
625 aura::Window* lock_screen_related_containers = CreateContainer(
626 kShellWindowId_LockScreenRelatedContainersContainer,
627 "LockScreenRelatedContainersContainer",
628 root_window);
630 CreateContainer(kShellWindowId_UnparentedControlContainer,
631 "UnparentedControlContainer",
632 non_lock_screen_containers);
634 aura::Window* default_container = CreateContainer(
635 kShellWindowId_DefaultContainer,
636 "DefaultContainer",
637 non_lock_screen_containers);
638 views::corewm::SetChildWindowVisibilityChangesAnimated(default_container);
639 SetUsesScreenCoordinates(default_container);
641 aura::Window* always_on_top_container = CreateContainer(
642 kShellWindowId_AlwaysOnTopContainer,
643 "AlwaysOnTopContainer",
644 non_lock_screen_containers);
645 always_on_top_container_handler_.reset(
646 new ToplevelWindowEventHandler(always_on_top_container));
647 views::corewm::SetChildWindowVisibilityChangesAnimated(
648 always_on_top_container);
649 SetUsesScreenCoordinates(always_on_top_container);
651 aura::Window* docked_container = CreateContainer(
652 kShellWindowId_DockedContainer,
653 "DockedContainer",
654 non_lock_screen_containers);
655 SetUsesScreenCoordinates(docked_container);
657 aura::Window* panel_container = CreateContainer(
658 kShellWindowId_PanelContainer,
659 "PanelContainer",
660 non_lock_screen_containers);
661 SetUsesScreenCoordinates(panel_container);
663 aura::Window* shelf_container =
664 CreateContainer(kShellWindowId_ShelfContainer,
665 "ShelfContainer",
666 non_lock_screen_containers);
667 SetUsesScreenCoordinates(shelf_container);
668 DescendantShouldStayInSameRootWindow(shelf_container);
670 aura::Window* app_list_container =
671 CreateContainer(kShellWindowId_AppListContainer,
672 "AppListContainer",
673 non_lock_screen_containers);
674 SetUsesScreenCoordinates(app_list_container);
676 aura::Window* modal_container = CreateContainer(
677 kShellWindowId_SystemModalContainer,
678 "SystemModalContainer",
679 non_lock_screen_containers);
680 modal_container_handler_.reset(
681 new ToplevelWindowEventHandler(modal_container));
682 modal_container->SetLayoutManager(
683 new SystemModalContainerLayoutManager(modal_container));
684 views::corewm::SetChildWindowVisibilityChangesAnimated(modal_container);
685 SetUsesScreenCoordinates(modal_container);
687 aura::Window* input_method_container = CreateContainer(
688 kShellWindowId_InputMethodContainer,
689 "InputMethodContainer",
690 non_lock_screen_containers);
691 SetUsesScreenCoordinates(input_method_container);
693 // TODO(beng): Figure out if we can make this use
694 // SystemModalContainerEventFilter instead of stops_event_propagation.
695 aura::Window* lock_container = CreateContainer(
696 kShellWindowId_LockScreenContainer,
697 "LockScreenContainer",
698 lock_screen_containers);
699 lock_container->SetLayoutManager(
700 new BaseLayoutManager(root_window));
701 SetUsesScreenCoordinates(lock_container);
702 // TODO(beng): stopsevents
704 aura::Window* lock_modal_container = CreateContainer(
705 kShellWindowId_LockSystemModalContainer,
706 "LockSystemModalContainer",
707 lock_screen_containers);
708 lock_modal_container_handler_.reset(
709 new ToplevelWindowEventHandler(lock_modal_container));
710 lock_modal_container->SetLayoutManager(
711 new SystemModalContainerLayoutManager(lock_modal_container));
712 views::corewm::SetChildWindowVisibilityChangesAnimated(lock_modal_container);
713 SetUsesScreenCoordinates(lock_modal_container);
715 aura::Window* status_container =
716 CreateContainer(kShellWindowId_StatusContainer,
717 "StatusContainer",
718 lock_screen_related_containers);
719 SetUsesScreenCoordinates(status_container);
720 DescendantShouldStayInSameRootWindow(status_container);
722 aura::Window* settings_bubble_container = CreateContainer(
723 kShellWindowId_SettingBubbleContainer,
724 "SettingBubbleContainer",
725 lock_screen_related_containers);
726 views::corewm::SetChildWindowVisibilityChangesAnimated(
727 settings_bubble_container);
728 SetUsesScreenCoordinates(settings_bubble_container);
729 DescendantShouldStayInSameRootWindow(settings_bubble_container);
731 aura::Window* menu_container = CreateContainer(
732 kShellWindowId_MenuContainer,
733 "MenuContainer",
734 lock_screen_related_containers);
735 views::corewm::SetChildWindowVisibilityChangesAnimated(menu_container);
736 SetUsesScreenCoordinates(menu_container);
738 aura::Window* drag_drop_container = CreateContainer(
739 kShellWindowId_DragImageAndTooltipContainer,
740 "DragImageAndTooltipContainer",
741 lock_screen_related_containers);
742 views::corewm::SetChildWindowVisibilityChangesAnimated(drag_drop_container);
743 SetUsesScreenCoordinates(drag_drop_container);
745 aura::Window* overlay_container = CreateContainer(
746 kShellWindowId_OverlayContainer,
747 "OverlayContainer",
748 lock_screen_related_containers);
749 SetUsesScreenCoordinates(overlay_container);
751 CreateContainer(kShellWindowId_PowerButtonAnimationContainer,
752 "PowerButtonAnimationContainer", root_window) ;
755 void RootWindowController::EnableTouchHudProjection() {
756 if (touch_hud_projection_)
757 return;
758 set_touch_hud_projection(new TouchHudProjection(root_window_.get()));
761 void RootWindowController::DisableTouchHudProjection() {
762 if (!touch_hud_projection_)
763 return;
764 touch_hud_projection_->Remove();
767 void RootWindowController::OnLoginStateChanged(user::LoginStatus status) {
768 shelf_->shelf_layout_manager()->UpdateVisibilityState();
771 void RootWindowController::OnTouchHudProjectionToggled(bool enabled) {
772 if (enabled)
773 EnableTouchHudProjection();
774 else
775 DisableTouchHudProjection();
778 } // namespace internal
779 } // namespace ash