blob: 1af782d079b4a04fcfb9e8af165b6ded86a2a3d9 [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]97decb52013-11-14 02:27:5039#include "ash/wm/solo_window_tracker.h"
[email protected]2a2caa02013-01-22 20:50:3640#include "ash/wm/stacking_controller.h"
[email protected]e74aaf0a2012-10-12 18:42:2841#include "ash/wm/status_area_layout_manager.h"
[email protected]e6e41d2f2012-10-29 19:22:1942#include "ash/wm/system_background_controller.h"
[email protected]d90b8392012-06-13 09:34:5643#include "ash/wm/system_modal_container_layout_manager.h"
[email protected]342d56a2013-12-20 23:01:0244#include "ash/wm/toplevel_window_event_handler.h"
[email protected]8d625fb2012-07-18 16:40:0645#include "ash/wm/window_properties.h"
[email protected]a41b4e12013-09-20 04:36:3446#include "ash/wm/window_state.h"
[email protected]700849f2013-04-30 17:49:2047#include "ash/wm/window_util.h"
[email protected]d90b8392012-06-13 09:34:5648#include "ash/wm/workspace_controller.h"
[email protected]e6e41d2f2012-10-29 19:22:1949#include "base/command_line.h"
[email protected]1e84c632013-06-27 23:12:2150#include "base/time/time.h"
[email protected]f1853122012-06-27 16:21:2651#include "ui/aura/client/aura_constants.h"
[email protected]8b3e3d82013-08-20 14:36:3052#include "ui/aura/client/drag_drop_client.h"
[email protected]d90b8392012-06-13 09:34:5653#include "ui/aura/client/tooltip_client.h"
54#include "ui/aura/root_window.h"
[email protected]f1853122012-06-27 16:21:2655#include "ui/aura/window.h"
[email protected]cf6fea22013-08-07 14:24:0156#include "ui/aura/window_delegate.h"
[email protected]f1853122012-06-27 16:21:2657#include "ui/aura/window_observer.h"
[email protected]8b3e3d82013-08-20 14:36:3058#include "ui/aura/window_tracker.h"
[email protected]cf6fea22013-08-07 14:24:0159#include "ui/base/hit_test.h"
[email protected]431552c2012-10-23 00:38:3360#include "ui/base/models/menu_model.h"
[email protected]f8e6aad2013-08-30 21:49:1161#include "ui/gfx/display.h"
[email protected]8d625fb2012-07-18 16:40:0662#include "ui/gfx/screen.h"
[email protected]86459e2c2013-04-10 13:39:2463#include "ui/keyboard/keyboard_controller.h"
64#include "ui/keyboard/keyboard_util.h"
[email protected]431552c2012-10-23 00:38:3365#include "ui/views/controls/menu/menu_runner.h"
[email protected]23a2dc82013-08-22 15:04:2266#include "ui/views/corewm/capture_controller.h"
[email protected]b5756e22012-11-30 01:32:0267#include "ui/views/corewm/visibility_controller.h"
[email protected]431552c2012-10-23 00:38:3368#include "ui/views/view_model.h"
69#include "ui/views/view_model_utils.h"
[email protected]c5be8d672014-01-07 13:33:4170#include "ui/wm/public/easy_resize_window_targeter.h"
[email protected]5b251f12013-12-19 01:50:0571#include "ui/wm/public/window_types.h"
[email protected]d90b8392012-06-13 09:34:5672
[email protected]252eb232013-08-14 22:09:2773#if defined(OS_CHROMEOS)
74#include "ash/wm/boot_splash_screen_chromeos.h"
75#endif
76
[email protected]d90b8392012-06-13 09:34:5677namespace ash {
78namespace {
79
[email protected]252eb232013-08-14 22:09:2780#if defined(OS_CHROMEOS)
[email protected]bca9a7e2012-11-10 06:25:4981// Duration for the animation that hides the boot splash screen, in
82// milliseconds. This should be short enough in relation to
83// wm/window_animation.cc's brightness/grayscale fade animation that the login
84// background image animation isn't hidden by the splash screen animation.
85const int kBootSplashScreenHideDurationMs = 500;
[email protected]252eb232013-08-14 22:09:2786#endif
[email protected]bca9a7e2012-11-10 06:25:4987
[email protected]d90b8392012-06-13 09:34:5688// Creates a new window for use as a container.
89aura::Window* CreateContainer(int window_id,
90 const char* name,
91 aura::Window* parent) {
92 aura::Window* container = new aura::Window(NULL);
93 container->set_id(window_id);
94 container->SetName(name);
95 container->Init(ui::LAYER_NOT_DRAWN);
96 parent->AddChild(container);
97 if (window_id != internal::kShellWindowId_UnparentedControlContainer)
98 container->Show();
99 return container;
100}
101
[email protected]2816c2462013-12-17 02:22:25102float ToRelativeValue(int value, int src, int dst) {
103 return static_cast<float>(value) / static_cast<float>(src) * dst;
104}
105
106void MoveOriginRelativeToSize(const gfx::Size& src_size,
107 const gfx::Size& dst_size,
108 gfx::Rect* bounds_in_out) {
109 gfx::Point origin = bounds_in_out->origin();
110 bounds_in_out->set_origin(gfx::Point(
111 ToRelativeValue(origin.x(), src_size.width(), dst_size.width()),
112 ToRelativeValue(origin.y(), src_size.height(), dst_size.height())));
113}
114
[email protected]95058572012-08-20 14:57:29115// Reparents |window| to |new_parent|.
116void ReparentWindow(aura::Window* window, aura::Window* new_parent) {
[email protected]2816c2462013-12-17 02:22:25117 const gfx::Size src_size = window->parent()->bounds().size();
118 const gfx::Size dst_size = new_parent->bounds().size();
[email protected]95058572012-08-20 14:57:29119 // Update the restore bounds to make it relative to the display.
[email protected]a41b4e12013-09-20 04:36:34120 wm::WindowState* state = wm::GetWindowState(window);
121 gfx::Rect restore_bounds;
122 bool has_restore_bounds = state->HasRestoreBounds();
[email protected]2816c2462013-12-17 02:22:25123
124 // TODO(oshima): snapped state should be handled by the layout manager.
125 bool update_bounds = state->IsNormalShowState() || state->IsMinimized();
126 gfx::Rect local_bounds;
127 if (update_bounds) {
128 local_bounds = state->window()->bounds();
129 MoveOriginRelativeToSize(src_size, dst_size, &local_bounds);
130 }
131
132 if (has_restore_bounds) {
[email protected]a41b4e12013-09-20 04:36:34133 restore_bounds = state->GetRestoreBoundsInParent();
[email protected]2816c2462013-12-17 02:22:25134 MoveOriginRelativeToSize(src_size, dst_size, &restore_bounds);
135 }
136
[email protected]95058572012-08-20 14:57:29137 new_parent->AddChild(window);
[email protected]2816c2462013-12-17 02:22:25138
139 if (update_bounds)
140 window->SetBounds(local_bounds);
141
[email protected]a41b4e12013-09-20 04:36:34142 if (has_restore_bounds)
143 state->SetRestoreBoundsInParent(restore_bounds);
[email protected]95058572012-08-20 14:57:29144}
145
146// Reparents the appropriate set of windows from |src| to |dst|.
[email protected]bf9cdb362013-10-25 19:22:45147void ReparentAllWindows(aura::Window* src, aura::Window* dst) {
[email protected]95058572012-08-20 14:57:29148 // Set of windows to move.
[email protected]f1853122012-06-27 16:21:26149 const int kContainerIdsToMove[] = {
150 internal::kShellWindowId_DefaultContainer,
[email protected]beb4e5c2013-06-18 15:37:07151 internal::kShellWindowId_DockedContainer,
[email protected]95db9c12013-01-31 11:47:44152 internal::kShellWindowId_PanelContainer,
[email protected]f1853122012-06-27 16:21:26153 internal::kShellWindowId_AlwaysOnTopContainer,
154 internal::kShellWindowId_SystemModalContainer,
155 internal::kShellWindowId_LockSystemModalContainer,
[email protected]6274d312012-10-04 22:06:41156 internal::kShellWindowId_InputMethodContainer,
[email protected]a9754872013-01-25 07:44:00157 internal::kShellWindowId_UnparentedControlContainer,
[email protected]f1853122012-06-27 16:21:26158 };
[email protected]f1853122012-06-27 16:21:26159 for (size_t i = 0; i < arraysize(kContainerIdsToMove); i++) {
160 int id = kContainerIdsToMove[i];
161 aura::Window* src_container = Shell::GetContainer(src, id);
162 aura::Window* dst_container = Shell::GetContainer(dst, id);
[email protected]5b6021902013-02-26 05:33:29163 while (!src_container->children().empty()) {
164 // Restart iteration from the source container windows each time as they
165 // may change as a result of moving other windows.
166 aura::Window::Windows::const_iterator iter =
167 src_container->children().begin();
168 while (iter != src_container->children().end() &&
169 internal::SystemModalContainerLayoutManager::IsModalBackground(
170 *iter)) {
171 ++iter;
172 }
173 // If the entire window list is modal background windows then stop.
174 if (iter == src_container->children().end())
175 break;
176 ReparentWindow(*iter, dst_container);
[email protected]f1853122012-06-27 16:21:26177 }
178 }
179}
180
[email protected]8d625fb2012-07-18 16:40:06181// Mark the container window so that a widget added to this container will
182// use the virtual screeen coordinates instead of parent.
183void SetUsesScreenCoordinates(aura::Window* container) {
184 container->SetProperty(internal::kUsesScreenCoordinatesKey, true);
185}
186
[email protected]e887c6c2013-07-08 19:35:53187// Mark the container window so that a widget added to this container will
188// say in the same root window regardless of the bounds specified.
189void DescendantShouldStayInSameRootWindow(aura::Window* container) {
190 container->SetProperty(internal::kStayInSameRootWindowKey, true);
191}
192
[email protected]c5be8d672014-01-07 13:33:41193void SetUsesEasyResizeTargeter(aura::Window* container) {
194 gfx::Insets mouse_extend(-kResizeOutsideBoundsSize,
195 -kResizeOutsideBoundsSize,
196 -kResizeOutsideBoundsSize,
197 -kResizeOutsideBoundsSize);
198 gfx::Insets touch_extend = mouse_extend.Scale(
199 kResizeOutsideBoundsScaleForTouch);
200 container->set_event_targeter(scoped_ptr<ui::EventTargeter>(
201 new ::wm::EasyResizeWindowTargeter(container, mouse_extend,
202 touch_extend)));
203}
204
[email protected]cf6fea22013-08-07 14:24:01205// A window delegate which does nothing. Used to create a window that
206// is a event target, but do nothing.
207class EmptyWindowDelegate : public aura::WindowDelegate {
208 public:
209 EmptyWindowDelegate() {}
210 virtual ~EmptyWindowDelegate() {}
211
212 // aura::WindowDelegate overrides:
213 virtual gfx::Size GetMinimumSize() const OVERRIDE {
214 return gfx::Size();
215 }
216 virtual gfx::Size GetMaximumSize() const OVERRIDE {
217 return gfx::Size();
218 }
219 virtual void OnBoundsChanged(const gfx::Rect& old_bounds,
220 const gfx::Rect& new_bounds) OVERRIDE {
221 }
222 virtual gfx::NativeCursor GetCursor(const gfx::Point& point) OVERRIDE {
223 return gfx::kNullCursor;
224 }
225 virtual int GetNonClientComponent(
226 const gfx::Point& point) const OVERRIDE {
227 return HTNOWHERE;
228 }
229 virtual bool ShouldDescendIntoChildForEventHandling(
230 aura::Window* child,
231 const gfx::Point& location) OVERRIDE {
232 return false;
233 }
234 virtual bool CanFocus() OVERRIDE {
235 return false;
236 }
237 virtual void OnCaptureLost() OVERRIDE {
238 }
239 virtual void OnPaint(gfx::Canvas* canvas) OVERRIDE {
240 }
241 virtual void OnDeviceScaleFactorChanged(
242 float device_scale_factor) OVERRIDE {
243 }
244 virtual void OnWindowDestroying() OVERRIDE {}
[email protected]febe1fd62013-08-07 16:07:24245 virtual void OnWindowDestroyed() OVERRIDE {
246 delete this;
247 }
[email protected]cf6fea22013-08-07 14:24:01248 virtual void OnWindowTargetVisibilityChanged(bool visible) OVERRIDE {
249 }
250 virtual bool HasHitTestMask() const OVERRIDE {
251 return false;
252 }
253 virtual void GetHitTestMask(gfx::Path* mask) const OVERRIDE {}
[email protected]1ddbe932013-09-12 06:23:16254 virtual void DidRecreateLayer(ui::Layer* old_layer,
255 ui::Layer* new_layer) OVERRIDE {}
[email protected]cf6fea22013-08-07 14:24:01256
257 private:
258 DISALLOW_COPY_AND_ASSIGN(EmptyWindowDelegate);
259};
260
[email protected]d90b8392012-06-13 09:34:56261} // namespace
262
263namespace internal {
264
[email protected]a273d33a2013-10-17 12:41:21265void RootWindowController::CreateForPrimaryDisplay(
[email protected]bf9cdb362013-10-25 19:22:45266 aura::RootWindow* root) {
[email protected]a273d33a2013-10-17 12:41:21267 RootWindowController* controller = new RootWindowController(root);
[email protected]608de6c2013-10-29 00:14:28268 controller->Init(RootWindowController::PRIMARY,
[email protected]a273d33a2013-10-17 12:41:21269 Shell::GetInstance()->delegate()->IsFirstRunAfterBoot());
[email protected]d90b8392012-06-13 09:34:56270}
271
[email protected]a273d33a2013-10-17 12:41:21272void RootWindowController::CreateForSecondaryDisplay(aura::RootWindow * root) {
273 RootWindowController* controller = new RootWindowController(root);
[email protected]608de6c2013-10-29 00:14:28274 controller->Init(RootWindowController::SECONDARY, false /* first run */);
275}
276
277void RootWindowController::CreateForVirtualKeyboardDisplay(
278 aura::RootWindow * root) {
279 RootWindowController* controller = new RootWindowController(root);
280 controller->Init(RootWindowController::VIRTUAL_KEYBOARD,
281 false /* first run */);
[email protected]6675e1c2012-09-11 09:15:45282}
283
[email protected]88d71122012-10-18 07:11:01284// static
[email protected]864b58552013-12-19 04:19:38285RootWindowController* RootWindowController::ForShelf(aura::Window* window) {
[email protected]8c0ec432013-05-10 04:33:39286 return GetRootWindowController(window->GetRootWindow());
[email protected]88d71122012-10-18 07:11:01287}
288
[email protected]a0afeb12012-12-10 22:57:09289// static
[email protected]ccff3d72013-02-06 04:26:28290RootWindowController* RootWindowController::ForWindow(
291 const aura::Window* window) {
[email protected]a0afeb12012-12-10 22:57:09292 return GetRootWindowController(window->GetRootWindow());
293}
294
295// static
[email protected]d17642d2013-09-12 23:44:38296RootWindowController* RootWindowController::ForTargetRootWindow() {
297 return internal::GetRootWindowController(Shell::GetTargetRootWindow());
[email protected]a0afeb12012-12-10 22:57:09298}
299
[email protected]a5c78802013-12-12 22:07:01300// static
301aura::Window* RootWindowController::GetContainerForWindow(
302 aura::Window* window) {
303 aura::Window* container = window->parent();
[email protected]5b251f12013-12-19 01:50:05304 while (container && container->type() != ui::wm::WINDOW_TYPE_UNKNOWN)
[email protected]a5c78802013-12-12 22:07:01305 container = container->parent();
306 return container;
307}
308
[email protected]a273d33a2013-10-17 12:41:21309RootWindowController::~RootWindowController() {
310 Shutdown();
311 root_window_.reset();
312 // The CaptureClient needs to be around for as long as the RootWindow is
313 // valid.
314 capture_client_.reset();
315}
316
[email protected]0bf61732013-07-02 04:35:10317void RootWindowController::SetWallpaperController(
318 DesktopBackgroundWidgetController* controller) {
319 wallpaper_controller_.reset(controller);
320}
321
322void RootWindowController::SetAnimatingWallpaperController(
323 AnimatingDesktopController* controller) {
324 if (animating_wallpaper_controller_.get())
325 animating_wallpaper_controller_->StopAnimating();
326 animating_wallpaper_controller_.reset(controller);
327}
328
[email protected]6675e1c2012-09-11 09:15:45329void RootWindowController::Shutdown() {
[email protected]d141b922013-07-09 08:13:17330 Shell::GetInstance()->RemoveShellObserver(this);
331
[email protected]0bf61732013-07-02 04:35:10332 if (animating_wallpaper_controller_.get())
333 animating_wallpaper_controller_->StopAnimating();
334 wallpaper_controller_.reset();
335 animating_wallpaper_controller_.reset();
336
[email protected]d17642d2013-09-12 23:44:38337 // Change the target root window before closing child windows. If any child
[email protected]c98a4922013-09-05 20:01:42338 // being removed triggers a relayout of the shelf it will try to build a
[email protected]d17642d2013-09-12 23:44:38339 // window list adding windows from the target root window's containers which
[email protected]c98a4922013-09-05 20:01:42340 // may have already gone away.
[email protected]41baaed2013-11-09 04:18:26341 if (Shell::GetTargetRootWindow() == root_window()) {
[email protected]d17642d2013-09-12 23:44:38342 Shell::GetInstance()->set_target_root_window(
[email protected]41baaed2013-11-09 04:18:26343 Shell::GetPrimaryRootWindow() == root_window() ?
[email protected]f634dd32012-07-23 22:49:07344 NULL : Shell::GetPrimaryRootWindow());
345 }
[email protected]c98a4922013-09-05 20:01:42346
347 CloseChildWindows();
[email protected]41baaed2013-11-09 04:18:26348 GetRootWindowSettings(root_window())->controller = NULL;
[email protected]d90b8392012-06-13 09:34:56349 screen_dimmer_.reset();
350 workspace_controller_.reset();
[email protected]6675e1c2012-09-11 09:15:45351 // Forget with the display ID so that display lookup
352 // ends up with invalid display.
[email protected]41baaed2013-11-09 04:18:26353 internal::GetRootWindowSettings(root_window())->display_id =
[email protected]f8e6aad2013-08-30 21:49:11354 gfx::Display::kInvalidDisplayID;
[email protected]6675e1c2012-09-11 09:15:45355 // And this root window should no longer process events.
356 root_window_->PrepareForShutdown();
[email protected]e74aaf0a2012-10-12 18:42:28357
[email protected]956a6a42012-10-29 23:58:10358 system_background_.reset();
[email protected]d90b8392012-06-13 09:34:56359}
360
[email protected]c0ce80e2012-10-05 23:28:27361SystemModalContainerLayoutManager*
[email protected]8674b312012-10-12 19:02:44362RootWindowController::GetSystemModalLayoutManager(aura::Window* window) {
[email protected]a5c78802013-12-12 22:07:01363 aura::Window* modal_container = NULL;
[email protected]8674b312012-10-12 19:02:44364 if (window) {
[email protected]a5c78802013-12-12 22:07:01365 aura::Window* window_container = GetContainerForWindow(window);
366 if (window_container &&
367 window_container->id() >= kShellWindowId_LockScreenContainer) {
368 modal_container = GetContainer(kShellWindowId_LockSystemModalContainer);
[email protected]3b162e12012-11-09 11:52:35369 } else {
[email protected]a5c78802013-12-12 22:07:01370 modal_container = GetContainer(kShellWindowId_SystemModalContainer);
[email protected]3b162e12012-11-09 11:52:35371 }
[email protected]8674b312012-10-12 19:02:44372 } else {
[email protected]a44afbbd2013-07-24 21:49:35373 int modal_window_id = Shell::GetInstance()->session_state_delegate()
374 ->IsUserSessionBlocked() ? kShellWindowId_LockSystemModalContainer :
375 kShellWindowId_SystemModalContainer;
[email protected]a5c78802013-12-12 22:07:01376 modal_container = GetContainer(modal_window_id);
[email protected]8674b312012-10-12 19:02:44377 }
[email protected]a5c78802013-12-12 22:07:01378 return modal_container ? static_cast<SystemModalContainerLayoutManager*>(
379 modal_container->layout_manager()) : NULL;
[email protected]c0ce80e2012-10-05 23:28:27380}
381
[email protected]d90b8392012-06-13 09:34:56382aura::Window* RootWindowController::GetContainer(int container_id) {
[email protected]41baaed2013-11-09 04:18:26383 return root_window()->GetChildById(container_id);
[email protected]d90b8392012-06-13 09:34:56384}
385
[email protected]d8a24952013-08-05 20:05:05386const aura::Window* RootWindowController::GetContainer(int container_id) const {
[email protected]41baaed2013-11-09 04:18:26387 return root_window_->window()->GetChildById(container_id);
[email protected]d8a24952013-08-05 20:05:05388}
389
[email protected]864b58552013-12-19 04:19:38390void RootWindowController::ShowShelf() {
391 if (!shelf_->shelf())
[email protected]e74aaf0a2012-10-12 18:42:28392 return;
[email protected]864b58552013-12-19 04:19:38393 shelf_->shelf()->SetVisible(true);
[email protected]478c6c32013-03-09 02:50:58394 shelf_->status_area_widget()->Show();
[email protected]e74aaf0a2012-10-12 18:42:28395}
396
[email protected]864b58552013-12-19 04:19:38397void RootWindowController::OnShelfCreated() {
[email protected]756bda12013-07-03 08:17:06398 if (panel_layout_manager_)
[email protected]864b58552013-12-19 04:19:38399 panel_layout_manager_->SetShelf(shelf_->shelf());
[email protected]7115bd32013-07-19 08:25:39400 if (docked_layout_manager_) {
[email protected]864b58552013-12-19 04:19:38401 docked_layout_manager_->SetShelf(shelf_->shelf());
[email protected]7115bd32013-07-19 08:25:39402 if (shelf_->shelf_layout_manager())
403 docked_layout_manager_->AddObserver(shelf_->shelf_layout_manager());
404 }
[email protected]756bda12013-07-03 08:17:06405}
406
[email protected]16059276d2012-10-22 18:59:50407void RootWindowController::UpdateAfterLoginStatusChange(
408 user::LoginStatus status) {
[email protected]cf6fea22013-08-07 14:24:01409 if (status != user::LOGGED_IN_NONE)
410 mouse_event_target_.reset();
[email protected]80549c152013-07-02 01:42:47411 if (shelf_->status_area_widget())
[email protected]478c6c32013-03-09 02:50:58412 shelf_->status_area_widget()->UpdateAfterLoginStatusChange(status);
[email protected]16059276d2012-10-22 18:59:50413}
414
[email protected]bca9a7e2012-11-10 06:25:49415void RootWindowController::HandleInitialDesktopBackgroundAnimationStarted() {
[email protected]252eb232013-08-14 22:09:27416#if defined(OS_CHROMEOS)
[email protected]bca9a7e2012-11-10 06:25:49417 if (CommandLine::ForCurrentProcess()->HasSwitch(
418 switches::kAshAnimateFromBootSplashScreen) &&
419 boot_splash_screen_.get()) {
420 // Make the splash screen fade out so it doesn't obscure the desktop
421 // wallpaper's brightness/grayscale animation.
422 boot_splash_screen_->StartHideAnimation(
423 base::TimeDelta::FromMilliseconds(kBootSplashScreenHideDurationMs));
424 }
[email protected]252eb232013-08-14 22:09:27425#endif
[email protected]bca9a7e2012-11-10 06:25:49426}
427
[email protected]0bf61732013-07-02 04:35:10428void RootWindowController::OnWallpaperAnimationFinished(views::Widget* widget) {
429 // Make sure the wallpaper is visible.
[email protected]bca9a7e2012-11-10 06:25:49430 system_background_->SetColor(SK_ColorBLACK);
[email protected]252eb232013-08-14 22:09:27431#if defined(OS_CHROMEOS)
[email protected]bca9a7e2012-11-10 06:25:49432 boot_splash_screen_.reset();
[email protected]252eb232013-08-14 22:09:27433#endif
[email protected]0bf61732013-07-02 04:35:10434
435 Shell::GetInstance()->user_wallpaper_delegate()->
436 OnWallpaperAnimationFinished();
437 // Only removes old component when wallpaper animation finished. If we
438 // remove the old one before the new wallpaper is done fading in there will
439 // be a white flash during the animation.
440 if (animating_wallpaper_controller()) {
441 DesktopBackgroundWidgetController* controller =
442 animating_wallpaper_controller()->GetController(true);
443 // |desktop_widget_| should be the same animating widget we try to move
444 // to |kDesktopController|. Otherwise, we may close |desktop_widget_|
445 // before move it to |kDesktopController|.
446 DCHECK_EQ(controller->widget(), widget);
447 // Release the old controller and close its background widget.
448 SetWallpaperController(controller);
449 }
[email protected]697f04c2012-10-03 01:15:10450}
451
[email protected]d90b8392012-06-13 09:34:56452void RootWindowController::CloseChildWindows() {
[email protected]cf6fea22013-08-07 14:24:01453 mouse_event_target_.reset();
454
[email protected]97decb52013-11-14 02:27:50455 // |solo_window_tracker_| must be shut down before windows are destroyed.
456 if (solo_window_tracker_) {
457 if (docked_layout_manager_)
458 docked_layout_manager_->RemoveObserver(solo_window_tracker_.get());
459 solo_window_tracker_.reset();
460 }
461
[email protected]b6ba05d902013-10-04 21:38:45462 // Deactivate keyboard container before closing child windows and shutting
463 // down associated layout managers.
464 DeactivateKeyboard(Shell::GetInstance()->keyboard_controller());
465
[email protected]79a87b7e2013-01-25 05:08:22466 // panel_layout_manager_ needs to be shut down before windows are destroyed.
467 if (panel_layout_manager_) {
468 panel_layout_manager_->Shutdown();
469 panel_layout_manager_ = NULL;
470 }
[email protected]7115bd32013-07-19 08:25:39471 // docked_layout_manager_ needs to be shut down before windows are destroyed.
472 if (docked_layout_manager_) {
[email protected]bb42c932013-10-31 06:52:06473 if (shelf_ && shelf_->shelf_layout_manager())
[email protected]7115bd32013-07-19 08:25:39474 docked_layout_manager_->RemoveObserver(shelf_->shelf_layout_manager());
475 docked_layout_manager_->Shutdown();
476 docked_layout_manager_ = NULL;
477 }
[email protected]79a87b7e2013-01-25 05:08:22478
[email protected]41baaed2013-11-09 04:18:26479 aura::client::SetDragDropClient(root_window(), NULL);
[email protected]8b3e3d82013-08-20 14:36:30480
[email protected]478c6c32013-03-09 02:50:58481 // TODO(harrym): Remove when Status Area Widget is a child view.
[email protected]bb42c932013-10-31 06:52:06482 if (shelf_) {
483 shelf_->ShutdownStatusAreaWidget();
[email protected]478c6c32013-03-09 02:50:58484
[email protected]bb42c932013-10-31 06:52:06485 if (shelf_->shelf_layout_manager())
486 shelf_->shelf_layout_manager()->PrepareForShutdown();
487 }
[email protected]e74aaf0a2012-10-12 18:42:28488
[email protected]d90b8392012-06-13 09:34:56489 // Close background widget first as it depends on tooltip.
[email protected]0bf61732013-07-02 04:35:10490 wallpaper_controller_.reset();
491 animating_wallpaper_controller_.reset();
[email protected]b4ddc7a2012-08-07 04:17:32492
[email protected]d90b8392012-06-13 09:34:56493 workspace_controller_.reset();
[email protected]41baaed2013-11-09 04:18:26494 aura::client::SetTooltipClient(root_window(), NULL);
[email protected]d90b8392012-06-13 09:34:56495
[email protected]0fbfa972013-10-02 19:23:33496 // Explicitly destroy top level windows. We do this as during part of
497 // destruction such windows may query the RootWindow for state.
[email protected]8b3e3d82013-08-20 14:36:30498 std::queue<aura::Window*> non_toplevel_windows;
[email protected]41baaed2013-11-09 04:18:26499 non_toplevel_windows.push(root_window());
[email protected]8b3e3d82013-08-20 14:36:30500 while (!non_toplevel_windows.empty()) {
501 aura::Window* non_toplevel_window = non_toplevel_windows.front();
502 non_toplevel_windows.pop();
503 aura::WindowTracker toplevel_windows;
504 for (size_t i = 0; i < non_toplevel_window->children().size(); ++i) {
505 aura::Window* child = non_toplevel_window->children()[i];
[email protected]0fbfa972013-10-02 19:23:33506 if (!child->owned_by_parent())
507 continue;
[email protected]8b3e3d82013-08-20 14:36:30508 if (child->delegate())
509 toplevel_windows.Add(child);
510 else
511 non_toplevel_windows.push(child);
512 }
513 while (!toplevel_windows.windows().empty())
514 delete *toplevel_windows.windows().begin();
[email protected]d90b8392012-06-13 09:34:56515 }
[email protected]8b3e3d82013-08-20 14:36:30516 // And then remove the containers.
[email protected]41baaed2013-11-09 04:18:26517 while (!root_window()->children().empty()) {
518 aura::Window* window = root_window()->children()[0];
[email protected]0fbfa972013-10-02 19:23:33519 if (window->owned_by_parent()) {
520 delete window;
521 } else {
[email protected]41baaed2013-11-09 04:18:26522 root_window()->RemoveChild(window);
[email protected]0fbfa972013-10-02 19:23:33523 }
524 }
[email protected]478c6c32013-03-09 02:50:58525
[email protected]bb42c932013-10-31 06:52:06526 shelf_.reset();
[email protected]d90b8392012-06-13 09:34:56527}
528
[email protected]bf9cdb362013-10-25 19:22:45529void RootWindowController::MoveWindowsTo(aura::Window* dst) {
[email protected]8039e06c2013-01-17 23:34:50530 // Forget the shelf early so that shelf don't update itself using wrong
531 // display info.
532 workspace_controller_->SetShelf(NULL);
[email protected]41baaed2013-11-09 04:18:26533 ReparentAllWindows(root_window(), dst);
[email protected]f1853122012-06-27 16:21:26534}
535
[email protected]478c6c32013-03-09 02:50:58536ShelfLayoutManager* RootWindowController::GetShelfLayoutManager() {
[email protected]80549c152013-07-02 01:42:47537 return shelf_->shelf_layout_manager();
[email protected]478c6c32013-03-09 02:50:58538}
539
[email protected]a0afeb12012-12-10 22:57:09540SystemTray* RootWindowController::GetSystemTray() {
541 // We assume in throughout the code that this will not return NULL. If code
542 // triggers this for valid reasons, it should test status_area_widget first.
[email protected]80549c152013-07-02 01:42:47543 CHECK(shelf_->status_area_widget());
[email protected]478c6c32013-03-09 02:50:58544 return shelf_->status_area_widget()->system_tray();
[email protected]a0afeb12012-12-10 22:57:09545}
546
[email protected]940fb1c2013-06-18 16:54:28547void RootWindowController::ShowContextMenu(const gfx::Point& location_in_screen,
548 ui::MenuSourceType source_type) {
[email protected]431552c2012-10-23 00:38:33549 DCHECK(Shell::GetInstance()->delegate());
550 scoped_ptr<ui::MenuModel> menu_model(
[email protected]8c0ec432013-05-10 04:33:39551 Shell::GetInstance()->delegate()->CreateContextMenu(root_window()));
[email protected]7f7f65c2013-04-17 16:47:13552 if (!menu_model)
[email protected]8e837ec2013-01-31 01:48:33553 return;
[email protected]431552c2012-10-23 00:38:33554
[email protected]6175fc42013-04-05 05:58:58555 // Background controller may not be set yet if user clicked on status are
556 // before initial animation completion. See crbug.com/222218
[email protected]0bf61732013-07-02 04:35:10557 if (!wallpaper_controller_.get())
[email protected]431552c2012-10-23 00:38:33558 return;
559
[email protected]6175fc42013-04-05 05:58:58560 views::MenuRunner menu_runner(menu_model.get());
[email protected]0bf61732013-07-02 04:35:10561 if (menu_runner.RunMenuAt(wallpaper_controller_->widget(),
[email protected]6175fc42013-04-05 05:58:58562 NULL, gfx::Rect(location_in_screen, gfx::Size()),
[email protected]940fb1c2013-06-18 16:54:28563 views::MenuItemView::TOPLEFT, source_type,
564 views::MenuRunner::CONTEXT_MENU) ==
[email protected]6175fc42013-04-05 05:58:58565 views::MenuRunner::MENU_DELETED) {
566 return;
567 }
568
[email protected]431552c2012-10-23 00:38:33569 Shell::GetInstance()->UpdateShelfVisibility();
570}
571
[email protected]e74aaf0a2012-10-12 18:42:28572void RootWindowController::UpdateShelfVisibility() {
[email protected]478c6c32013-03-09 02:50:58573 shelf_->shelf_layout_manager()->UpdateVisibilityState();
[email protected]e74aaf0a2012-10-12 18:42:28574}
575
[email protected]2c9171d22013-12-10 21:55:10576const aura::Window* RootWindowController::GetWindowForFullscreenMode() const {
[email protected]e3bc88e2013-09-06 06:22:06577 const aura::Window::Windows& windows =
578 GetContainer(kShellWindowId_DefaultContainer)->children();
[email protected]2c9171d22013-12-10 21:55:10579 const aura::Window* topmost_window = NULL;
[email protected]e3bc88e2013-09-06 06:22:06580 for (aura::Window::Windows::const_reverse_iterator iter = windows.rbegin();
581 iter != windows.rend(); ++iter) {
[email protected]5b251f12013-12-19 01:50:05582 if (((*iter)->type() == ui::wm::WINDOW_TYPE_NORMAL ||
583 (*iter)->type() == ui::wm::WINDOW_TYPE_PANEL) &&
[email protected]2c9171d22013-12-10 21:55:10584 (*iter)->layer()->GetTargetVisibility()) {
585 topmost_window = *iter;
586 break;
587 }
588 }
589 while (topmost_window) {
590 if (wm::GetWindowState(topmost_window)->IsFullscreen())
591 return topmost_window;
592 topmost_window = topmost_window->transient_parent();
[email protected]2ee2f5d2013-01-10 23:37:16593 }
[email protected]700849f2013-04-30 17:49:20594 return NULL;
[email protected]2ee2f5d2013-01-10 23:37:16595}
596
[email protected]b6ba05d902013-10-04 21:38:45597void RootWindowController::ActivateKeyboard(
598 keyboard::KeyboardController* keyboard_controller) {
599 if (!keyboard::IsKeyboardEnabled() ||
600 GetContainer(kShellWindowId_VirtualKeyboardContainer)) {
601 return;
602 }
603 DCHECK(keyboard_controller);
[email protected]51f438112013-11-18 19:32:50604 if (!keyboard::IsKeyboardUsabilityExperimentEnabled()) {
605 keyboard_controller->AddObserver(shelf()->shelf_layout_manager());
606 keyboard_controller->AddObserver(panel_layout_manager_);
607 keyboard_controller->AddObserver(docked_layout_manager_);
608 }
[email protected]b6ba05d902013-10-04 21:38:45609 aura::Window* parent = root_window();
610 aura::Window* keyboard_container =
611 keyboard_controller->GetContainerWindow();
612 keyboard_container->set_id(kShellWindowId_VirtualKeyboardContainer);
613 parent->AddChild(keyboard_container);
614 // TODO(oshima): Bounds of keyboard container should be handled by
615 // RootWindowLayoutManager. Remove this after fixed RootWindowLayoutManager.
616 keyboard_container->SetBounds(parent->bounds());
617}
[email protected]86459e2c2013-04-10 13:39:24618
[email protected]b6ba05d902013-10-04 21:38:45619void RootWindowController::DeactivateKeyboard(
620 keyboard::KeyboardController* keyboard_controller) {
621 if (!keyboard::IsKeyboardEnabled())
622 return;
[email protected]5416f282013-04-29 20:52:48623
[email protected]b6ba05d902013-10-04 21:38:45624 DCHECK(keyboard_controller);
625 aura::Window* keyboard_container =
626 keyboard_controller->GetContainerWindow();
627 if (keyboard_container->GetRootWindow() == root_window()) {
628 root_window()->RemoveChild(keyboard_container);
[email protected]51f438112013-11-18 19:32:50629 if (!keyboard::IsKeyboardUsabilityExperimentEnabled()) {
630 keyboard_controller->RemoveObserver(shelf()->shelf_layout_manager());
631 keyboard_controller->RemoveObserver(panel_layout_manager_);
632 keyboard_controller->RemoveObserver(docked_layout_manager_);
633 }
[email protected]86459e2c2013-04-10 13:39:24634 }
635}
636
[email protected]a4cd6d32012-09-12 03:42:13637////////////////////////////////////////////////////////////////////////////////
638// RootWindowController, private:
639
[email protected]a273d33a2013-10-17 12:41:21640RootWindowController::RootWindowController(aura::RootWindow* root_window)
641 : root_window_(root_window),
642 root_window_layout_(NULL),
643 docked_layout_manager_(NULL),
644 panel_layout_manager_(NULL),
645 touch_hud_debug_(NULL),
646 touch_hud_projection_(NULL) {
[email protected]41baaed2013-11-09 04:18:26647 GetRootWindowSettings(root_window_->window())->controller = this;
648 screen_dimmer_.reset(new ScreenDimmer(root_window_->window()));
[email protected]a273d33a2013-10-17 12:41:21649
650 stacking_controller_.reset(new StackingController);
[email protected]41baaed2013-11-09 04:18:26651 aura::client::SetWindowTreeClient(root_window_->window(),
652 stacking_controller_.get());
653 capture_client_.reset(
654 new views::corewm::ScopedCaptureClient(root_window_->window()));
[email protected]a273d33a2013-10-17 12:41:21655}
656
[email protected]608de6c2013-10-29 00:14:28657void RootWindowController::Init(RootWindowType root_window_type,
658 bool first_run_after_boot) {
[email protected]51f438112013-11-18 19:32:50659 Shell* shell = Shell::GetInstance();
660 shell->InitRootWindow(root_window());
[email protected]a273d33a2013-10-17 12:41:21661
662 root_window_->SetCursor(ui::kCursorPointer);
[email protected]f7c05b22013-11-12 21:07:24663 CreateContainersInRootWindow(root_window_->window());
[email protected]608de6c2013-10-29 00:14:28664
[email protected]51f438112013-11-18 19:32:50665 if (root_window_type == VIRTUAL_KEYBOARD) {
666 shell->InitKeyboard();
[email protected]608de6c2013-10-29 00:14:28667 return;
[email protected]51f438112013-11-18 19:32:50668 }
[email protected]608de6c2013-10-29 00:14:28669
[email protected]a273d33a2013-10-17 12:41:21670 CreateSystemBackground(first_run_after_boot);
671
672 InitLayoutManagers();
673 InitTouchHuds();
674
675 if (Shell::GetPrimaryRootWindowController()->
676 GetSystemModalLayoutManager(NULL)->has_modal_background()) {
677 GetSystemModalLayoutManager(NULL)->CreateModalBackground();
678 }
679
[email protected]a273d33a2013-10-17 12:41:21680 shell->AddShellObserver(this);
681
[email protected]608de6c2013-10-29 00:14:28682 if (root_window_type == PRIMARY) {
[email protected]a3565792013-10-18 12:52:37683 root_window_layout()->OnWindowResized();
[email protected]51f438112013-11-18 19:32:50684 if (!keyboard::IsKeyboardUsabilityExperimentEnabled())
685 shell->InitKeyboard();
[email protected]a273d33a2013-10-17 12:41:21686 } else {
687 root_window_layout()->OnWindowResized();
[email protected]41baaed2013-11-09 04:18:26688 shell->desktop_background_controller()->OnRootWindowAdded(root_window());
[email protected]f7c05b22013-11-12 21:07:24689 shell->high_contrast_controller()->OnRootWindowAdded(
690 root_window_->window());
[email protected]228f0f02013-11-15 05:58:36691 root_window_->host()->Show();
[email protected]a273d33a2013-10-17 12:41:21692
[email protected]864b58552013-12-19 04:19:38693 // Create a shelf if a user is already logged in.
[email protected]a273d33a2013-10-17 12:41:21694 if (shell->session_state_delegate()->NumberOfLoggedInUsers())
[email protected]864b58552013-12-19 04:19:38695 shelf()->CreateShelf();
[email protected]a273d33a2013-10-17 12:41:21696 }
[email protected]97decb52013-11-14 02:27:50697
698 solo_window_tracker_.reset(new SoloWindowTracker(root_window_.get()));
699 if (docked_layout_manager_)
700 docked_layout_manager_->AddObserver(solo_window_tracker_.get());
[email protected]a273d33a2013-10-17 12:41:21701}
702
[email protected]756bda12013-07-03 08:17:06703void RootWindowController::InitLayoutManagers() {
[email protected]41baaed2013-11-09 04:18:26704 root_window_layout_ = new RootWindowLayoutManager(root_window());
705 root_window()->SetLayoutManager(root_window_layout_);
[email protected]756bda12013-07-03 08:17:06706
707 aura::Window* default_container =
708 GetContainer(kShellWindowId_DefaultContainer);
709 // Workspace manager has its own layout managers.
710 workspace_controller_.reset(
711 new WorkspaceController(default_container));
712
713 aura::Window* always_on_top_container =
714 GetContainer(kShellWindowId_AlwaysOnTopContainer);
715 always_on_top_container->SetLayoutManager(
716 new BaseLayoutManager(
717 always_on_top_container->GetRootWindow()));
718 always_on_top_controller_.reset(new internal::AlwaysOnTopController);
719 always_on_top_controller_->SetAlwaysOnTopContainer(always_on_top_container);
720
721 DCHECK(!shelf_.get());
722 aura::Window* shelf_container =
723 GetContainer(internal::kShellWindowId_ShelfContainer);
724 // TODO(harrym): Remove when status area is view.
725 aura::Window* status_container =
726 GetContainer(internal::kShellWindowId_StatusContainer);
727 shelf_.reset(new ShelfWidget(
728 shelf_container, status_container, workspace_controller()));
729
[email protected]cf6fea22013-08-07 14:24:01730 if (!Shell::GetInstance()->session_state_delegate()->
731 IsActiveUserSessionStarted()) {
732 // This window exists only to be a event target on login screen.
733 // It does not have to handle events, nor be visible.
734 mouse_event_target_.reset(new aura::Window(new EmptyWindowDelegate));
735 mouse_event_target_->Init(ui::LAYER_NOT_DRAWN);
736
737 aura::Window* lock_background_container =
738 GetContainer(internal::kShellWindowId_LockScreenBackgroundContainer);
739 lock_background_container->AddChild(mouse_event_target_.get());
740 mouse_event_target_->Show();
741 }
742
[email protected]756bda12013-07-03 08:17:06743 // Create Docked windows layout manager
744 aura::Window* docked_container = GetContainer(
745 internal::kShellWindowId_DockedContainer);
746 docked_layout_manager_ =
[email protected]375069e2013-10-04 13:54:31747 new internal::DockedWindowLayoutManager(docked_container,
748 workspace_controller());
[email protected]342d56a2013-12-20 23:01:02749 docked_container_handler_.reset(
750 new ToplevelWindowEventHandler(docked_container));
[email protected]756bda12013-07-03 08:17:06751 docked_container->SetLayoutManager(docked_layout_manager_);
752
753 // Create Panel layout manager
754 aura::Window* panel_container = GetContainer(
755 internal::kShellWindowId_PanelContainer);
756 panel_layout_manager_ =
757 new internal::PanelLayoutManager(panel_container);
[email protected]342d56a2013-12-20 23:01:02758 panel_container_handler_.reset(
759 new PanelWindowEventHandler(panel_container));
[email protected]756bda12013-07-03 08:17:06760 panel_container->SetLayoutManager(panel_layout_manager_);
761}
762
763void RootWindowController::InitTouchHuds() {
764 CommandLine* command_line = CommandLine::ForCurrentProcess();
765 if (command_line->HasSwitch(switches::kAshTouchHud))
[email protected]41baaed2013-11-09 04:18:26766 set_touch_hud_debug(new TouchHudDebug(root_window()));
[email protected]756bda12013-07-03 08:17:06767 if (Shell::GetInstance()->is_touch_hud_projection_enabled())
768 EnableTouchHudProjection();
769}
770
771void RootWindowController::CreateSystemBackground(
772 bool is_first_run_after_boot) {
773 SkColor color = SK_ColorBLACK;
774#if defined(OS_CHROMEOS)
775 if (is_first_run_after_boot)
776 color = kChromeOsBootColor;
777#endif
778 system_background_.reset(
[email protected]41baaed2013-11-09 04:18:26779 new SystemBackgroundController(root_window(), color));
[email protected]756bda12013-07-03 08:17:06780
781#if defined(OS_CHROMEOS)
782 // Make a copy of the system's boot splash screen so we can composite it
783 // onscreen until the desktop background is ready.
784 if (is_first_run_after_boot &&
785 (CommandLine::ForCurrentProcess()->HasSwitch(
786 switches::kAshCopyHostBackgroundAtBoot) ||
787 CommandLine::ForCurrentProcess()->HasSwitch(
788 switches::kAshAnimateFromBootSplashScreen)))
789 boot_splash_screen_.reset(new BootSplashScreen(root_window_.get()));
790#endif
791}
792
[email protected]a4cd6d32012-09-12 03:42:13793void RootWindowController::CreateContainersInRootWindow(
[email protected]41baaed2013-11-09 04:18:26794 aura::Window* root_window) {
[email protected]a4cd6d32012-09-12 03:42:13795 // These containers are just used by PowerButtonController to animate groups
796 // of containers simultaneously without messing up the current transformations
797 // on those containers. These are direct children of the root window; all of
798 // the other containers are their children.
[email protected]e6e41d2f2012-10-29 19:22:19799
800 // The desktop background container is not part of the lock animation, so it
801 // is not included in those animate groups.
[email protected]a4cd6d32012-09-12 03:42:13802 // When screen is locked desktop background is moved to lock screen background
803 // container (moved back on unlock). We want to make sure that there's an
804 // opaque layer occluding the non-lock-screen layers.
[email protected]e6e41d2f2012-10-29 19:22:19805 aura::Window* desktop_background_container = CreateContainer(
[email protected]c0ce80e2012-10-05 23:28:27806 kShellWindowId_DesktopBackgroundContainer,
[email protected]a4cd6d32012-09-12 03:42:13807 "DesktopBackgroundContainer",
808 root_window);
[email protected]b5756e22012-11-30 01:32:02809 views::corewm::SetChildWindowVisibilityChangesAnimated(
810 desktop_background_container);
[email protected]a4cd6d32012-09-12 03:42:13811
812 aura::Window* non_lock_screen_containers = CreateContainer(
[email protected]c0ce80e2012-10-05 23:28:27813 kShellWindowId_NonLockScreenContainersContainer,
[email protected]a4cd6d32012-09-12 03:42:13814 "NonLockScreenContainersContainer",
815 root_window);
816
817 aura::Window* lock_background_containers = CreateContainer(
[email protected]c0ce80e2012-10-05 23:28:27818 kShellWindowId_LockScreenBackgroundContainer,
[email protected]a4cd6d32012-09-12 03:42:13819 "LockScreenBackgroundContainer",
820 root_window);
[email protected]b5756e22012-11-30 01:32:02821 views::corewm::SetChildWindowVisibilityChangesAnimated(
822 lock_background_containers);
[email protected]a4cd6d32012-09-12 03:42:13823
824 aura::Window* lock_screen_containers = CreateContainer(
[email protected]c0ce80e2012-10-05 23:28:27825 kShellWindowId_LockScreenContainersContainer,
[email protected]a4cd6d32012-09-12 03:42:13826 "LockScreenContainersContainer",
827 root_window);
828 aura::Window* lock_screen_related_containers = CreateContainer(
[email protected]c0ce80e2012-10-05 23:28:27829 kShellWindowId_LockScreenRelatedContainersContainer,
[email protected]a4cd6d32012-09-12 03:42:13830 "LockScreenRelatedContainersContainer",
831 root_window);
832
[email protected]c0ce80e2012-10-05 23:28:27833 CreateContainer(kShellWindowId_UnparentedControlContainer,
[email protected]a4cd6d32012-09-12 03:42:13834 "UnparentedControlContainer",
835 non_lock_screen_containers);
836
837 aura::Window* default_container = CreateContainer(
[email protected]c0ce80e2012-10-05 23:28:27838 kShellWindowId_DefaultContainer,
[email protected]a4cd6d32012-09-12 03:42:13839 "DefaultContainer",
840 non_lock_screen_containers);
[email protected]b5756e22012-11-30 01:32:02841 views::corewm::SetChildWindowVisibilityChangesAnimated(default_container);
[email protected]a4cd6d32012-09-12 03:42:13842 SetUsesScreenCoordinates(default_container);
[email protected]c5be8d672014-01-07 13:33:41843 SetUsesEasyResizeTargeter(default_container);
[email protected]a4cd6d32012-09-12 03:42:13844
845 aura::Window* always_on_top_container = CreateContainer(
[email protected]c0ce80e2012-10-05 23:28:27846 kShellWindowId_AlwaysOnTopContainer,
[email protected]a4cd6d32012-09-12 03:42:13847 "AlwaysOnTopContainer",
848 non_lock_screen_containers);
[email protected]342d56a2013-12-20 23:01:02849 always_on_top_container_handler_.reset(
850 new ToplevelWindowEventHandler(always_on_top_container));
[email protected]b5756e22012-11-30 01:32:02851 views::corewm::SetChildWindowVisibilityChangesAnimated(
852 always_on_top_container);
[email protected]a4cd6d32012-09-12 03:42:13853 SetUsesScreenCoordinates(always_on_top_container);
854
[email protected]beb4e5c2013-06-18 15:37:07855 aura::Window* docked_container = CreateContainer(
856 kShellWindowId_DockedContainer,
857 "DockedContainer",
858 non_lock_screen_containers);
[email protected]5eab6e92013-09-19 19:09:27859 views::corewm::SetChildWindowVisibilityChangesAnimated(docked_container);
[email protected]beb4e5c2013-06-18 15:37:07860 SetUsesScreenCoordinates(docked_container);
861
[email protected]3f13cf12013-07-12 05:13:59862 aura::Window* shelf_container =
[email protected]478c6c32013-03-09 02:50:58863 CreateContainer(kShellWindowId_ShelfContainer,
[email protected]3f13cf12013-07-12 05:13:59864 "ShelfContainer",
[email protected]a4cd6d32012-09-12 03:42:13865 non_lock_screen_containers);
[email protected]3f13cf12013-07-12 05:13:59866 SetUsesScreenCoordinates(shelf_container);
867 DescendantShouldStayInSameRootWindow(shelf_container);
[email protected]a4cd6d32012-09-12 03:42:13868
[email protected]f2026eb2013-10-22 14:28:56869 aura::Window* panel_container = CreateContainer(
870 kShellWindowId_PanelContainer,
871 "PanelContainer",
872 non_lock_screen_containers);
873 SetUsesScreenCoordinates(panel_container);
[email protected]c5be8d672014-01-07 13:33:41874 SetUsesEasyResizeTargeter(panel_container);
[email protected]f2026eb2013-10-22 14:28:56875
876 aura::Window* shelf_bubble_container =
877 CreateContainer(kShellWindowId_ShelfBubbleContainer,
878 "ShelfBubbleContainer",
879 non_lock_screen_containers);
880 SetUsesScreenCoordinates(shelf_bubble_container);
881 DescendantShouldStayInSameRootWindow(shelf_bubble_container);
882
[email protected]dc851a4e52012-10-03 00:05:55883 aura::Window* app_list_container =
[email protected]c0ce80e2012-10-05 23:28:27884 CreateContainer(kShellWindowId_AppListContainer,
[email protected]dc851a4e52012-10-03 00:05:55885 "AppListContainer",
886 non_lock_screen_containers);
887 SetUsesScreenCoordinates(app_list_container);
[email protected]a4cd6d32012-09-12 03:42:13888
889 aura::Window* modal_container = CreateContainer(
[email protected]c0ce80e2012-10-05 23:28:27890 kShellWindowId_SystemModalContainer,
[email protected]a4cd6d32012-09-12 03:42:13891 "SystemModalContainer",
892 non_lock_screen_containers);
[email protected]342d56a2013-12-20 23:01:02893 modal_container_handler_.reset(
894 new ToplevelWindowEventHandler(modal_container));
[email protected]a4cd6d32012-09-12 03:42:13895 modal_container->SetLayoutManager(
[email protected]c0ce80e2012-10-05 23:28:27896 new SystemModalContainerLayoutManager(modal_container));
[email protected]b5756e22012-11-30 01:32:02897 views::corewm::SetChildWindowVisibilityChangesAnimated(modal_container);
[email protected]a4cd6d32012-09-12 03:42:13898 SetUsesScreenCoordinates(modal_container);
[email protected]c5be8d672014-01-07 13:33:41899 SetUsesEasyResizeTargeter(modal_container);
[email protected]a4cd6d32012-09-12 03:42:13900
901 aura::Window* input_method_container = CreateContainer(
[email protected]c0ce80e2012-10-05 23:28:27902 kShellWindowId_InputMethodContainer,
[email protected]a4cd6d32012-09-12 03:42:13903 "InputMethodContainer",
904 non_lock_screen_containers);
[email protected]649eb7462013-10-24 07:52:01905 views::corewm::SetChildWindowVisibilityChangesAnimated(
906 input_method_container);
[email protected]a4cd6d32012-09-12 03:42:13907 SetUsesScreenCoordinates(input_method_container);
908
909 // TODO(beng): Figure out if we can make this use
910 // SystemModalContainerEventFilter instead of stops_event_propagation.
911 aura::Window* lock_container = CreateContainer(
[email protected]c0ce80e2012-10-05 23:28:27912 kShellWindowId_LockScreenContainer,
[email protected]a4cd6d32012-09-12 03:42:13913 "LockScreenContainer",
914 lock_screen_containers);
915 lock_container->SetLayoutManager(
[email protected]c0ce80e2012-10-05 23:28:27916 new BaseLayoutManager(root_window));
[email protected]a4cd6d32012-09-12 03:42:13917 SetUsesScreenCoordinates(lock_container);
918 // TODO(beng): stopsevents
919
920 aura::Window* lock_modal_container = CreateContainer(
[email protected]c0ce80e2012-10-05 23:28:27921 kShellWindowId_LockSystemModalContainer,
[email protected]a4cd6d32012-09-12 03:42:13922 "LockSystemModalContainer",
923 lock_screen_containers);
[email protected]342d56a2013-12-20 23:01:02924 lock_modal_container_handler_.reset(
925 new ToplevelWindowEventHandler(lock_modal_container));
[email protected]a4cd6d32012-09-12 03:42:13926 lock_modal_container->SetLayoutManager(
[email protected]c0ce80e2012-10-05 23:28:27927 new SystemModalContainerLayoutManager(lock_modal_container));
[email protected]b5756e22012-11-30 01:32:02928 views::corewm::SetChildWindowVisibilityChangesAnimated(lock_modal_container);
[email protected]a4cd6d32012-09-12 03:42:13929 SetUsesScreenCoordinates(lock_modal_container);
[email protected]c5be8d672014-01-07 13:33:41930 SetUsesEasyResizeTargeter(lock_modal_container);
[email protected]a4cd6d32012-09-12 03:42:13931
932 aura::Window* status_container =
[email protected]c0ce80e2012-10-05 23:28:27933 CreateContainer(kShellWindowId_StatusContainer,
[email protected]a4cd6d32012-09-12 03:42:13934 "StatusContainer",
935 lock_screen_related_containers);
936 SetUsesScreenCoordinates(status_container);
[email protected]e887c6c2013-07-08 19:35:53937 DescendantShouldStayInSameRootWindow(status_container);
[email protected]a4cd6d32012-09-12 03:42:13938
939 aura::Window* settings_bubble_container = CreateContainer(
[email protected]c0ce80e2012-10-05 23:28:27940 kShellWindowId_SettingBubbleContainer,
[email protected]a4cd6d32012-09-12 03:42:13941 "SettingBubbleContainer",
942 lock_screen_related_containers);
[email protected]b5756e22012-11-30 01:32:02943 views::corewm::SetChildWindowVisibilityChangesAnimated(
944 settings_bubble_container);
[email protected]a4cd6d32012-09-12 03:42:13945 SetUsesScreenCoordinates(settings_bubble_container);
[email protected]e887c6c2013-07-08 19:35:53946 DescendantShouldStayInSameRootWindow(settings_bubble_container);
[email protected]a4cd6d32012-09-12 03:42:13947
948 aura::Window* menu_container = CreateContainer(
[email protected]c0ce80e2012-10-05 23:28:27949 kShellWindowId_MenuContainer,
[email protected]a4cd6d32012-09-12 03:42:13950 "MenuContainer",
951 lock_screen_related_containers);
[email protected]b5756e22012-11-30 01:32:02952 views::corewm::SetChildWindowVisibilityChangesAnimated(menu_container);
[email protected]a4cd6d32012-09-12 03:42:13953 SetUsesScreenCoordinates(menu_container);
954
955 aura::Window* drag_drop_container = CreateContainer(
[email protected]c0ce80e2012-10-05 23:28:27956 kShellWindowId_DragImageAndTooltipContainer,
[email protected]a4cd6d32012-09-12 03:42:13957 "DragImageAndTooltipContainer",
958 lock_screen_related_containers);
[email protected]b5756e22012-11-30 01:32:02959 views::corewm::SetChildWindowVisibilityChangesAnimated(drag_drop_container);
[email protected]a4cd6d32012-09-12 03:42:13960 SetUsesScreenCoordinates(drag_drop_container);
961
962 aura::Window* overlay_container = CreateContainer(
[email protected]c0ce80e2012-10-05 23:28:27963 kShellWindowId_OverlayContainer,
[email protected]a4cd6d32012-09-12 03:42:13964 "OverlayContainer",
965 lock_screen_related_containers);
966 SetUsesScreenCoordinates(overlay_container);
[email protected]a07615f2012-10-24 08:23:08967
968 CreateContainer(kShellWindowId_PowerButtonAnimationContainer,
969 "PowerButtonAnimationContainer", root_window) ;
[email protected]a4cd6d32012-09-12 03:42:13970}
971
[email protected]d141b922013-07-09 08:13:17972void RootWindowController::EnableTouchHudProjection() {
973 if (touch_hud_projection_)
974 return;
[email protected]41baaed2013-11-09 04:18:26975 set_touch_hud_projection(new TouchHudProjection(root_window()));
[email protected]d141b922013-07-09 08:13:17976}
977
978void RootWindowController::DisableTouchHudProjection() {
979 if (!touch_hud_projection_)
980 return;
981 touch_hud_projection_->Remove();
982}
983
984void RootWindowController::OnLoginStateChanged(user::LoginStatus status) {
985 shelf_->shelf_layout_manager()->UpdateVisibilityState();
986}
987
988void RootWindowController::OnTouchHudProjectionToggled(bool enabled) {
989 if (enabled)
990 EnableTouchHudProjection();
991 else
992 DisableTouchHudProjection();
993}
994
[email protected]6b2d4a0b2013-09-06 06:29:54995RootWindowController* GetRootWindowController(
[email protected]bf9cdb362013-10-25 19:22:45996 const aura::Window* root_window) {
[email protected]6b2d4a0b2013-09-06 06:29:54997 return root_window ? GetRootWindowSettings(root_window)->controller : NULL;
998}
999
[email protected]d90b8392012-06-13 09:34:561000} // namespace internal
1001} // namespace ash