blob: cd246364601336c1fd821b6108aee89c0a5f5876 [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]1af71f72014-01-29 20:00:5546#include "ash/wm/workspace/workspace_layout_manager.h"
[email protected]d90b8392012-06-13 09:34:5647#include "ash/wm/workspace_controller.h"
[email protected]e6e41d2f2012-10-29 19:22:1948#include "base/command_line.h"
[email protected]1e84c632013-06-27 23:12:2149#include "base/time/time.h"
[email protected]f1853122012-06-27 16:21:2650#include "ui/aura/client/aura_constants.h"
[email protected]8b3e3d82013-08-20 14:36:3051#include "ui/aura/client/drag_drop_client.h"
[email protected]d90b8392012-06-13 09:34:5652#include "ui/aura/client/tooltip_client.h"
53#include "ui/aura/root_window.h"
[email protected]f1853122012-06-27 16:21:2654#include "ui/aura/window.h"
[email protected]cf6fea22013-08-07 14:24:0155#include "ui/aura/window_delegate.h"
[email protected]f1853122012-06-27 16:21:2656#include "ui/aura/window_observer.h"
[email protected]8b3e3d82013-08-20 14:36:3057#include "ui/aura/window_tracker.h"
[email protected]cf6fea22013-08-07 14:24:0158#include "ui/base/hit_test.h"
[email protected]431552c2012-10-23 00:38:3359#include "ui/base/models/menu_model.h"
[email protected]f8e6aad2013-08-30 21:49:1160#include "ui/gfx/display.h"
[email protected]8d625fb2012-07-18 16:40:0661#include "ui/gfx/screen.h"
[email protected]86459e2c2013-04-10 13:39:2462#include "ui/keyboard/keyboard_controller.h"
63#include "ui/keyboard/keyboard_util.h"
[email protected]431552c2012-10-23 00:38:3364#include "ui/views/controls/menu/menu_runner.h"
[email protected]23a2dc82013-08-22 15:04:2265#include "ui/views/corewm/capture_controller.h"
[email protected]b5756e22012-11-30 01:32:0266#include "ui/views/corewm/visibility_controller.h"
[email protected]751b13df2014-01-07 19:52:5267#include "ui/views/corewm/window_util.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);
[email protected]52b02a72014-01-08 21:41:5095 container->Init(aura::WINDOW_LAYER_NOT_DRAWN);
[email protected]d90b8392012-06-13 09:34:5696 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
[email protected]8663b7a62014-01-18 01:24:21124 bool update_bounds = (state->IsNormalShowState() || state->IsMinimized()) &&
125 new_parent->id() != internal::kShellWindowId_DockedContainer;
[email protected]2816c2462013-12-17 02:22:25126 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
[email protected]8663b7a62014-01-18 01:24:21139 // Docked windows have bounds handled by the layout manager in AddChild().
[email protected]2816c2462013-12-17 02:22:25140 if (update_bounds)
141 window->SetBounds(local_bounds);
142
[email protected]a41b4e12013-09-20 04:36:34143 if (has_restore_bounds)
144 state->SetRestoreBoundsInParent(restore_bounds);
[email protected]95058572012-08-20 14:57:29145}
146
147// Reparents the appropriate set of windows from |src| to |dst|.
[email protected]bf9cdb362013-10-25 19:22:45148void ReparentAllWindows(aura::Window* src, aura::Window* dst) {
[email protected]95058572012-08-20 14:57:29149 // Set of windows to move.
[email protected]f1853122012-06-27 16:21:26150 const int kContainerIdsToMove[] = {
151 internal::kShellWindowId_DefaultContainer,
[email protected]beb4e5c2013-06-18 15:37:07152 internal::kShellWindowId_DockedContainer,
[email protected]95db9c12013-01-31 11:47:44153 internal::kShellWindowId_PanelContainer,
[email protected]f1853122012-06-27 16:21:26154 internal::kShellWindowId_AlwaysOnTopContainer,
155 internal::kShellWindowId_SystemModalContainer,
156 internal::kShellWindowId_LockSystemModalContainer,
[email protected]6274d312012-10-04 22:06:41157 internal::kShellWindowId_InputMethodContainer,
[email protected]a9754872013-01-25 07:44:00158 internal::kShellWindowId_UnparentedControlContainer,
[email protected]f1853122012-06-27 16:21:26159 };
[email protected]f1853122012-06-27 16:21:26160 for (size_t i = 0; i < arraysize(kContainerIdsToMove); i++) {
161 int id = kContainerIdsToMove[i];
162 aura::Window* src_container = Shell::GetContainer(src, id);
163 aura::Window* dst_container = Shell::GetContainer(dst, id);
[email protected]5b6021902013-02-26 05:33:29164 while (!src_container->children().empty()) {
165 // Restart iteration from the source container windows each time as they
166 // may change as a result of moving other windows.
167 aura::Window::Windows::const_iterator iter =
168 src_container->children().begin();
169 while (iter != src_container->children().end() &&
170 internal::SystemModalContainerLayoutManager::IsModalBackground(
171 *iter)) {
172 ++iter;
173 }
174 // If the entire window list is modal background windows then stop.
175 if (iter == src_container->children().end())
176 break;
177 ReparentWindow(*iter, dst_container);
[email protected]f1853122012-06-27 16:21:26178 }
179 }
180}
181
[email protected]8d625fb2012-07-18 16:40:06182// Mark the container window so that a widget added to this container will
183// use the virtual screeen coordinates instead of parent.
184void SetUsesScreenCoordinates(aura::Window* container) {
185 container->SetProperty(internal::kUsesScreenCoordinatesKey, true);
186}
187
[email protected]e887c6c2013-07-08 19:35:53188// Mark the container window so that a widget added to this container will
189// say in the same root window regardless of the bounds specified.
190void DescendantShouldStayInSameRootWindow(aura::Window* container) {
191 container->SetProperty(internal::kStayInSameRootWindowKey, true);
192}
193
[email protected]c5be8d672014-01-07 13:33:41194void SetUsesEasyResizeTargeter(aura::Window* container) {
195 gfx::Insets mouse_extend(-kResizeOutsideBoundsSize,
196 -kResizeOutsideBoundsSize,
197 -kResizeOutsideBoundsSize,
198 -kResizeOutsideBoundsSize);
199 gfx::Insets touch_extend = mouse_extend.Scale(
200 kResizeOutsideBoundsScaleForTouch);
[email protected]95f642cb2014-01-31 01:35:41201 container->SetEventTargeter(scoped_ptr<ui::EventTargeter>(
[email protected]c5be8d672014-01-07 13:33:41202 new ::wm::EasyResizeWindowTargeter(container, mouse_extend,
203 touch_extend)));
204}
205
[email protected]cf6fea22013-08-07 14:24:01206// A window delegate which does nothing. Used to create a window that
207// is a event target, but do nothing.
208class EmptyWindowDelegate : public aura::WindowDelegate {
209 public:
210 EmptyWindowDelegate() {}
211 virtual ~EmptyWindowDelegate() {}
212
213 // aura::WindowDelegate overrides:
214 virtual gfx::Size GetMinimumSize() const OVERRIDE {
215 return gfx::Size();
216 }
217 virtual gfx::Size GetMaximumSize() const OVERRIDE {
218 return gfx::Size();
219 }
220 virtual void OnBoundsChanged(const gfx::Rect& old_bounds,
221 const gfx::Rect& new_bounds) OVERRIDE {
222 }
223 virtual gfx::NativeCursor GetCursor(const gfx::Point& point) OVERRIDE {
224 return gfx::kNullCursor;
225 }
226 virtual int GetNonClientComponent(
227 const gfx::Point& point) const OVERRIDE {
228 return HTNOWHERE;
229 }
230 virtual bool ShouldDescendIntoChildForEventHandling(
231 aura::Window* child,
232 const gfx::Point& location) OVERRIDE {
233 return false;
234 }
235 virtual bool CanFocus() OVERRIDE {
236 return false;
237 }
238 virtual void OnCaptureLost() OVERRIDE {
239 }
240 virtual void OnPaint(gfx::Canvas* canvas) OVERRIDE {
241 }
242 virtual void OnDeviceScaleFactorChanged(
243 float device_scale_factor) OVERRIDE {
244 }
245 virtual void OnWindowDestroying() OVERRIDE {}
[email protected]febe1fd62013-08-07 16:07:24246 virtual void OnWindowDestroyed() OVERRIDE {
247 delete this;
248 }
[email protected]cf6fea22013-08-07 14:24:01249 virtual void OnWindowTargetVisibilityChanged(bool visible) OVERRIDE {
250 }
251 virtual bool HasHitTestMask() const OVERRIDE {
252 return false;
253 }
254 virtual void GetHitTestMask(gfx::Path* mask) const OVERRIDE {}
[email protected]1ddbe932013-09-12 06:23:16255 virtual void DidRecreateLayer(ui::Layer* old_layer,
256 ui::Layer* new_layer) OVERRIDE {}
[email protected]cf6fea22013-08-07 14:24:01257
258 private:
259 DISALLOW_COPY_AND_ASSIGN(EmptyWindowDelegate);
260};
261
[email protected]d90b8392012-06-13 09:34:56262} // namespace
263
264namespace internal {
265
[email protected]a273d33a2013-10-17 12:41:21266void RootWindowController::CreateForPrimaryDisplay(
[email protected]bf9cdb362013-10-25 19:22:45267 aura::RootWindow* root) {
[email protected]a273d33a2013-10-17 12:41:21268 RootWindowController* controller = new RootWindowController(root);
[email protected]608de6c2013-10-29 00:14:28269 controller->Init(RootWindowController::PRIMARY,
[email protected]a273d33a2013-10-17 12:41:21270 Shell::GetInstance()->delegate()->IsFirstRunAfterBoot());
[email protected]d90b8392012-06-13 09:34:56271}
272
[email protected]a273d33a2013-10-17 12:41:21273void RootWindowController::CreateForSecondaryDisplay(aura::RootWindow * root) {
274 RootWindowController* controller = new RootWindowController(root);
[email protected]608de6c2013-10-29 00:14:28275 controller->Init(RootWindowController::SECONDARY, false /* first run */);
276}
277
278void RootWindowController::CreateForVirtualKeyboardDisplay(
279 aura::RootWindow * root) {
280 RootWindowController* controller = new RootWindowController(root);
281 controller->Init(RootWindowController::VIRTUAL_KEYBOARD,
282 false /* first run */);
[email protected]6675e1c2012-09-11 09:15:45283}
284
[email protected]88d71122012-10-18 07:11:01285// static
[email protected]864b58552013-12-19 04:19:38286RootWindowController* RootWindowController::ForShelf(aura::Window* window) {
[email protected]8c0ec432013-05-10 04:33:39287 return GetRootWindowController(window->GetRootWindow());
[email protected]88d71122012-10-18 07:11:01288}
289
[email protected]a0afeb12012-12-10 22:57:09290// static
[email protected]ccff3d72013-02-06 04:26:28291RootWindowController* RootWindowController::ForWindow(
292 const aura::Window* window) {
[email protected]a0afeb12012-12-10 22:57:09293 return GetRootWindowController(window->GetRootWindow());
294}
295
296// static
[email protected]d17642d2013-09-12 23:44:38297RootWindowController* RootWindowController::ForTargetRootWindow() {
298 return internal::GetRootWindowController(Shell::GetTargetRootWindow());
[email protected]a0afeb12012-12-10 22:57:09299}
300
[email protected]a5c78802013-12-12 22:07:01301// static
302aura::Window* RootWindowController::GetContainerForWindow(
303 aura::Window* window) {
304 aura::Window* container = window->parent();
[email protected]5b251f12013-12-19 01:50:05305 while (container && container->type() != ui::wm::WINDOW_TYPE_UNKNOWN)
[email protected]a5c78802013-12-12 22:07:01306 container = container->parent();
307 return container;
308}
309
[email protected]a273d33a2013-10-17 12:41:21310RootWindowController::~RootWindowController() {
311 Shutdown();
312 root_window_.reset();
313 // The CaptureClient needs to be around for as long as the RootWindow is
314 // valid.
315 capture_client_.reset();
316}
317
[email protected]0bf61732013-07-02 04:35:10318void RootWindowController::SetWallpaperController(
319 DesktopBackgroundWidgetController* controller) {
320 wallpaper_controller_.reset(controller);
321}
322
323void RootWindowController::SetAnimatingWallpaperController(
324 AnimatingDesktopController* controller) {
325 if (animating_wallpaper_controller_.get())
326 animating_wallpaper_controller_->StopAnimating();
327 animating_wallpaper_controller_.reset(controller);
328}
329
[email protected]6675e1c2012-09-11 09:15:45330void RootWindowController::Shutdown() {
[email protected]d141b922013-07-09 08:13:17331 Shell::GetInstance()->RemoveShellObserver(this);
332
[email protected]0bf61732013-07-02 04:35:10333 if (animating_wallpaper_controller_.get())
334 animating_wallpaper_controller_->StopAnimating();
335 wallpaper_controller_.reset();
336 animating_wallpaper_controller_.reset();
337
[email protected]d17642d2013-09-12 23:44:38338 // Change the target root window before closing child windows. If any child
[email protected]c98a4922013-09-05 20:01:42339 // being removed triggers a relayout of the shelf it will try to build a
[email protected]d17642d2013-09-12 23:44:38340 // window list adding windows from the target root window's containers which
[email protected]c98a4922013-09-05 20:01:42341 // may have already gone away.
[email protected]41baaed2013-11-09 04:18:26342 if (Shell::GetTargetRootWindow() == root_window()) {
[email protected]d17642d2013-09-12 23:44:38343 Shell::GetInstance()->set_target_root_window(
[email protected]41baaed2013-11-09 04:18:26344 Shell::GetPrimaryRootWindow() == root_window() ?
[email protected]f634dd32012-07-23 22:49:07345 NULL : Shell::GetPrimaryRootWindow());
346 }
[email protected]c98a4922013-09-05 20:01:42347
348 CloseChildWindows();
[email protected]41baaed2013-11-09 04:18:26349 GetRootWindowSettings(root_window())->controller = NULL;
[email protected]d90b8392012-06-13 09:34:56350 screen_dimmer_.reset();
351 workspace_controller_.reset();
[email protected]6675e1c2012-09-11 09:15:45352 // Forget with the display ID so that display lookup
353 // ends up with invalid display.
[email protected]41baaed2013-11-09 04:18:26354 internal::GetRootWindowSettings(root_window())->display_id =
[email protected]f8e6aad2013-08-30 21:49:11355 gfx::Display::kInvalidDisplayID;
[email protected]6675e1c2012-09-11 09:15:45356 // And this root window should no longer process events.
357 root_window_->PrepareForShutdown();
[email protected]e74aaf0a2012-10-12 18:42:28358
[email protected]956a6a42012-10-29 23:58:10359 system_background_.reset();
[email protected]d90b8392012-06-13 09:34:56360}
361
[email protected]c0ce80e2012-10-05 23:28:27362SystemModalContainerLayoutManager*
[email protected]8674b312012-10-12 19:02:44363RootWindowController::GetSystemModalLayoutManager(aura::Window* window) {
[email protected]a5c78802013-12-12 22:07:01364 aura::Window* modal_container = NULL;
[email protected]8674b312012-10-12 19:02:44365 if (window) {
[email protected]a5c78802013-12-12 22:07:01366 aura::Window* window_container = GetContainerForWindow(window);
367 if (window_container &&
368 window_container->id() >= kShellWindowId_LockScreenContainer) {
369 modal_container = GetContainer(kShellWindowId_LockSystemModalContainer);
[email protected]3b162e12012-11-09 11:52:35370 } else {
[email protected]a5c78802013-12-12 22:07:01371 modal_container = GetContainer(kShellWindowId_SystemModalContainer);
[email protected]3b162e12012-11-09 11:52:35372 }
[email protected]8674b312012-10-12 19:02:44373 } else {
[email protected]a44afbbd2013-07-24 21:49:35374 int modal_window_id = Shell::GetInstance()->session_state_delegate()
375 ->IsUserSessionBlocked() ? kShellWindowId_LockSystemModalContainer :
376 kShellWindowId_SystemModalContainer;
[email protected]a5c78802013-12-12 22:07:01377 modal_container = GetContainer(modal_window_id);
[email protected]8674b312012-10-12 19:02:44378 }
[email protected]a5c78802013-12-12 22:07:01379 return modal_container ? static_cast<SystemModalContainerLayoutManager*>(
380 modal_container->layout_manager()) : NULL;
[email protected]c0ce80e2012-10-05 23:28:27381}
382
[email protected]d90b8392012-06-13 09:34:56383aura::Window* RootWindowController::GetContainer(int container_id) {
[email protected]41baaed2013-11-09 04:18:26384 return root_window()->GetChildById(container_id);
[email protected]d90b8392012-06-13 09:34:56385}
386
[email protected]d8a24952013-08-05 20:05:05387const aura::Window* RootWindowController::GetContainer(int container_id) const {
[email protected]41baaed2013-11-09 04:18:26388 return root_window_->window()->GetChildById(container_id);
[email protected]d8a24952013-08-05 20:05:05389}
390
[email protected]864b58552013-12-19 04:19:38391void RootWindowController::ShowShelf() {
392 if (!shelf_->shelf())
[email protected]e74aaf0a2012-10-12 18:42:28393 return;
[email protected]864b58552013-12-19 04:19:38394 shelf_->shelf()->SetVisible(true);
[email protected]478c6c32013-03-09 02:50:58395 shelf_->status_area_widget()->Show();
[email protected]e74aaf0a2012-10-12 18:42:28396}
397
[email protected]864b58552013-12-19 04:19:38398void RootWindowController::OnShelfCreated() {
[email protected]756bda12013-07-03 08:17:06399 if (panel_layout_manager_)
[email protected]864b58552013-12-19 04:19:38400 panel_layout_manager_->SetShelf(shelf_->shelf());
[email protected]7115bd32013-07-19 08:25:39401 if (docked_layout_manager_) {
[email protected]864b58552013-12-19 04:19:38402 docked_layout_manager_->SetShelf(shelf_->shelf());
[email protected]7115bd32013-07-19 08:25:39403 if (shelf_->shelf_layout_manager())
404 docked_layout_manager_->AddObserver(shelf_->shelf_layout_manager());
405 }
[email protected]756bda12013-07-03 08:17:06406}
407
[email protected]16059276d2012-10-22 18:59:50408void RootWindowController::UpdateAfterLoginStatusChange(
409 user::LoginStatus status) {
[email protected]cf6fea22013-08-07 14:24:01410 if (status != user::LOGGED_IN_NONE)
411 mouse_event_target_.reset();
[email protected]80549c152013-07-02 01:42:47412 if (shelf_->status_area_widget())
[email protected]478c6c32013-03-09 02:50:58413 shelf_->status_area_widget()->UpdateAfterLoginStatusChange(status);
[email protected]16059276d2012-10-22 18:59:50414}
415
[email protected]bca9a7e2012-11-10 06:25:49416void RootWindowController::HandleInitialDesktopBackgroundAnimationStarted() {
[email protected]252eb232013-08-14 22:09:27417#if defined(OS_CHROMEOS)
[email protected]bca9a7e2012-11-10 06:25:49418 if (CommandLine::ForCurrentProcess()->HasSwitch(
419 switches::kAshAnimateFromBootSplashScreen) &&
420 boot_splash_screen_.get()) {
421 // Make the splash screen fade out so it doesn't obscure the desktop
422 // wallpaper's brightness/grayscale animation.
423 boot_splash_screen_->StartHideAnimation(
424 base::TimeDelta::FromMilliseconds(kBootSplashScreenHideDurationMs));
425 }
[email protected]252eb232013-08-14 22:09:27426#endif
[email protected]bca9a7e2012-11-10 06:25:49427}
428
[email protected]0bf61732013-07-02 04:35:10429void RootWindowController::OnWallpaperAnimationFinished(views::Widget* widget) {
430 // Make sure the wallpaper is visible.
[email protected]bca9a7e2012-11-10 06:25:49431 system_background_->SetColor(SK_ColorBLACK);
[email protected]252eb232013-08-14 22:09:27432#if defined(OS_CHROMEOS)
[email protected]bca9a7e2012-11-10 06:25:49433 boot_splash_screen_.reset();
[email protected]252eb232013-08-14 22:09:27434#endif
[email protected]0bf61732013-07-02 04:35:10435
436 Shell::GetInstance()->user_wallpaper_delegate()->
437 OnWallpaperAnimationFinished();
438 // Only removes old component when wallpaper animation finished. If we
439 // remove the old one before the new wallpaper is done fading in there will
440 // be a white flash during the animation.
441 if (animating_wallpaper_controller()) {
442 DesktopBackgroundWidgetController* controller =
443 animating_wallpaper_controller()->GetController(true);
444 // |desktop_widget_| should be the same animating widget we try to move
445 // to |kDesktopController|. Otherwise, we may close |desktop_widget_|
446 // before move it to |kDesktopController|.
447 DCHECK_EQ(controller->widget(), widget);
448 // Release the old controller and close its background widget.
449 SetWallpaperController(controller);
450 }
[email protected]697f04c2012-10-03 01:15:10451}
452
[email protected]d90b8392012-06-13 09:34:56453void RootWindowController::CloseChildWindows() {
[email protected]cf6fea22013-08-07 14:24:01454 mouse_event_target_.reset();
455
[email protected]b6ba05d902013-10-04 21:38:45456 // Deactivate keyboard container before closing child windows and shutting
457 // down associated layout managers.
458 DeactivateKeyboard(Shell::GetInstance()->keyboard_controller());
459
[email protected]79a87b7e2013-01-25 05:08:22460 // panel_layout_manager_ needs to be shut down before windows are destroyed.
461 if (panel_layout_manager_) {
462 panel_layout_manager_->Shutdown();
463 panel_layout_manager_ = NULL;
464 }
[email protected]7115bd32013-07-19 08:25:39465 // docked_layout_manager_ needs to be shut down before windows are destroyed.
466 if (docked_layout_manager_) {
[email protected]bb42c932013-10-31 06:52:06467 if (shelf_ && shelf_->shelf_layout_manager())
[email protected]7115bd32013-07-19 08:25:39468 docked_layout_manager_->RemoveObserver(shelf_->shelf_layout_manager());
469 docked_layout_manager_->Shutdown();
470 docked_layout_manager_ = NULL;
471 }
[email protected]79a87b7e2013-01-25 05:08:22472
[email protected]41baaed2013-11-09 04:18:26473 aura::client::SetDragDropClient(root_window(), NULL);
[email protected]8b3e3d82013-08-20 14:36:30474
[email protected]478c6c32013-03-09 02:50:58475 // TODO(harrym): Remove when Status Area Widget is a child view.
[email protected]bb42c932013-10-31 06:52:06476 if (shelf_) {
477 shelf_->ShutdownStatusAreaWidget();
[email protected]478c6c32013-03-09 02:50:58478
[email protected]bb42c932013-10-31 06:52:06479 if (shelf_->shelf_layout_manager())
480 shelf_->shelf_layout_manager()->PrepareForShutdown();
481 }
[email protected]e74aaf0a2012-10-12 18:42:28482
[email protected]d90b8392012-06-13 09:34:56483 // Close background widget first as it depends on tooltip.
[email protected]0bf61732013-07-02 04:35:10484 wallpaper_controller_.reset();
485 animating_wallpaper_controller_.reset();
[email protected]b4ddc7a2012-08-07 04:17:32486
[email protected]d90b8392012-06-13 09:34:56487 workspace_controller_.reset();
[email protected]41baaed2013-11-09 04:18:26488 aura::client::SetTooltipClient(root_window(), NULL);
[email protected]d90b8392012-06-13 09:34:56489
[email protected]0fbfa972013-10-02 19:23:33490 // Explicitly destroy top level windows. We do this as during part of
491 // destruction such windows may query the RootWindow for state.
[email protected]8b3e3d82013-08-20 14:36:30492 std::queue<aura::Window*> non_toplevel_windows;
[email protected]41baaed2013-11-09 04:18:26493 non_toplevel_windows.push(root_window());
[email protected]8b3e3d82013-08-20 14:36:30494 while (!non_toplevel_windows.empty()) {
495 aura::Window* non_toplevel_window = non_toplevel_windows.front();
496 non_toplevel_windows.pop();
497 aura::WindowTracker toplevel_windows;
498 for (size_t i = 0; i < non_toplevel_window->children().size(); ++i) {
499 aura::Window* child = non_toplevel_window->children()[i];
[email protected]0fbfa972013-10-02 19:23:33500 if (!child->owned_by_parent())
501 continue;
[email protected]8b3e3d82013-08-20 14:36:30502 if (child->delegate())
503 toplevel_windows.Add(child);
504 else
505 non_toplevel_windows.push(child);
506 }
507 while (!toplevel_windows.windows().empty())
508 delete *toplevel_windows.windows().begin();
[email protected]d90b8392012-06-13 09:34:56509 }
[email protected]8b3e3d82013-08-20 14:36:30510 // And then remove the containers.
[email protected]41baaed2013-11-09 04:18:26511 while (!root_window()->children().empty()) {
512 aura::Window* window = root_window()->children()[0];
[email protected]0fbfa972013-10-02 19:23:33513 if (window->owned_by_parent()) {
514 delete window;
515 } else {
[email protected]41baaed2013-11-09 04:18:26516 root_window()->RemoveChild(window);
[email protected]0fbfa972013-10-02 19:23:33517 }
518 }
[email protected]478c6c32013-03-09 02:50:58519
[email protected]bb42c932013-10-31 06:52:06520 shelf_.reset();
[email protected]d90b8392012-06-13 09:34:56521}
522
[email protected]bf9cdb362013-10-25 19:22:45523void RootWindowController::MoveWindowsTo(aura::Window* dst) {
[email protected]8039e06c2013-01-17 23:34:50524 // Forget the shelf early so that shelf don't update itself using wrong
525 // display info.
526 workspace_controller_->SetShelf(NULL);
[email protected]41baaed2013-11-09 04:18:26527 ReparentAllWindows(root_window(), dst);
[email protected]f1853122012-06-27 16:21:26528}
529
[email protected]478c6c32013-03-09 02:50:58530ShelfLayoutManager* RootWindowController::GetShelfLayoutManager() {
[email protected]80549c152013-07-02 01:42:47531 return shelf_->shelf_layout_manager();
[email protected]478c6c32013-03-09 02:50:58532}
533
[email protected]a0afeb12012-12-10 22:57:09534SystemTray* RootWindowController::GetSystemTray() {
535 // We assume in throughout the code that this will not return NULL. If code
536 // triggers this for valid reasons, it should test status_area_widget first.
[email protected]80549c152013-07-02 01:42:47537 CHECK(shelf_->status_area_widget());
[email protected]478c6c32013-03-09 02:50:58538 return shelf_->status_area_widget()->system_tray();
[email protected]a0afeb12012-12-10 22:57:09539}
540
[email protected]940fb1c2013-06-18 16:54:28541void RootWindowController::ShowContextMenu(const gfx::Point& location_in_screen,
542 ui::MenuSourceType source_type) {
[email protected]431552c2012-10-23 00:38:33543 DCHECK(Shell::GetInstance()->delegate());
544 scoped_ptr<ui::MenuModel> menu_model(
[email protected]e0cfc7f2014-01-09 20:25:42545 Shell::GetInstance()->delegate()->CreateContextMenu(root_window(),
546 NULL,
547 NULL));
[email protected]7f7f65c2013-04-17 16:47:13548 if (!menu_model)
[email protected]8e837ec2013-01-31 01:48:33549 return;
[email protected]431552c2012-10-23 00:38:33550
[email protected]6175fc42013-04-05 05:58:58551 // Background controller may not be set yet if user clicked on status are
552 // before initial animation completion. See crbug.com/222218
[email protected]0bf61732013-07-02 04:35:10553 if (!wallpaper_controller_.get())
[email protected]431552c2012-10-23 00:38:33554 return;
555
[email protected]6175fc42013-04-05 05:58:58556 views::MenuRunner menu_runner(menu_model.get());
[email protected]0bf61732013-07-02 04:35:10557 if (menu_runner.RunMenuAt(wallpaper_controller_->widget(),
[email protected]6175fc42013-04-05 05:58:58558 NULL, gfx::Rect(location_in_screen, gfx::Size()),
[email protected]940fb1c2013-06-18 16:54:28559 views::MenuItemView::TOPLEFT, source_type,
560 views::MenuRunner::CONTEXT_MENU) ==
[email protected]6175fc42013-04-05 05:58:58561 views::MenuRunner::MENU_DELETED) {
562 return;
563 }
564
[email protected]431552c2012-10-23 00:38:33565 Shell::GetInstance()->UpdateShelfVisibility();
566}
567
[email protected]e74aaf0a2012-10-12 18:42:28568void RootWindowController::UpdateShelfVisibility() {
[email protected]478c6c32013-03-09 02:50:58569 shelf_->shelf_layout_manager()->UpdateVisibilityState();
[email protected]e74aaf0a2012-10-12 18:42:28570}
571
[email protected]2c9171d22013-12-10 21:55:10572const aura::Window* RootWindowController::GetWindowForFullscreenMode() const {
[email protected]e3bc88e2013-09-06 06:22:06573 const aura::Window::Windows& windows =
574 GetContainer(kShellWindowId_DefaultContainer)->children();
[email protected]2c9171d22013-12-10 21:55:10575 const aura::Window* topmost_window = NULL;
[email protected]e3bc88e2013-09-06 06:22:06576 for (aura::Window::Windows::const_reverse_iterator iter = windows.rbegin();
577 iter != windows.rend(); ++iter) {
[email protected]5b251f12013-12-19 01:50:05578 if (((*iter)->type() == ui::wm::WINDOW_TYPE_NORMAL ||
579 (*iter)->type() == ui::wm::WINDOW_TYPE_PANEL) &&
[email protected]2c9171d22013-12-10 21:55:10580 (*iter)->layer()->GetTargetVisibility()) {
581 topmost_window = *iter;
582 break;
583 }
584 }
585 while (topmost_window) {
586 if (wm::GetWindowState(topmost_window)->IsFullscreen())
587 return topmost_window;
[email protected]751b13df2014-01-07 19:52:52588 topmost_window = views::corewm::GetTransientParent(topmost_window);
[email protected]2ee2f5d2013-01-10 23:37:16589 }
[email protected]700849f2013-04-30 17:49:20590 return NULL;
[email protected]2ee2f5d2013-01-10 23:37:16591}
592
[email protected]b6ba05d902013-10-04 21:38:45593void RootWindowController::ActivateKeyboard(
594 keyboard::KeyboardController* keyboard_controller) {
595 if (!keyboard::IsKeyboardEnabled() ||
596 GetContainer(kShellWindowId_VirtualKeyboardContainer)) {
597 return;
598 }
599 DCHECK(keyboard_controller);
[email protected]51f438112013-11-18 19:32:50600 if (!keyboard::IsKeyboardUsabilityExperimentEnabled()) {
601 keyboard_controller->AddObserver(shelf()->shelf_layout_manager());
602 keyboard_controller->AddObserver(panel_layout_manager_);
603 keyboard_controller->AddObserver(docked_layout_manager_);
604 }
[email protected]b6ba05d902013-10-04 21:38:45605 aura::Window* parent = root_window();
606 aura::Window* keyboard_container =
607 keyboard_controller->GetContainerWindow();
608 keyboard_container->set_id(kShellWindowId_VirtualKeyboardContainer);
609 parent->AddChild(keyboard_container);
610 // TODO(oshima): Bounds of keyboard container should be handled by
611 // RootWindowLayoutManager. Remove this after fixed RootWindowLayoutManager.
612 keyboard_container->SetBounds(parent->bounds());
613}
[email protected]86459e2c2013-04-10 13:39:24614
[email protected]b6ba05d902013-10-04 21:38:45615void RootWindowController::DeactivateKeyboard(
616 keyboard::KeyboardController* keyboard_controller) {
[email protected]e1b299b2014-01-29 23:53:41617 if (!keyboard_controller ||
618 !keyboard_controller->keyboard_container_initialized()) {
[email protected]b6ba05d902013-10-04 21:38:45619 return;
[email protected]e1b299b2014-01-29 23:53:41620 }
[email protected]b6ba05d902013-10-04 21:38:45621 aura::Window* keyboard_container =
622 keyboard_controller->GetContainerWindow();
623 if (keyboard_container->GetRootWindow() == root_window()) {
624 root_window()->RemoveChild(keyboard_container);
[email protected]51f438112013-11-18 19:32:50625 if (!keyboard::IsKeyboardUsabilityExperimentEnabled()) {
626 keyboard_controller->RemoveObserver(shelf()->shelf_layout_manager());
627 keyboard_controller->RemoveObserver(panel_layout_manager_);
628 keyboard_controller->RemoveObserver(docked_layout_manager_);
629 }
[email protected]86459e2c2013-04-10 13:39:24630 }
631}
632
[email protected]a4cd6d32012-09-12 03:42:13633////////////////////////////////////////////////////////////////////////////////
634// RootWindowController, private:
635
[email protected]a273d33a2013-10-17 12:41:21636RootWindowController::RootWindowController(aura::RootWindow* root_window)
637 : root_window_(root_window),
638 root_window_layout_(NULL),
639 docked_layout_manager_(NULL),
640 panel_layout_manager_(NULL),
641 touch_hud_debug_(NULL),
642 touch_hud_projection_(NULL) {
[email protected]41baaed2013-11-09 04:18:26643 GetRootWindowSettings(root_window_->window())->controller = this;
644 screen_dimmer_.reset(new ScreenDimmer(root_window_->window()));
[email protected]a273d33a2013-10-17 12:41:21645
646 stacking_controller_.reset(new StackingController);
[email protected]41baaed2013-11-09 04:18:26647 aura::client::SetWindowTreeClient(root_window_->window(),
648 stacking_controller_.get());
649 capture_client_.reset(
650 new views::corewm::ScopedCaptureClient(root_window_->window()));
[email protected]a273d33a2013-10-17 12:41:21651}
652
[email protected]608de6c2013-10-29 00:14:28653void RootWindowController::Init(RootWindowType root_window_type,
654 bool first_run_after_boot) {
[email protected]51f438112013-11-18 19:32:50655 Shell* shell = Shell::GetInstance();
656 shell->InitRootWindow(root_window());
[email protected]a273d33a2013-10-17 12:41:21657
658 root_window_->SetCursor(ui::kCursorPointer);
[email protected]f7c05b22013-11-12 21:07:24659 CreateContainersInRootWindow(root_window_->window());
[email protected]608de6c2013-10-29 00:14:28660
[email protected]51f438112013-11-18 19:32:50661 if (root_window_type == VIRTUAL_KEYBOARD) {
662 shell->InitKeyboard();
[email protected]608de6c2013-10-29 00:14:28663 return;
[email protected]51f438112013-11-18 19:32:50664 }
[email protected]608de6c2013-10-29 00:14:28665
[email protected]a273d33a2013-10-17 12:41:21666 CreateSystemBackground(first_run_after_boot);
667
668 InitLayoutManagers();
669 InitTouchHuds();
670
671 if (Shell::GetPrimaryRootWindowController()->
672 GetSystemModalLayoutManager(NULL)->has_modal_background()) {
673 GetSystemModalLayoutManager(NULL)->CreateModalBackground();
674 }
675
[email protected]a273d33a2013-10-17 12:41:21676 shell->AddShellObserver(this);
677
[email protected]608de6c2013-10-29 00:14:28678 if (root_window_type == PRIMARY) {
[email protected]a3565792013-10-18 12:52:37679 root_window_layout()->OnWindowResized();
[email protected]51f438112013-11-18 19:32:50680 if (!keyboard::IsKeyboardUsabilityExperimentEnabled())
681 shell->InitKeyboard();
[email protected]a273d33a2013-10-17 12:41:21682 } else {
683 root_window_layout()->OnWindowResized();
[email protected]41baaed2013-11-09 04:18:26684 shell->desktop_background_controller()->OnRootWindowAdded(root_window());
[email protected]f7c05b22013-11-12 21:07:24685 shell->high_contrast_controller()->OnRootWindowAdded(
686 root_window_->window());
[email protected]228f0f02013-11-15 05:58:36687 root_window_->host()->Show();
[email protected]a273d33a2013-10-17 12:41:21688
[email protected]864b58552013-12-19 04:19:38689 // Create a shelf if a user is already logged in.
[email protected]a273d33a2013-10-17 12:41:21690 if (shell->session_state_delegate()->NumberOfLoggedInUsers())
[email protected]864b58552013-12-19 04:19:38691 shelf()->CreateShelf();
[email protected]a273d33a2013-10-17 12:41:21692 }
693}
694
[email protected]756bda12013-07-03 08:17:06695void RootWindowController::InitLayoutManagers() {
[email protected]41baaed2013-11-09 04:18:26696 root_window_layout_ = new RootWindowLayoutManager(root_window());
697 root_window()->SetLayoutManager(root_window_layout_);
[email protected]756bda12013-07-03 08:17:06698
699 aura::Window* default_container =
700 GetContainer(kShellWindowId_DefaultContainer);
701 // Workspace manager has its own layout managers.
702 workspace_controller_.reset(
703 new WorkspaceController(default_container));
704
705 aura::Window* always_on_top_container =
706 GetContainer(kShellWindowId_AlwaysOnTopContainer);
707 always_on_top_container->SetLayoutManager(
[email protected]1af71f72014-01-29 20:00:55708 new internal::WorkspaceLayoutManager(
709 always_on_top_container));
[email protected]756bda12013-07-03 08:17:06710 always_on_top_controller_.reset(new internal::AlwaysOnTopController);
711 always_on_top_controller_->SetAlwaysOnTopContainer(always_on_top_container);
712
713 DCHECK(!shelf_.get());
714 aura::Window* shelf_container =
715 GetContainer(internal::kShellWindowId_ShelfContainer);
716 // TODO(harrym): Remove when status area is view.
717 aura::Window* status_container =
718 GetContainer(internal::kShellWindowId_StatusContainer);
719 shelf_.reset(new ShelfWidget(
720 shelf_container, status_container, workspace_controller()));
721
[email protected]cf6fea22013-08-07 14:24:01722 if (!Shell::GetInstance()->session_state_delegate()->
723 IsActiveUserSessionStarted()) {
724 // This window exists only to be a event target on login screen.
725 // It does not have to handle events, nor be visible.
726 mouse_event_target_.reset(new aura::Window(new EmptyWindowDelegate));
[email protected]52b02a72014-01-08 21:41:50727 mouse_event_target_->Init(aura::WINDOW_LAYER_NOT_DRAWN);
[email protected]cf6fea22013-08-07 14:24:01728
729 aura::Window* lock_background_container =
730 GetContainer(internal::kShellWindowId_LockScreenBackgroundContainer);
731 lock_background_container->AddChild(mouse_event_target_.get());
732 mouse_event_target_->Show();
733 }
734
[email protected]756bda12013-07-03 08:17:06735 // Create Docked windows layout manager
736 aura::Window* docked_container = GetContainer(
737 internal::kShellWindowId_DockedContainer);
738 docked_layout_manager_ =
[email protected]375069e2013-10-04 13:54:31739 new internal::DockedWindowLayoutManager(docked_container,
740 workspace_controller());
[email protected]756bda12013-07-03 08:17:06741 docked_container->SetLayoutManager(docked_layout_manager_);
742
743 // Create Panel layout manager
744 aura::Window* panel_container = GetContainer(
745 internal::kShellWindowId_PanelContainer);
746 panel_layout_manager_ =
747 new internal::PanelLayoutManager(panel_container);
[email protected]756bda12013-07-03 08:17:06748 panel_container->SetLayoutManager(panel_layout_manager_);
[email protected]3537d472014-01-15 05:45:31749 panel_container_handler_.reset(new PanelWindowEventHandler);
750 panel_container->AddPreTargetHandler(panel_container_handler_.get());
[email protected]756bda12013-07-03 08:17:06751}
752
753void RootWindowController::InitTouchHuds() {
754 CommandLine* command_line = CommandLine::ForCurrentProcess();
755 if (command_line->HasSwitch(switches::kAshTouchHud))
[email protected]41baaed2013-11-09 04:18:26756 set_touch_hud_debug(new TouchHudDebug(root_window()));
[email protected]756bda12013-07-03 08:17:06757 if (Shell::GetInstance()->is_touch_hud_projection_enabled())
758 EnableTouchHudProjection();
759}
760
761void RootWindowController::CreateSystemBackground(
762 bool is_first_run_after_boot) {
763 SkColor color = SK_ColorBLACK;
764#if defined(OS_CHROMEOS)
765 if (is_first_run_after_boot)
766 color = kChromeOsBootColor;
767#endif
768 system_background_.reset(
[email protected]41baaed2013-11-09 04:18:26769 new SystemBackgroundController(root_window(), color));
[email protected]756bda12013-07-03 08:17:06770
771#if defined(OS_CHROMEOS)
772 // Make a copy of the system's boot splash screen so we can composite it
773 // onscreen until the desktop background is ready.
774 if (is_first_run_after_boot &&
775 (CommandLine::ForCurrentProcess()->HasSwitch(
776 switches::kAshCopyHostBackgroundAtBoot) ||
777 CommandLine::ForCurrentProcess()->HasSwitch(
778 switches::kAshAnimateFromBootSplashScreen)))
779 boot_splash_screen_.reset(new BootSplashScreen(root_window_.get()));
780#endif
781}
782
[email protected]a4cd6d32012-09-12 03:42:13783void RootWindowController::CreateContainersInRootWindow(
[email protected]41baaed2013-11-09 04:18:26784 aura::Window* root_window) {
[email protected]a4cd6d32012-09-12 03:42:13785 // These containers are just used by PowerButtonController to animate groups
786 // of containers simultaneously without messing up the current transformations
787 // on those containers. These are direct children of the root window; all of
788 // the other containers are their children.
[email protected]e6e41d2f2012-10-29 19:22:19789
790 // The desktop background container is not part of the lock animation, so it
791 // is not included in those animate groups.
[email protected]a4cd6d32012-09-12 03:42:13792 // When screen is locked desktop background is moved to lock screen background
793 // container (moved back on unlock). We want to make sure that there's an
794 // opaque layer occluding the non-lock-screen layers.
[email protected]e6e41d2f2012-10-29 19:22:19795 aura::Window* desktop_background_container = CreateContainer(
[email protected]c0ce80e2012-10-05 23:28:27796 kShellWindowId_DesktopBackgroundContainer,
[email protected]a4cd6d32012-09-12 03:42:13797 "DesktopBackgroundContainer",
798 root_window);
[email protected]b5756e22012-11-30 01:32:02799 views::corewm::SetChildWindowVisibilityChangesAnimated(
800 desktop_background_container);
[email protected]a4cd6d32012-09-12 03:42:13801
802 aura::Window* non_lock_screen_containers = CreateContainer(
[email protected]c0ce80e2012-10-05 23:28:27803 kShellWindowId_NonLockScreenContainersContainer,
[email protected]a4cd6d32012-09-12 03:42:13804 "NonLockScreenContainersContainer",
805 root_window);
806
807 aura::Window* lock_background_containers = CreateContainer(
[email protected]c0ce80e2012-10-05 23:28:27808 kShellWindowId_LockScreenBackgroundContainer,
[email protected]a4cd6d32012-09-12 03:42:13809 "LockScreenBackgroundContainer",
810 root_window);
[email protected]b5756e22012-11-30 01:32:02811 views::corewm::SetChildWindowVisibilityChangesAnimated(
812 lock_background_containers);
[email protected]a4cd6d32012-09-12 03:42:13813
814 aura::Window* lock_screen_containers = CreateContainer(
[email protected]c0ce80e2012-10-05 23:28:27815 kShellWindowId_LockScreenContainersContainer,
[email protected]a4cd6d32012-09-12 03:42:13816 "LockScreenContainersContainer",
817 root_window);
818 aura::Window* lock_screen_related_containers = CreateContainer(
[email protected]c0ce80e2012-10-05 23:28:27819 kShellWindowId_LockScreenRelatedContainersContainer,
[email protected]a4cd6d32012-09-12 03:42:13820 "LockScreenRelatedContainersContainer",
821 root_window);
822
[email protected]c0ce80e2012-10-05 23:28:27823 CreateContainer(kShellWindowId_UnparentedControlContainer,
[email protected]a4cd6d32012-09-12 03:42:13824 "UnparentedControlContainer",
825 non_lock_screen_containers);
826
827 aura::Window* default_container = CreateContainer(
[email protected]c0ce80e2012-10-05 23:28:27828 kShellWindowId_DefaultContainer,
[email protected]a4cd6d32012-09-12 03:42:13829 "DefaultContainer",
830 non_lock_screen_containers);
[email protected]b5756e22012-11-30 01:32:02831 views::corewm::SetChildWindowVisibilityChangesAnimated(default_container);
[email protected]a4cd6d32012-09-12 03:42:13832 SetUsesScreenCoordinates(default_container);
[email protected]c5be8d672014-01-07 13:33:41833 SetUsesEasyResizeTargeter(default_container);
[email protected]a4cd6d32012-09-12 03:42:13834
835 aura::Window* always_on_top_container = CreateContainer(
[email protected]c0ce80e2012-10-05 23:28:27836 kShellWindowId_AlwaysOnTopContainer,
[email protected]a4cd6d32012-09-12 03:42:13837 "AlwaysOnTopContainer",
838 non_lock_screen_containers);
[email protected]b5756e22012-11-30 01:32:02839 views::corewm::SetChildWindowVisibilityChangesAnimated(
840 always_on_top_container);
[email protected]a4cd6d32012-09-12 03:42:13841 SetUsesScreenCoordinates(always_on_top_container);
842
[email protected]beb4e5c2013-06-18 15:37:07843 aura::Window* docked_container = CreateContainer(
844 kShellWindowId_DockedContainer,
845 "DockedContainer",
846 non_lock_screen_containers);
[email protected]5eab6e92013-09-19 19:09:27847 views::corewm::SetChildWindowVisibilityChangesAnimated(docked_container);
[email protected]beb4e5c2013-06-18 15:37:07848 SetUsesScreenCoordinates(docked_container);
[email protected]1ff0c492014-01-21 20:20:44849 SetUsesEasyResizeTargeter(docked_container);
[email protected]beb4e5c2013-06-18 15:37:07850
[email protected]3f13cf12013-07-12 05:13:59851 aura::Window* shelf_container =
[email protected]478c6c32013-03-09 02:50:58852 CreateContainer(kShellWindowId_ShelfContainer,
[email protected]3f13cf12013-07-12 05:13:59853 "ShelfContainer",
[email protected]a4cd6d32012-09-12 03:42:13854 non_lock_screen_containers);
[email protected]3f13cf12013-07-12 05:13:59855 SetUsesScreenCoordinates(shelf_container);
856 DescendantShouldStayInSameRootWindow(shelf_container);
[email protected]a4cd6d32012-09-12 03:42:13857
[email protected]f2026eb2013-10-22 14:28:56858 aura::Window* panel_container = CreateContainer(
859 kShellWindowId_PanelContainer,
860 "PanelContainer",
861 non_lock_screen_containers);
862 SetUsesScreenCoordinates(panel_container);
[email protected]c5be8d672014-01-07 13:33:41863 SetUsesEasyResizeTargeter(panel_container);
[email protected]f2026eb2013-10-22 14:28:56864
865 aura::Window* shelf_bubble_container =
866 CreateContainer(kShellWindowId_ShelfBubbleContainer,
867 "ShelfBubbleContainer",
868 non_lock_screen_containers);
869 SetUsesScreenCoordinates(shelf_bubble_container);
870 DescendantShouldStayInSameRootWindow(shelf_bubble_container);
871
[email protected]dc851a4e52012-10-03 00:05:55872 aura::Window* app_list_container =
[email protected]c0ce80e2012-10-05 23:28:27873 CreateContainer(kShellWindowId_AppListContainer,
[email protected]dc851a4e52012-10-03 00:05:55874 "AppListContainer",
875 non_lock_screen_containers);
876 SetUsesScreenCoordinates(app_list_container);
[email protected]a4cd6d32012-09-12 03:42:13877
878 aura::Window* modal_container = CreateContainer(
[email protected]c0ce80e2012-10-05 23:28:27879 kShellWindowId_SystemModalContainer,
[email protected]a4cd6d32012-09-12 03:42:13880 "SystemModalContainer",
881 non_lock_screen_containers);
[email protected]a4cd6d32012-09-12 03:42:13882 modal_container->SetLayoutManager(
[email protected]c0ce80e2012-10-05 23:28:27883 new SystemModalContainerLayoutManager(modal_container));
[email protected]b5756e22012-11-30 01:32:02884 views::corewm::SetChildWindowVisibilityChangesAnimated(modal_container);
[email protected]a4cd6d32012-09-12 03:42:13885 SetUsesScreenCoordinates(modal_container);
[email protected]c5be8d672014-01-07 13:33:41886 SetUsesEasyResizeTargeter(modal_container);
[email protected]a4cd6d32012-09-12 03:42:13887
888 aura::Window* input_method_container = CreateContainer(
[email protected]c0ce80e2012-10-05 23:28:27889 kShellWindowId_InputMethodContainer,
[email protected]a4cd6d32012-09-12 03:42:13890 "InputMethodContainer",
891 non_lock_screen_containers);
[email protected]649eb7462013-10-24 07:52:01892 views::corewm::SetChildWindowVisibilityChangesAnimated(
893 input_method_container);
[email protected]a4cd6d32012-09-12 03:42:13894 SetUsesScreenCoordinates(input_method_container);
895
896 // TODO(beng): Figure out if we can make this use
897 // SystemModalContainerEventFilter instead of stops_event_propagation.
898 aura::Window* lock_container = CreateContainer(
[email protected]c0ce80e2012-10-05 23:28:27899 kShellWindowId_LockScreenContainer,
[email protected]a4cd6d32012-09-12 03:42:13900 "LockScreenContainer",
901 lock_screen_containers);
902 lock_container->SetLayoutManager(
[email protected]1af71f72014-01-29 20:00:55903 new internal::WorkspaceLayoutManager(lock_container));
[email protected]a4cd6d32012-09-12 03:42:13904 SetUsesScreenCoordinates(lock_container);
905 // TODO(beng): stopsevents
906
907 aura::Window* lock_modal_container = CreateContainer(
[email protected]c0ce80e2012-10-05 23:28:27908 kShellWindowId_LockSystemModalContainer,
[email protected]a4cd6d32012-09-12 03:42:13909 "LockSystemModalContainer",
910 lock_screen_containers);
[email protected]a4cd6d32012-09-12 03:42:13911 lock_modal_container->SetLayoutManager(
[email protected]c0ce80e2012-10-05 23:28:27912 new SystemModalContainerLayoutManager(lock_modal_container));
[email protected]b5756e22012-11-30 01:32:02913 views::corewm::SetChildWindowVisibilityChangesAnimated(lock_modal_container);
[email protected]a4cd6d32012-09-12 03:42:13914 SetUsesScreenCoordinates(lock_modal_container);
[email protected]c5be8d672014-01-07 13:33:41915 SetUsesEasyResizeTargeter(lock_modal_container);
[email protected]a4cd6d32012-09-12 03:42:13916
917 aura::Window* status_container =
[email protected]c0ce80e2012-10-05 23:28:27918 CreateContainer(kShellWindowId_StatusContainer,
[email protected]a4cd6d32012-09-12 03:42:13919 "StatusContainer",
920 lock_screen_related_containers);
921 SetUsesScreenCoordinates(status_container);
[email protected]e887c6c2013-07-08 19:35:53922 DescendantShouldStayInSameRootWindow(status_container);
[email protected]a4cd6d32012-09-12 03:42:13923
924 aura::Window* settings_bubble_container = CreateContainer(
[email protected]c0ce80e2012-10-05 23:28:27925 kShellWindowId_SettingBubbleContainer,
[email protected]a4cd6d32012-09-12 03:42:13926 "SettingBubbleContainer",
927 lock_screen_related_containers);
[email protected]b5756e22012-11-30 01:32:02928 views::corewm::SetChildWindowVisibilityChangesAnimated(
929 settings_bubble_container);
[email protected]a4cd6d32012-09-12 03:42:13930 SetUsesScreenCoordinates(settings_bubble_container);
[email protected]e887c6c2013-07-08 19:35:53931 DescendantShouldStayInSameRootWindow(settings_bubble_container);
[email protected]a4cd6d32012-09-12 03:42:13932
933 aura::Window* menu_container = CreateContainer(
[email protected]c0ce80e2012-10-05 23:28:27934 kShellWindowId_MenuContainer,
[email protected]a4cd6d32012-09-12 03:42:13935 "MenuContainer",
936 lock_screen_related_containers);
[email protected]b5756e22012-11-30 01:32:02937 views::corewm::SetChildWindowVisibilityChangesAnimated(menu_container);
[email protected]a4cd6d32012-09-12 03:42:13938 SetUsesScreenCoordinates(menu_container);
939
940 aura::Window* drag_drop_container = CreateContainer(
[email protected]c0ce80e2012-10-05 23:28:27941 kShellWindowId_DragImageAndTooltipContainer,
[email protected]a4cd6d32012-09-12 03:42:13942 "DragImageAndTooltipContainer",
943 lock_screen_related_containers);
[email protected]b5756e22012-11-30 01:32:02944 views::corewm::SetChildWindowVisibilityChangesAnimated(drag_drop_container);
[email protected]a4cd6d32012-09-12 03:42:13945 SetUsesScreenCoordinates(drag_drop_container);
946
947 aura::Window* overlay_container = CreateContainer(
[email protected]c0ce80e2012-10-05 23:28:27948 kShellWindowId_OverlayContainer,
[email protected]a4cd6d32012-09-12 03:42:13949 "OverlayContainer",
950 lock_screen_related_containers);
951 SetUsesScreenCoordinates(overlay_container);
[email protected]a07615f2012-10-24 08:23:08952
953 CreateContainer(kShellWindowId_PowerButtonAnimationContainer,
954 "PowerButtonAnimationContainer", root_window) ;
[email protected]a4cd6d32012-09-12 03:42:13955}
956
[email protected]d141b922013-07-09 08:13:17957void RootWindowController::EnableTouchHudProjection() {
958 if (touch_hud_projection_)
959 return;
[email protected]41baaed2013-11-09 04:18:26960 set_touch_hud_projection(new TouchHudProjection(root_window()));
[email protected]d141b922013-07-09 08:13:17961}
962
963void RootWindowController::DisableTouchHudProjection() {
964 if (!touch_hud_projection_)
965 return;
966 touch_hud_projection_->Remove();
967}
968
969void RootWindowController::OnLoginStateChanged(user::LoginStatus status) {
970 shelf_->shelf_layout_manager()->UpdateVisibilityState();
971}
972
973void RootWindowController::OnTouchHudProjectionToggled(bool enabled) {
974 if (enabled)
975 EnableTouchHudProjection();
976 else
977 DisableTouchHudProjection();
978}
979
[email protected]6b2d4a0b2013-09-06 06:29:54980RootWindowController* GetRootWindowController(
[email protected]bf9cdb362013-10-25 19:22:45981 const aura::Window* root_window) {
[email protected]6b2d4a0b2013-09-06 06:29:54982 return root_window ? GetRootWindowSettings(root_window)->controller : NULL;
983}
984
[email protected]d90b8392012-06-13 09:34:56985} // namespace internal
986} // namespace ash