blob: 68bbc74426e0029a37837c1bb102429d1182934d [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]f5c9dbc2014-04-11 08:13:4518#include "ash/host/ash_window_tree_host.h"
[email protected]f8e6aad2013-08-30 21:49:1119#include "ash/root_window_settings.h"
[email protected]fdf74bf2014-04-30 21:24:0220#include "ash/session/session_state_delegate.h"
[email protected]478c6c32013-03-09 02:50:5821#include "ash/shelf/shelf_layout_manager.h"
22#include "ash/shelf/shelf_types.h"
23#include "ash/shelf/shelf_widget.h"
[email protected]d90b8392012-06-13 09:34:5624#include "ash/shell.h"
[email protected]e74aaf0a2012-10-12 18:42:2825#include "ash/shell_delegate.h"
[email protected]d90b8392012-06-13 09:34:5626#include "ash/shell_factory.h"
27#include "ash/shell_window_ids.h"
[email protected]e74aaf0a2012-10-12 18:42:2828#include "ash/system/status_area_widget.h"
[email protected]8674b312012-10-12 19:02:4429#include "ash/system/tray/system_tray_delegate.h"
[email protected]a825e8312014-05-05 22:05:0130#include "ash/system/tray/system_tray_notifier.h"
[email protected]2b8a9bb2013-07-01 22:43:4031#include "ash/touch/touch_hud_debug.h"
32#include "ash/touch/touch_hud_projection.h"
[email protected]80549c152013-07-02 01:42:4733#include "ash/touch/touch_observer_hud.h"
sky3f7af8812016-04-21 19:30:0334#include "ash/wm/aura/aura_layout_manager_adapter.h"
sky019ff29c2016-04-26 19:40:5935#include "ash/wm/aura/wm_shelf_aura.h"
skyf961b3562016-04-20 00:53:5036#include "ash/wm/aura/wm_window_aura.h"
sky2f50fdc2016-04-28 05:56:1337#include "ash/wm/common/always_on_top_controller.h"
skycb51abf2016-05-05 18:24:4838#include "ash/wm/common/container_finder.h"
sky75677b502016-04-26 22:41:5939#include "ash/wm/common/dock/docked_window_layout_manager.h"
sky4dc7d0492016-04-28 04:15:2240#include "ash/wm/common/fullscreen_window_finder.h"
sky28a737f32016-05-02 15:44:3141#include "ash/wm/common/panels/panel_layout_manager.h"
sky4dc7d0492016-04-28 04:15:2242#include "ash/wm/common/switchable_windows.h"
sky75677b502016-04-26 22:41:5943#include "ash/wm/common/window_state.h"
sky2f50fdc2016-04-28 05:56:1344#include "ash/wm/common/workspace/workspace_layout_manager.h"
sky1e30f062016-04-14 21:19:1645#include "ash/wm/common/workspace/workspace_layout_manager_delegate.h"
[email protected]68d51332014-06-06 13:51:1346#include "ash/wm/lock_layout_manager.h"
[email protected]b8642ec2014-04-17 05:20:3947#include "ash/wm/panels/attached_panel_window_targeter.h"
[email protected]100659412013-06-21 22:59:5548#include "ash/wm/panels/panel_window_event_handler.h"
[email protected]d90b8392012-06-13 09:34:5649#include "ash/wm/root_window_layout_manager.h"
[email protected]2a2caa02013-01-22 20:50:3650#include "ash/wm/stacking_controller.h"
[email protected]e74aaf0a2012-10-12 18:42:2851#include "ash/wm/status_area_layout_manager.h"
[email protected]e6e41d2f2012-10-29 19:22:1952#include "ash/wm/system_background_controller.h"
[email protected]d90b8392012-06-13 09:34:5653#include "ash/wm/system_modal_container_layout_manager.h"
[email protected]8d625fb2012-07-18 16:40:0654#include "ash/wm/window_properties.h"
sky8d5646fe2016-04-15 17:03:4655#include "ash/wm/window_state_aura.h"
[email protected]700849f2013-04-30 17:49:2056#include "ash/wm/window_util.h"
[email protected]d90b8392012-06-13 09:34:5657#include "ash/wm/workspace_controller.h"
[email protected]e6e41d2f2012-10-29 19:22:1958#include "base/command_line.h"
jonrossa90d8982016-05-16 18:14:2559#include "base/macros.h"
sky1e30f062016-04-14 21:19:1660#include "base/memory/ptr_util.h"
[email protected]1e84c632013-06-27 23:12:2161#include "base/time/time.h"
[email protected]f1853122012-06-27 16:21:2662#include "ui/aura/client/aura_constants.h"
[email protected]2374d1812014-03-04 03:42:2763#include "ui/aura/client/screen_position_client.h"
[email protected]f1853122012-06-27 16:21:2664#include "ui/aura/window.h"
[email protected]cf6fea22013-08-07 14:24:0165#include "ui/aura/window_delegate.h"
[email protected]fcc51c952014-02-21 21:31:2666#include "ui/aura/window_event_dispatcher.h"
[email protected]f1853122012-06-27 16:21:2667#include "ui/aura/window_observer.h"
[email protected]8b3e3d82013-08-20 14:36:3068#include "ui/aura/window_tracker.h"
[email protected]cf6fea22013-08-07 14:24:0169#include "ui/base/hit_test.h"
[email protected]431552c2012-10-23 00:38:3370#include "ui/base/models/menu_model.h"
oshimaf84b0da722016-04-27 19:47:1971#include "ui/display/display.h"
72#include "ui/display/screen.h"
[email protected]86459e2c2013-04-10 13:39:2473#include "ui/keyboard/keyboard_controller.h"
74#include "ui/keyboard/keyboard_util.h"
jonrossa90d8982016-05-16 18:14:2575#include "ui/views/controls/menu/menu_model_adapter.h"
[email protected]431552c2012-10-23 00:38:3376#include "ui/views/controls/menu/menu_runner.h"
77#include "ui/views/view_model.h"
78#include "ui/views/view_model_utils.h"
[email protected]ee3ed10772014-03-11 22:02:0179#include "ui/wm/core/capture_controller.h"
[email protected]e319c7e2014-03-14 19:56:1480#include "ui/wm/core/easy_resize_window_targeter.h"
[email protected]ee3ed10772014-03-11 22:02:0181#include "ui/wm/core/visibility_controller.h"
82#include "ui/wm/core/window_util.h"
[email protected]af4552b22014-03-21 19:45:0183#include "ui/wm/public/drag_drop_client.h"
84#include "ui/wm/public/tooltip_client.h"
[email protected]5b251f12013-12-19 01:50:0585#include "ui/wm/public/window_types.h"
[email protected]d90b8392012-06-13 09:34:5686
[email protected]252eb232013-08-14 22:09:2787#if defined(OS_CHROMEOS)
[email protected]7d487592014-07-24 03:54:5088#include "ash/ash_touch_exploration_manager_chromeos.h"
[email protected]252eb232013-08-14 22:09:2789#include "ash/wm/boot_splash_screen_chromeos.h"
[email protected]a825e8312014-05-05 22:05:0190#include "ui/chromeos/touch_exploration_controller.h"
[email protected]252eb232013-08-14 22:09:2791#endif
92
[email protected]d90b8392012-06-13 09:34:5693namespace ash {
94namespace {
95
[email protected]252eb232013-08-14 22:09:2796#if defined(OS_CHROMEOS)
[email protected]bca9a7e2012-11-10 06:25:4997// Duration for the animation that hides the boot splash screen, in
98// milliseconds. This should be short enough in relation to
99// wm/window_animation.cc's brightness/grayscale fade animation that the login
100// background image animation isn't hidden by the splash screen animation.
101const int kBootSplashScreenHideDurationMs = 500;
[email protected]252eb232013-08-14 22:09:27102#endif
[email protected]bca9a7e2012-11-10 06:25:49103
[email protected]d90b8392012-06-13 09:34:56104// Creates a new window for use as a container.
105aura::Window* CreateContainer(int window_id,
106 const char* name,
107 aura::Window* parent) {
108 aura::Window* container = new aura::Window(NULL);
109 container->set_id(window_id);
110 container->SetName(name);
danakjb161836d2015-04-03 05:14:18111 container->Init(ui::LAYER_NOT_DRAWN);
[email protected]d90b8392012-06-13 09:34:56112 parent->AddChild(container);
[email protected]093b8d642014-04-03 20:59:28113 if (window_id != kShellWindowId_UnparentedControlContainer)
[email protected]d90b8392012-06-13 09:34:56114 container->Show();
115 return container;
116}
117
[email protected]2816c2462013-12-17 02:22:25118float ToRelativeValue(int value, int src, int dst) {
119 return static_cast<float>(value) / static_cast<float>(src) * dst;
120}
121
122void MoveOriginRelativeToSize(const gfx::Size& src_size,
123 const gfx::Size& dst_size,
124 gfx::Rect* bounds_in_out) {
125 gfx::Point origin = bounds_in_out->origin();
126 bounds_in_out->set_origin(gfx::Point(
127 ToRelativeValue(origin.x(), src_size.width(), dst_size.width()),
128 ToRelativeValue(origin.y(), src_size.height(), dst_size.height())));
129}
130
[email protected]95058572012-08-20 14:57:29131// Reparents |window| to |new_parent|.
132void ReparentWindow(aura::Window* window, aura::Window* new_parent) {
[email protected]2816c2462013-12-17 02:22:25133 const gfx::Size src_size = window->parent()->bounds().size();
134 const gfx::Size dst_size = new_parent->bounds().size();
[email protected]95058572012-08-20 14:57:29135 // Update the restore bounds to make it relative to the display.
[email protected]a41b4e12013-09-20 04:36:34136 wm::WindowState* state = wm::GetWindowState(window);
137 gfx::Rect restore_bounds;
138 bool has_restore_bounds = state->HasRestoreBounds();
[email protected]2816c2462013-12-17 02:22:25139
[email protected]9cfd3d12014-02-25 15:33:45140 bool update_bounds = (state->IsNormalOrSnapped() || state->IsMinimized()) &&
[email protected]093b8d642014-04-03 20:59:28141 new_parent->id() != kShellWindowId_DockedContainer;
[email protected]2816c2462013-12-17 02:22:25142 gfx::Rect local_bounds;
143 if (update_bounds) {
skyf961b3562016-04-20 00:53:50144 local_bounds = wm::WmWindowAura::GetAuraWindow(state->window())->bounds();
[email protected]2816c2462013-12-17 02:22:25145 MoveOriginRelativeToSize(src_size, dst_size, &local_bounds);
146 }
147
148 if (has_restore_bounds) {
[email protected]a41b4e12013-09-20 04:36:34149 restore_bounds = state->GetRestoreBoundsInParent();
[email protected]2816c2462013-12-17 02:22:25150 MoveOriginRelativeToSize(src_size, dst_size, &restore_bounds);
151 }
152
[email protected]95058572012-08-20 14:57:29153 new_parent->AddChild(window);
[email protected]2816c2462013-12-17 02:22:25154
[email protected]8663b7a62014-01-18 01:24:21155 // Docked windows have bounds handled by the layout manager in AddChild().
[email protected]2816c2462013-12-17 02:22:25156 if (update_bounds)
157 window->SetBounds(local_bounds);
158
[email protected]a41b4e12013-09-20 04:36:34159 if (has_restore_bounds)
160 state->SetRestoreBoundsInParent(restore_bounds);
[email protected]95058572012-08-20 14:57:29161}
162
163// Reparents the appropriate set of windows from |src| to |dst|.
[email protected]bf9cdb362013-10-25 19:22:45164void ReparentAllWindows(aura::Window* src, aura::Window* dst) {
[email protected]95058572012-08-20 14:57:29165 // Set of windows to move.
[email protected]f1853122012-06-27 16:21:26166 const int kContainerIdsToMove[] = {
[email protected]093b8d642014-04-03 20:59:28167 kShellWindowId_DefaultContainer,
168 kShellWindowId_DockedContainer,
169 kShellWindowId_PanelContainer,
170 kShellWindowId_AlwaysOnTopContainer,
171 kShellWindowId_SystemModalContainer,
172 kShellWindowId_LockSystemModalContainer,
tengsf98986c2014-12-06 01:42:21173 kShellWindowId_UnparentedControlContainer,
oshima022a9542015-05-01 00:15:02174 kShellWindowId_OverlayContainer,
175 };
176 const int kExtraContainerIdsToMoveInUnifiedMode[] = {
177 kShellWindowId_LockScreenContainer,
178 kShellWindowId_LockScreenBackgroundContainer,
179 };
180 std::vector<int> container_ids(
181 kContainerIdsToMove,
182 kContainerIdsToMove + arraysize(kContainerIdsToMove));
183 // Check the default_multi_display_mode because this is also necessary
184 // in trasition between mirror <-> unified mode.
oshima628a6172015-08-01 01:33:14185 if (Shell::GetInstance()
186 ->display_manager()
187 ->current_default_multi_display_mode() == DisplayManager::UNIFIED) {
oshima022a9542015-05-01 00:15:02188 for (int id : kExtraContainerIdsToMoveInUnifiedMode)
189 container_ids.push_back(id);
190 }
191
192 for (int id : container_ids) {
[email protected]f1853122012-06-27 16:21:26193 aura::Window* src_container = Shell::GetContainer(src, id);
194 aura::Window* dst_container = Shell::GetContainer(dst, id);
[email protected]5b6021902013-02-26 05:33:29195 while (!src_container->children().empty()) {
196 // Restart iteration from the source container windows each time as they
197 // may change as a result of moving other windows.
198 aura::Window::Windows::const_iterator iter =
199 src_container->children().begin();
200 while (iter != src_container->children().end() &&
[email protected]093b8d642014-04-03 20:59:28201 SystemModalContainerLayoutManager::IsModalBackground(*iter)) {
[email protected]5b6021902013-02-26 05:33:29202 ++iter;
203 }
204 // If the entire window list is modal background windows then stop.
205 if (iter == src_container->children().end())
206 break;
207 ReparentWindow(*iter, dst_container);
[email protected]f1853122012-06-27 16:21:26208 }
209 }
210}
211
[email protected]8d625fb2012-07-18 16:40:06212// Mark the container window so that a widget added to this container will
213// use the virtual screeen coordinates instead of parent.
214void SetUsesScreenCoordinates(aura::Window* container) {
[email protected]093b8d642014-04-03 20:59:28215 container->SetProperty(kUsesScreenCoordinatesKey, true);
[email protected]8d625fb2012-07-18 16:40:06216}
217
[email protected]e887c6c2013-07-08 19:35:53218// Mark the container window so that a widget added to this container will
219// say in the same root window regardless of the bounds specified.
220void DescendantShouldStayInSameRootWindow(aura::Window* container) {
[email protected]093b8d642014-04-03 20:59:28221 container->SetProperty(kStayInSameRootWindowKey, true);
[email protected]e887c6c2013-07-08 19:35:53222}
223
[email protected]c5be8d672014-01-07 13:33:41224void SetUsesEasyResizeTargeter(aura::Window* container) {
225 gfx::Insets mouse_extend(-kResizeOutsideBoundsSize,
226 -kResizeOutsideBoundsSize,
227 -kResizeOutsideBoundsSize,
228 -kResizeOutsideBoundsSize);
229 gfx::Insets touch_extend = mouse_extend.Scale(
230 kResizeOutsideBoundsScaleForTouch);
dchenga94547472016-04-08 08:41:11231 container->SetEventTargeter(
232 std::unique_ptr<ui::EventTargeter>(new ::wm::EasyResizeWindowTargeter(
233 container, mouse_extend, touch_extend)));
[email protected]c5be8d672014-01-07 13:33:41234}
235
[email protected]cf6fea22013-08-07 14:24:01236// A window delegate which does nothing. Used to create a window that
237// is a event target, but do nothing.
238class EmptyWindowDelegate : public aura::WindowDelegate {
239 public:
240 EmptyWindowDelegate() {}
dcheng1f4538e2014-10-27 23:57:05241 ~EmptyWindowDelegate() override {}
[email protected]cf6fea22013-08-07 14:24:01242
243 // aura::WindowDelegate overrides:
dcheng1f4538e2014-10-27 23:57:05244 gfx::Size GetMinimumSize() const override { return gfx::Size(); }
245 gfx::Size GetMaximumSize() const override { return gfx::Size(); }
246 void OnBoundsChanged(const gfx::Rect& old_bounds,
247 const gfx::Rect& new_bounds) override {}
248 gfx::NativeCursor GetCursor(const gfx::Point& point) override {
[email protected]62c9f102014-03-27 06:07:04249 return gfx::kNullCursor;
250 }
dcheng1f4538e2014-10-27 23:57:05251 int GetNonClientComponent(const gfx::Point& point) const override {
[email protected]cf6fea22013-08-07 14:24:01252 return HTNOWHERE;
253 }
dcheng1f4538e2014-10-27 23:57:05254 bool ShouldDescendIntoChildForEventHandling(
[email protected]cf6fea22013-08-07 14:24:01255 aura::Window* child,
mostynb10d6b382014-10-03 16:23:45256 const gfx::Point& location) override {
[email protected]cf6fea22013-08-07 14:24:01257 return false;
258 }
dcheng1f4538e2014-10-27 23:57:05259 bool CanFocus() override { return false; }
260 void OnCaptureLost() override {}
danakj85d970e2015-04-04 00:15:24261 void OnPaint(const ui::PaintContext& context) override {}
dcheng1f4538e2014-10-27 23:57:05262 void OnDeviceScaleFactorChanged(float device_scale_factor) override {}
263 void OnWindowDestroying(aura::Window* window) override {}
264 void OnWindowDestroyed(aura::Window* window) override { delete this; }
265 void OnWindowTargetVisibilityChanged(bool visible) override {}
266 bool HasHitTestMask() const override { return false; }
267 void GetHitTestMask(gfx::Path* mask) const override {}
[email protected]cf6fea22013-08-07 14:24:01268
269 private:
270 DISALLOW_COPY_AND_ASSIGN(EmptyWindowDelegate);
271};
272
sky1e30f062016-04-14 21:19:16273class WorkspaceLayoutManagerDelegateImpl
274 : public wm::WorkspaceLayoutManagerDelegate {
275 public:
276 explicit WorkspaceLayoutManagerDelegateImpl(aura::Window* root_window)
277 : root_window_(root_window) {}
278 ~WorkspaceLayoutManagerDelegateImpl() override = default;
279
280 void set_shelf(ShelfLayoutManager* shelf) { shelf_ = shelf; }
281
282 // WorkspaceLayoutManagerDelegate:
283 void UpdateShelfVisibility() override {
284 if (shelf_)
285 shelf_->UpdateVisibilityState();
286 }
287 void OnFullscreenStateChanged(bool is_fullscreen) override {
288 if (shelf_) {
289 ash::Shell::GetInstance()->NotifyFullscreenStateChange(is_fullscreen,
290 root_window_);
291 }
292 }
293
294 private:
295 aura::Window* root_window_;
296 ShelfLayoutManager* shelf_ = nullptr;
297
298 DISALLOW_COPY_AND_ASSIGN(WorkspaceLayoutManagerDelegateImpl);
299};
300
[email protected]d90b8392012-06-13 09:34:56301} // namespace
302
[email protected]f5c9dbc2014-04-11 08:13:45303void RootWindowController::CreateForPrimaryDisplay(AshWindowTreeHost* host) {
[email protected]2f2620332014-02-28 10:07:38304 RootWindowController* controller = new RootWindowController(host);
[email protected]608de6c2013-10-29 00:14:28305 controller->Init(RootWindowController::PRIMARY,
[email protected]a273d33a2013-10-17 12:41:21306 Shell::GetInstance()->delegate()->IsFirstRunAfterBoot());
[email protected]d90b8392012-06-13 09:34:56307}
308
[email protected]f5c9dbc2014-04-11 08:13:45309void RootWindowController::CreateForSecondaryDisplay(AshWindowTreeHost* host) {
[email protected]2f2620332014-02-28 10:07:38310 RootWindowController* controller = new RootWindowController(host);
[email protected]608de6c2013-10-29 00:14:28311 controller->Init(RootWindowController::SECONDARY, false /* first run */);
312}
313
[email protected]88d71122012-10-18 07:11:01314// static
[email protected]ccff3d72013-02-06 04:26:28315RootWindowController* RootWindowController::ForWindow(
316 const aura::Window* window) {
oshima9eea82da2014-09-13 01:11:07317 CHECK(Shell::HasInstance());
[email protected]a0afeb12012-12-10 22:57:09318 return GetRootWindowController(window->GetRootWindow());
319}
320
321// static
[email protected]d17642d2013-09-12 23:44:38322RootWindowController* RootWindowController::ForTargetRootWindow() {
oshima9eea82da2014-09-13 01:11:07323 CHECK(Shell::HasInstance());
[email protected]093b8d642014-04-03 20:59:28324 return GetRootWindowController(Shell::GetTargetRootWindow());
[email protected]a0afeb12012-12-10 22:57:09325}
326
[email protected]a273d33a2013-10-17 12:41:21327RootWindowController::~RootWindowController() {
328 Shutdown();
[email protected]f5c9dbc2014-04-11 08:13:45329 ash_host_.reset();
[email protected]a273d33a2013-10-17 12:41:21330 // The CaptureClient needs to be around for as long as the RootWindow is
331 // valid.
332 capture_client_.reset();
333}
334
[email protected]f5c9dbc2014-04-11 08:13:45335aura::WindowTreeHost* RootWindowController::GetHost() {
336 return ash_host_->AsWindowTreeHost();
337}
338
339const aura::WindowTreeHost* RootWindowController::GetHost() const {
340 return ash_host_->AsWindowTreeHost();
341}
342
343aura::Window* RootWindowController::GetRootWindow() {
344 return GetHost()->window();
345}
346
347const aura::Window* RootWindowController::GetRootWindow() const {
348 return GetHost()->window();
349}
350
[email protected]0bf61732013-07-02 04:35:10351void RootWindowController::SetWallpaperController(
352 DesktopBackgroundWidgetController* controller) {
353 wallpaper_controller_.reset(controller);
354}
355
356void RootWindowController::SetAnimatingWallpaperController(
357 AnimatingDesktopController* controller) {
358 if (animating_wallpaper_controller_.get())
359 animating_wallpaper_controller_->StopAnimating();
360 animating_wallpaper_controller_.reset(controller);
361}
362
[email protected]6675e1c2012-09-11 09:15:45363void RootWindowController::Shutdown() {
[email protected]a825e8312014-05-05 22:05:01364 Shell* shell = Shell::GetInstance();
365 shell->RemoveShellObserver(this);
366
367#if defined(OS_CHROMEOS)
[email protected]7d487592014-07-24 03:54:50368 if (touch_exploration_manager_) {
369 touch_exploration_manager_.reset();
[email protected]a825e8312014-05-05 22:05:01370 }
371#endif
[email protected]d141b922013-07-09 08:13:17372
[email protected]0bf61732013-07-02 04:35:10373 if (animating_wallpaper_controller_.get())
374 animating_wallpaper_controller_->StopAnimating();
375 wallpaper_controller_.reset();
376 animating_wallpaper_controller_.reset();
[email protected]f5c9dbc2014-04-11 08:13:45377 aura::Window* root_window = GetRootWindow();
[email protected]d17642d2013-09-12 23:44:38378 // Change the target root window before closing child windows. If any child
[email protected]c98a4922013-09-05 20:01:42379 // being removed triggers a relayout of the shelf it will try to build a
[email protected]d17642d2013-09-12 23:44:38380 // window list adding windows from the target root window's containers which
[email protected]c98a4922013-09-05 20:01:42381 // may have already gone away.
[email protected]f5c9dbc2014-04-11 08:13:45382 if (Shell::GetTargetRootWindow() == root_window) {
[email protected]a825e8312014-05-05 22:05:01383 shell->set_target_root_window(
[email protected]f5c9dbc2014-04-11 08:13:45384 Shell::GetPrimaryRootWindow() == root_window
385 ? NULL
386 : Shell::GetPrimaryRootWindow());
[email protected]f634dd32012-07-23 22:49:07387 }
[email protected]c98a4922013-09-05 20:01:42388
389 CloseChildWindows();
[email protected]f5c9dbc2014-04-11 08:13:45390 GetRootWindowSettings(root_window)->controller = NULL;
[email protected]d90b8392012-06-13 09:34:56391 workspace_controller_.reset();
[email protected]6675e1c2012-09-11 09:15:45392 // Forget with the display ID so that display lookup
393 // ends up with invalid display.
[email protected]f5c9dbc2014-04-11 08:13:45394 GetRootWindowSettings(root_window)->display_id =
oshimaf84b0da722016-04-27 19:47:19395 display::Display::kInvalidDisplayID;
[email protected]8f5209c2014-05-22 20:36:11396 ash_host_->PrepareForShutdown();
[email protected]e74aaf0a2012-10-12 18:42:28397
[email protected]956a6a42012-10-29 23:58:10398 system_background_.reset();
[email protected]f5c9dbc2014-04-11 08:13:45399 aura::client::SetScreenPositionClient(root_window, NULL);
[email protected]d90b8392012-06-13 09:34:56400}
401
[email protected]c0ce80e2012-10-05 23:28:27402SystemModalContainerLayoutManager*
[email protected]8674b312012-10-12 19:02:44403RootWindowController::GetSystemModalLayoutManager(aura::Window* window) {
[email protected]a5c78802013-12-12 22:07:01404 aura::Window* modal_container = NULL;
[email protected]8674b312012-10-12 19:02:44405 if (window) {
skycb51abf2016-05-05 18:24:48406 aura::Window* window_container = wm::WmWindowAura::GetAuraWindow(
407 wm::GetContainerForWindow(wm::WmWindowAura::Get(window)));
[email protected]a5c78802013-12-12 22:07:01408 if (window_container &&
409 window_container->id() >= kShellWindowId_LockScreenContainer) {
410 modal_container = GetContainer(kShellWindowId_LockSystemModalContainer);
[email protected]3b162e12012-11-09 11:52:35411 } else {
[email protected]a5c78802013-12-12 22:07:01412 modal_container = GetContainer(kShellWindowId_SystemModalContainer);
[email protected]3b162e12012-11-09 11:52:35413 }
[email protected]8674b312012-10-12 19:02:44414 } else {
[email protected]a44afbbd2013-07-24 21:49:35415 int modal_window_id = Shell::GetInstance()->session_state_delegate()
416 ->IsUserSessionBlocked() ? kShellWindowId_LockSystemModalContainer :
417 kShellWindowId_SystemModalContainer;
[email protected]a5c78802013-12-12 22:07:01418 modal_container = GetContainer(modal_window_id);
[email protected]8674b312012-10-12 19:02:44419 }
[email protected]a5c78802013-12-12 22:07:01420 return modal_container ? static_cast<SystemModalContainerLayoutManager*>(
421 modal_container->layout_manager()) : NULL;
[email protected]c0ce80e2012-10-05 23:28:27422}
423
[email protected]d90b8392012-06-13 09:34:56424aura::Window* RootWindowController::GetContainer(int container_id) {
[email protected]f5c9dbc2014-04-11 08:13:45425 return GetRootWindow()->GetChildById(container_id);
[email protected]d90b8392012-06-13 09:34:56426}
427
[email protected]d8a24952013-08-05 20:05:05428const aura::Window* RootWindowController::GetContainer(int container_id) const {
[email protected]f5c9dbc2014-04-11 08:13:45429 return ash_host_->AsWindowTreeHost()->window()->GetChildById(container_id);
[email protected]d8a24952013-08-05 20:05:05430}
431
[email protected]864b58552013-12-19 04:19:38432void RootWindowController::ShowShelf() {
433 if (!shelf_->shelf())
[email protected]e74aaf0a2012-10-12 18:42:28434 return;
[email protected]864b58552013-12-19 04:19:38435 shelf_->shelf()->SetVisible(true);
[email protected]478c6c32013-03-09 02:50:58436 shelf_->status_area_widget()->Show();
[email protected]e74aaf0a2012-10-12 18:42:28437}
438
[email protected]864b58552013-12-19 04:19:38439void RootWindowController::OnShelfCreated() {
[email protected]756bda12013-07-03 08:17:06440 if (panel_layout_manager_)
skya9a6deb32016-04-29 01:15:38441 panel_layout_manager_->SetShelf(shelf_->shelf()->wm_shelf());
[email protected]7115bd32013-07-19 08:25:39442 if (docked_layout_manager_) {
sky019ff29c2016-04-26 19:40:59443 docked_layout_manager_->SetShelf(shelf_->shelf()->wm_shelf());
[email protected]7115bd32013-07-19 08:25:39444 if (shelf_->shelf_layout_manager())
445 docked_layout_manager_->AddObserver(shelf_->shelf_layout_manager());
446 }
[email protected]b8642ec2014-04-17 05:20:39447
448 // Notify shell observers that the shelf has been created.
449 Shell::GetInstance()->OnShelfCreatedForRootWindow(GetRootWindow());
[email protected]756bda12013-07-03 08:17:06450}
451
[email protected]16059276d2012-10-22 18:59:50452void RootWindowController::UpdateAfterLoginStatusChange(
453 user::LoginStatus status) {
[email protected]cf6fea22013-08-07 14:24:01454 if (status != user::LOGGED_IN_NONE)
455 mouse_event_target_.reset();
[email protected]80549c152013-07-02 01:42:47456 if (shelf_->status_area_widget())
[email protected]478c6c32013-03-09 02:50:58457 shelf_->status_area_widget()->UpdateAfterLoginStatusChange(status);
[email protected]16059276d2012-10-22 18:59:50458}
459
[email protected]bca9a7e2012-11-10 06:25:49460void RootWindowController::HandleInitialDesktopBackgroundAnimationStarted() {
[email protected]252eb232013-08-14 22:09:27461#if defined(OS_CHROMEOS)
pgal.u-szegedd84534d32014-10-29 12:34:30462 if (base::CommandLine::ForCurrentProcess()->HasSwitch(
[email protected]bca9a7e2012-11-10 06:25:49463 switches::kAshAnimateFromBootSplashScreen) &&
464 boot_splash_screen_.get()) {
465 // Make the splash screen fade out so it doesn't obscure the desktop
466 // wallpaper's brightness/grayscale animation.
467 boot_splash_screen_->StartHideAnimation(
468 base::TimeDelta::FromMilliseconds(kBootSplashScreenHideDurationMs));
469 }
[email protected]252eb232013-08-14 22:09:27470#endif
[email protected]bca9a7e2012-11-10 06:25:49471}
472
[email protected]0bf61732013-07-02 04:35:10473void RootWindowController::OnWallpaperAnimationFinished(views::Widget* widget) {
474 // Make sure the wallpaper is visible.
[email protected]bca9a7e2012-11-10 06:25:49475 system_background_->SetColor(SK_ColorBLACK);
[email protected]252eb232013-08-14 22:09:27476#if defined(OS_CHROMEOS)
[email protected]bca9a7e2012-11-10 06:25:49477 boot_splash_screen_.reset();
[email protected]252eb232013-08-14 22:09:27478#endif
[email protected]0bf61732013-07-02 04:35:10479
480 Shell::GetInstance()->user_wallpaper_delegate()->
481 OnWallpaperAnimationFinished();
482 // Only removes old component when wallpaper animation finished. If we
483 // remove the old one before the new wallpaper is done fading in there will
484 // be a white flash during the animation.
485 if (animating_wallpaper_controller()) {
486 DesktopBackgroundWidgetController* controller =
487 animating_wallpaper_controller()->GetController(true);
488 // |desktop_widget_| should be the same animating widget we try to move
489 // to |kDesktopController|. Otherwise, we may close |desktop_widget_|
490 // before move it to |kDesktopController|.
491 DCHECK_EQ(controller->widget(), widget);
492 // Release the old controller and close its background widget.
493 SetWallpaperController(controller);
494 }
[email protected]697f04c2012-10-03 01:15:10495}
496
[email protected]d90b8392012-06-13 09:34:56497void RootWindowController::CloseChildWindows() {
[email protected]cf6fea22013-08-07 14:24:01498 mouse_event_target_.reset();
499
[email protected]2a57beb52014-06-09 20:02:26500 // Remove observer as deactivating keyboard causes |docked_layout_manager_|
501 // to fire notifications.
502 if (docked_layout_manager_ && shelf_ && shelf_->shelf_layout_manager())
503 docked_layout_manager_->RemoveObserver(shelf_->shelf_layout_manager());
504
[email protected]b6ba05d902013-10-04 21:38:45505 // Deactivate keyboard container before closing child windows and shutting
506 // down associated layout managers.
[email protected]a0b3fb882014-04-07 19:26:03507 DeactivateKeyboard(keyboard::KeyboardController::GetInstance());
[email protected]b6ba05d902013-10-04 21:38:45508
[email protected]79a87b7e2013-01-25 05:08:22509 // panel_layout_manager_ needs to be shut down before windows are destroyed.
510 if (panel_layout_manager_) {
511 panel_layout_manager_->Shutdown();
512 panel_layout_manager_ = NULL;
513 }
[email protected]7115bd32013-07-19 08:25:39514 // docked_layout_manager_ needs to be shut down before windows are destroyed.
515 if (docked_layout_manager_) {
[email protected]7115bd32013-07-19 08:25:39516 docked_layout_manager_->Shutdown();
517 docked_layout_manager_ = NULL;
518 }
[email protected]f5c9dbc2014-04-11 08:13:45519 aura::Window* root_window = GetRootWindow();
520 aura::client::SetDragDropClient(root_window, NULL);
[email protected]8b3e3d82013-08-20 14:36:30521
[email protected]478c6c32013-03-09 02:50:58522 // TODO(harrym): Remove when Status Area Widget is a child view.
[email protected]bb42c932013-10-31 06:52:06523 if (shelf_) {
524 shelf_->ShutdownStatusAreaWidget();
[email protected]478c6c32013-03-09 02:50:58525
[email protected]bb42c932013-10-31 06:52:06526 if (shelf_->shelf_layout_manager())
527 shelf_->shelf_layout_manager()->PrepareForShutdown();
528 }
[email protected]e74aaf0a2012-10-12 18:42:28529
[email protected]d90b8392012-06-13 09:34:56530 // Close background widget first as it depends on tooltip.
[email protected]0bf61732013-07-02 04:35:10531 wallpaper_controller_.reset();
532 animating_wallpaper_controller_.reset();
[email protected]b4ddc7a2012-08-07 04:17:32533
[email protected]d90b8392012-06-13 09:34:56534 workspace_controller_.reset();
[email protected]f5c9dbc2014-04-11 08:13:45535 aura::client::SetTooltipClient(root_window, NULL);
[email protected]d90b8392012-06-13 09:34:56536
[email protected]0fbfa972013-10-02 19:23:33537 // Explicitly destroy top level windows. We do this as during part of
538 // destruction such windows may query the RootWindow for state.
oshimaf38efa92015-10-27 19:06:52539 aura::WindowTracker non_toplevel_windows;
540 non_toplevel_windows.Add(root_window);
541 while (!non_toplevel_windows.windows().empty()) {
542 const aura::Window* non_toplevel_window =
543 *non_toplevel_windows.windows().begin();
544 non_toplevel_windows.Remove(const_cast<aura::Window*>(non_toplevel_window));
[email protected]8b3e3d82013-08-20 14:36:30545 aura::WindowTracker toplevel_windows;
546 for (size_t i = 0; i < non_toplevel_window->children().size(); ++i) {
547 aura::Window* child = non_toplevel_window->children()[i];
[email protected]0fbfa972013-10-02 19:23:33548 if (!child->owned_by_parent())
549 continue;
[email protected]8b3e3d82013-08-20 14:36:30550 if (child->delegate())
551 toplevel_windows.Add(child);
552 else
oshimaf38efa92015-10-27 19:06:52553 non_toplevel_windows.Add(child);
[email protected]8b3e3d82013-08-20 14:36:30554 }
555 while (!toplevel_windows.windows().empty())
556 delete *toplevel_windows.windows().begin();
[email protected]d90b8392012-06-13 09:34:56557 }
[email protected]8b3e3d82013-08-20 14:36:30558 // And then remove the containers.
[email protected]f5c9dbc2014-04-11 08:13:45559 while (!root_window->children().empty()) {
560 aura::Window* window = root_window->children()[0];
[email protected]0fbfa972013-10-02 19:23:33561 if (window->owned_by_parent()) {
562 delete window;
563 } else {
[email protected]f5c9dbc2014-04-11 08:13:45564 root_window->RemoveChild(window);
[email protected]0fbfa972013-10-02 19:23:33565 }
566 }
[email protected]478c6c32013-03-09 02:50:58567
[email protected]bb42c932013-10-31 06:52:06568 shelf_.reset();
[email protected]d90b8392012-06-13 09:34:56569}
570
[email protected]bf9cdb362013-10-25 19:22:45571void RootWindowController::MoveWindowsTo(aura::Window* dst) {
[email protected]8039e06c2013-01-17 23:34:50572 // Forget the shelf early so that shelf don't update itself using wrong
573 // display info.
sky1e30f062016-04-14 21:19:16574 workspace_controller_->SetShelf(nullptr);
575 workspace_controller_->layout_manager()->DeleteDelegate();
[email protected]f5c9dbc2014-04-11 08:13:45576 ReparentAllWindows(GetRootWindow(), dst);
[email protected]f1853122012-06-27 16:21:26577}
578
[email protected]478c6c32013-03-09 02:50:58579ShelfLayoutManager* RootWindowController::GetShelfLayoutManager() {
[email protected]80549c152013-07-02 01:42:47580 return shelf_->shelf_layout_manager();
[email protected]478c6c32013-03-09 02:50:58581}
582
[email protected]a0afeb12012-12-10 22:57:09583SystemTray* RootWindowController::GetSystemTray() {
584 // We assume in throughout the code that this will not return NULL. If code
585 // triggers this for valid reasons, it should test status_area_widget first.
[email protected]80549c152013-07-02 01:42:47586 CHECK(shelf_->status_area_widget());
[email protected]478c6c32013-03-09 02:50:58587 return shelf_->status_area_widget()->system_tray();
[email protected]a0afeb12012-12-10 22:57:09588}
589
[email protected]940fb1c2013-06-18 16:54:28590void RootWindowController::ShowContextMenu(const gfx::Point& location_in_screen,
591 ui::MenuSourceType source_type) {
msw141c6b22016-03-04 00:55:30592 ShellDelegate* delegate = Shell::GetInstance()->delegate();
593 DCHECK(delegate);
jonrossa90d8982016-05-16 18:14:25594 menu_model_.reset(delegate->CreateContextMenu(shelf_->shelf(), nullptr));
595 if (!menu_model_)
[email protected]8e837ec2013-01-31 01:48:33596 return;
[email protected]431552c2012-10-23 00:38:33597
jonrossa90d8982016-05-16 18:14:25598 menu_model_adapter_.reset(new views::MenuModelAdapter(
599 menu_model_.get(),
600 base::Bind(&RootWindowController::OnMenuClosed, base::Unretained(this))));
601
[email protected]6175fc42013-04-05 05:58:58602 // Background controller may not be set yet if user clicked on status are
603 // before initial animation completion. See crbug.com/222218
[email protected]0bf61732013-07-02 04:35:10604 if (!wallpaper_controller_.get())
[email protected]431552c2012-10-23 00:38:33605 return;
606
jonrossa90d8982016-05-16 18:14:25607 menu_runner_.reset(new views::MenuRunner(
608 menu_model_adapter_->CreateMenu(),
609 views::MenuRunner::CONTEXT_MENU | views::MenuRunner::ASYNC));
610 ignore_result(
611 menu_runner_->RunMenuAt(wallpaper_controller_->widget(), NULL,
612 gfx::Rect(location_in_screen, gfx::Size()),
613 views::MENU_ANCHOR_TOPLEFT, source_type));
[email protected]431552c2012-10-23 00:38:33614}
615
[email protected]e74aaf0a2012-10-12 18:42:28616void RootWindowController::UpdateShelfVisibility() {
[email protected]478c6c32013-03-09 02:50:58617 shelf_->shelf_layout_manager()->UpdateVisibilityState();
[email protected]e74aaf0a2012-10-12 18:42:28618}
619
varkhad99fa94f2015-06-29 22:35:46620aura::Window* RootWindowController::GetWindowForFullscreenMode() {
sky4dc7d0492016-04-28 04:15:22621 return wm::WmWindowAura::GetAuraWindow(
622 wm::GetWindowForFullscreenMode(wm::WmWindowAura::Get(GetRootWindow())));
[email protected]2ee2f5d2013-01-10 23:37:16623}
624
[email protected]b6ba05d902013-10-04 21:38:45625void RootWindowController::ActivateKeyboard(
626 keyboard::KeyboardController* keyboard_controller) {
627 if (!keyboard::IsKeyboardEnabled() ||
628 GetContainer(kShellWindowId_VirtualKeyboardContainer)) {
629 return;
630 }
631 DCHECK(keyboard_controller);
bshe9858b4a2014-09-16 20:46:38632 keyboard_controller->AddObserver(shelf()->shelf_layout_manager());
633 keyboard_controller->AddObserver(panel_layout_manager_);
634 keyboard_controller->AddObserver(docked_layout_manager_);
635 keyboard_controller->AddObserver(workspace_controller_->layout_manager());
rsadam7bd510bb2014-12-09 20:10:56636 keyboard_controller->AddObserver(
637 always_on_top_controller_->GetLayoutManager());
bshe9858b4a2014-09-16 20:46:38638 Shell::GetInstance()->delegate()->VirtualKeyboardActivated(true);
bshec3875422014-09-29 13:21:30639 aura::Window* parent = GetContainer(kShellWindowId_ImeWindowParentContainer);
[email protected]b2da9b602014-03-05 18:39:52640 DCHECK(parent);
[email protected]b6ba05d902013-10-04 21:38:45641 aura::Window* keyboard_container =
642 keyboard_controller->GetContainerWindow();
643 keyboard_container->set_id(kShellWindowId_VirtualKeyboardContainer);
644 parent->AddChild(keyboard_container);
[email protected]b6ba05d902013-10-04 21:38:45645}
[email protected]86459e2c2013-04-10 13:39:24646
[email protected]b6ba05d902013-10-04 21:38:45647void RootWindowController::DeactivateKeyboard(
648 keyboard::KeyboardController* keyboard_controller) {
[email protected]e1b299b2014-01-29 23:53:41649 if (!keyboard_controller ||
650 !keyboard_controller->keyboard_container_initialized()) {
[email protected]b6ba05d902013-10-04 21:38:45651 return;
[email protected]e1b299b2014-01-29 23:53:41652 }
[email protected]b6ba05d902013-10-04 21:38:45653 aura::Window* keyboard_container =
654 keyboard_controller->GetContainerWindow();
[email protected]f5c9dbc2014-04-11 08:13:45655 if (keyboard_container->GetRootWindow() == GetRootWindow()) {
bshec3875422014-09-29 13:21:30656 aura::Window* parent =
657 GetContainer(kShellWindowId_ImeWindowParentContainer);
[email protected]b2da9b602014-03-05 18:39:52658 DCHECK(parent);
659 parent->RemoveChild(keyboard_container);
bshe9858b4a2014-09-16 20:46:38660 // Virtual keyboard may be deactivated while still showing, notify all
661 // observers that keyboard bounds changed to 0 before remove them.
662 keyboard_controller->NotifyKeyboardBoundsChanging(gfx::Rect());
663 keyboard_controller->RemoveObserver(shelf()->shelf_layout_manager());
664 keyboard_controller->RemoveObserver(panel_layout_manager_);
665 keyboard_controller->RemoveObserver(docked_layout_manager_);
666 keyboard_controller->RemoveObserver(
667 workspace_controller_->layout_manager());
rsadam7bd510bb2014-12-09 20:10:56668 keyboard_controller->RemoveObserver(
669 always_on_top_controller_->GetLayoutManager());
bshe9858b4a2014-09-16 20:46:38670 Shell::GetInstance()->delegate()->VirtualKeyboardActivated(false);
[email protected]86459e2c2013-04-10 13:39:24671 }
672}
673
[email protected]602022b2014-03-31 17:07:31674bool RootWindowController::IsVirtualKeyboardWindow(aura::Window* window) {
bshec3875422014-09-29 13:21:30675 aura::Window* parent = GetContainer(kShellWindowId_ImeWindowParentContainer);
[email protected]602022b2014-03-31 17:07:31676 return parent ? parent->Contains(window) : false;
677}
678
[email protected]a4cd6d32012-09-12 03:42:13679////////////////////////////////////////////////////////////////////////////////
680// RootWindowController, private:
681
[email protected]f5c9dbc2014-04-11 08:13:45682RootWindowController::RootWindowController(AshWindowTreeHost* ash_host)
683 : ash_host_(ash_host),
[email protected]a273d33a2013-10-17 12:41:21684 root_window_layout_(NULL),
685 docked_layout_manager_(NULL),
686 panel_layout_manager_(NULL),
687 touch_hud_debug_(NULL),
688 touch_hud_projection_(NULL) {
[email protected]f5c9dbc2014-04-11 08:13:45689 aura::Window* root_window = GetRootWindow();
690 GetRootWindowSettings(root_window)->controller = this;
[email protected]a273d33a2013-10-17 12:41:21691
692 stacking_controller_.reset(new StackingController);
[email protected]f5c9dbc2014-04-11 08:13:45693 aura::client::SetWindowTreeClient(root_window, stacking_controller_.get());
694 capture_client_.reset(new ::wm::ScopedCaptureClient(root_window));
[email protected]a273d33a2013-10-17 12:41:21695}
696
[email protected]608de6c2013-10-29 00:14:28697void RootWindowController::Init(RootWindowType root_window_type,
698 bool first_run_after_boot) {
[email protected]f5c9dbc2014-04-11 08:13:45699 aura::Window* root_window = GetRootWindow();
[email protected]51f438112013-11-18 19:32:50700 Shell* shell = Shell::GetInstance();
[email protected]f5c9dbc2014-04-11 08:13:45701 shell->InitRootWindow(root_window);
[email protected]a273d33a2013-10-17 12:41:21702
[email protected]f5c9dbc2014-04-11 08:13:45703 CreateContainersInRootWindow(root_window);
[email protected]608de6c2013-10-29 00:14:28704
[email protected]a273d33a2013-10-17 12:41:21705 CreateSystemBackground(first_run_after_boot);
706
707 InitLayoutManagers();
708 InitTouchHuds();
709
710 if (Shell::GetPrimaryRootWindowController()->
711 GetSystemModalLayoutManager(NULL)->has_modal_background()) {
712 GetSystemModalLayoutManager(NULL)->CreateModalBackground();
713 }
714
[email protected]a273d33a2013-10-17 12:41:21715 shell->AddShellObserver(this);
716
[email protected]608de6c2013-10-29 00:14:28717 if (root_window_type == PRIMARY) {
[email protected]a3565792013-10-18 12:52:37718 root_window_layout()->OnWindowResized();
bshe9858b4a2014-09-16 20:46:38719 shell->InitKeyboard();
[email protected]a273d33a2013-10-17 12:41:21720 } else {
721 root_window_layout()->OnWindowResized();
[email protected]f5c9dbc2014-04-11 08:13:45722 ash_host_->AsWindowTreeHost()->Show();
[email protected]a273d33a2013-10-17 12:41:21723
[email protected]864b58552013-12-19 04:19:38724 // Create a shelf if a user is already logged in.
[email protected]a273d33a2013-10-17 12:41:21725 if (shell->session_state_delegate()->NumberOfLoggedInUsers())
[email protected]864b58552013-12-19 04:19:38726 shelf()->CreateShelf();
[email protected]0e3e7cb2014-04-12 05:18:25727
728 // Notify shell observers about new root window.
729 shell->OnRootWindowAdded(root_window);
[email protected]a273d33a2013-10-17 12:41:21730 }
[email protected]a825e8312014-05-05 22:05:01731
732#if defined(OS_CHROMEOS)
pgal.u-szegedd84534d32014-10-29 12:34:30733 if (!base::CommandLine::ForCurrentProcess()->HasSwitch(
[email protected]2e0b2352014-07-28 13:28:28734 switches::kAshDisableTouchExplorationMode)) {
[email protected]7d487592014-07-24 03:54:50735 touch_exploration_manager_.reset(new AshTouchExplorationManager(this));
[email protected]a825e8312014-05-05 22:05:01736 }
737#endif
[email protected]a273d33a2013-10-17 12:41:21738}
739
[email protected]756bda12013-07-03 08:17:06740void RootWindowController::InitLayoutManagers() {
[email protected]f5c9dbc2014-04-11 08:13:45741 aura::Window* root_window = GetRootWindow();
742 root_window_layout_ = new RootWindowLayoutManager(root_window);
743 root_window->SetLayoutManager(root_window_layout_);
[email protected]756bda12013-07-03 08:17:06744
745 aura::Window* default_container =
746 GetContainer(kShellWindowId_DefaultContainer);
747 // Workspace manager has its own layout managers.
sky1e30f062016-04-14 21:19:16748
749 WorkspaceLayoutManagerDelegateImpl* workspace_layout_manager_delegate =
750 new WorkspaceLayoutManagerDelegateImpl(root_window);
751 workspace_controller_.reset(new WorkspaceController(
752 default_container, base::WrapUnique(workspace_layout_manager_delegate)));
[email protected]756bda12013-07-03 08:17:06753
sky4dc7d0492016-04-28 04:15:22754 wm::WmWindow* always_on_top_container =
755 wm::WmWindowAura::Get(GetContainer(kShellWindowId_AlwaysOnTopContainer));
rsadam7bd510bb2014-12-09 20:10:56756 always_on_top_controller_.reset(
757 new AlwaysOnTopController(always_on_top_container));
[email protected]756bda12013-07-03 08:17:06758
759 DCHECK(!shelf_.get());
[email protected]093b8d642014-04-03 20:59:28760 aura::Window* shelf_container = GetContainer(kShellWindowId_ShelfContainer);
[email protected]756bda12013-07-03 08:17:06761 // TODO(harrym): Remove when status area is view.
[email protected]093b8d642014-04-03 20:59:28762 aura::Window* status_container = GetContainer(kShellWindowId_StatusContainer);
[email protected]756bda12013-07-03 08:17:06763 shelf_.reset(new ShelfWidget(
764 shelf_container, status_container, workspace_controller()));
sky1e30f062016-04-14 21:19:16765 workspace_layout_manager_delegate->set_shelf(shelf_->shelf_layout_manager());
[email protected]756bda12013-07-03 08:17:06766
[email protected]cf6fea22013-08-07 14:24:01767 if (!Shell::GetInstance()->session_state_delegate()->
768 IsActiveUserSessionStarted()) {
769 // This window exists only to be a event target on login screen.
770 // It does not have to handle events, nor be visible.
771 mouse_event_target_.reset(new aura::Window(new EmptyWindowDelegate));
danakjb161836d2015-04-03 05:14:18772 mouse_event_target_->Init(ui::LAYER_NOT_DRAWN);
[email protected]cf6fea22013-08-07 14:24:01773
774 aura::Window* lock_background_container =
[email protected]093b8d642014-04-03 20:59:28775 GetContainer(kShellWindowId_LockScreenBackgroundContainer);
[email protected]cf6fea22013-08-07 14:24:01776 lock_background_container->AddChild(mouse_event_target_.get());
777 mouse_event_target_->Show();
778 }
779
[email protected]756bda12013-07-03 08:17:06780 // Create Docked windows layout manager
sky3f7af8812016-04-21 19:30:03781 wm::WmWindow* docked_container =
782 wm::WmWindowAura::Get(GetContainer(kShellWindowId_DockedContainer));
skyca4122692016-04-26 04:47:57783 docked_layout_manager_ = new DockedWindowLayoutManager(docked_container);
sky3f7af8812016-04-21 19:30:03784 docked_container->SetLayoutManager(base::WrapUnique(docked_layout_manager_));
[email protected]756bda12013-07-03 08:17:06785
[email protected]1ca79d42014-07-18 16:26:10786 // Installs SnapLayoutManager to containers who set the
787 // |kSnapsChildrenToPhysicalPixelBoundary| property.
788 wm::InstallSnapLayoutManagerToContainers(root_window);
789
[email protected]756bda12013-07-03 08:17:06790 // Create Panel layout manager
[email protected]093b8d642014-04-03 20:59:28791 aura::Window* panel_container = GetContainer(kShellWindowId_PanelContainer);
skyad0315022016-04-25 19:40:31792 wm::WmWindow* wm_panel_container = wm::WmWindowAura::Get(panel_container);
793 panel_layout_manager_ = new PanelLayoutManager(wm_panel_container);
794 wm_panel_container->SetLayoutManager(base::WrapUnique(panel_layout_manager_));
[email protected]3537d472014-01-15 05:45:31795 panel_container_handler_.reset(new PanelWindowEventHandler);
796 panel_container->AddPreTargetHandler(panel_container_handler_.get());
[email protected]b8642ec2014-04-17 05:20:39797
798 // Install an AttachedPanelWindowTargeter on the panel container to make it
799 // easier to correctly target shelf buttons with touch.
800 gfx::Insets mouse_extend(-kResizeOutsideBoundsSize,
801 -kResizeOutsideBoundsSize,
802 -kResizeOutsideBoundsSize,
803 -kResizeOutsideBoundsSize);
804 gfx::Insets touch_extend = mouse_extend.Scale(
805 kResizeOutsideBoundsScaleForTouch);
dchenga94547472016-04-08 08:41:11806 panel_container->SetEventTargeter(
807 std::unique_ptr<ui::EventTargeter>(new AttachedPanelWindowTargeter(
808 panel_container, mouse_extend, touch_extend, panel_layout_manager_)));
[email protected]756bda12013-07-03 08:17:06809}
810
811void RootWindowController::InitTouchHuds() {
pgal.u-szegedd84534d32014-10-29 12:34:30812 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess();
[email protected]756bda12013-07-03 08:17:06813 if (command_line->HasSwitch(switches::kAshTouchHud))
[email protected]f5c9dbc2014-04-11 08:13:45814 set_touch_hud_debug(new TouchHudDebug(GetRootWindow()));
[email protected]756bda12013-07-03 08:17:06815 if (Shell::GetInstance()->is_touch_hud_projection_enabled())
816 EnableTouchHudProjection();
817}
818
819void RootWindowController::CreateSystemBackground(
820 bool is_first_run_after_boot) {
821 SkColor color = SK_ColorBLACK;
822#if defined(OS_CHROMEOS)
823 if (is_first_run_after_boot)
824 color = kChromeOsBootColor;
825#endif
826 system_background_.reset(
[email protected]f5c9dbc2014-04-11 08:13:45827 new SystemBackgroundController(GetRootWindow(), color));
[email protected]756bda12013-07-03 08:17:06828
829#if defined(OS_CHROMEOS)
830 // Make a copy of the system's boot splash screen so we can composite it
831 // onscreen until the desktop background is ready.
832 if (is_first_run_after_boot &&
pgal.u-szegedd84534d32014-10-29 12:34:30833 (base::CommandLine::ForCurrentProcess()->HasSwitch(
[email protected]756bda12013-07-03 08:17:06834 switches::kAshCopyHostBackgroundAtBoot) ||
pgal.u-szegedd84534d32014-10-29 12:34:30835 base::CommandLine::ForCurrentProcess()->HasSwitch(
[email protected]756bda12013-07-03 08:17:06836 switches::kAshAnimateFromBootSplashScreen)))
[email protected]f5c9dbc2014-04-11 08:13:45837 boot_splash_screen_.reset(new BootSplashScreen(GetHost()));
[email protected]756bda12013-07-03 08:17:06838#endif
839}
840
[email protected]a4cd6d32012-09-12 03:42:13841void RootWindowController::CreateContainersInRootWindow(
[email protected]41baaed2013-11-09 04:18:26842 aura::Window* root_window) {
[email protected]a4cd6d32012-09-12 03:42:13843 // These containers are just used by PowerButtonController to animate groups
844 // of containers simultaneously without messing up the current transformations
845 // on those containers. These are direct children of the root window; all of
846 // the other containers are their children.
[email protected]e6e41d2f2012-10-29 19:22:19847
848 // The desktop background container is not part of the lock animation, so it
849 // is not included in those animate groups.
[email protected]a4cd6d32012-09-12 03:42:13850 // When screen is locked desktop background is moved to lock screen background
851 // container (moved back on unlock). We want to make sure that there's an
852 // opaque layer occluding the non-lock-screen layers.
[email protected]e6e41d2f2012-10-29 19:22:19853 aura::Window* desktop_background_container = CreateContainer(
[email protected]c0ce80e2012-10-05 23:28:27854 kShellWindowId_DesktopBackgroundContainer,
[email protected]a4cd6d32012-09-12 03:42:13855 "DesktopBackgroundContainer",
856 root_window);
[email protected]e319c7e2014-03-14 19:56:14857 ::wm::SetChildWindowVisibilityChangesAnimated(desktop_background_container);
[email protected]a4cd6d32012-09-12 03:42:13858
859 aura::Window* non_lock_screen_containers = CreateContainer(
[email protected]c0ce80e2012-10-05 23:28:27860 kShellWindowId_NonLockScreenContainersContainer,
[email protected]a4cd6d32012-09-12 03:42:13861 "NonLockScreenContainersContainer",
862 root_window);
oshimaf52e1be2015-05-06 21:29:34863 // Clip all windows inside this container, as half pixel of the window's
864 // texture may become visible when the screen is scaled. crbug.com/368591.
865 non_lock_screen_containers->layer()->SetMasksToBounds(true);
[email protected]a4cd6d32012-09-12 03:42:13866
867 aura::Window* lock_background_containers = CreateContainer(
[email protected]c0ce80e2012-10-05 23:28:27868 kShellWindowId_LockScreenBackgroundContainer,
[email protected]a4cd6d32012-09-12 03:42:13869 "LockScreenBackgroundContainer",
870 root_window);
[email protected]e319c7e2014-03-14 19:56:14871 ::wm::SetChildWindowVisibilityChangesAnimated(lock_background_containers);
[email protected]a4cd6d32012-09-12 03:42:13872
873 aura::Window* lock_screen_containers = CreateContainer(
[email protected]c0ce80e2012-10-05 23:28:27874 kShellWindowId_LockScreenContainersContainer,
[email protected]a4cd6d32012-09-12 03:42:13875 "LockScreenContainersContainer",
876 root_window);
877 aura::Window* lock_screen_related_containers = CreateContainer(
[email protected]c0ce80e2012-10-05 23:28:27878 kShellWindowId_LockScreenRelatedContainersContainer,
[email protected]a4cd6d32012-09-12 03:42:13879 "LockScreenRelatedContainersContainer",
880 root_window);
881
[email protected]c0ce80e2012-10-05 23:28:27882 CreateContainer(kShellWindowId_UnparentedControlContainer,
[email protected]a4cd6d32012-09-12 03:42:13883 "UnparentedControlContainer",
884 non_lock_screen_containers);
885
886 aura::Window* default_container = CreateContainer(
[email protected]c0ce80e2012-10-05 23:28:27887 kShellWindowId_DefaultContainer,
[email protected]a4cd6d32012-09-12 03:42:13888 "DefaultContainer",
889 non_lock_screen_containers);
[email protected]e319c7e2014-03-14 19:56:14890 ::wm::SetChildWindowVisibilityChangesAnimated(default_container);
[email protected]1ca79d42014-07-18 16:26:10891 wm::SetSnapsChildrenToPhysicalPixelBoundary(default_container);
[email protected]a4cd6d32012-09-12 03:42:13892 SetUsesScreenCoordinates(default_container);
[email protected]c5be8d672014-01-07 13:33:41893 SetUsesEasyResizeTargeter(default_container);
[email protected]a4cd6d32012-09-12 03:42:13894
895 aura::Window* always_on_top_container = CreateContainer(
[email protected]c0ce80e2012-10-05 23:28:27896 kShellWindowId_AlwaysOnTopContainer,
[email protected]a4cd6d32012-09-12 03:42:13897 "AlwaysOnTopContainer",
898 non_lock_screen_containers);
[email protected]e319c7e2014-03-14 19:56:14899 ::wm::SetChildWindowVisibilityChangesAnimated(always_on_top_container);
[email protected]1ca79d42014-07-18 16:26:10900 wm::SetSnapsChildrenToPhysicalPixelBoundary(always_on_top_container);
[email protected]a4cd6d32012-09-12 03:42:13901 SetUsesScreenCoordinates(always_on_top_container);
902
[email protected]beb4e5c2013-06-18 15:37:07903 aura::Window* docked_container = CreateContainer(
904 kShellWindowId_DockedContainer,
905 "DockedContainer",
906 non_lock_screen_containers);
[email protected]e319c7e2014-03-14 19:56:14907 ::wm::SetChildWindowVisibilityChangesAnimated(docked_container);
[email protected]1ca79d42014-07-18 16:26:10908 wm::SetSnapsChildrenToPhysicalPixelBoundary(docked_container);
[email protected]beb4e5c2013-06-18 15:37:07909 SetUsesScreenCoordinates(docked_container);
[email protected]1ff0c492014-01-21 20:20:44910 SetUsesEasyResizeTargeter(docked_container);
[email protected]beb4e5c2013-06-18 15:37:07911
[email protected]3f13cf12013-07-12 05:13:59912 aura::Window* shelf_container =
[email protected]478c6c32013-03-09 02:50:58913 CreateContainer(kShellWindowId_ShelfContainer,
[email protected]3f13cf12013-07-12 05:13:59914 "ShelfContainer",
[email protected]a4cd6d32012-09-12 03:42:13915 non_lock_screen_containers);
[email protected]1ca79d42014-07-18 16:26:10916 wm::SetSnapsChildrenToPhysicalPixelBoundary(shelf_container);
[email protected]3f13cf12013-07-12 05:13:59917 SetUsesScreenCoordinates(shelf_container);
918 DescendantShouldStayInSameRootWindow(shelf_container);
[email protected]a4cd6d32012-09-12 03:42:13919
[email protected]f2026eb2013-10-22 14:28:56920 aura::Window* panel_container = CreateContainer(
921 kShellWindowId_PanelContainer,
922 "PanelContainer",
923 non_lock_screen_containers);
[email protected]1ca79d42014-07-18 16:26:10924 wm::SetSnapsChildrenToPhysicalPixelBoundary(panel_container);
[email protected]f2026eb2013-10-22 14:28:56925 SetUsesScreenCoordinates(panel_container);
926
927 aura::Window* shelf_bubble_container =
928 CreateContainer(kShellWindowId_ShelfBubbleContainer,
929 "ShelfBubbleContainer",
930 non_lock_screen_containers);
[email protected]1ca79d42014-07-18 16:26:10931 wm::SetSnapsChildrenToPhysicalPixelBoundary(shelf_bubble_container);
[email protected]f2026eb2013-10-22 14:28:56932 SetUsesScreenCoordinates(shelf_bubble_container);
933 DescendantShouldStayInSameRootWindow(shelf_bubble_container);
934
[email protected]dc851a4e52012-10-03 00:05:55935 aura::Window* app_list_container =
[email protected]c0ce80e2012-10-05 23:28:27936 CreateContainer(kShellWindowId_AppListContainer,
[email protected]dc851a4e52012-10-03 00:05:55937 "AppListContainer",
938 non_lock_screen_containers);
[email protected]1ca79d42014-07-18 16:26:10939 wm::SetSnapsChildrenToPhysicalPixelBoundary(app_list_container);
[email protected]dc851a4e52012-10-03 00:05:55940 SetUsesScreenCoordinates(app_list_container);
[email protected]a4cd6d32012-09-12 03:42:13941
942 aura::Window* modal_container = CreateContainer(
[email protected]c0ce80e2012-10-05 23:28:27943 kShellWindowId_SystemModalContainer,
[email protected]a4cd6d32012-09-12 03:42:13944 "SystemModalContainer",
945 non_lock_screen_containers);
[email protected]1ca79d42014-07-18 16:26:10946 wm::SetSnapsChildrenToPhysicalPixelBoundary(modal_container);
[email protected]a4cd6d32012-09-12 03:42:13947 modal_container->SetLayoutManager(
[email protected]c0ce80e2012-10-05 23:28:27948 new SystemModalContainerLayoutManager(modal_container));
[email protected]e319c7e2014-03-14 19:56:14949 ::wm::SetChildWindowVisibilityChangesAnimated(modal_container);
[email protected]a4cd6d32012-09-12 03:42:13950 SetUsesScreenCoordinates(modal_container);
[email protected]c5be8d672014-01-07 13:33:41951 SetUsesEasyResizeTargeter(modal_container);
[email protected]a4cd6d32012-09-12 03:42:13952
[email protected]a4cd6d32012-09-12 03:42:13953 // TODO(beng): Figure out if we can make this use
954 // SystemModalContainerEventFilter instead of stops_event_propagation.
955 aura::Window* lock_container = CreateContainer(
[email protected]c0ce80e2012-10-05 23:28:27956 kShellWindowId_LockScreenContainer,
[email protected]a4cd6d32012-09-12 03:42:13957 "LockScreenContainer",
958 lock_screen_containers);
[email protected]1ca79d42014-07-18 16:26:10959 wm::SetSnapsChildrenToPhysicalPixelBoundary(lock_container);
oshima96f6a502015-05-02 08:43:32960 lock_container->SetLayoutManager(new LockLayoutManager(lock_container));
[email protected]a4cd6d32012-09-12 03:42:13961 SetUsesScreenCoordinates(lock_container);
962 // TODO(beng): stopsevents
963
964 aura::Window* lock_modal_container = CreateContainer(
[email protected]c0ce80e2012-10-05 23:28:27965 kShellWindowId_LockSystemModalContainer,
[email protected]a4cd6d32012-09-12 03:42:13966 "LockSystemModalContainer",
967 lock_screen_containers);
[email protected]1ca79d42014-07-18 16:26:10968 wm::SetSnapsChildrenToPhysicalPixelBoundary(lock_modal_container);
[email protected]a4cd6d32012-09-12 03:42:13969 lock_modal_container->SetLayoutManager(
[email protected]c0ce80e2012-10-05 23:28:27970 new SystemModalContainerLayoutManager(lock_modal_container));
[email protected]e319c7e2014-03-14 19:56:14971 ::wm::SetChildWindowVisibilityChangesAnimated(lock_modal_container);
[email protected]a4cd6d32012-09-12 03:42:13972 SetUsesScreenCoordinates(lock_modal_container);
[email protected]c5be8d672014-01-07 13:33:41973 SetUsesEasyResizeTargeter(lock_modal_container);
[email protected]a4cd6d32012-09-12 03:42:13974
975 aura::Window* status_container =
[email protected]c0ce80e2012-10-05 23:28:27976 CreateContainer(kShellWindowId_StatusContainer,
[email protected]a4cd6d32012-09-12 03:42:13977 "StatusContainer",
978 lock_screen_related_containers);
[email protected]1ca79d42014-07-18 16:26:10979 wm::SetSnapsChildrenToPhysicalPixelBoundary(status_container);
[email protected]a4cd6d32012-09-12 03:42:13980 SetUsesScreenCoordinates(status_container);
[email protected]e887c6c2013-07-08 19:35:53981 DescendantShouldStayInSameRootWindow(status_container);
[email protected]a4cd6d32012-09-12 03:42:13982
983 aura::Window* settings_bubble_container = CreateContainer(
[email protected]c0ce80e2012-10-05 23:28:27984 kShellWindowId_SettingBubbleContainer,
[email protected]a4cd6d32012-09-12 03:42:13985 "SettingBubbleContainer",
986 lock_screen_related_containers);
[email protected]e319c7e2014-03-14 19:56:14987 ::wm::SetChildWindowVisibilityChangesAnimated(settings_bubble_container);
[email protected]1ca79d42014-07-18 16:26:10988 wm::SetSnapsChildrenToPhysicalPixelBoundary(settings_bubble_container);
[email protected]a4cd6d32012-09-12 03:42:13989 SetUsesScreenCoordinates(settings_bubble_container);
[email protected]e887c6c2013-07-08 19:35:53990 DescendantShouldStayInSameRootWindow(settings_bubble_container);
[email protected]a4cd6d32012-09-12 03:42:13991
kevers23f3987d2014-09-17 13:50:12992 aura::Window* virtual_keyboard_parent_container =
bshec3875422014-09-29 13:21:30993 CreateContainer(kShellWindowId_ImeWindowParentContainer,
kevers23f3987d2014-09-17 13:50:12994 "VirtualKeyboardParentContainer",
995 lock_screen_related_containers);
996 wm::SetSnapsChildrenToPhysicalPixelBoundary(
997 virtual_keyboard_parent_container);
998 SetUsesScreenCoordinates(virtual_keyboard_parent_container);
999
[email protected]a4cd6d32012-09-12 03:42:131000 aura::Window* menu_container = CreateContainer(
[email protected]c0ce80e2012-10-05 23:28:271001 kShellWindowId_MenuContainer,
[email protected]a4cd6d32012-09-12 03:42:131002 "MenuContainer",
1003 lock_screen_related_containers);
[email protected]e319c7e2014-03-14 19:56:141004 ::wm::SetChildWindowVisibilityChangesAnimated(menu_container);
[email protected]1ca79d42014-07-18 16:26:101005 wm::SetSnapsChildrenToPhysicalPixelBoundary(menu_container);
[email protected]a4cd6d32012-09-12 03:42:131006 SetUsesScreenCoordinates(menu_container);
1007
1008 aura::Window* drag_drop_container = CreateContainer(
[email protected]c0ce80e2012-10-05 23:28:271009 kShellWindowId_DragImageAndTooltipContainer,
[email protected]a4cd6d32012-09-12 03:42:131010 "DragImageAndTooltipContainer",
1011 lock_screen_related_containers);
[email protected]e319c7e2014-03-14 19:56:141012 ::wm::SetChildWindowVisibilityChangesAnimated(drag_drop_container);
[email protected]1ca79d42014-07-18 16:26:101013 wm::SetSnapsChildrenToPhysicalPixelBoundary(drag_drop_container);
[email protected]a4cd6d32012-09-12 03:42:131014 SetUsesScreenCoordinates(drag_drop_container);
1015
1016 aura::Window* overlay_container = CreateContainer(
[email protected]c0ce80e2012-10-05 23:28:271017 kShellWindowId_OverlayContainer,
[email protected]a4cd6d32012-09-12 03:42:131018 "OverlayContainer",
1019 lock_screen_related_containers);
[email protected]1ca79d42014-07-18 16:26:101020 wm::SetSnapsChildrenToPhysicalPixelBoundary(overlay_container);
[email protected]a4cd6d32012-09-12 03:42:131021 SetUsesScreenCoordinates(overlay_container);
[email protected]a07615f2012-10-24 08:23:081022
[email protected]b2da9b602014-03-05 18:39:521023#if defined(OS_CHROMEOS)
1024 aura::Window* mouse_cursor_container = CreateContainer(
1025 kShellWindowId_MouseCursorContainer,
1026 "MouseCursorContainer",
1027 root_window);
1028 SetUsesScreenCoordinates(mouse_cursor_container);
1029#endif
1030
[email protected]a07615f2012-10-24 08:23:081031 CreateContainer(kShellWindowId_PowerButtonAnimationContainer,
[email protected]b2da9b602014-03-05 18:39:521032 "PowerButtonAnimationContainer", root_window);
[email protected]a4cd6d32012-09-12 03:42:131033}
1034
[email protected]d141b922013-07-09 08:13:171035void RootWindowController::EnableTouchHudProjection() {
1036 if (touch_hud_projection_)
1037 return;
[email protected]f5c9dbc2014-04-11 08:13:451038 set_touch_hud_projection(new TouchHudProjection(GetRootWindow()));
[email protected]d141b922013-07-09 08:13:171039}
1040
1041void RootWindowController::DisableTouchHudProjection() {
1042 if (!touch_hud_projection_)
1043 return;
1044 touch_hud_projection_->Remove();
1045}
1046
jonrossa90d8982016-05-16 18:14:251047void RootWindowController::OnMenuClosed() {
1048 menu_runner_.reset();
1049 menu_model_adapter_.reset();
1050 menu_model_.reset();
1051 Shell::GetInstance()->UpdateShelfVisibility();
1052}
1053
[email protected]d141b922013-07-09 08:13:171054void RootWindowController::OnLoginStateChanged(user::LoginStatus status) {
1055 shelf_->shelf_layout_manager()->UpdateVisibilityState();
1056}
1057
1058void RootWindowController::OnTouchHudProjectionToggled(bool enabled) {
1059 if (enabled)
1060 EnableTouchHudProjection();
1061 else
1062 DisableTouchHudProjection();
1063}
1064
[email protected]6b2d4a0b2013-09-06 06:29:541065RootWindowController* GetRootWindowController(
[email protected]bf9cdb362013-10-25 19:22:451066 const aura::Window* root_window) {
jamescook5d74ac02016-05-12 19:57:121067 if (!root_window)
1068 return nullptr;
1069
1070 if (Shell::GetInstance()->in_mus()) {
1071 // On mus, like desktop aura, each top-level widget has its own root window,
1072 // so |root_window| is not necessarily the display's root. For now, just
1073 // the use the primary display root.
1074 // TODO(jamescook): Multi-display support. This depends on how mus windows
1075 // will be owned by displays.
1076 aura::Window* primary_root_window = Shell::GetInstance()
1077 ->window_tree_host_manager()
1078 ->GetPrimaryRootWindow();
1079 return GetRootWindowSettings(primary_root_window)->controller;
1080 }
1081
1082 return GetRootWindowSettings(root_window)->controller;
[email protected]6b2d4a0b2013-09-06 06:29:541083}
1084
[email protected]d90b8392012-06-13 09:34:561085} // namespace ash