blob: 3cfb6d26b813187ffbd2887439b9fc2e519e9c5b [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]8b3e3d82013-08-20 14:36:307#include <queue>
[email protected]8d625fb2012-07-18 16:40:068#include <vector>
9
[email protected]44d444c2013-01-30 01:47:4410#include "ash/ash_constants.h"
[email protected]e6e41d2f2012-10-29 19:22:1911#include "ash/ash_switches.h"
[email protected]a273d33a2013-10-17 12:41:2112#include "ash/desktop_background/desktop_background_controller.h"
[email protected]b4ddc7a2012-08-07 04:17:3213#include "ash/desktop_background/desktop_background_widget_controller.h"
[email protected]0bf61732013-07-02 04:35:1014#include "ash/desktop_background/user_wallpaper_delegate.h"
[email protected]6bdf7952012-11-14 10:10:5815#include "ash/display/display_manager.h"
[email protected]e74aaf0a2012-10-12 18:42:2816#include "ash/focus_cycler.h"
[email protected]a273d33a2013-10-17 12:41:2117#include "ash/high_contrast/high_contrast_controller.h"
[email protected]f8e6aad2013-08-30 21:49:1118#include "ash/root_window_settings.h"
[email protected]fcb123d2013-04-17 15:58:4919#include "ash/session_state_delegate.h"
[email protected]478c6c32013-03-09 02:50:5820#include "ash/shelf/shelf_layout_manager.h"
21#include "ash/shelf/shelf_types.h"
22#include "ash/shelf/shelf_widget.h"
[email protected]d90b8392012-06-13 09:34:5623#include "ash/shell.h"
[email protected]e74aaf0a2012-10-12 18:42:2824#include "ash/shell_delegate.h"
[email protected]d90b8392012-06-13 09:34:5625#include "ash/shell_factory.h"
26#include "ash/shell_window_ids.h"
[email protected]e74aaf0a2012-10-12 18:42:2827#include "ash/system/status_area_widget.h"
[email protected]8674b312012-10-12 19:02:4428#include "ash/system/tray/system_tray_delegate.h"
[email protected]2b8a9bb2013-07-01 22:43:4029#include "ash/touch/touch_hud_debug.h"
30#include "ash/touch/touch_hud_projection.h"
[email protected]80549c152013-07-02 01:42:4731#include "ash/touch/touch_observer_hud.h"
32#include "ash/wm/always_on_top_controller.h"
[email protected]d90b8392012-06-13 09:34:5633#include "ash/wm/base_layout_manager.h"
[email protected]beb4e5c2013-06-18 15:37:0734#include "ash/wm/dock/docked_window_layout_manager.h"
[email protected]7095a652013-03-07 19:41:4935#include "ash/wm/panels/panel_layout_manager.h"
[email protected]100659412013-06-21 22:59:5536#include "ash/wm/panels/panel_window_event_handler.h"
[email protected]d90b8392012-06-13 09:34:5637#include "ash/wm/root_window_layout_manager.h"
38#include "ash/wm/screen_dimmer.h"
[email protected]2a2caa02013-01-22 20:50:3639#include "ash/wm/stacking_controller.h"
[email protected]e74aaf0a2012-10-12 18:42:2840#include "ash/wm/status_area_layout_manager.h"
[email protected]e6e41d2f2012-10-29 19:22:1941#include "ash/wm/system_background_controller.h"
[email protected]d90b8392012-06-13 09:34:5642#include "ash/wm/system_modal_container_layout_manager.h"
[email protected]5dc51db82012-09-11 03:39:0143#include "ash/wm/toplevel_window_event_handler.h"
[email protected]8d625fb2012-07-18 16:40:0644#include "ash/wm/window_properties.h"
[email protected]a41b4e12013-09-20 04:36:3445#include "ash/wm/window_state.h"
[email protected]700849f2013-04-30 17:49:2046#include "ash/wm/window_util.h"
[email protected]d90b8392012-06-13 09:34:5647#include "ash/wm/workspace_controller.h"
[email protected]e6e41d2f2012-10-29 19:22:1948#include "base/command_line.h"
[email protected]1e84c632013-06-27 23:12:2149#include "base/time/time.h"
[email protected]f1853122012-06-27 16:21:2650#include "ui/aura/client/aura_constants.h"
[email protected]8b3e3d82013-08-20 14:36:3051#include "ui/aura/client/drag_drop_client.h"
[email protected]d90b8392012-06-13 09:34:5652#include "ui/aura/client/tooltip_client.h"
53#include "ui/aura/root_window.h"
[email protected]f1853122012-06-27 16:21:2654#include "ui/aura/window.h"
[email protected]cf6fea22013-08-07 14:24:0155#include "ui/aura/window_delegate.h"
[email protected]f1853122012-06-27 16:21:2656#include "ui/aura/window_observer.h"
[email protected]8b3e3d82013-08-20 14:36:3057#include "ui/aura/window_tracker.h"
[email protected]cf6fea22013-08-07 14:24:0158#include "ui/base/hit_test.h"
[email protected]431552c2012-10-23 00:38:3359#include "ui/base/models/menu_model.h"
[email protected]f8e6aad2013-08-30 21:49:1160#include "ui/gfx/display.h"
[email protected]8d625fb2012-07-18 16:40:0661#include "ui/gfx/screen.h"
[email protected]86459e2c2013-04-10 13:39:2462#include "ui/keyboard/keyboard_controller.h"
63#include "ui/keyboard/keyboard_util.h"
[email protected]431552c2012-10-23 00:38:3364#include "ui/views/controls/menu/menu_runner.h"
[email protected]23a2dc82013-08-22 15:04:2265#include "ui/views/corewm/capture_controller.h"
[email protected]b5756e22012-11-30 01:32:0266#include "ui/views/corewm/visibility_controller.h"
[email protected]431552c2012-10-23 00:38:3367#include "ui/views/view_model.h"
68#include "ui/views/view_model_utils.h"
[email protected]d90b8392012-06-13 09:34:5669
[email protected]252eb232013-08-14 22:09:2770#if defined(OS_CHROMEOS)
71#include "ash/wm/boot_splash_screen_chromeos.h"
72#endif
73
[email protected]d90b8392012-06-13 09:34:5674namespace ash {
75namespace {
76
[email protected]252eb232013-08-14 22:09:2777#if defined(OS_CHROMEOS)
[email protected]bca9a7e2012-11-10 06:25:4978// Duration for the animation that hides the boot splash screen, in
79// milliseconds. This should be short enough in relation to
80// wm/window_animation.cc's brightness/grayscale fade animation that the login
81// background image animation isn't hidden by the splash screen animation.
82const int kBootSplashScreenHideDurationMs = 500;
[email protected]252eb232013-08-14 22:09:2783#endif
[email protected]bca9a7e2012-11-10 06:25:4984
[email protected]d90b8392012-06-13 09:34:5685// Creates a new window for use as a container.
86aura::Window* CreateContainer(int window_id,
87 const char* name,
88 aura::Window* parent) {
89 aura::Window* container = new aura::Window(NULL);
90 container->set_id(window_id);
91 container->SetName(name);
92 container->Init(ui::LAYER_NOT_DRAWN);
93 parent->AddChild(container);
94 if (window_id != internal::kShellWindowId_UnparentedControlContainer)
95 container->Show();
96 return container;
97}
98
[email protected]95058572012-08-20 14:57:2999// Reparents |window| to |new_parent|.
100void ReparentWindow(aura::Window* window, aura::Window* new_parent) {
101 // Update the restore bounds to make it relative to the display.
[email protected]a41b4e12013-09-20 04:36:34102 wm::WindowState* state = wm::GetWindowState(window);
103 gfx::Rect restore_bounds;
104 bool has_restore_bounds = state->HasRestoreBounds();
105 if (has_restore_bounds)
106 restore_bounds = state->GetRestoreBoundsInParent();
[email protected]95058572012-08-20 14:57:29107 new_parent->AddChild(window);
[email protected]a41b4e12013-09-20 04:36:34108 if (has_restore_bounds)
109 state->SetRestoreBoundsInParent(restore_bounds);
[email protected]95058572012-08-20 14:57:29110}
111
112// Reparents the appropriate set of windows from |src| to |dst|.
[email protected]bf9cdb362013-10-25 19:22:45113void ReparentAllWindows(aura::Window* src, aura::Window* dst) {
[email protected]95058572012-08-20 14:57:29114 // Set of windows to move.
[email protected]f1853122012-06-27 16:21:26115 const int kContainerIdsToMove[] = {
116 internal::kShellWindowId_DefaultContainer,
[email protected]beb4e5c2013-06-18 15:37:07117 internal::kShellWindowId_DockedContainer,
[email protected]95db9c12013-01-31 11:47:44118 internal::kShellWindowId_PanelContainer,
[email protected]f1853122012-06-27 16:21:26119 internal::kShellWindowId_AlwaysOnTopContainer,
120 internal::kShellWindowId_SystemModalContainer,
121 internal::kShellWindowId_LockSystemModalContainer,
[email protected]6274d312012-10-04 22:06:41122 internal::kShellWindowId_InputMethodContainer,
[email protected]a9754872013-01-25 07:44:00123 internal::kShellWindowId_UnparentedControlContainer,
[email protected]f1853122012-06-27 16:21:26124 };
[email protected]f1853122012-06-27 16:21:26125 for (size_t i = 0; i < arraysize(kContainerIdsToMove); i++) {
126 int id = kContainerIdsToMove[i];
127 aura::Window* src_container = Shell::GetContainer(src, id);
128 aura::Window* dst_container = Shell::GetContainer(dst, id);
[email protected]5b6021902013-02-26 05:33:29129 while (!src_container->children().empty()) {
130 // Restart iteration from the source container windows each time as they
131 // may change as a result of moving other windows.
132 aura::Window::Windows::const_iterator iter =
133 src_container->children().begin();
134 while (iter != src_container->children().end() &&
135 internal::SystemModalContainerLayoutManager::IsModalBackground(
136 *iter)) {
137 ++iter;
138 }
139 // If the entire window list is modal background windows then stop.
140 if (iter == src_container->children().end())
141 break;
142 ReparentWindow(*iter, dst_container);
[email protected]f1853122012-06-27 16:21:26143 }
144 }
145}
146
[email protected]8d625fb2012-07-18 16:40:06147// Mark the container window so that a widget added to this container will
148// use the virtual screeen coordinates instead of parent.
149void SetUsesScreenCoordinates(aura::Window* container) {
150 container->SetProperty(internal::kUsesScreenCoordinatesKey, true);
151}
152
[email protected]e887c6c2013-07-08 19:35:53153// Mark the container window so that a widget added to this container will
154// say in the same root window regardless of the bounds specified.
155void DescendantShouldStayInSameRootWindow(aura::Window* container) {
156 container->SetProperty(internal::kStayInSameRootWindowKey, true);
157}
158
[email protected]cf6fea22013-08-07 14:24:01159// A window delegate which does nothing. Used to create a window that
160// is a event target, but do nothing.
161class EmptyWindowDelegate : public aura::WindowDelegate {
162 public:
163 EmptyWindowDelegate() {}
164 virtual ~EmptyWindowDelegate() {}
165
166 // aura::WindowDelegate overrides:
167 virtual gfx::Size GetMinimumSize() const OVERRIDE {
168 return gfx::Size();
169 }
170 virtual gfx::Size GetMaximumSize() const OVERRIDE {
171 return gfx::Size();
172 }
173 virtual void OnBoundsChanged(const gfx::Rect& old_bounds,
174 const gfx::Rect& new_bounds) OVERRIDE {
175 }
176 virtual gfx::NativeCursor GetCursor(const gfx::Point& point) OVERRIDE {
177 return gfx::kNullCursor;
178 }
179 virtual int GetNonClientComponent(
180 const gfx::Point& point) const OVERRIDE {
181 return HTNOWHERE;
182 }
183 virtual bool ShouldDescendIntoChildForEventHandling(
184 aura::Window* child,
185 const gfx::Point& location) OVERRIDE {
186 return false;
187 }
188 virtual bool CanFocus() OVERRIDE {
189 return false;
190 }
191 virtual void OnCaptureLost() OVERRIDE {
192 }
193 virtual void OnPaint(gfx::Canvas* canvas) OVERRIDE {
194 }
195 virtual void OnDeviceScaleFactorChanged(
196 float device_scale_factor) OVERRIDE {
197 }
198 virtual void OnWindowDestroying() OVERRIDE {}
[email protected]febe1fd62013-08-07 16:07:24199 virtual void OnWindowDestroyed() OVERRIDE {
200 delete this;
201 }
[email protected]cf6fea22013-08-07 14:24:01202 virtual void OnWindowTargetVisibilityChanged(bool visible) OVERRIDE {
203 }
204 virtual bool HasHitTestMask() const OVERRIDE {
205 return false;
206 }
207 virtual void GetHitTestMask(gfx::Path* mask) const OVERRIDE {}
[email protected]1ddbe932013-09-12 06:23:16208 virtual void DidRecreateLayer(ui::Layer* old_layer,
209 ui::Layer* new_layer) OVERRIDE {}
[email protected]cf6fea22013-08-07 14:24:01210
211 private:
212 DISALLOW_COPY_AND_ASSIGN(EmptyWindowDelegate);
213};
214
[email protected]d90b8392012-06-13 09:34:56215} // namespace
216
217namespace internal {
218
[email protected]a273d33a2013-10-17 12:41:21219void RootWindowController::CreateForPrimaryDisplay(
[email protected]bf9cdb362013-10-25 19:22:45220 aura::RootWindow* root) {
[email protected]a273d33a2013-10-17 12:41:21221 RootWindowController* controller = new RootWindowController(root);
[email protected]608de6c2013-10-29 00:14:28222 controller->Init(RootWindowController::PRIMARY,
[email protected]a273d33a2013-10-17 12:41:21223 Shell::GetInstance()->delegate()->IsFirstRunAfterBoot());
[email protected]d90b8392012-06-13 09:34:56224}
225
[email protected]a273d33a2013-10-17 12:41:21226void RootWindowController::CreateForSecondaryDisplay(aura::RootWindow * root) {
227 RootWindowController* controller = new RootWindowController(root);
[email protected]608de6c2013-10-29 00:14:28228 controller->Init(RootWindowController::SECONDARY, false /* first run */);
229}
230
231void RootWindowController::CreateForVirtualKeyboardDisplay(
232 aura::RootWindow * root) {
233 RootWindowController* controller = new RootWindowController(root);
234 controller->Init(RootWindowController::VIRTUAL_KEYBOARD,
235 false /* first run */);
[email protected]6675e1c2012-09-11 09:15:45236}
237
[email protected]88d71122012-10-18 07:11:01238// static
[email protected]a0afeb12012-12-10 22:57:09239RootWindowController* RootWindowController::ForLauncher(aura::Window* window) {
[email protected]8c0ec432013-05-10 04:33:39240 return GetRootWindowController(window->GetRootWindow());
[email protected]88d71122012-10-18 07:11:01241}
242
[email protected]a0afeb12012-12-10 22:57:09243// static
[email protected]ccff3d72013-02-06 04:26:28244RootWindowController* RootWindowController::ForWindow(
245 const aura::Window* window) {
[email protected]a0afeb12012-12-10 22:57:09246 return GetRootWindowController(window->GetRootWindow());
247}
248
249// static
[email protected]d17642d2013-09-12 23:44:38250RootWindowController* RootWindowController::ForTargetRootWindow() {
251 return internal::GetRootWindowController(Shell::GetTargetRootWindow());
[email protected]a0afeb12012-12-10 22:57:09252}
253
[email protected]a273d33a2013-10-17 12:41:21254RootWindowController::~RootWindowController() {
255 Shutdown();
256 root_window_.reset();
257 // The CaptureClient needs to be around for as long as the RootWindow is
258 // valid.
259 capture_client_.reset();
260}
261
[email protected]0bf61732013-07-02 04:35:10262void RootWindowController::SetWallpaperController(
263 DesktopBackgroundWidgetController* controller) {
264 wallpaper_controller_.reset(controller);
265}
266
267void RootWindowController::SetAnimatingWallpaperController(
268 AnimatingDesktopController* controller) {
269 if (animating_wallpaper_controller_.get())
270 animating_wallpaper_controller_->StopAnimating();
271 animating_wallpaper_controller_.reset(controller);
272}
273
[email protected]6675e1c2012-09-11 09:15:45274void RootWindowController::Shutdown() {
[email protected]d141b922013-07-09 08:13:17275 Shell::GetInstance()->RemoveShellObserver(this);
276
[email protected]0bf61732013-07-02 04:35:10277 if (animating_wallpaper_controller_.get())
278 animating_wallpaper_controller_->StopAnimating();
279 wallpaper_controller_.reset();
280 animating_wallpaper_controller_.reset();
281
[email protected]d17642d2013-09-12 23:44:38282 // Change the target root window before closing child windows. If any child
[email protected]c98a4922013-09-05 20:01:42283 // being removed triggers a relayout of the shelf it will try to build a
[email protected]d17642d2013-09-12 23:44:38284 // window list adding windows from the target root window's containers which
[email protected]c98a4922013-09-05 20:01:42285 // may have already gone away.
[email protected]41baaed2013-11-09 04:18:26286 if (Shell::GetTargetRootWindow() == root_window()) {
[email protected]d17642d2013-09-12 23:44:38287 Shell::GetInstance()->set_target_root_window(
[email protected]41baaed2013-11-09 04:18:26288 Shell::GetPrimaryRootWindow() == root_window() ?
[email protected]f634dd32012-07-23 22:49:07289 NULL : Shell::GetPrimaryRootWindow());
290 }
[email protected]c98a4922013-09-05 20:01:42291
292 CloseChildWindows();
[email protected]41baaed2013-11-09 04:18:26293 GetRootWindowSettings(root_window())->controller = NULL;
[email protected]d90b8392012-06-13 09:34:56294 screen_dimmer_.reset();
295 workspace_controller_.reset();
[email protected]6675e1c2012-09-11 09:15:45296 // Forget with the display ID so that display lookup
297 // ends up with invalid display.
[email protected]41baaed2013-11-09 04:18:26298 internal::GetRootWindowSettings(root_window())->display_id =
[email protected]f8e6aad2013-08-30 21:49:11299 gfx::Display::kInvalidDisplayID;
[email protected]6675e1c2012-09-11 09:15:45300 // And this root window should no longer process events.
301 root_window_->PrepareForShutdown();
[email protected]e74aaf0a2012-10-12 18:42:28302
[email protected]956a6a42012-10-29 23:58:10303 system_background_.reset();
[email protected]d90b8392012-06-13 09:34:56304}
305
[email protected]c0ce80e2012-10-05 23:28:27306SystemModalContainerLayoutManager*
[email protected]8674b312012-10-12 19:02:44307RootWindowController::GetSystemModalLayoutManager(aura::Window* window) {
308 aura::Window* container = NULL;
309 if (window) {
[email protected]3b162e12012-11-09 11:52:35310 if (window->parent() &&
311 window->parent()->id() >= kShellWindowId_LockScreenContainer) {
312 container = GetContainer(kShellWindowId_LockSystemModalContainer);
313 } else {
[email protected]8674b312012-10-12 19:02:44314 container = GetContainer(kShellWindowId_SystemModalContainer);
[email protected]3b162e12012-11-09 11:52:35315 }
[email protected]8674b312012-10-12 19:02:44316 } else {
[email protected]a44afbbd2013-07-24 21:49:35317 int modal_window_id = Shell::GetInstance()->session_state_delegate()
318 ->IsUserSessionBlocked() ? kShellWindowId_LockSystemModalContainer :
319 kShellWindowId_SystemModalContainer;
[email protected]8674b312012-10-12 19:02:44320 container = GetContainer(modal_window_id);
321 }
[email protected]bb0c7cd42013-05-20 23:39:45322 return container ? static_cast<SystemModalContainerLayoutManager*>(
323 container->layout_manager()) : NULL;
[email protected]c0ce80e2012-10-05 23:28:27324}
325
[email protected]d90b8392012-06-13 09:34:56326aura::Window* RootWindowController::GetContainer(int container_id) {
[email protected]41baaed2013-11-09 04:18:26327 return root_window()->GetChildById(container_id);
[email protected]d90b8392012-06-13 09:34:56328}
329
[email protected]d8a24952013-08-05 20:05:05330const aura::Window* RootWindowController::GetContainer(int container_id) const {
[email protected]41baaed2013-11-09 04:18:26331 return root_window_->window()->GetChildById(container_id);
[email protected]d8a24952013-08-05 20:05:05332}
333
[email protected]e74aaf0a2012-10-12 18:42:28334void RootWindowController::ShowLauncher() {
[email protected]80549c152013-07-02 01:42:47335 if (!shelf_->launcher())
[email protected]e74aaf0a2012-10-12 18:42:28336 return;
[email protected]478c6c32013-03-09 02:50:58337 shelf_->launcher()->SetVisible(true);
338 shelf_->status_area_widget()->Show();
[email protected]e74aaf0a2012-10-12 18:42:28339}
340
[email protected]756bda12013-07-03 08:17:06341void RootWindowController::OnLauncherCreated() {
342 if (panel_layout_manager_)
343 panel_layout_manager_->SetLauncher(shelf_->launcher());
[email protected]7115bd32013-07-19 08:25:39344 if (docked_layout_manager_) {
[email protected]756bda12013-07-03 08:17:06345 docked_layout_manager_->SetLauncher(shelf_->launcher());
[email protected]7115bd32013-07-19 08:25:39346 if (shelf_->shelf_layout_manager())
347 docked_layout_manager_->AddObserver(shelf_->shelf_layout_manager());
348 }
[email protected]756bda12013-07-03 08:17:06349}
350
[email protected]16059276d2012-10-22 18:59:50351void RootWindowController::UpdateAfterLoginStatusChange(
352 user::LoginStatus status) {
[email protected]cf6fea22013-08-07 14:24:01353 if (status != user::LOGGED_IN_NONE)
354 mouse_event_target_.reset();
[email protected]80549c152013-07-02 01:42:47355 if (shelf_->status_area_widget())
[email protected]478c6c32013-03-09 02:50:58356 shelf_->status_area_widget()->UpdateAfterLoginStatusChange(status);
[email protected]16059276d2012-10-22 18:59:50357}
358
[email protected]bca9a7e2012-11-10 06:25:49359void RootWindowController::HandleInitialDesktopBackgroundAnimationStarted() {
[email protected]252eb232013-08-14 22:09:27360#if defined(OS_CHROMEOS)
[email protected]bca9a7e2012-11-10 06:25:49361 if (CommandLine::ForCurrentProcess()->HasSwitch(
362 switches::kAshAnimateFromBootSplashScreen) &&
363 boot_splash_screen_.get()) {
364 // Make the splash screen fade out so it doesn't obscure the desktop
365 // wallpaper's brightness/grayscale animation.
366 boot_splash_screen_->StartHideAnimation(
367 base::TimeDelta::FromMilliseconds(kBootSplashScreenHideDurationMs));
368 }
[email protected]252eb232013-08-14 22:09:27369#endif
[email protected]bca9a7e2012-11-10 06:25:49370}
371
[email protected]0bf61732013-07-02 04:35:10372void RootWindowController::OnWallpaperAnimationFinished(views::Widget* widget) {
373 // Make sure the wallpaper is visible.
[email protected]bca9a7e2012-11-10 06:25:49374 system_background_->SetColor(SK_ColorBLACK);
[email protected]252eb232013-08-14 22:09:27375#if defined(OS_CHROMEOS)
[email protected]bca9a7e2012-11-10 06:25:49376 boot_splash_screen_.reset();
[email protected]252eb232013-08-14 22:09:27377#endif
[email protected]0bf61732013-07-02 04:35:10378
379 Shell::GetInstance()->user_wallpaper_delegate()->
380 OnWallpaperAnimationFinished();
381 // Only removes old component when wallpaper animation finished. If we
382 // remove the old one before the new wallpaper is done fading in there will
383 // be a white flash during the animation.
384 if (animating_wallpaper_controller()) {
385 DesktopBackgroundWidgetController* controller =
386 animating_wallpaper_controller()->GetController(true);
387 // |desktop_widget_| should be the same animating widget we try to move
388 // to |kDesktopController|. Otherwise, we may close |desktop_widget_|
389 // before move it to |kDesktopController|.
390 DCHECK_EQ(controller->widget(), widget);
391 // Release the old controller and close its background widget.
392 SetWallpaperController(controller);
393 }
[email protected]697f04c2012-10-03 01:15:10394}
395
[email protected]d90b8392012-06-13 09:34:56396void RootWindowController::CloseChildWindows() {
[email protected]cf6fea22013-08-07 14:24:01397 mouse_event_target_.reset();
398
[email protected]b6ba05d902013-10-04 21:38:45399 // Deactivate keyboard container before closing child windows and shutting
400 // down associated layout managers.
401 DeactivateKeyboard(Shell::GetInstance()->keyboard_controller());
402
[email protected]79a87b7e2013-01-25 05:08:22403 // panel_layout_manager_ needs to be shut down before windows are destroyed.
404 if (panel_layout_manager_) {
405 panel_layout_manager_->Shutdown();
406 panel_layout_manager_ = NULL;
407 }
[email protected]7115bd32013-07-19 08:25:39408 // docked_layout_manager_ needs to be shut down before windows are destroyed.
409 if (docked_layout_manager_) {
[email protected]bb42c932013-10-31 06:52:06410 if (shelf_ && shelf_->shelf_layout_manager())
[email protected]7115bd32013-07-19 08:25:39411 docked_layout_manager_->RemoveObserver(shelf_->shelf_layout_manager());
412 docked_layout_manager_->Shutdown();
413 docked_layout_manager_ = NULL;
414 }
[email protected]79a87b7e2013-01-25 05:08:22415
[email protected]41baaed2013-11-09 04:18:26416 aura::client::SetDragDropClient(root_window(), NULL);
[email protected]8b3e3d82013-08-20 14:36:30417
[email protected]478c6c32013-03-09 02:50:58418 // TODO(harrym): Remove when Status Area Widget is a child view.
[email protected]bb42c932013-10-31 06:52:06419 if (shelf_) {
420 shelf_->ShutdownStatusAreaWidget();
[email protected]478c6c32013-03-09 02:50:58421
[email protected]bb42c932013-10-31 06:52:06422 if (shelf_->shelf_layout_manager())
423 shelf_->shelf_layout_manager()->PrepareForShutdown();
424 }
[email protected]e74aaf0a2012-10-12 18:42:28425
[email protected]d90b8392012-06-13 09:34:56426 // Close background widget first as it depends on tooltip.
[email protected]0bf61732013-07-02 04:35:10427 wallpaper_controller_.reset();
428 animating_wallpaper_controller_.reset();
[email protected]b4ddc7a2012-08-07 04:17:32429
[email protected]d90b8392012-06-13 09:34:56430 workspace_controller_.reset();
[email protected]41baaed2013-11-09 04:18:26431 aura::client::SetTooltipClient(root_window(), NULL);
[email protected]d90b8392012-06-13 09:34:56432
[email protected]0fbfa972013-10-02 19:23:33433 // Explicitly destroy top level windows. We do this as during part of
434 // destruction such windows may query the RootWindow for state.
[email protected]8b3e3d82013-08-20 14:36:30435 std::queue<aura::Window*> non_toplevel_windows;
[email protected]41baaed2013-11-09 04:18:26436 non_toplevel_windows.push(root_window());
[email protected]8b3e3d82013-08-20 14:36:30437 while (!non_toplevel_windows.empty()) {
438 aura::Window* non_toplevel_window = non_toplevel_windows.front();
439 non_toplevel_windows.pop();
440 aura::WindowTracker toplevel_windows;
441 for (size_t i = 0; i < non_toplevel_window->children().size(); ++i) {
442 aura::Window* child = non_toplevel_window->children()[i];
[email protected]0fbfa972013-10-02 19:23:33443 if (!child->owned_by_parent())
444 continue;
[email protected]8b3e3d82013-08-20 14:36:30445 if (child->delegate())
446 toplevel_windows.Add(child);
447 else
448 non_toplevel_windows.push(child);
449 }
450 while (!toplevel_windows.windows().empty())
451 delete *toplevel_windows.windows().begin();
[email protected]d90b8392012-06-13 09:34:56452 }
[email protected]8b3e3d82013-08-20 14:36:30453 // And then remove the containers.
[email protected]41baaed2013-11-09 04:18:26454 while (!root_window()->children().empty()) {
455 aura::Window* window = root_window()->children()[0];
[email protected]0fbfa972013-10-02 19:23:33456 if (window->owned_by_parent()) {
457 delete window;
458 } else {
[email protected]41baaed2013-11-09 04:18:26459 root_window()->RemoveChild(window);
[email protected]0fbfa972013-10-02 19:23:33460 }
461 }
[email protected]478c6c32013-03-09 02:50:58462
[email protected]bb42c932013-10-31 06:52:06463 shelf_.reset();
[email protected]d90b8392012-06-13 09:34:56464}
465
[email protected]bf9cdb362013-10-25 19:22:45466void RootWindowController::MoveWindowsTo(aura::Window* dst) {
[email protected]8039e06c2013-01-17 23:34:50467 // Forget the shelf early so that shelf don't update itself using wrong
468 // display info.
469 workspace_controller_->SetShelf(NULL);
[email protected]41baaed2013-11-09 04:18:26470 ReparentAllWindows(root_window(), dst);
[email protected]f1853122012-06-27 16:21:26471}
472
[email protected]478c6c32013-03-09 02:50:58473ShelfLayoutManager* RootWindowController::GetShelfLayoutManager() {
[email protected]80549c152013-07-02 01:42:47474 return shelf_->shelf_layout_manager();
[email protected]478c6c32013-03-09 02:50:58475}
476
[email protected]a0afeb12012-12-10 22:57:09477SystemTray* RootWindowController::GetSystemTray() {
478 // We assume in throughout the code that this will not return NULL. If code
479 // triggers this for valid reasons, it should test status_area_widget first.
[email protected]80549c152013-07-02 01:42:47480 CHECK(shelf_->status_area_widget());
[email protected]478c6c32013-03-09 02:50:58481 return shelf_->status_area_widget()->system_tray();
[email protected]a0afeb12012-12-10 22:57:09482}
483
[email protected]940fb1c2013-06-18 16:54:28484void RootWindowController::ShowContextMenu(const gfx::Point& location_in_screen,
485 ui::MenuSourceType source_type) {
[email protected]431552c2012-10-23 00:38:33486 DCHECK(Shell::GetInstance()->delegate());
487 scoped_ptr<ui::MenuModel> menu_model(
[email protected]8c0ec432013-05-10 04:33:39488 Shell::GetInstance()->delegate()->CreateContextMenu(root_window()));
[email protected]7f7f65c2013-04-17 16:47:13489 if (!menu_model)
[email protected]8e837ec2013-01-31 01:48:33490 return;
[email protected]431552c2012-10-23 00:38:33491
[email protected]6175fc42013-04-05 05:58:58492 // Background controller may not be set yet if user clicked on status are
493 // before initial animation completion. See crbug.com/222218
[email protected]0bf61732013-07-02 04:35:10494 if (!wallpaper_controller_.get())
[email protected]431552c2012-10-23 00:38:33495 return;
496
[email protected]6175fc42013-04-05 05:58:58497 views::MenuRunner menu_runner(menu_model.get());
[email protected]0bf61732013-07-02 04:35:10498 if (menu_runner.RunMenuAt(wallpaper_controller_->widget(),
[email protected]6175fc42013-04-05 05:58:58499 NULL, gfx::Rect(location_in_screen, gfx::Size()),
[email protected]940fb1c2013-06-18 16:54:28500 views::MenuItemView::TOPLEFT, source_type,
501 views::MenuRunner::CONTEXT_MENU) ==
[email protected]6175fc42013-04-05 05:58:58502 views::MenuRunner::MENU_DELETED) {
503 return;
504 }
505
[email protected]431552c2012-10-23 00:38:33506 Shell::GetInstance()->UpdateShelfVisibility();
507}
508
[email protected]e74aaf0a2012-10-12 18:42:28509void RootWindowController::UpdateShelfVisibility() {
[email protected]478c6c32013-03-09 02:50:58510 shelf_->shelf_layout_manager()->UpdateVisibilityState();
[email protected]e74aaf0a2012-10-12 18:42:28511}
512
[email protected]e3bc88e2013-09-06 06:22:06513const aura::Window* RootWindowController::GetTopmostFullscreenWindow() const {
514 const aura::Window::Windows& windows =
515 GetContainer(kShellWindowId_DefaultContainer)->children();
516 for (aura::Window::Windows::const_reverse_iterator iter = windows.rbegin();
517 iter != windows.rend(); ++iter) {
[email protected]a41b4e12013-09-20 04:36:34518 if (wm::GetWindowState(*iter)->IsFullscreen())
[email protected]e3bc88e2013-09-06 06:22:06519 return *iter;
[email protected]2ee2f5d2013-01-10 23:37:16520 }
[email protected]700849f2013-04-30 17:49:20521 return NULL;
[email protected]2ee2f5d2013-01-10 23:37:16522}
523
[email protected]b6ba05d902013-10-04 21:38:45524void RootWindowController::ActivateKeyboard(
525 keyboard::KeyboardController* keyboard_controller) {
526 if (!keyboard::IsKeyboardEnabled() ||
527 GetContainer(kShellWindowId_VirtualKeyboardContainer)) {
528 return;
529 }
530 DCHECK(keyboard_controller);
531 keyboard_controller->AddObserver(shelf()->shelf_layout_manager());
532 keyboard_controller->AddObserver(panel_layout_manager_);
533 keyboard_controller->AddObserver(docked_layout_manager_);
534 aura::Window* parent = root_window();
535 aura::Window* keyboard_container =
536 keyboard_controller->GetContainerWindow();
537 keyboard_container->set_id(kShellWindowId_VirtualKeyboardContainer);
538 parent->AddChild(keyboard_container);
539 // TODO(oshima): Bounds of keyboard container should be handled by
540 // RootWindowLayoutManager. Remove this after fixed RootWindowLayoutManager.
541 keyboard_container->SetBounds(parent->bounds());
542}
[email protected]86459e2c2013-04-10 13:39:24543
[email protected]b6ba05d902013-10-04 21:38:45544void RootWindowController::DeactivateKeyboard(
545 keyboard::KeyboardController* keyboard_controller) {
546 if (!keyboard::IsKeyboardEnabled())
547 return;
[email protected]5416f282013-04-29 20:52:48548
[email protected]b6ba05d902013-10-04 21:38:45549 DCHECK(keyboard_controller);
550 aura::Window* keyboard_container =
551 keyboard_controller->GetContainerWindow();
552 if (keyboard_container->GetRootWindow() == root_window()) {
553 root_window()->RemoveChild(keyboard_container);
554 keyboard_controller->RemoveObserver(shelf()->shelf_layout_manager());
555 keyboard_controller->RemoveObserver(panel_layout_manager_);
556 keyboard_controller->RemoveObserver(docked_layout_manager_);
[email protected]86459e2c2013-04-10 13:39:24557 }
558}
559
560
[email protected]a4cd6d32012-09-12 03:42:13561////////////////////////////////////////////////////////////////////////////////
562// RootWindowController, private:
563
[email protected]a273d33a2013-10-17 12:41:21564RootWindowController::RootWindowController(aura::RootWindow* root_window)
565 : root_window_(root_window),
566 root_window_layout_(NULL),
567 docked_layout_manager_(NULL),
568 panel_layout_manager_(NULL),
569 touch_hud_debug_(NULL),
570 touch_hud_projection_(NULL) {
[email protected]41baaed2013-11-09 04:18:26571 GetRootWindowSettings(root_window_->window())->controller = this;
572 screen_dimmer_.reset(new ScreenDimmer(root_window_->window()));
[email protected]a273d33a2013-10-17 12:41:21573
574 stacking_controller_.reset(new StackingController);
[email protected]41baaed2013-11-09 04:18:26575 aura::client::SetWindowTreeClient(root_window_->window(),
576 stacking_controller_.get());
577 capture_client_.reset(
578 new views::corewm::ScopedCaptureClient(root_window_->window()));
[email protected]a273d33a2013-10-17 12:41:21579}
580
[email protected]608de6c2013-10-29 00:14:28581void RootWindowController::Init(RootWindowType root_window_type,
582 bool first_run_after_boot) {
[email protected]41baaed2013-11-09 04:18:26583 Shell::GetInstance()->InitRootWindow(root_window());
[email protected]a273d33a2013-10-17 12:41:21584
585 root_window_->SetCursor(ui::kCursorPointer);
586 CreateContainersInRootWindow(root_window_.get());
[email protected]608de6c2013-10-29 00:14:28587
588 if (root_window_type == VIRTUAL_KEYBOARD)
589 return;
590
[email protected]a273d33a2013-10-17 12:41:21591 CreateSystemBackground(first_run_after_boot);
592
593 InitLayoutManagers();
594 InitTouchHuds();
595
596 if (Shell::GetPrimaryRootWindowController()->
597 GetSystemModalLayoutManager(NULL)->has_modal_background()) {
598 GetSystemModalLayoutManager(NULL)->CreateModalBackground();
599 }
600
601 Shell* shell = Shell::GetInstance();
602 shell->AddShellObserver(this);
603
[email protected]608de6c2013-10-29 00:14:28604 if (root_window_type == PRIMARY) {
[email protected]a3565792013-10-18 12:52:37605 root_window_layout()->OnWindowResized();
[email protected]a273d33a2013-10-17 12:41:21606 shell->InitKeyboard(this);
607 } else {
608 root_window_layout()->OnWindowResized();
[email protected]41baaed2013-11-09 04:18:26609 shell->desktop_background_controller()->OnRootWindowAdded(root_window());
[email protected]a273d33a2013-10-17 12:41:21610 shell->high_contrast_controller()->OnRootWindowAdded(root_window_.get());
611 root_window_->ShowRootWindow();
[email protected]a273d33a2013-10-17 12:41:21612
613 // Create a launcher if a user is already logged.
614 if (shell->session_state_delegate()->NumberOfLoggedInUsers())
615 shelf()->CreateLauncher();
616 }
617}
618
[email protected]756bda12013-07-03 08:17:06619void RootWindowController::InitLayoutManagers() {
[email protected]41baaed2013-11-09 04:18:26620 root_window_layout_ = new RootWindowLayoutManager(root_window());
621 root_window()->SetLayoutManager(root_window_layout_);
[email protected]756bda12013-07-03 08:17:06622
623 aura::Window* default_container =
624 GetContainer(kShellWindowId_DefaultContainer);
625 // Workspace manager has its own layout managers.
626 workspace_controller_.reset(
627 new WorkspaceController(default_container));
628
629 aura::Window* always_on_top_container =
630 GetContainer(kShellWindowId_AlwaysOnTopContainer);
631 always_on_top_container->SetLayoutManager(
632 new BaseLayoutManager(
633 always_on_top_container->GetRootWindow()));
634 always_on_top_controller_.reset(new internal::AlwaysOnTopController);
635 always_on_top_controller_->SetAlwaysOnTopContainer(always_on_top_container);
636
637 DCHECK(!shelf_.get());
638 aura::Window* shelf_container =
639 GetContainer(internal::kShellWindowId_ShelfContainer);
640 // TODO(harrym): Remove when status area is view.
641 aura::Window* status_container =
642 GetContainer(internal::kShellWindowId_StatusContainer);
643 shelf_.reset(new ShelfWidget(
644 shelf_container, status_container, workspace_controller()));
645
[email protected]cf6fea22013-08-07 14:24:01646 if (!Shell::GetInstance()->session_state_delegate()->
647 IsActiveUserSessionStarted()) {
648 // This window exists only to be a event target on login screen.
649 // It does not have to handle events, nor be visible.
650 mouse_event_target_.reset(new aura::Window(new EmptyWindowDelegate));
651 mouse_event_target_->Init(ui::LAYER_NOT_DRAWN);
652
653 aura::Window* lock_background_container =
654 GetContainer(internal::kShellWindowId_LockScreenBackgroundContainer);
655 lock_background_container->AddChild(mouse_event_target_.get());
656 mouse_event_target_->Show();
657 }
658
[email protected]756bda12013-07-03 08:17:06659 // Create Docked windows layout manager
660 aura::Window* docked_container = GetContainer(
661 internal::kShellWindowId_DockedContainer);
662 docked_layout_manager_ =
[email protected]375069e2013-10-04 13:54:31663 new internal::DockedWindowLayoutManager(docked_container,
664 workspace_controller());
[email protected]756bda12013-07-03 08:17:06665 docked_container_handler_.reset(
666 new ToplevelWindowEventHandler(docked_container));
667 docked_container->SetLayoutManager(docked_layout_manager_);
668
669 // Create Panel layout manager
670 aura::Window* panel_container = GetContainer(
671 internal::kShellWindowId_PanelContainer);
672 panel_layout_manager_ =
673 new internal::PanelLayoutManager(panel_container);
674 panel_container_handler_.reset(
675 new PanelWindowEventHandler(panel_container));
676 panel_container->SetLayoutManager(panel_layout_manager_);
677}
678
679void RootWindowController::InitTouchHuds() {
680 CommandLine* command_line = CommandLine::ForCurrentProcess();
681 if (command_line->HasSwitch(switches::kAshTouchHud))
[email protected]41baaed2013-11-09 04:18:26682 set_touch_hud_debug(new TouchHudDebug(root_window()));
[email protected]756bda12013-07-03 08:17:06683 if (Shell::GetInstance()->is_touch_hud_projection_enabled())
684 EnableTouchHudProjection();
685}
686
687void RootWindowController::CreateSystemBackground(
688 bool is_first_run_after_boot) {
689 SkColor color = SK_ColorBLACK;
690#if defined(OS_CHROMEOS)
691 if (is_first_run_after_boot)
692 color = kChromeOsBootColor;
693#endif
694 system_background_.reset(
[email protected]41baaed2013-11-09 04:18:26695 new SystemBackgroundController(root_window(), color));
[email protected]756bda12013-07-03 08:17:06696
697#if defined(OS_CHROMEOS)
698 // Make a copy of the system's boot splash screen so we can composite it
699 // onscreen until the desktop background is ready.
700 if (is_first_run_after_boot &&
701 (CommandLine::ForCurrentProcess()->HasSwitch(
702 switches::kAshCopyHostBackgroundAtBoot) ||
703 CommandLine::ForCurrentProcess()->HasSwitch(
704 switches::kAshAnimateFromBootSplashScreen)))
705 boot_splash_screen_.reset(new BootSplashScreen(root_window_.get()));
706#endif
707}
708
[email protected]a4cd6d32012-09-12 03:42:13709void RootWindowController::CreateContainersInRootWindow(
[email protected]41baaed2013-11-09 04:18:26710 aura::Window* root_window) {
[email protected]a4cd6d32012-09-12 03:42:13711 // These containers are just used by PowerButtonController to animate groups
712 // of containers simultaneously without messing up the current transformations
713 // on those containers. These are direct children of the root window; all of
714 // the other containers are their children.
[email protected]e6e41d2f2012-10-29 19:22:19715
716 // The desktop background container is not part of the lock animation, so it
717 // is not included in those animate groups.
[email protected]a4cd6d32012-09-12 03:42:13718 // When screen is locked desktop background is moved to lock screen background
719 // container (moved back on unlock). We want to make sure that there's an
720 // opaque layer occluding the non-lock-screen layers.
[email protected]e6e41d2f2012-10-29 19:22:19721 aura::Window* desktop_background_container = CreateContainer(
[email protected]c0ce80e2012-10-05 23:28:27722 kShellWindowId_DesktopBackgroundContainer,
[email protected]a4cd6d32012-09-12 03:42:13723 "DesktopBackgroundContainer",
724 root_window);
[email protected]b5756e22012-11-30 01:32:02725 views::corewm::SetChildWindowVisibilityChangesAnimated(
726 desktop_background_container);
[email protected]a4cd6d32012-09-12 03:42:13727
728 aura::Window* non_lock_screen_containers = CreateContainer(
[email protected]c0ce80e2012-10-05 23:28:27729 kShellWindowId_NonLockScreenContainersContainer,
[email protected]a4cd6d32012-09-12 03:42:13730 "NonLockScreenContainersContainer",
731 root_window);
732
733 aura::Window* lock_background_containers = CreateContainer(
[email protected]c0ce80e2012-10-05 23:28:27734 kShellWindowId_LockScreenBackgroundContainer,
[email protected]a4cd6d32012-09-12 03:42:13735 "LockScreenBackgroundContainer",
736 root_window);
[email protected]b5756e22012-11-30 01:32:02737 views::corewm::SetChildWindowVisibilityChangesAnimated(
738 lock_background_containers);
[email protected]a4cd6d32012-09-12 03:42:13739
740 aura::Window* lock_screen_containers = CreateContainer(
[email protected]c0ce80e2012-10-05 23:28:27741 kShellWindowId_LockScreenContainersContainer,
[email protected]a4cd6d32012-09-12 03:42:13742 "LockScreenContainersContainer",
743 root_window);
744 aura::Window* lock_screen_related_containers = CreateContainer(
[email protected]c0ce80e2012-10-05 23:28:27745 kShellWindowId_LockScreenRelatedContainersContainer,
[email protected]a4cd6d32012-09-12 03:42:13746 "LockScreenRelatedContainersContainer",
747 root_window);
748
[email protected]c0ce80e2012-10-05 23:28:27749 CreateContainer(kShellWindowId_UnparentedControlContainer,
[email protected]a4cd6d32012-09-12 03:42:13750 "UnparentedControlContainer",
751 non_lock_screen_containers);
752
753 aura::Window* default_container = CreateContainer(
[email protected]c0ce80e2012-10-05 23:28:27754 kShellWindowId_DefaultContainer,
[email protected]a4cd6d32012-09-12 03:42:13755 "DefaultContainer",
756 non_lock_screen_containers);
[email protected]b5756e22012-11-30 01:32:02757 views::corewm::SetChildWindowVisibilityChangesAnimated(default_container);
[email protected]a4cd6d32012-09-12 03:42:13758 SetUsesScreenCoordinates(default_container);
759
760 aura::Window* always_on_top_container = CreateContainer(
[email protected]c0ce80e2012-10-05 23:28:27761 kShellWindowId_AlwaysOnTopContainer,
[email protected]a4cd6d32012-09-12 03:42:13762 "AlwaysOnTopContainer",
763 non_lock_screen_containers);
764 always_on_top_container_handler_.reset(
765 new ToplevelWindowEventHandler(always_on_top_container));
[email protected]b5756e22012-11-30 01:32:02766 views::corewm::SetChildWindowVisibilityChangesAnimated(
767 always_on_top_container);
[email protected]a4cd6d32012-09-12 03:42:13768 SetUsesScreenCoordinates(always_on_top_container);
769
[email protected]beb4e5c2013-06-18 15:37:07770 aura::Window* docked_container = CreateContainer(
771 kShellWindowId_DockedContainer,
772 "DockedContainer",
773 non_lock_screen_containers);
[email protected]5eab6e92013-09-19 19:09:27774 views::corewm::SetChildWindowVisibilityChangesAnimated(docked_container);
[email protected]beb4e5c2013-06-18 15:37:07775 SetUsesScreenCoordinates(docked_container);
776
[email protected]3f13cf12013-07-12 05:13:59777 aura::Window* shelf_container =
[email protected]478c6c32013-03-09 02:50:58778 CreateContainer(kShellWindowId_ShelfContainer,
[email protected]3f13cf12013-07-12 05:13:59779 "ShelfContainer",
[email protected]a4cd6d32012-09-12 03:42:13780 non_lock_screen_containers);
[email protected]3f13cf12013-07-12 05:13:59781 SetUsesScreenCoordinates(shelf_container);
782 DescendantShouldStayInSameRootWindow(shelf_container);
[email protected]a4cd6d32012-09-12 03:42:13783
[email protected]f2026eb2013-10-22 14:28:56784 aura::Window* panel_container = CreateContainer(
785 kShellWindowId_PanelContainer,
786 "PanelContainer",
787 non_lock_screen_containers);
788 SetUsesScreenCoordinates(panel_container);
789
790 aura::Window* shelf_bubble_container =
791 CreateContainer(kShellWindowId_ShelfBubbleContainer,
792 "ShelfBubbleContainer",
793 non_lock_screen_containers);
794 SetUsesScreenCoordinates(shelf_bubble_container);
795 DescendantShouldStayInSameRootWindow(shelf_bubble_container);
796
[email protected]dc851a4e52012-10-03 00:05:55797 aura::Window* app_list_container =
[email protected]c0ce80e2012-10-05 23:28:27798 CreateContainer(kShellWindowId_AppListContainer,
[email protected]dc851a4e52012-10-03 00:05:55799 "AppListContainer",
800 non_lock_screen_containers);
801 SetUsesScreenCoordinates(app_list_container);
[email protected]a4cd6d32012-09-12 03:42:13802
803 aura::Window* modal_container = CreateContainer(
[email protected]c0ce80e2012-10-05 23:28:27804 kShellWindowId_SystemModalContainer,
[email protected]a4cd6d32012-09-12 03:42:13805 "SystemModalContainer",
806 non_lock_screen_containers);
807 modal_container_handler_.reset(
808 new ToplevelWindowEventHandler(modal_container));
[email protected]a4cd6d32012-09-12 03:42:13809 modal_container->SetLayoutManager(
[email protected]c0ce80e2012-10-05 23:28:27810 new SystemModalContainerLayoutManager(modal_container));
[email protected]b5756e22012-11-30 01:32:02811 views::corewm::SetChildWindowVisibilityChangesAnimated(modal_container);
[email protected]a4cd6d32012-09-12 03:42:13812 SetUsesScreenCoordinates(modal_container);
813
814 aura::Window* input_method_container = CreateContainer(
[email protected]c0ce80e2012-10-05 23:28:27815 kShellWindowId_InputMethodContainer,
[email protected]a4cd6d32012-09-12 03:42:13816 "InputMethodContainer",
817 non_lock_screen_containers);
[email protected]649eb7462013-10-24 07:52:01818 views::corewm::SetChildWindowVisibilityChangesAnimated(
819 input_method_container);
[email protected]a4cd6d32012-09-12 03:42:13820 SetUsesScreenCoordinates(input_method_container);
821
822 // TODO(beng): Figure out if we can make this use
823 // SystemModalContainerEventFilter instead of stops_event_propagation.
824 aura::Window* lock_container = CreateContainer(
[email protected]c0ce80e2012-10-05 23:28:27825 kShellWindowId_LockScreenContainer,
[email protected]a4cd6d32012-09-12 03:42:13826 "LockScreenContainer",
827 lock_screen_containers);
828 lock_container->SetLayoutManager(
[email protected]c0ce80e2012-10-05 23:28:27829 new BaseLayoutManager(root_window));
[email protected]a4cd6d32012-09-12 03:42:13830 SetUsesScreenCoordinates(lock_container);
831 // TODO(beng): stopsevents
832
833 aura::Window* lock_modal_container = CreateContainer(
[email protected]c0ce80e2012-10-05 23:28:27834 kShellWindowId_LockSystemModalContainer,
[email protected]a4cd6d32012-09-12 03:42:13835 "LockSystemModalContainer",
836 lock_screen_containers);
837 lock_modal_container_handler_.reset(
838 new ToplevelWindowEventHandler(lock_modal_container));
[email protected]a4cd6d32012-09-12 03:42:13839 lock_modal_container->SetLayoutManager(
[email protected]c0ce80e2012-10-05 23:28:27840 new SystemModalContainerLayoutManager(lock_modal_container));
[email protected]b5756e22012-11-30 01:32:02841 views::corewm::SetChildWindowVisibilityChangesAnimated(lock_modal_container);
[email protected]a4cd6d32012-09-12 03:42:13842 SetUsesScreenCoordinates(lock_modal_container);
843
844 aura::Window* status_container =
[email protected]c0ce80e2012-10-05 23:28:27845 CreateContainer(kShellWindowId_StatusContainer,
[email protected]a4cd6d32012-09-12 03:42:13846 "StatusContainer",
847 lock_screen_related_containers);
848 SetUsesScreenCoordinates(status_container);
[email protected]e887c6c2013-07-08 19:35:53849 DescendantShouldStayInSameRootWindow(status_container);
[email protected]a4cd6d32012-09-12 03:42:13850
851 aura::Window* settings_bubble_container = CreateContainer(
[email protected]c0ce80e2012-10-05 23:28:27852 kShellWindowId_SettingBubbleContainer,
[email protected]a4cd6d32012-09-12 03:42:13853 "SettingBubbleContainer",
854 lock_screen_related_containers);
[email protected]b5756e22012-11-30 01:32:02855 views::corewm::SetChildWindowVisibilityChangesAnimated(
856 settings_bubble_container);
[email protected]a4cd6d32012-09-12 03:42:13857 SetUsesScreenCoordinates(settings_bubble_container);
[email protected]e887c6c2013-07-08 19:35:53858 DescendantShouldStayInSameRootWindow(settings_bubble_container);
[email protected]a4cd6d32012-09-12 03:42:13859
860 aura::Window* menu_container = CreateContainer(
[email protected]c0ce80e2012-10-05 23:28:27861 kShellWindowId_MenuContainer,
[email protected]a4cd6d32012-09-12 03:42:13862 "MenuContainer",
863 lock_screen_related_containers);
[email protected]b5756e22012-11-30 01:32:02864 views::corewm::SetChildWindowVisibilityChangesAnimated(menu_container);
[email protected]a4cd6d32012-09-12 03:42:13865 SetUsesScreenCoordinates(menu_container);
866
867 aura::Window* drag_drop_container = CreateContainer(
[email protected]c0ce80e2012-10-05 23:28:27868 kShellWindowId_DragImageAndTooltipContainer,
[email protected]a4cd6d32012-09-12 03:42:13869 "DragImageAndTooltipContainer",
870 lock_screen_related_containers);
[email protected]b5756e22012-11-30 01:32:02871 views::corewm::SetChildWindowVisibilityChangesAnimated(drag_drop_container);
[email protected]a4cd6d32012-09-12 03:42:13872 SetUsesScreenCoordinates(drag_drop_container);
873
874 aura::Window* overlay_container = CreateContainer(
[email protected]c0ce80e2012-10-05 23:28:27875 kShellWindowId_OverlayContainer,
[email protected]a4cd6d32012-09-12 03:42:13876 "OverlayContainer",
877 lock_screen_related_containers);
878 SetUsesScreenCoordinates(overlay_container);
[email protected]a07615f2012-10-24 08:23:08879
880 CreateContainer(kShellWindowId_PowerButtonAnimationContainer,
881 "PowerButtonAnimationContainer", root_window) ;
[email protected]a4cd6d32012-09-12 03:42:13882}
883
[email protected]d141b922013-07-09 08:13:17884void RootWindowController::EnableTouchHudProjection() {
885 if (touch_hud_projection_)
886 return;
[email protected]41baaed2013-11-09 04:18:26887 set_touch_hud_projection(new TouchHudProjection(root_window()));
[email protected]d141b922013-07-09 08:13:17888}
889
890void RootWindowController::DisableTouchHudProjection() {
891 if (!touch_hud_projection_)
892 return;
893 touch_hud_projection_->Remove();
894}
895
896void RootWindowController::OnLoginStateChanged(user::LoginStatus status) {
897 shelf_->shelf_layout_manager()->UpdateVisibilityState();
898}
899
900void RootWindowController::OnTouchHudProjectionToggled(bool enabled) {
901 if (enabled)
902 EnableTouchHudProjection();
903 else
904 DisableTouchHudProjection();
905}
906
[email protected]6b2d4a0b2013-09-06 06:29:54907RootWindowController* GetRootWindowController(
[email protected]bf9cdb362013-10-25 19:22:45908 const aura::Window* root_window) {
[email protected]6b2d4a0b2013-09-06 06:29:54909 return root_window ? GetRootWindowSettings(root_window)->controller : NULL;
910}
911
[email protected]d90b8392012-06-13 09:34:56912} // namespace internal
913} // namespace ash