blob: 3b718fc90b10dce0372a7f7bb295dd438a9e2456 [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]8d625fb2012-07-18 16:40:0643#include "ash/wm/window_properties.h"
[email protected]a41b4e12013-09-20 04:36:3444#include "ash/wm/window_state.h"
[email protected]700849f2013-04-30 17:49:2045#include "ash/wm/window_util.h"
[email protected]d90b8392012-06-13 09:34:5646#include "ash/wm/workspace_controller.h"
[email protected]e6e41d2f2012-10-29 19:22:1947#include "base/command_line.h"
[email protected]1e84c632013-06-27 23:12:2148#include "base/time/time.h"
[email protected]f1853122012-06-27 16:21:2649#include "ui/aura/client/aura_constants.h"
[email protected]8b3e3d82013-08-20 14:36:3050#include "ui/aura/client/drag_drop_client.h"
[email protected]d90b8392012-06-13 09:34:5651#include "ui/aura/client/tooltip_client.h"
52#include "ui/aura/root_window.h"
[email protected]f1853122012-06-27 16:21:2653#include "ui/aura/window.h"
[email protected]cf6fea22013-08-07 14:24:0154#include "ui/aura/window_delegate.h"
[email protected]f1853122012-06-27 16:21:2655#include "ui/aura/window_observer.h"
[email protected]8b3e3d82013-08-20 14:36:3056#include "ui/aura/window_tracker.h"
[email protected]cf6fea22013-08-07 14:24:0157#include "ui/base/hit_test.h"
[email protected]431552c2012-10-23 00:38:3358#include "ui/base/models/menu_model.h"
[email protected]f8e6aad2013-08-30 21:49:1159#include "ui/gfx/display.h"
[email protected]8d625fb2012-07-18 16:40:0660#include "ui/gfx/screen.h"
[email protected]86459e2c2013-04-10 13:39:2461#include "ui/keyboard/keyboard_controller.h"
62#include "ui/keyboard/keyboard_util.h"
[email protected]431552c2012-10-23 00:38:3363#include "ui/views/controls/menu/menu_runner.h"
[email protected]23a2dc82013-08-22 15:04:2264#include "ui/views/corewm/capture_controller.h"
[email protected]b5756e22012-11-30 01:32:0265#include "ui/views/corewm/visibility_controller.h"
[email protected]751b13df2014-01-07 19:52:5266#include "ui/views/corewm/window_util.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]c5be8d672014-01-07 13:33:4169#include "ui/wm/public/easy_resize_window_targeter.h"
[email protected]5b251f12013-12-19 01:50:0570#include "ui/wm/public/window_types.h"
[email protected]d90b8392012-06-13 09:34:5671
[email protected]252eb232013-08-14 22:09:2772#if defined(OS_CHROMEOS)
73#include "ash/wm/boot_splash_screen_chromeos.h"
74#endif
75
[email protected]d90b8392012-06-13 09:34:5676namespace ash {
77namespace {
78
[email protected]252eb232013-08-14 22:09:2779#if defined(OS_CHROMEOS)
[email protected]bca9a7e2012-11-10 06:25:4980// Duration for the animation that hides the boot splash screen, in
81// milliseconds. This should be short enough in relation to
82// wm/window_animation.cc's brightness/grayscale fade animation that the login
83// background image animation isn't hidden by the splash screen animation.
84const int kBootSplashScreenHideDurationMs = 500;
[email protected]252eb232013-08-14 22:09:2785#endif
[email protected]bca9a7e2012-11-10 06:25:4986
[email protected]d90b8392012-06-13 09:34:5687// Creates a new window for use as a container.
88aura::Window* CreateContainer(int window_id,
89 const char* name,
90 aura::Window* parent) {
91 aura::Window* container = new aura::Window(NULL);
92 container->set_id(window_id);
93 container->SetName(name);
[email protected]52b02a72014-01-08 21:41:5094 container->Init(aura::WINDOW_LAYER_NOT_DRAWN);
[email protected]d90b8392012-06-13 09:34:5695 parent->AddChild(container);
96 if (window_id != internal::kShellWindowId_UnparentedControlContainer)
97 container->Show();
98 return container;
99}
100
[email protected]2816c2462013-12-17 02:22:25101float ToRelativeValue(int value, int src, int dst) {
102 return static_cast<float>(value) / static_cast<float>(src) * dst;
103}
104
105void MoveOriginRelativeToSize(const gfx::Size& src_size,
106 const gfx::Size& dst_size,
107 gfx::Rect* bounds_in_out) {
108 gfx::Point origin = bounds_in_out->origin();
109 bounds_in_out->set_origin(gfx::Point(
110 ToRelativeValue(origin.x(), src_size.width(), dst_size.width()),
111 ToRelativeValue(origin.y(), src_size.height(), dst_size.height())));
112}
113
[email protected]95058572012-08-20 14:57:29114// Reparents |window| to |new_parent|.
115void ReparentWindow(aura::Window* window, aura::Window* new_parent) {
[email protected]2816c2462013-12-17 02:22:25116 const gfx::Size src_size = window->parent()->bounds().size();
117 const gfx::Size dst_size = new_parent->bounds().size();
[email protected]95058572012-08-20 14:57:29118 // Update the restore bounds to make it relative to the display.
[email protected]a41b4e12013-09-20 04:36:34119 wm::WindowState* state = wm::GetWindowState(window);
120 gfx::Rect restore_bounds;
121 bool has_restore_bounds = state->HasRestoreBounds();
[email protected]2816c2462013-12-17 02:22:25122
123 // TODO(oshima): snapped state should be handled by the layout manager.
124 bool update_bounds = state->IsNormalShowState() || state->IsMinimized();
125 gfx::Rect local_bounds;
126 if (update_bounds) {
127 local_bounds = state->window()->bounds();
128 MoveOriginRelativeToSize(src_size, dst_size, &local_bounds);
129 }
130
131 if (has_restore_bounds) {
[email protected]a41b4e12013-09-20 04:36:34132 restore_bounds = state->GetRestoreBoundsInParent();
[email protected]2816c2462013-12-17 02:22:25133 MoveOriginRelativeToSize(src_size, dst_size, &restore_bounds);
134 }
135
[email protected]95058572012-08-20 14:57:29136 new_parent->AddChild(window);
[email protected]2816c2462013-12-17 02:22:25137
138 if (update_bounds)
139 window->SetBounds(local_bounds);
140
[email protected]a41b4e12013-09-20 04:36:34141 if (has_restore_bounds)
142 state->SetRestoreBoundsInParent(restore_bounds);
[email protected]95058572012-08-20 14:57:29143}
144
145// Reparents the appropriate set of windows from |src| to |dst|.
[email protected]bf9cdb362013-10-25 19:22:45146void ReparentAllWindows(aura::Window* src, aura::Window* dst) {
[email protected]95058572012-08-20 14:57:29147 // Set of windows to move.
[email protected]f1853122012-06-27 16:21:26148 const int kContainerIdsToMove[] = {
149 internal::kShellWindowId_DefaultContainer,
[email protected]beb4e5c2013-06-18 15:37:07150 internal::kShellWindowId_DockedContainer,
[email protected]95db9c12013-01-31 11:47:44151 internal::kShellWindowId_PanelContainer,
[email protected]f1853122012-06-27 16:21:26152 internal::kShellWindowId_AlwaysOnTopContainer,
153 internal::kShellWindowId_SystemModalContainer,
154 internal::kShellWindowId_LockSystemModalContainer,
[email protected]6274d312012-10-04 22:06:41155 internal::kShellWindowId_InputMethodContainer,
[email protected]a9754872013-01-25 07:44:00156 internal::kShellWindowId_UnparentedControlContainer,
[email protected]f1853122012-06-27 16:21:26157 };
[email protected]f1853122012-06-27 16:21:26158 for (size_t i = 0; i < arraysize(kContainerIdsToMove); i++) {
159 int id = kContainerIdsToMove[i];
160 aura::Window* src_container = Shell::GetContainer(src, id);
161 aura::Window* dst_container = Shell::GetContainer(dst, id);
[email protected]5b6021902013-02-26 05:33:29162 while (!src_container->children().empty()) {
163 // Restart iteration from the source container windows each time as they
164 // may change as a result of moving other windows.
165 aura::Window::Windows::const_iterator iter =
166 src_container->children().begin();
167 while (iter != src_container->children().end() &&
168 internal::SystemModalContainerLayoutManager::IsModalBackground(
169 *iter)) {
170 ++iter;
171 }
172 // If the entire window list is modal background windows then stop.
173 if (iter == src_container->children().end())
174 break;
175 ReparentWindow(*iter, dst_container);
[email protected]f1853122012-06-27 16:21:26176 }
177 }
178}
179
[email protected]8d625fb2012-07-18 16:40:06180// Mark the container window so that a widget added to this container will
181// use the virtual screeen coordinates instead of parent.
182void SetUsesScreenCoordinates(aura::Window* container) {
183 container->SetProperty(internal::kUsesScreenCoordinatesKey, true);
184}
185
[email protected]e887c6c2013-07-08 19:35:53186// Mark the container window so that a widget added to this container will
187// say in the same root window regardless of the bounds specified.
188void DescendantShouldStayInSameRootWindow(aura::Window* container) {
189 container->SetProperty(internal::kStayInSameRootWindowKey, true);
190}
191
[email protected]c5be8d672014-01-07 13:33:41192void SetUsesEasyResizeTargeter(aura::Window* container) {
193 gfx::Insets mouse_extend(-kResizeOutsideBoundsSize,
194 -kResizeOutsideBoundsSize,
195 -kResizeOutsideBoundsSize,
196 -kResizeOutsideBoundsSize);
197 gfx::Insets touch_extend = mouse_extend.Scale(
198 kResizeOutsideBoundsScaleForTouch);
199 container->set_event_targeter(scoped_ptr<ui::EventTargeter>(
200 new ::wm::EasyResizeWindowTargeter(container, mouse_extend,
201 touch_extend)));
202}
203
[email protected]cf6fea22013-08-07 14:24:01204// A window delegate which does nothing. Used to create a window that
205// is a event target, but do nothing.
206class EmptyWindowDelegate : public aura::WindowDelegate {
207 public:
208 EmptyWindowDelegate() {}
209 virtual ~EmptyWindowDelegate() {}
210
211 // aura::WindowDelegate overrides:
212 virtual gfx::Size GetMinimumSize() const OVERRIDE {
213 return gfx::Size();
214 }
215 virtual gfx::Size GetMaximumSize() const OVERRIDE {
216 return gfx::Size();
217 }
218 virtual void OnBoundsChanged(const gfx::Rect& old_bounds,
219 const gfx::Rect& new_bounds) OVERRIDE {
220 }
221 virtual gfx::NativeCursor GetCursor(const gfx::Point& point) OVERRIDE {
222 return gfx::kNullCursor;
223 }
224 virtual int GetNonClientComponent(
225 const gfx::Point& point) const OVERRIDE {
226 return HTNOWHERE;
227 }
228 virtual bool ShouldDescendIntoChildForEventHandling(
229 aura::Window* child,
230 const gfx::Point& location) OVERRIDE {
231 return false;
232 }
233 virtual bool CanFocus() OVERRIDE {
234 return false;
235 }
236 virtual void OnCaptureLost() OVERRIDE {
237 }
238 virtual void OnPaint(gfx::Canvas* canvas) OVERRIDE {
239 }
240 virtual void OnDeviceScaleFactorChanged(
241 float device_scale_factor) OVERRIDE {
242 }
243 virtual void OnWindowDestroying() OVERRIDE {}
[email protected]febe1fd62013-08-07 16:07:24244 virtual void OnWindowDestroyed() OVERRIDE {
245 delete this;
246 }
[email protected]cf6fea22013-08-07 14:24:01247 virtual void OnWindowTargetVisibilityChanged(bool visible) OVERRIDE {
248 }
249 virtual bool HasHitTestMask() const OVERRIDE {
250 return false;
251 }
252 virtual void GetHitTestMask(gfx::Path* mask) const OVERRIDE {}
[email protected]1ddbe932013-09-12 06:23:16253 virtual void DidRecreateLayer(ui::Layer* old_layer,
254 ui::Layer* new_layer) OVERRIDE {}
[email protected]cf6fea22013-08-07 14:24:01255
256 private:
257 DISALLOW_COPY_AND_ASSIGN(EmptyWindowDelegate);
258};
259
[email protected]d90b8392012-06-13 09:34:56260} // namespace
261
262namespace internal {
263
[email protected]a273d33a2013-10-17 12:41:21264void RootWindowController::CreateForPrimaryDisplay(
[email protected]bf9cdb362013-10-25 19:22:45265 aura::RootWindow* root) {
[email protected]a273d33a2013-10-17 12:41:21266 RootWindowController* controller = new RootWindowController(root);
[email protected]608de6c2013-10-29 00:14:28267 controller->Init(RootWindowController::PRIMARY,
[email protected]a273d33a2013-10-17 12:41:21268 Shell::GetInstance()->delegate()->IsFirstRunAfterBoot());
[email protected]d90b8392012-06-13 09:34:56269}
270
[email protected]a273d33a2013-10-17 12:41:21271void RootWindowController::CreateForSecondaryDisplay(aura::RootWindow * root) {
272 RootWindowController* controller = new RootWindowController(root);
[email protected]608de6c2013-10-29 00:14:28273 controller->Init(RootWindowController::SECONDARY, false /* first run */);
274}
275
276void RootWindowController::CreateForVirtualKeyboardDisplay(
277 aura::RootWindow * root) {
278 RootWindowController* controller = new RootWindowController(root);
279 controller->Init(RootWindowController::VIRTUAL_KEYBOARD,
280 false /* first run */);
[email protected]6675e1c2012-09-11 09:15:45281}
282
[email protected]88d71122012-10-18 07:11:01283// static
[email protected]864b58552013-12-19 04:19:38284RootWindowController* RootWindowController::ForShelf(aura::Window* window) {
[email protected]8c0ec432013-05-10 04:33:39285 return GetRootWindowController(window->GetRootWindow());
[email protected]88d71122012-10-18 07:11:01286}
287
[email protected]a0afeb12012-12-10 22:57:09288// static
[email protected]ccff3d72013-02-06 04:26:28289RootWindowController* RootWindowController::ForWindow(
290 const aura::Window* window) {
[email protected]a0afeb12012-12-10 22:57:09291 return GetRootWindowController(window->GetRootWindow());
292}
293
294// static
[email protected]d17642d2013-09-12 23:44:38295RootWindowController* RootWindowController::ForTargetRootWindow() {
296 return internal::GetRootWindowController(Shell::GetTargetRootWindow());
[email protected]a0afeb12012-12-10 22:57:09297}
298
[email protected]a5c78802013-12-12 22:07:01299// static
300aura::Window* RootWindowController::GetContainerForWindow(
301 aura::Window* window) {
302 aura::Window* container = window->parent();
[email protected]5b251f12013-12-19 01:50:05303 while (container && container->type() != ui::wm::WINDOW_TYPE_UNKNOWN)
[email protected]a5c78802013-12-12 22:07:01304 container = container->parent();
305 return container;
306}
307
[email protected]a273d33a2013-10-17 12:41:21308RootWindowController::~RootWindowController() {
309 Shutdown();
310 root_window_.reset();
311 // The CaptureClient needs to be around for as long as the RootWindow is
312 // valid.
313 capture_client_.reset();
314}
315
[email protected]0bf61732013-07-02 04:35:10316void RootWindowController::SetWallpaperController(
317 DesktopBackgroundWidgetController* controller) {
318 wallpaper_controller_.reset(controller);
319}
320
321void RootWindowController::SetAnimatingWallpaperController(
322 AnimatingDesktopController* controller) {
323 if (animating_wallpaper_controller_.get())
324 animating_wallpaper_controller_->StopAnimating();
325 animating_wallpaper_controller_.reset(controller);
326}
327
[email protected]6675e1c2012-09-11 09:15:45328void RootWindowController::Shutdown() {
[email protected]d141b922013-07-09 08:13:17329 Shell::GetInstance()->RemoveShellObserver(this);
330
[email protected]0bf61732013-07-02 04:35:10331 if (animating_wallpaper_controller_.get())
332 animating_wallpaper_controller_->StopAnimating();
333 wallpaper_controller_.reset();
334 animating_wallpaper_controller_.reset();
335
[email protected]d17642d2013-09-12 23:44:38336 // Change the target root window before closing child windows. If any child
[email protected]c98a4922013-09-05 20:01:42337 // being removed triggers a relayout of the shelf it will try to build a
[email protected]d17642d2013-09-12 23:44:38338 // window list adding windows from the target root window's containers which
[email protected]c98a4922013-09-05 20:01:42339 // may have already gone away.
[email protected]41baaed2013-11-09 04:18:26340 if (Shell::GetTargetRootWindow() == root_window()) {
[email protected]d17642d2013-09-12 23:44:38341 Shell::GetInstance()->set_target_root_window(
[email protected]41baaed2013-11-09 04:18:26342 Shell::GetPrimaryRootWindow() == root_window() ?
[email protected]f634dd32012-07-23 22:49:07343 NULL : Shell::GetPrimaryRootWindow());
344 }
[email protected]c98a4922013-09-05 20:01:42345
346 CloseChildWindows();
[email protected]41baaed2013-11-09 04:18:26347 GetRootWindowSettings(root_window())->controller = NULL;
[email protected]d90b8392012-06-13 09:34:56348 screen_dimmer_.reset();
349 workspace_controller_.reset();
[email protected]6675e1c2012-09-11 09:15:45350 // Forget with the display ID so that display lookup
351 // ends up with invalid display.
[email protected]41baaed2013-11-09 04:18:26352 internal::GetRootWindowSettings(root_window())->display_id =
[email protected]f8e6aad2013-08-30 21:49:11353 gfx::Display::kInvalidDisplayID;
[email protected]6675e1c2012-09-11 09:15:45354 // And this root window should no longer process events.
355 root_window_->PrepareForShutdown();
[email protected]e74aaf0a2012-10-12 18:42:28356
[email protected]956a6a42012-10-29 23:58:10357 system_background_.reset();
[email protected]d90b8392012-06-13 09:34:56358}
359
[email protected]c0ce80e2012-10-05 23:28:27360SystemModalContainerLayoutManager*
[email protected]8674b312012-10-12 19:02:44361RootWindowController::GetSystemModalLayoutManager(aura::Window* window) {
[email protected]a5c78802013-12-12 22:07:01362 aura::Window* modal_container = NULL;
[email protected]8674b312012-10-12 19:02:44363 if (window) {
[email protected]a5c78802013-12-12 22:07:01364 aura::Window* window_container = GetContainerForWindow(window);
365 if (window_container &&
366 window_container->id() >= kShellWindowId_LockScreenContainer) {
367 modal_container = GetContainer(kShellWindowId_LockSystemModalContainer);
[email protected]3b162e12012-11-09 11:52:35368 } else {
[email protected]a5c78802013-12-12 22:07:01369 modal_container = GetContainer(kShellWindowId_SystemModalContainer);
[email protected]3b162e12012-11-09 11:52:35370 }
[email protected]8674b312012-10-12 19:02:44371 } else {
[email protected]a44afbbd2013-07-24 21:49:35372 int modal_window_id = Shell::GetInstance()->session_state_delegate()
373 ->IsUserSessionBlocked() ? kShellWindowId_LockSystemModalContainer :
374 kShellWindowId_SystemModalContainer;
[email protected]a5c78802013-12-12 22:07:01375 modal_container = GetContainer(modal_window_id);
[email protected]8674b312012-10-12 19:02:44376 }
[email protected]a5c78802013-12-12 22:07:01377 return modal_container ? static_cast<SystemModalContainerLayoutManager*>(
378 modal_container->layout_manager()) : NULL;
[email protected]c0ce80e2012-10-05 23:28:27379}
380
[email protected]d90b8392012-06-13 09:34:56381aura::Window* RootWindowController::GetContainer(int container_id) {
[email protected]41baaed2013-11-09 04:18:26382 return root_window()->GetChildById(container_id);
[email protected]d90b8392012-06-13 09:34:56383}
384
[email protected]d8a24952013-08-05 20:05:05385const aura::Window* RootWindowController::GetContainer(int container_id) const {
[email protected]41baaed2013-11-09 04:18:26386 return root_window_->window()->GetChildById(container_id);
[email protected]d8a24952013-08-05 20:05:05387}
388
[email protected]864b58552013-12-19 04:19:38389void RootWindowController::ShowShelf() {
390 if (!shelf_->shelf())
[email protected]e74aaf0a2012-10-12 18:42:28391 return;
[email protected]864b58552013-12-19 04:19:38392 shelf_->shelf()->SetVisible(true);
[email protected]478c6c32013-03-09 02:50:58393 shelf_->status_area_widget()->Show();
[email protected]e74aaf0a2012-10-12 18:42:28394}
395
[email protected]864b58552013-12-19 04:19:38396void RootWindowController::OnShelfCreated() {
[email protected]756bda12013-07-03 08:17:06397 if (panel_layout_manager_)
[email protected]864b58552013-12-19 04:19:38398 panel_layout_manager_->SetShelf(shelf_->shelf());
[email protected]7115bd32013-07-19 08:25:39399 if (docked_layout_manager_) {
[email protected]864b58552013-12-19 04:19:38400 docked_layout_manager_->SetShelf(shelf_->shelf());
[email protected]7115bd32013-07-19 08:25:39401 if (shelf_->shelf_layout_manager())
402 docked_layout_manager_->AddObserver(shelf_->shelf_layout_manager());
403 }
[email protected]756bda12013-07-03 08:17:06404}
405
[email protected]16059276d2012-10-22 18:59:50406void RootWindowController::UpdateAfterLoginStatusChange(
407 user::LoginStatus status) {
[email protected]cf6fea22013-08-07 14:24:01408 if (status != user::LOGGED_IN_NONE)
409 mouse_event_target_.reset();
[email protected]80549c152013-07-02 01:42:47410 if (shelf_->status_area_widget())
[email protected]478c6c32013-03-09 02:50:58411 shelf_->status_area_widget()->UpdateAfterLoginStatusChange(status);
[email protected]16059276d2012-10-22 18:59:50412}
413
[email protected]bca9a7e2012-11-10 06:25:49414void RootWindowController::HandleInitialDesktopBackgroundAnimationStarted() {
[email protected]252eb232013-08-14 22:09:27415#if defined(OS_CHROMEOS)
[email protected]bca9a7e2012-11-10 06:25:49416 if (CommandLine::ForCurrentProcess()->HasSwitch(
417 switches::kAshAnimateFromBootSplashScreen) &&
418 boot_splash_screen_.get()) {
419 // Make the splash screen fade out so it doesn't obscure the desktop
420 // wallpaper's brightness/grayscale animation.
421 boot_splash_screen_->StartHideAnimation(
422 base::TimeDelta::FromMilliseconds(kBootSplashScreenHideDurationMs));
423 }
[email protected]252eb232013-08-14 22:09:27424#endif
[email protected]bca9a7e2012-11-10 06:25:49425}
426
[email protected]0bf61732013-07-02 04:35:10427void RootWindowController::OnWallpaperAnimationFinished(views::Widget* widget) {
428 // Make sure the wallpaper is visible.
[email protected]bca9a7e2012-11-10 06:25:49429 system_background_->SetColor(SK_ColorBLACK);
[email protected]252eb232013-08-14 22:09:27430#if defined(OS_CHROMEOS)
[email protected]bca9a7e2012-11-10 06:25:49431 boot_splash_screen_.reset();
[email protected]252eb232013-08-14 22:09:27432#endif
[email protected]0bf61732013-07-02 04:35:10433
434 Shell::GetInstance()->user_wallpaper_delegate()->
435 OnWallpaperAnimationFinished();
436 // Only removes old component when wallpaper animation finished. If we
437 // remove the old one before the new wallpaper is done fading in there will
438 // be a white flash during the animation.
439 if (animating_wallpaper_controller()) {
440 DesktopBackgroundWidgetController* controller =
441 animating_wallpaper_controller()->GetController(true);
442 // |desktop_widget_| should be the same animating widget we try to move
443 // to |kDesktopController|. Otherwise, we may close |desktop_widget_|
444 // before move it to |kDesktopController|.
445 DCHECK_EQ(controller->widget(), widget);
446 // Release the old controller and close its background widget.
447 SetWallpaperController(controller);
448 }
[email protected]697f04c2012-10-03 01:15:10449}
450
[email protected]d90b8392012-06-13 09:34:56451void RootWindowController::CloseChildWindows() {
[email protected]cf6fea22013-08-07 14:24:01452 mouse_event_target_.reset();
453
[email protected]b6ba05d902013-10-04 21:38:45454 // Deactivate keyboard container before closing child windows and shutting
455 // down associated layout managers.
456 DeactivateKeyboard(Shell::GetInstance()->keyboard_controller());
457
[email protected]79a87b7e2013-01-25 05:08:22458 // panel_layout_manager_ needs to be shut down before windows are destroyed.
459 if (panel_layout_manager_) {
460 panel_layout_manager_->Shutdown();
461 panel_layout_manager_ = NULL;
462 }
[email protected]7115bd32013-07-19 08:25:39463 // docked_layout_manager_ needs to be shut down before windows are destroyed.
464 if (docked_layout_manager_) {
[email protected]bb42c932013-10-31 06:52:06465 if (shelf_ && shelf_->shelf_layout_manager())
[email protected]7115bd32013-07-19 08:25:39466 docked_layout_manager_->RemoveObserver(shelf_->shelf_layout_manager());
467 docked_layout_manager_->Shutdown();
468 docked_layout_manager_ = NULL;
469 }
[email protected]79a87b7e2013-01-25 05:08:22470
[email protected]41baaed2013-11-09 04:18:26471 aura::client::SetDragDropClient(root_window(), NULL);
[email protected]8b3e3d82013-08-20 14:36:30472
[email protected]478c6c32013-03-09 02:50:58473 // TODO(harrym): Remove when Status Area Widget is a child view.
[email protected]bb42c932013-10-31 06:52:06474 if (shelf_) {
475 shelf_->ShutdownStatusAreaWidget();
[email protected]478c6c32013-03-09 02:50:58476
[email protected]bb42c932013-10-31 06:52:06477 if (shelf_->shelf_layout_manager())
478 shelf_->shelf_layout_manager()->PrepareForShutdown();
479 }
[email protected]e74aaf0a2012-10-12 18:42:28480
[email protected]d90b8392012-06-13 09:34:56481 // Close background widget first as it depends on tooltip.
[email protected]0bf61732013-07-02 04:35:10482 wallpaper_controller_.reset();
483 animating_wallpaper_controller_.reset();
[email protected]b4ddc7a2012-08-07 04:17:32484
[email protected]d90b8392012-06-13 09:34:56485 workspace_controller_.reset();
[email protected]41baaed2013-11-09 04:18:26486 aura::client::SetTooltipClient(root_window(), NULL);
[email protected]d90b8392012-06-13 09:34:56487
[email protected]0fbfa972013-10-02 19:23:33488 // Explicitly destroy top level windows. We do this as during part of
489 // destruction such windows may query the RootWindow for state.
[email protected]8b3e3d82013-08-20 14:36:30490 std::queue<aura::Window*> non_toplevel_windows;
[email protected]41baaed2013-11-09 04:18:26491 non_toplevel_windows.push(root_window());
[email protected]8b3e3d82013-08-20 14:36:30492 while (!non_toplevel_windows.empty()) {
493 aura::Window* non_toplevel_window = non_toplevel_windows.front();
494 non_toplevel_windows.pop();
495 aura::WindowTracker toplevel_windows;
496 for (size_t i = 0; i < non_toplevel_window->children().size(); ++i) {
497 aura::Window* child = non_toplevel_window->children()[i];
[email protected]0fbfa972013-10-02 19:23:33498 if (!child->owned_by_parent())
499 continue;
[email protected]8b3e3d82013-08-20 14:36:30500 if (child->delegate())
501 toplevel_windows.Add(child);
502 else
503 non_toplevel_windows.push(child);
504 }
505 while (!toplevel_windows.windows().empty())
506 delete *toplevel_windows.windows().begin();
[email protected]d90b8392012-06-13 09:34:56507 }
[email protected]8b3e3d82013-08-20 14:36:30508 // And then remove the containers.
[email protected]41baaed2013-11-09 04:18:26509 while (!root_window()->children().empty()) {
510 aura::Window* window = root_window()->children()[0];
[email protected]0fbfa972013-10-02 19:23:33511 if (window->owned_by_parent()) {
512 delete window;
513 } else {
[email protected]41baaed2013-11-09 04:18:26514 root_window()->RemoveChild(window);
[email protected]0fbfa972013-10-02 19:23:33515 }
516 }
[email protected]478c6c32013-03-09 02:50:58517
[email protected]bb42c932013-10-31 06:52:06518 shelf_.reset();
[email protected]d90b8392012-06-13 09:34:56519}
520
[email protected]bf9cdb362013-10-25 19:22:45521void RootWindowController::MoveWindowsTo(aura::Window* dst) {
[email protected]8039e06c2013-01-17 23:34:50522 // Forget the shelf early so that shelf don't update itself using wrong
523 // display info.
524 workspace_controller_->SetShelf(NULL);
[email protected]41baaed2013-11-09 04:18:26525 ReparentAllWindows(root_window(), dst);
[email protected]f1853122012-06-27 16:21:26526}
527
[email protected]478c6c32013-03-09 02:50:58528ShelfLayoutManager* RootWindowController::GetShelfLayoutManager() {
[email protected]80549c152013-07-02 01:42:47529 return shelf_->shelf_layout_manager();
[email protected]478c6c32013-03-09 02:50:58530}
531
[email protected]a0afeb12012-12-10 22:57:09532SystemTray* RootWindowController::GetSystemTray() {
533 // We assume in throughout the code that this will not return NULL. If code
534 // triggers this for valid reasons, it should test status_area_widget first.
[email protected]80549c152013-07-02 01:42:47535 CHECK(shelf_->status_area_widget());
[email protected]478c6c32013-03-09 02:50:58536 return shelf_->status_area_widget()->system_tray();
[email protected]a0afeb12012-12-10 22:57:09537}
538
[email protected]940fb1c2013-06-18 16:54:28539void RootWindowController::ShowContextMenu(const gfx::Point& location_in_screen,
540 ui::MenuSourceType source_type) {
[email protected]431552c2012-10-23 00:38:33541 DCHECK(Shell::GetInstance()->delegate());
542 scoped_ptr<ui::MenuModel> menu_model(
[email protected]e0cfc7f2014-01-09 20:25:42543 Shell::GetInstance()->delegate()->CreateContextMenu(root_window(),
544 NULL,
545 NULL));
[email protected]7f7f65c2013-04-17 16:47:13546 if (!menu_model)
[email protected]8e837ec2013-01-31 01:48:33547 return;
[email protected]431552c2012-10-23 00:38:33548
[email protected]6175fc42013-04-05 05:58:58549 // Background controller may not be set yet if user clicked on status are
550 // before initial animation completion. See crbug.com/222218
[email protected]0bf61732013-07-02 04:35:10551 if (!wallpaper_controller_.get())
[email protected]431552c2012-10-23 00:38:33552 return;
553
[email protected]6175fc42013-04-05 05:58:58554 views::MenuRunner menu_runner(menu_model.get());
[email protected]0bf61732013-07-02 04:35:10555 if (menu_runner.RunMenuAt(wallpaper_controller_->widget(),
[email protected]6175fc42013-04-05 05:58:58556 NULL, gfx::Rect(location_in_screen, gfx::Size()),
[email protected]940fb1c2013-06-18 16:54:28557 views::MenuItemView::TOPLEFT, source_type,
558 views::MenuRunner::CONTEXT_MENU) ==
[email protected]6175fc42013-04-05 05:58:58559 views::MenuRunner::MENU_DELETED) {
560 return;
561 }
562
[email protected]431552c2012-10-23 00:38:33563 Shell::GetInstance()->UpdateShelfVisibility();
564}
565
[email protected]e74aaf0a2012-10-12 18:42:28566void RootWindowController::UpdateShelfVisibility() {
[email protected]478c6c32013-03-09 02:50:58567 shelf_->shelf_layout_manager()->UpdateVisibilityState();
[email protected]e74aaf0a2012-10-12 18:42:28568}
569
[email protected]2c9171d22013-12-10 21:55:10570const aura::Window* RootWindowController::GetWindowForFullscreenMode() const {
[email protected]e3bc88e2013-09-06 06:22:06571 const aura::Window::Windows& windows =
572 GetContainer(kShellWindowId_DefaultContainer)->children();
[email protected]2c9171d22013-12-10 21:55:10573 const aura::Window* topmost_window = NULL;
[email protected]e3bc88e2013-09-06 06:22:06574 for (aura::Window::Windows::const_reverse_iterator iter = windows.rbegin();
575 iter != windows.rend(); ++iter) {
[email protected]5b251f12013-12-19 01:50:05576 if (((*iter)->type() == ui::wm::WINDOW_TYPE_NORMAL ||
577 (*iter)->type() == ui::wm::WINDOW_TYPE_PANEL) &&
[email protected]2c9171d22013-12-10 21:55:10578 (*iter)->layer()->GetTargetVisibility()) {
579 topmost_window = *iter;
580 break;
581 }
582 }
583 while (topmost_window) {
584 if (wm::GetWindowState(topmost_window)->IsFullscreen())
585 return topmost_window;
[email protected]751b13df2014-01-07 19:52:52586 topmost_window = views::corewm::GetTransientParent(topmost_window);
[email protected]2ee2f5d2013-01-10 23:37:16587 }
[email protected]700849f2013-04-30 17:49:20588 return NULL;
[email protected]2ee2f5d2013-01-10 23:37:16589}
590
[email protected]b6ba05d902013-10-04 21:38:45591void RootWindowController::ActivateKeyboard(
592 keyboard::KeyboardController* keyboard_controller) {
593 if (!keyboard::IsKeyboardEnabled() ||
594 GetContainer(kShellWindowId_VirtualKeyboardContainer)) {
595 return;
596 }
597 DCHECK(keyboard_controller);
[email protected]51f438112013-11-18 19:32:50598 if (!keyboard::IsKeyboardUsabilityExperimentEnabled()) {
599 keyboard_controller->AddObserver(shelf()->shelf_layout_manager());
600 keyboard_controller->AddObserver(panel_layout_manager_);
601 keyboard_controller->AddObserver(docked_layout_manager_);
602 }
[email protected]b6ba05d902013-10-04 21:38:45603 aura::Window* parent = root_window();
604 aura::Window* keyboard_container =
605 keyboard_controller->GetContainerWindow();
606 keyboard_container->set_id(kShellWindowId_VirtualKeyboardContainer);
607 parent->AddChild(keyboard_container);
608 // TODO(oshima): Bounds of keyboard container should be handled by
609 // RootWindowLayoutManager. Remove this after fixed RootWindowLayoutManager.
610 keyboard_container->SetBounds(parent->bounds());
611}
[email protected]86459e2c2013-04-10 13:39:24612
[email protected]b6ba05d902013-10-04 21:38:45613void RootWindowController::DeactivateKeyboard(
614 keyboard::KeyboardController* keyboard_controller) {
615 if (!keyboard::IsKeyboardEnabled())
616 return;
[email protected]5416f282013-04-29 20:52:48617
[email protected]b6ba05d902013-10-04 21:38:45618 DCHECK(keyboard_controller);
619 aura::Window* keyboard_container =
620 keyboard_controller->GetContainerWindow();
621 if (keyboard_container->GetRootWindow() == root_window()) {
622 root_window()->RemoveChild(keyboard_container);
[email protected]51f438112013-11-18 19:32:50623 if (!keyboard::IsKeyboardUsabilityExperimentEnabled()) {
624 keyboard_controller->RemoveObserver(shelf()->shelf_layout_manager());
625 keyboard_controller->RemoveObserver(panel_layout_manager_);
626 keyboard_controller->RemoveObserver(docked_layout_manager_);
627 }
[email protected]86459e2c2013-04-10 13:39:24628 }
629}
630
[email protected]a4cd6d32012-09-12 03:42:13631////////////////////////////////////////////////////////////////////////////////
632// RootWindowController, private:
633
[email protected]a273d33a2013-10-17 12:41:21634RootWindowController::RootWindowController(aura::RootWindow* root_window)
635 : root_window_(root_window),
636 root_window_layout_(NULL),
637 docked_layout_manager_(NULL),
638 panel_layout_manager_(NULL),
639 touch_hud_debug_(NULL),
640 touch_hud_projection_(NULL) {
[email protected]41baaed2013-11-09 04:18:26641 GetRootWindowSettings(root_window_->window())->controller = this;
642 screen_dimmer_.reset(new ScreenDimmer(root_window_->window()));
[email protected]a273d33a2013-10-17 12:41:21643
644 stacking_controller_.reset(new StackingController);
[email protected]41baaed2013-11-09 04:18:26645 aura::client::SetWindowTreeClient(root_window_->window(),
646 stacking_controller_.get());
647 capture_client_.reset(
648 new views::corewm::ScopedCaptureClient(root_window_->window()));
[email protected]a273d33a2013-10-17 12:41:21649}
650
[email protected]608de6c2013-10-29 00:14:28651void RootWindowController::Init(RootWindowType root_window_type,
652 bool first_run_after_boot) {
[email protected]51f438112013-11-18 19:32:50653 Shell* shell = Shell::GetInstance();
654 shell->InitRootWindow(root_window());
[email protected]a273d33a2013-10-17 12:41:21655
656 root_window_->SetCursor(ui::kCursorPointer);
[email protected]f7c05b22013-11-12 21:07:24657 CreateContainersInRootWindow(root_window_->window());
[email protected]608de6c2013-10-29 00:14:28658
[email protected]51f438112013-11-18 19:32:50659 if (root_window_type == VIRTUAL_KEYBOARD) {
660 shell->InitKeyboard();
[email protected]608de6c2013-10-29 00:14:28661 return;
[email protected]51f438112013-11-18 19:32:50662 }
[email protected]608de6c2013-10-29 00:14:28663
[email protected]a273d33a2013-10-17 12:41:21664 CreateSystemBackground(first_run_after_boot);
665
666 InitLayoutManagers();
667 InitTouchHuds();
668
669 if (Shell::GetPrimaryRootWindowController()->
670 GetSystemModalLayoutManager(NULL)->has_modal_background()) {
671 GetSystemModalLayoutManager(NULL)->CreateModalBackground();
672 }
673
[email protected]a273d33a2013-10-17 12:41:21674 shell->AddShellObserver(this);
675
[email protected]608de6c2013-10-29 00:14:28676 if (root_window_type == PRIMARY) {
[email protected]a3565792013-10-18 12:52:37677 root_window_layout()->OnWindowResized();
[email protected]51f438112013-11-18 19:32:50678 if (!keyboard::IsKeyboardUsabilityExperimentEnabled())
679 shell->InitKeyboard();
[email protected]a273d33a2013-10-17 12:41:21680 } else {
681 root_window_layout()->OnWindowResized();
[email protected]41baaed2013-11-09 04:18:26682 shell->desktop_background_controller()->OnRootWindowAdded(root_window());
[email protected]f7c05b22013-11-12 21:07:24683 shell->high_contrast_controller()->OnRootWindowAdded(
684 root_window_->window());
[email protected]228f0f02013-11-15 05:58:36685 root_window_->host()->Show();
[email protected]a273d33a2013-10-17 12:41:21686
[email protected]864b58552013-12-19 04:19:38687 // Create a shelf if a user is already logged in.
[email protected]a273d33a2013-10-17 12:41:21688 if (shell->session_state_delegate()->NumberOfLoggedInUsers())
[email protected]864b58552013-12-19 04:19:38689 shelf()->CreateShelf();
[email protected]a273d33a2013-10-17 12:41:21690 }
[email protected]a273d33a2013-10-17 12:41:21691}
692
[email protected]756bda12013-07-03 08:17:06693void RootWindowController::InitLayoutManagers() {
[email protected]41baaed2013-11-09 04:18:26694 root_window_layout_ = new RootWindowLayoutManager(root_window());
695 root_window()->SetLayoutManager(root_window_layout_);
[email protected]756bda12013-07-03 08:17:06696
697 aura::Window* default_container =
698 GetContainer(kShellWindowId_DefaultContainer);
699 // Workspace manager has its own layout managers.
700 workspace_controller_.reset(
701 new WorkspaceController(default_container));
702
703 aura::Window* always_on_top_container =
704 GetContainer(kShellWindowId_AlwaysOnTopContainer);
705 always_on_top_container->SetLayoutManager(
706 new BaseLayoutManager(
707 always_on_top_container->GetRootWindow()));
708 always_on_top_controller_.reset(new internal::AlwaysOnTopController);
709 always_on_top_controller_->SetAlwaysOnTopContainer(always_on_top_container);
710
711 DCHECK(!shelf_.get());
712 aura::Window* shelf_container =
713 GetContainer(internal::kShellWindowId_ShelfContainer);
714 // TODO(harrym): Remove when status area is view.
715 aura::Window* status_container =
716 GetContainer(internal::kShellWindowId_StatusContainer);
717 shelf_.reset(new ShelfWidget(
718 shelf_container, status_container, workspace_controller()));
719
[email protected]cf6fea22013-08-07 14:24:01720 if (!Shell::GetInstance()->session_state_delegate()->
721 IsActiveUserSessionStarted()) {
722 // This window exists only to be a event target on login screen.
723 // It does not have to handle events, nor be visible.
724 mouse_event_target_.reset(new aura::Window(new EmptyWindowDelegate));
[email protected]52b02a72014-01-08 21:41:50725 mouse_event_target_->Init(aura::WINDOW_LAYER_NOT_DRAWN);
[email protected]cf6fea22013-08-07 14:24:01726
727 aura::Window* lock_background_container =
728 GetContainer(internal::kShellWindowId_LockScreenBackgroundContainer);
729 lock_background_container->AddChild(mouse_event_target_.get());
730 mouse_event_target_->Show();
731 }
732
[email protected]756bda12013-07-03 08:17:06733 // Create Docked windows layout manager
734 aura::Window* docked_container = GetContainer(
735 internal::kShellWindowId_DockedContainer);
736 docked_layout_manager_ =
[email protected]375069e2013-10-04 13:54:31737 new internal::DockedWindowLayoutManager(docked_container,
738 workspace_controller());
[email protected]756bda12013-07-03 08:17:06739 docked_container->SetLayoutManager(docked_layout_manager_);
740
741 // Create Panel layout manager
742 aura::Window* panel_container = GetContainer(
743 internal::kShellWindowId_PanelContainer);
744 panel_layout_manager_ =
745 new internal::PanelLayoutManager(panel_container);
[email protected]756bda12013-07-03 08:17:06746 panel_container->SetLayoutManager(panel_layout_manager_);
[email protected]3537d472014-01-15 05:45:31747 panel_container_handler_.reset(new PanelWindowEventHandler);
748 panel_container->AddPreTargetHandler(panel_container_handler_.get());
[email protected]756bda12013-07-03 08:17:06749}
750
751void RootWindowController::InitTouchHuds() {
752 CommandLine* command_line = CommandLine::ForCurrentProcess();
753 if (command_line->HasSwitch(switches::kAshTouchHud))
[email protected]41baaed2013-11-09 04:18:26754 set_touch_hud_debug(new TouchHudDebug(root_window()));
[email protected]756bda12013-07-03 08:17:06755 if (Shell::GetInstance()->is_touch_hud_projection_enabled())
756 EnableTouchHudProjection();
757}
758
759void RootWindowController::CreateSystemBackground(
760 bool is_first_run_after_boot) {
761 SkColor color = SK_ColorBLACK;
762#if defined(OS_CHROMEOS)
763 if (is_first_run_after_boot)
764 color = kChromeOsBootColor;
765#endif
766 system_background_.reset(
[email protected]41baaed2013-11-09 04:18:26767 new SystemBackgroundController(root_window(), color));
[email protected]756bda12013-07-03 08:17:06768
769#if defined(OS_CHROMEOS)
770 // Make a copy of the system's boot splash screen so we can composite it
771 // onscreen until the desktop background is ready.
772 if (is_first_run_after_boot &&
773 (CommandLine::ForCurrentProcess()->HasSwitch(
774 switches::kAshCopyHostBackgroundAtBoot) ||
775 CommandLine::ForCurrentProcess()->HasSwitch(
776 switches::kAshAnimateFromBootSplashScreen)))
777 boot_splash_screen_.reset(new BootSplashScreen(root_window_.get()));
778#endif
779}
780
[email protected]a4cd6d32012-09-12 03:42:13781void RootWindowController::CreateContainersInRootWindow(
[email protected]41baaed2013-11-09 04:18:26782 aura::Window* root_window) {
[email protected]a4cd6d32012-09-12 03:42:13783 // These containers are just used by PowerButtonController to animate groups
784 // of containers simultaneously without messing up the current transformations
785 // on those containers. These are direct children of the root window; all of
786 // the other containers are their children.
[email protected]e6e41d2f2012-10-29 19:22:19787
788 // The desktop background container is not part of the lock animation, so it
789 // is not included in those animate groups.
[email protected]a4cd6d32012-09-12 03:42:13790 // When screen is locked desktop background is moved to lock screen background
791 // container (moved back on unlock). We want to make sure that there's an
792 // opaque layer occluding the non-lock-screen layers.
[email protected]e6e41d2f2012-10-29 19:22:19793 aura::Window* desktop_background_container = CreateContainer(
[email protected]c0ce80e2012-10-05 23:28:27794 kShellWindowId_DesktopBackgroundContainer,
[email protected]a4cd6d32012-09-12 03:42:13795 "DesktopBackgroundContainer",
796 root_window);
[email protected]b5756e22012-11-30 01:32:02797 views::corewm::SetChildWindowVisibilityChangesAnimated(
798 desktop_background_container);
[email protected]a4cd6d32012-09-12 03:42:13799
800 aura::Window* non_lock_screen_containers = CreateContainer(
[email protected]c0ce80e2012-10-05 23:28:27801 kShellWindowId_NonLockScreenContainersContainer,
[email protected]a4cd6d32012-09-12 03:42:13802 "NonLockScreenContainersContainer",
803 root_window);
804
805 aura::Window* lock_background_containers = CreateContainer(
[email protected]c0ce80e2012-10-05 23:28:27806 kShellWindowId_LockScreenBackgroundContainer,
[email protected]a4cd6d32012-09-12 03:42:13807 "LockScreenBackgroundContainer",
808 root_window);
[email protected]b5756e22012-11-30 01:32:02809 views::corewm::SetChildWindowVisibilityChangesAnimated(
810 lock_background_containers);
[email protected]a4cd6d32012-09-12 03:42:13811
812 aura::Window* lock_screen_containers = CreateContainer(
[email protected]c0ce80e2012-10-05 23:28:27813 kShellWindowId_LockScreenContainersContainer,
[email protected]a4cd6d32012-09-12 03:42:13814 "LockScreenContainersContainer",
815 root_window);
816 aura::Window* lock_screen_related_containers = CreateContainer(
[email protected]c0ce80e2012-10-05 23:28:27817 kShellWindowId_LockScreenRelatedContainersContainer,
[email protected]a4cd6d32012-09-12 03:42:13818 "LockScreenRelatedContainersContainer",
819 root_window);
820
[email protected]c0ce80e2012-10-05 23:28:27821 CreateContainer(kShellWindowId_UnparentedControlContainer,
[email protected]a4cd6d32012-09-12 03:42:13822 "UnparentedControlContainer",
823 non_lock_screen_containers);
824
825 aura::Window* default_container = CreateContainer(
[email protected]c0ce80e2012-10-05 23:28:27826 kShellWindowId_DefaultContainer,
[email protected]a4cd6d32012-09-12 03:42:13827 "DefaultContainer",
828 non_lock_screen_containers);
[email protected]b5756e22012-11-30 01:32:02829 views::corewm::SetChildWindowVisibilityChangesAnimated(default_container);
[email protected]a4cd6d32012-09-12 03:42:13830 SetUsesScreenCoordinates(default_container);
[email protected]c5be8d672014-01-07 13:33:41831 SetUsesEasyResizeTargeter(default_container);
[email protected]a4cd6d32012-09-12 03:42:13832
833 aura::Window* always_on_top_container = CreateContainer(
[email protected]c0ce80e2012-10-05 23:28:27834 kShellWindowId_AlwaysOnTopContainer,
[email protected]a4cd6d32012-09-12 03:42:13835 "AlwaysOnTopContainer",
836 non_lock_screen_containers);
[email protected]b5756e22012-11-30 01:32:02837 views::corewm::SetChildWindowVisibilityChangesAnimated(
838 always_on_top_container);
[email protected]a4cd6d32012-09-12 03:42:13839 SetUsesScreenCoordinates(always_on_top_container);
840
[email protected]beb4e5c2013-06-18 15:37:07841 aura::Window* docked_container = CreateContainer(
842 kShellWindowId_DockedContainer,
843 "DockedContainer",
844 non_lock_screen_containers);
[email protected]5eab6e92013-09-19 19:09:27845 views::corewm::SetChildWindowVisibilityChangesAnimated(docked_container);
[email protected]beb4e5c2013-06-18 15:37:07846 SetUsesScreenCoordinates(docked_container);
847
[email protected]3f13cf12013-07-12 05:13:59848 aura::Window* shelf_container =
[email protected]478c6c32013-03-09 02:50:58849 CreateContainer(kShellWindowId_ShelfContainer,
[email protected]3f13cf12013-07-12 05:13:59850 "ShelfContainer",
[email protected]a4cd6d32012-09-12 03:42:13851 non_lock_screen_containers);
[email protected]3f13cf12013-07-12 05:13:59852 SetUsesScreenCoordinates(shelf_container);
853 DescendantShouldStayInSameRootWindow(shelf_container);
[email protected]a4cd6d32012-09-12 03:42:13854
[email protected]f2026eb2013-10-22 14:28:56855 aura::Window* panel_container = CreateContainer(
856 kShellWindowId_PanelContainer,
857 "PanelContainer",
858 non_lock_screen_containers);
859 SetUsesScreenCoordinates(panel_container);
[email protected]c5be8d672014-01-07 13:33:41860 SetUsesEasyResizeTargeter(panel_container);
[email protected]f2026eb2013-10-22 14:28:56861
862 aura::Window* shelf_bubble_container =
863 CreateContainer(kShellWindowId_ShelfBubbleContainer,
864 "ShelfBubbleContainer",
865 non_lock_screen_containers);
866 SetUsesScreenCoordinates(shelf_bubble_container);
867 DescendantShouldStayInSameRootWindow(shelf_bubble_container);
868
[email protected]dc851a4e52012-10-03 00:05:55869 aura::Window* app_list_container =
[email protected]c0ce80e2012-10-05 23:28:27870 CreateContainer(kShellWindowId_AppListContainer,
[email protected]dc851a4e52012-10-03 00:05:55871 "AppListContainer",
872 non_lock_screen_containers);
873 SetUsesScreenCoordinates(app_list_container);
[email protected]a4cd6d32012-09-12 03:42:13874
875 aura::Window* modal_container = CreateContainer(
[email protected]c0ce80e2012-10-05 23:28:27876 kShellWindowId_SystemModalContainer,
[email protected]a4cd6d32012-09-12 03:42:13877 "SystemModalContainer",
878 non_lock_screen_containers);
[email protected]a4cd6d32012-09-12 03:42:13879 modal_container->SetLayoutManager(
[email protected]c0ce80e2012-10-05 23:28:27880 new SystemModalContainerLayoutManager(modal_container));
[email protected]b5756e22012-11-30 01:32:02881 views::corewm::SetChildWindowVisibilityChangesAnimated(modal_container);
[email protected]a4cd6d32012-09-12 03:42:13882 SetUsesScreenCoordinates(modal_container);
[email protected]c5be8d672014-01-07 13:33:41883 SetUsesEasyResizeTargeter(modal_container);
[email protected]a4cd6d32012-09-12 03:42:13884
885 aura::Window* input_method_container = CreateContainer(
[email protected]c0ce80e2012-10-05 23:28:27886 kShellWindowId_InputMethodContainer,
[email protected]a4cd6d32012-09-12 03:42:13887 "InputMethodContainer",
888 non_lock_screen_containers);
[email protected]649eb7462013-10-24 07:52:01889 views::corewm::SetChildWindowVisibilityChangesAnimated(
890 input_method_container);
[email protected]a4cd6d32012-09-12 03:42:13891 SetUsesScreenCoordinates(input_method_container);
892
893 // TODO(beng): Figure out if we can make this use
894 // SystemModalContainerEventFilter instead of stops_event_propagation.
895 aura::Window* lock_container = CreateContainer(
[email protected]c0ce80e2012-10-05 23:28:27896 kShellWindowId_LockScreenContainer,
[email protected]a4cd6d32012-09-12 03:42:13897 "LockScreenContainer",
898 lock_screen_containers);
899 lock_container->SetLayoutManager(
[email protected]c0ce80e2012-10-05 23:28:27900 new BaseLayoutManager(root_window));
[email protected]a4cd6d32012-09-12 03:42:13901 SetUsesScreenCoordinates(lock_container);
902 // TODO(beng): stopsevents
903
904 aura::Window* lock_modal_container = CreateContainer(
[email protected]c0ce80e2012-10-05 23:28:27905 kShellWindowId_LockSystemModalContainer,
[email protected]a4cd6d32012-09-12 03:42:13906 "LockSystemModalContainer",
907 lock_screen_containers);
[email protected]a4cd6d32012-09-12 03:42:13908 lock_modal_container->SetLayoutManager(
[email protected]c0ce80e2012-10-05 23:28:27909 new SystemModalContainerLayoutManager(lock_modal_container));
[email protected]b5756e22012-11-30 01:32:02910 views::corewm::SetChildWindowVisibilityChangesAnimated(lock_modal_container);
[email protected]a4cd6d32012-09-12 03:42:13911 SetUsesScreenCoordinates(lock_modal_container);
[email protected]c5be8d672014-01-07 13:33:41912 SetUsesEasyResizeTargeter(lock_modal_container);
[email protected]a4cd6d32012-09-12 03:42:13913
914 aura::Window* status_container =
[email protected]c0ce80e2012-10-05 23:28:27915 CreateContainer(kShellWindowId_StatusContainer,
[email protected]a4cd6d32012-09-12 03:42:13916 "StatusContainer",
917 lock_screen_related_containers);
918 SetUsesScreenCoordinates(status_container);
[email protected]e887c6c2013-07-08 19:35:53919 DescendantShouldStayInSameRootWindow(status_container);
[email protected]a4cd6d32012-09-12 03:42:13920
921 aura::Window* settings_bubble_container = CreateContainer(
[email protected]c0ce80e2012-10-05 23:28:27922 kShellWindowId_SettingBubbleContainer,
[email protected]a4cd6d32012-09-12 03:42:13923 "SettingBubbleContainer",
924 lock_screen_related_containers);
[email protected]b5756e22012-11-30 01:32:02925 views::corewm::SetChildWindowVisibilityChangesAnimated(
926 settings_bubble_container);
[email protected]a4cd6d32012-09-12 03:42:13927 SetUsesScreenCoordinates(settings_bubble_container);
[email protected]e887c6c2013-07-08 19:35:53928 DescendantShouldStayInSameRootWindow(settings_bubble_container);
[email protected]a4cd6d32012-09-12 03:42:13929
930 aura::Window* menu_container = CreateContainer(
[email protected]c0ce80e2012-10-05 23:28:27931 kShellWindowId_MenuContainer,
[email protected]a4cd6d32012-09-12 03:42:13932 "MenuContainer",
933 lock_screen_related_containers);
[email protected]b5756e22012-11-30 01:32:02934 views::corewm::SetChildWindowVisibilityChangesAnimated(menu_container);
[email protected]a4cd6d32012-09-12 03:42:13935 SetUsesScreenCoordinates(menu_container);
936
937 aura::Window* drag_drop_container = CreateContainer(
[email protected]c0ce80e2012-10-05 23:28:27938 kShellWindowId_DragImageAndTooltipContainer,
[email protected]a4cd6d32012-09-12 03:42:13939 "DragImageAndTooltipContainer",
940 lock_screen_related_containers);
[email protected]b5756e22012-11-30 01:32:02941 views::corewm::SetChildWindowVisibilityChangesAnimated(drag_drop_container);
[email protected]a4cd6d32012-09-12 03:42:13942 SetUsesScreenCoordinates(drag_drop_container);
943
944 aura::Window* overlay_container = CreateContainer(
[email protected]c0ce80e2012-10-05 23:28:27945 kShellWindowId_OverlayContainer,
[email protected]a4cd6d32012-09-12 03:42:13946 "OverlayContainer",
947 lock_screen_related_containers);
948 SetUsesScreenCoordinates(overlay_container);
[email protected]a07615f2012-10-24 08:23:08949
950 CreateContainer(kShellWindowId_PowerButtonAnimationContainer,
951 "PowerButtonAnimationContainer", root_window) ;
[email protected]a4cd6d32012-09-12 03:42:13952}
953
[email protected]d141b922013-07-09 08:13:17954void RootWindowController::EnableTouchHudProjection() {
955 if (touch_hud_projection_)
956 return;
[email protected]41baaed2013-11-09 04:18:26957 set_touch_hud_projection(new TouchHudProjection(root_window()));
[email protected]d141b922013-07-09 08:13:17958}
959
960void RootWindowController::DisableTouchHudProjection() {
961 if (!touch_hud_projection_)
962 return;
963 touch_hud_projection_->Remove();
964}
965
966void RootWindowController::OnLoginStateChanged(user::LoginStatus status) {
967 shelf_->shelf_layout_manager()->UpdateVisibilityState();
968}
969
970void RootWindowController::OnTouchHudProjectionToggled(bool enabled) {
971 if (enabled)
972 EnableTouchHudProjection();
973 else
974 DisableTouchHudProjection();
975}
976
[email protected]6b2d4a0b2013-09-06 06:29:54977RootWindowController* GetRootWindowController(
[email protected]bf9cdb362013-10-25 19:22:45978 const aura::Window* root_window) {
[email protected]6b2d4a0b2013-09-06 06:29:54979 return root_window ? GetRootWindowSettings(root_window)->controller : NULL;
980}
981
[email protected]d90b8392012-06-13 09:34:56982} // namespace internal
983} // namespace ash