blob: 805191e08cf2cea62690f34cbf6e687dd5ef8c07 [file] [log] [blame]
[email protected]e0d22e82012-01-04 00:46:571// Copyright (c) 2012 The Chromium Authors. All rights reserved.
[email protected]87b0d82e2011-10-07 21:02:592// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
[email protected]b65bdda2011-12-23 23:35:315#include "ash/shell.h"
[email protected]87b0d82e2011-10-07 21:02:596
[email protected]f7eb89c2011-12-13 09:48:547#include <algorithm>
[email protected]0039db92012-05-09 04:11:458#include <string>
[email protected]f7eb89c2011-12-13 09:48:549
[email protected]e7293fa2012-05-17 04:42:3310#include "ash/accelerators/focus_manager_factory.h"
[email protected]b65bdda2011-12-23 23:35:3111#include "ash/ash_switches.h"
[email protected]e70cf0ed2012-03-15 16:24:4712#include "ash/desktop_background/desktop_background_controller.h"
13#include "ash/desktop_background/desktop_background_resources.h"
14#include "ash/desktop_background/desktop_background_view.h"
[email protected]2f744282011-12-23 22:40:5215#include "ash/drag_drop/drag_drop_controller.h"
[email protected]3d29912a2012-02-07 07:41:5116#include "ash/focus_cycler.h"
[email protected]f48075d2012-05-24 11:06:5117#include "ash/high_contrast/high_contrast_controller.h"
[email protected]7634f962011-12-23 21:35:5218#include "ash/launcher/launcher.h"
[email protected]c1c670172012-04-26 04:20:2619#include "ash/magnifier/magnification_controller.h"
[email protected]2e236a52012-06-27 22:21:4720#include "ash/display/display_controller.h"
21#include "ash/display/mouse_cursor_event_filter.h"
22#include "ash/display/multi_display_manager.h"
[email protected]8d625fb2012-07-18 16:40:0623#include "ash/display/screen_position_controller.h"
[email protected]2e236a52012-06-27 22:21:4724#include "ash/display/secondary_display_view.h"
[email protected]d90b8392012-06-13 09:34:5625#include "ash/root_window_controller.h"
[email protected]1a2145b2012-03-13 21:09:1726#include "ash/screen_ash.h"
[email protected]0cfc18e2012-04-11 18:17:4727#include "ash/shell_context_menu.h"
[email protected]b65bdda2011-12-23 23:35:3128#include "ash/shell_delegate.h"
29#include "ash/shell_factory.h"
30#include "ash/shell_window_ids.h"
[email protected]6d6546e2012-05-30 23:12:0231#include "ash/system/status_area_widget.h"
[email protected]bfb411312012-02-27 20:59:2732#include "ash/system/tray/system_tray.h"
[email protected]2f744282011-12-23 22:40:5233#include "ash/tooltips/tooltip_controller.h"
[email protected]73074742012-05-17 01:44:4134#include "ash/touch/touch_observer_hud.h"
[email protected]7634f962011-12-23 21:35:5235#include "ash/wm/activation_controller.h"
[email protected]f059c6942012-07-21 14:27:5736#include "ash/wm/always_on_top_controller.h"
[email protected]0039db92012-05-09 04:11:4537#include "ash/wm/app_list_controller.h"
[email protected]8812588c2012-01-30 21:19:0338#include "ash/wm/base_layout_manager.h"
[email protected]60a978b72012-06-08 00:29:1839#include "ash/wm/capture_controller.h"
[email protected]9d4d1712012-03-06 06:55:2540#include "ash/wm/custom_frame_view_ash.h"
[email protected]57b8bb352012-01-11 05:11:4641#include "ash/wm/dialog_frame_view.h"
[email protected]262f8bd2012-03-23 19:30:2742#include "ash/wm/event_client_impl.h"
[email protected]b9d224c2012-07-13 01:09:0343#include "ash/wm/event_rewriter_event_filter.h"
[email protected]9ae32df2012-07-26 03:25:1844#include "ash/wm/overlay_event_filter.h"
[email protected]6b854932012-02-04 16:44:2745#include "ash/wm/panel_layout_manager.h"
[email protected]c7839552012-04-03 21:14:3646#include "ash/wm/panel_window_event_filter.h"
[email protected]e0d22e82012-01-04 00:46:5747#include "ash/wm/power_button_controller.h"
[email protected]7ae525002012-07-26 23:55:1048#include "ash/wm/property_util.h"
[email protected]e4a181cc2012-03-17 02:20:5749#include "ash/wm/resize_shadow_controller.h"
[email protected]a3301dc2011-12-23 16:34:5150#include "ash/wm/root_window_layout_manager.h"
[email protected]42993212012-04-30 23:42:0451#include "ash/wm/screen_dimmer.h"
[email protected]75859672011-12-23 01:04:5652#include "ash/wm/shadow_controller.h"
[email protected]7634f962011-12-23 21:35:5253#include "ash/wm/shelf_layout_manager.h"
[email protected]75859672011-12-23 01:04:5654#include "ash/wm/stacking_controller.h"
[email protected]7634f962011-12-23 21:35:5255#include "ash/wm/status_area_layout_manager.h"
[email protected]435b212e2012-04-05 19:43:3756#include "ash/wm/system_gesture_event_filter.h"
[email protected]4244d6992012-01-23 17:14:3357#include "ash/wm/system_modal_container_layout_manager.h"
[email protected]a3301dc2011-12-23 16:34:5158#include "ash/wm/toplevel_window_event_filter.h"
[email protected]c16b9422012-06-06 21:51:1159#include "ash/wm/user_activity_detector.h"
[email protected]9633a9d22012-01-21 16:40:5860#include "ash/wm/video_detector.h"
[email protected]ddd91e92012-01-27 16:03:4861#include "ash/wm/visibility_controller.h"
[email protected]40c4cbb2012-01-10 23:26:0762#include "ash/wm/window_cycle_controller.h"
[email protected]80373572012-01-06 23:14:3063#include "ash/wm/window_modality_controller.h"
[email protected]40c4cbb2012-01-10 23:26:0764#include "ash/wm/window_util.h"
[email protected]f059c6942012-07-21 14:27:5765#include "ash/wm/window_properties.h"
[email protected]9633a9d22012-01-21 16:40:5866#include "ash/wm/workspace/workspace_event_filter.h"
67#include "ash/wm/workspace/workspace_layout_manager.h"
[email protected]c7839552012-04-03 21:14:3668#include "ash/wm/workspace_controller.h"
[email protected]f296be72011-10-11 15:40:0069#include "base/bind.h"
[email protected]46ca3632011-11-03 03:33:4270#include "base/command_line.h"
[email protected]7c0c96f42012-03-14 01:04:2771#include "grit/ui_resources.h"
[email protected]2c456102011-12-26 06:26:3472#include "ui/aura/client/aura_constants.h"
[email protected]c28853612012-05-31 22:43:4473#include "ui/aura/client/user_action_client.h"
[email protected]8a45c972012-03-14 18:22:4474#include "ui/aura/env.h"
[email protected]a857dbe2012-05-30 22:10:1475#include "ui/aura/focus_manager.h"
[email protected]4bb16502011-12-06 14:44:5876#include "ui/aura/layout_manager.h"
[email protected]2e236a52012-06-27 22:21:4777#include "ui/aura/display_manager.h"
[email protected]2c456102011-12-26 06:26:3478#include "ui/aura/root_window.h"
[email protected]1aad3322012-06-06 06:37:0979#include "ui/aura/shared/compound_event_filter.h"
[email protected]0e46c272012-05-15 18:15:2380#include "ui/aura/shared/input_method_event_filter.h"
[email protected]536f8082012-03-16 09:30:3381#include "ui/aura/ui_controls_aura.h"
[email protected]87b0d82e2011-10-07 21:02:5982#include "ui/aura/window.h"
[email protected]116302fc2012-05-05 21:45:4183#include "ui/compositor/layer.h"
84#include "ui/compositor/layer_animator.h"
[email protected]7da9c4c2012-06-12 14:43:0185#include "ui/gfx/display.h"
[email protected]9ec0f452012-05-31 15:58:5386#include "ui/gfx/image/image_skia.h"
[email protected]b82c42c42012-04-25 20:03:4187#include "ui/gfx/screen.h"
[email protected]b0639282011-12-22 21:12:2788#include "ui/gfx/size.h"
[email protected]536f8082012-03-16 09:30:3389#include "ui/ui_controls/ui_controls.h"
[email protected]e7293fa2012-05-17 04:42:3390#include "ui/views/focus/focus_manager_factory.h"
[email protected]c13be0d2011-11-22 02:09:5891#include "ui/views/widget/native_widget_aura.h"
92#include "ui/views/widget/widget.h"
[email protected]87b0d82e2011-10-07 21:02:5993
[email protected]6e9f6aa2012-02-09 04:16:2094#if !defined(OS_MACOSX)
95#include "ash/accelerators/accelerator_controller.h"
96#include "ash/accelerators/accelerator_filter.h"
97#include "ash/accelerators/nested_dispatcher_controller.h"
98#endif
99
[email protected]70b3e7d52012-06-02 22:12:25100#if defined(OS_CHROMEOS)
[email protected]196e9452012-08-01 06:42:51101#include "ash/display/output_configurator_animation.h"
[email protected]2e236a52012-06-27 22:21:47102#include "chromeos/display/output_configurator.h"
[email protected]70b3e7d52012-06-02 22:12:25103#include "ui/aura/dispatcher_linux.h"
104#endif // defined(OS_CHROMEOS)
105
[email protected]55f593352011-12-24 05:42:46106namespace ash {
[email protected]87b0d82e2011-10-07 21:02:59107
108namespace {
[email protected]671a2ae2011-10-13 21:53:23109
[email protected]615922f2012-02-07 02:41:15110using aura::Window;
[email protected]3f02dc52011-10-21 19:36:45111using views::Widget;
112
[email protected]10b22612012-03-22 17:07:55113// This dummy class is used for shell unit tests. We dont have chrome delegate
114// in these tests.
[email protected]5c543242012-03-24 16:25:42115class DummyUserWallpaperDelegate : public UserWallpaperDelegate {
[email protected]10b22612012-03-22 17:07:55116 public:
117 DummyUserWallpaperDelegate() {}
118
119 virtual ~DummyUserWallpaperDelegate() {}
120
[email protected]815d0c382012-07-21 08:13:44121 virtual ash::WindowVisibilityAnimationType GetAnimationType() OVERRIDE {
122 return WINDOW_VISIBILITY_ANIMATION_TYPE_FADE;
123 }
124
[email protected]0c4f87d2012-06-12 02:00:35125 virtual void InitializeWallpaper() OVERRIDE {
[email protected]d50034732012-06-04 19:11:04126 ash::Shell::GetInstance()->desktop_background_controller()->
127 CreateEmptyWallpaper();
[email protected]10b22612012-03-22 17:07:55128 }
129
[email protected]5c543242012-03-24 16:25:42130 virtual void OpenSetWallpaperPage() OVERRIDE {
131 }
132
[email protected]0cfc18e2012-04-11 18:17:47133 virtual bool CanOpenSetWallpaperPage() OVERRIDE {
134 return false;
135 }
136
[email protected]07a2fa62012-06-26 10:39:38137 virtual void OnWallpaperAnimationFinished() OVERRIDE {
138 }
139
[email protected]10b22612012-03-22 17:07:55140 private:
[email protected]0039db92012-05-09 04:11:45141 DISALLOW_COPY_AND_ASSIGN(DummyUserWallpaperDelegate);
[email protected]10b22612012-03-22 17:07:55142};
143
[email protected]87b0d82e2011-10-07 21:02:59144} // namespace
145
[email protected]cac10fc62011-10-07 23:22:56146// static
147Shell* Shell::instance_ = NULL;
[email protected]2b4cd302012-02-24 20:21:13148// static
[email protected]9488d4d2012-02-29 18:32:37149bool Shell::initially_hide_cursor_ = false;
[email protected]2b4cd302012-02-24 20:21:13150
151////////////////////////////////////////////////////////////////////////////////
152// Shell::TestApi
153
154Shell::TestApi::TestApi(Shell* shell) : shell_(shell) {}
155
[email protected]2b4cd302012-02-24 20:21:13156internal::RootWindowLayoutManager* Shell::TestApi::root_window_layout() {
[email protected]d90b8392012-06-13 09:34:56157 return shell_->GetPrimaryRootWindowController()->root_window_layout();
[email protected]2b4cd302012-02-24 20:21:13158}
[email protected]cac10fc62011-10-07 23:22:56159
[email protected]0e46c272012-05-15 18:15:23160aura::shared::InputMethodEventFilter*
161 Shell::TestApi::input_method_event_filter() {
[email protected]db9131602012-02-29 19:06:32162 return shell_->input_method_filter_.get();
163}
164
[email protected]435b212e2012-04-05 19:43:37165internal::SystemGestureEventFilter*
166 Shell::TestApi::system_gesture_event_filter() {
167 return shell_->system_gesture_filter_.get();
168}
169
[email protected]db9131602012-02-29 19:06:32170internal::WorkspaceController* Shell::TestApi::workspace_controller() {
[email protected]d90b8392012-06-13 09:34:56171 return shell_->GetPrimaryRootWindowController()->workspace_controller();
[email protected]db9131602012-02-29 19:06:32172}
173
[email protected]cac10fc62011-10-07 23:22:56174////////////////////////////////////////////////////////////////////////////////
175// Shell, public:
176
[email protected]3266c2b92011-11-14 00:06:08177Shell::Shell(ShellDelegate* delegate)
[email protected]d90b8392012-06-13 09:34:56178 : screen_(new ScreenAsh),
[email protected]be65be362012-06-15 07:38:23179 active_root_window_(NULL),
[email protected]1aad3322012-06-06 06:37:09180 env_filter_(NULL),
[email protected]9c66adc2012-01-05 02:10:16181 delegate_(delegate),
[email protected]70b3e7d52012-06-02 22:12:25182#if defined(OS_CHROMEOS)
[email protected]fb792f32012-08-01 01:07:01183 output_configurator_(new chromeos::OutputConfigurator(
184 internal::DisplayController::IsExtendedDesktopEnabled())),
[email protected]196e9452012-08-01 06:42:51185 output_configurator_animation_(
186 new internal::OutputConfiguratorAnimation()),
[email protected]70b3e7d52012-06-02 22:12:25187#endif // defined(OS_CHROMEOS)
[email protected]4e437632012-02-13 22:39:40188 shelf_(NULL),
[email protected]7cf8dd62012-04-22 05:14:58189 panel_layout_manager_(NULL),
[email protected]6d6546e2012-05-30 23:12:02190 status_area_widget_(NULL),
191 browser_context_(NULL) {
[email protected]1a2145b2012-03-13 21:09:17192 gfx::Screen::SetInstance(screen_);
[email protected]054b2d72012-06-08 04:52:25193 ui_controls::InstallUIControlsAura(internal::CreateUIControls());
[email protected]70b3e7d52012-06-02 22:12:25194#if defined(OS_CHROMEOS)
[email protected]196e9452012-08-01 06:42:51195 output_configurator_->AddObserver(output_configurator_animation_.get());
[email protected]70b3e7d52012-06-02 22:12:25196 static_cast<aura::DispatcherLinux*>(
197 aura::Env::GetInstance()->GetDispatcher())->AddDispatcherForRootWindow(
198 output_configurator());
199#endif // defined(OS_CHROMEOS)
[email protected]87b0d82e2011-10-07 21:02:59200}
201
202Shell::~Shell() {
[email protected]e7293fa2012-05-17 04:42:33203 views::FocusManagerFactory::Install(NULL);
[email protected]cb3b8b22012-06-27 23:26:37204
205 // Remove the focus from any window. This will prevent overhead and side
206 // effects (e.g. crashes) from changing focus during shutdown.
207 // See bug crbug.com/134502.
208 if (active_root_window_)
209 active_root_window_->GetFocusManager()->SetFocusedWindow(NULL, NULL);
210
[email protected]4b8003c2012-07-26 00:54:19211 cursor_manager_.set_delegate(NULL);
[email protected]e7293fa2012-05-17 04:42:33212
[email protected]9861f1752012-06-01 07:16:14213 // Please keep in same order as in Init() because it's easy to miss one.
[email protected]c16b9422012-06-06 21:51:11214 RemoveEnvEventFilter(user_activity_detector_.get());
[email protected]b9d224c2012-07-13 01:09:03215 RemoveEnvEventFilter(event_rewriter_filter_.get());
[email protected]9ae32df2012-07-26 03:25:18216 RemoveEnvEventFilter(overlay_filter_.get());
[email protected]1aad3322012-06-06 06:37:09217 RemoveEnvEventFilter(input_method_filter_.get());
218 RemoveEnvEventFilter(window_modality_controller_.get());
[email protected]78d96302012-06-22 00:58:07219 if (mouse_cursor_filter_.get())
220 RemoveEnvEventFilter(mouse_cursor_filter_.get());
[email protected]1aad3322012-06-06 06:37:09221 RemoveEnvEventFilter(system_gesture_filter_.get());
[email protected]6e9f6aa2012-02-09 04:16:20222#if !defined(OS_MACOSX)
[email protected]1aad3322012-06-06 06:37:09223 RemoveEnvEventFilter(accelerator_filter_.get());
[email protected]6e9f6aa2012-02-09 04:16:20224#endif
[email protected]73074742012-05-17 01:44:41225 if (touch_observer_hud_.get())
[email protected]1aad3322012-06-06 06:37:09226 RemoveEnvEventFilter(touch_observer_hud_.get());
[email protected]745816be2011-11-22 05:08:30227
[email protected]931f4f42012-02-10 23:49:42228 // TooltipController is deleted with the Shell so removing its references.
[email protected]1aad3322012-06-06 06:37:09229 RemoveEnvEventFilter(tooltip_controller_.get());
[email protected]ef589af2011-12-03 01:07:15230
[email protected]aa54218b2012-06-12 16:51:42231 // The status area needs to be shut down before the windows are destroyed.
232 status_area_widget_->Shutdown();
[email protected]bfb411312012-02-27 20:59:27233
[email protected]f5f3c752012-06-07 05:16:02234 // AppList needs to be released before shelf layout manager, which is
235 // destroyed with launcher container in the loop below. However, app list
236 // container is now on top of launcher container and released after it.
237 // TODO(xiyuan): Move it back when app list container is no longer needed.
238 app_list_controller_.reset();
239
[email protected]be65be362012-06-15 07:38:23240 // Destroy all child windows including widgets.
[email protected]2e236a52012-06-27 22:21:47241 display_controller_->CloseChildWindows();
[email protected]ef589af2011-12-03 01:07:15242
[email protected]40c4cbb2012-01-10 23:26:07243 // These need a valid Shell instance to clean up properly, so explicitly
244 // delete them before invalidating the instance.
[email protected]58482fa2012-03-02 14:57:39245 // Alphabetical.
[email protected]084b6bb2011-11-17 05:18:16246 drag_drop_controller_.reset();
[email protected]c1c670172012-04-26 04:20:26247 magnification_controller_.reset();
[email protected]aa476502012-05-01 18:03:19248 power_button_controller_.reset();
[email protected]e4a181cc2012-03-17 02:20:57249 resize_shadow_controller_.reset();
[email protected]58482fa2012-03-02 14:57:39250 shadow_controller_.reset();
[email protected]fd162f72012-04-14 03:24:53251 tooltip_controller_.reset();
[email protected]aa476502012-05-01 18:03:19252 window_cycle_controller_.reset();
[email protected]60a978b72012-06-08 00:29:18253 capture_controller_.reset();
[email protected]60a978b72012-06-08 00:29:18254 nested_dispatcher_controller_.reset();
[email protected]60a978b72012-06-08 00:29:18255 user_action_client_.reset();
[email protected]60a978b72012-06-08 00:29:18256 visibility_controller_.reset();
[email protected]084b6bb2011-11-17 05:18:16257
[email protected]be65be362012-06-15 07:38:23258 // This also deletes all RootWindows.
[email protected]2e236a52012-06-27 22:21:47259 display_controller_.reset();
[email protected]8d625fb2012-07-18 16:40:06260 screen_position_controller_.reset();
[email protected]d90b8392012-06-13 09:34:56261
[email protected]0a704f02012-02-15 17:49:43262 // Launcher widget has a InputMethodBridge that references to
263 // input_method_filter_'s input_method_. So explicitly release launcher_
264 // before input_method_filter_. And this needs to be after we delete all
265 // containers in case there are still live browser windows which access
266 // LauncherModel during close.
267 launcher_.reset();
268
[email protected]764864e2012-06-11 19:16:16269 // Delete the activation controller after other controllers and launcher
270 // because they might have registered ActivationChangeObserver.
[email protected]764864e2012-06-11 19:16:16271 activation_controller_.reset();
272
[email protected]488b42042011-11-15 00:20:18273 DCHECK(instance_ == this);
274 instance_ = NULL;
[email protected]70b3e7d52012-06-02 22:12:25275
276#if defined(OS_CHROMEOS)
[email protected]196e9452012-08-01 06:42:51277 output_configurator_->RemoveObserver(output_configurator_animation_.get());
[email protected]70b3e7d52012-06-02 22:12:25278 // Remove OutputConfigurator from Dispatcher.
279 static_cast<aura::DispatcherLinux*>(
280 aura::Env::GetInstance()->GetDispatcher())->RemoveDispatcherForRootWindow(
281 output_configurator());
282#endif // defined(OS_CHROMEOS)
[email protected]87b0d82e2011-10-07 21:02:59283}
284
[email protected]cac10fc62011-10-07 23:22:56285// static
[email protected]3266c2b92011-11-14 00:06:08286Shell* Shell::CreateInstance(ShellDelegate* delegate) {
287 CHECK(!instance_);
[email protected]2e236a52012-06-27 22:21:47288 aura::Env::GetInstance()->SetDisplayManager(
289 new internal::MultiDisplayManager());
[email protected]3266c2b92011-11-14 00:06:08290 instance_ = new Shell(delegate);
291 instance_->Init();
292 return instance_;
293}
294
295// static
[email protected]cac10fc62011-10-07 23:22:56296Shell* Shell::GetInstance() {
[email protected]3266c2b92011-11-14 00:06:08297 DCHECK(instance_);
[email protected]cac10fc62011-10-07 23:22:56298 return instance_;
299}
300
[email protected]6377a002011-11-10 20:26:47301// static
[email protected]b3b7bcd2012-03-06 19:35:45302bool Shell::HasInstance() {
303 return !!instance_;
304}
305
306// static
[email protected]ef589af2011-12-03 01:07:15307void Shell::DeleteInstance() {
[email protected]6377a002011-11-10 20:26:47308 delete instance_;
309 instance_ = NULL;
310}
311
[email protected]e73bd7802012-02-17 20:10:34312// static
[email protected]d90b8392012-06-13 09:34:56313internal::RootWindowController* Shell::GetPrimaryRootWindowController() {
[email protected]7ae525002012-07-26 23:55:10314 return GetRootWindowController(GetPrimaryRootWindow());
[email protected]be65be362012-06-15 07:38:23315}
316
317// static
318Shell::RootWindowControllerList Shell::GetAllRootWindowControllers() {
[email protected]2e236a52012-06-27 22:21:47319 return Shell::GetInstance()->display_controller()->
[email protected]be65be362012-06-15 07:38:23320 GetAllRootWindowControllers();
[email protected]d90b8392012-06-13 09:34:56321}
322
323// static
[email protected]42713f72012-05-25 00:41:50324aura::RootWindow* Shell::GetPrimaryRootWindow() {
[email protected]2e236a52012-06-27 22:21:47325 return GetInstance()->display_controller()->GetPrimaryRootWindow();
[email protected]e73bd7802012-02-17 20:10:34326}
327
[email protected]7b0f7502012-06-11 00:12:39328// static
[email protected]a857dbe2012-05-30 22:10:14329aura::RootWindow* Shell::GetActiveRootWindow() {
330 return GetInstance()->active_root_window_;
331}
332
[email protected]7b0f7502012-06-11 00:12:39333// static
[email protected]f18e84522012-06-05 00:34:18334aura::RootWindow* Shell::GetRootWindowAt(const gfx::Point& point) {
[email protected]f1ddc1d2012-07-09 17:26:19335 const gfx::Display& display = gfx::Screen::GetDisplayNearestPoint(point);
336 return Shell::GetInstance()->display_controller()->
337 GetRootWindowForDisplayId(display.id());
[email protected]f18e84522012-06-05 00:34:18338}
339
[email protected]7b0f7502012-06-11 00:12:39340// static
[email protected]20c59762012-06-23 01:10:24341aura::RootWindow* Shell::GetRootWindowMatching(const gfx::Rect& rect) {
[email protected]f1ddc1d2012-07-09 17:26:19342 const gfx::Display& display = gfx::Screen::GetDisplayMatching(rect);
343 return Shell::GetInstance()->display_controller()->
344 GetRootWindowForDisplayId(display.id());
[email protected]20c59762012-06-23 01:10:24345}
346
347// static
[email protected]be65be362012-06-15 07:38:23348Shell::RootWindowList Shell::GetAllRootWindows() {
[email protected]2e236a52012-06-27 22:21:47349 return Shell::GetInstance()->display_controller()->
[email protected]be65be362012-06-15 07:38:23350 GetAllRootWindows();
351}
352
353// static
[email protected]7b0f7502012-06-11 00:12:39354aura::Window* Shell::GetContainer(aura::RootWindow* root_window,
355 int container_id) {
356 return root_window->GetChildById(container_id);
357}
358
359// static
360std::vector<aura::Window*> Shell::GetAllContainers(int container_id) {
361 // TODO(oshima): Support multiple root windows.
362 std::vector<aura::Window*> containers;
363 aura::Window* container = GetPrimaryRootWindow()->GetChildById(container_id);
364 if (container)
365 containers.push_back(container);
366 return containers;
367}
368
[email protected]87b0d82e2011-10-07 21:02:59369void Shell::Init() {
[email protected]c9301e32012-05-23 08:34:58370 // Install the custom factory first so that views::FocusManagers for Tray,
371 // Launcher, and WallPaper could be created by the factory.
372 views::FocusManagerFactory::Install(new AshFocusManagerFactory);
373
[email protected]1aad3322012-06-06 06:37:09374 env_filter_ = new aura::shared::CompoundEventFilter;
375 // Pass ownership of the filter to the Env.
376 aura::Env::GetInstance()->SetEventFilter(env_filter_);
377
[email protected]4b8003c2012-07-26 00:54:19378 cursor_manager_.set_delegate(this);
[email protected]a857dbe2012-05-30 22:10:14379
380 focus_manager_.reset(new aura::FocusManager);
[email protected]be65be362012-06-15 07:38:23381 activation_controller_.reset(
382 new internal::ActivationController(focus_manager_.get()));
383
[email protected]8d625fb2012-07-18 16:40:06384 screen_position_controller_.reset(new internal::ScreenPositionController);
[email protected]2e236a52012-06-27 22:21:47385 display_controller_.reset(new internal::DisplayController);
386 display_controller_->InitPrimaryDisplay();
387 aura::RootWindow* root_window = display_controller_->GetPrimaryRootWindow();
[email protected]be65be362012-06-15 07:38:23388 active_root_window_ = root_window;
[email protected]a857dbe2012-05-30 22:10:14389
[email protected]58482fa2012-03-02 14:57:39390#if !defined(OS_MACOSX)
391 nested_dispatcher_controller_.reset(new NestedDispatcherController);
392 accelerator_controller_.reset(new AcceleratorController);
393#endif
[email protected]0cfc18e2012-04-11 18:17:47394 shell_context_menu_.reset(new internal::ShellContextMenu);
[email protected]58482fa2012-03-02 14:57:39395
[email protected]c16b9422012-06-06 21:51:11396 // The order in which event filters are added is significant.
[email protected]1aad3322012-06-06 06:37:09397 DCHECK(!GetEnvEventFilterCount());
[email protected]c16b9422012-06-06 21:51:11398 user_activity_detector_.reset(new UserActivityDetector);
399 AddEnvEventFilter(user_activity_detector_.get());
400
401 DCHECK_EQ(1U, GetEnvEventFilterCount());
[email protected]b9d224c2012-07-13 01:09:03402 event_rewriter_filter_.reset(new internal::EventRewriterEventFilter);
403 AddEnvEventFilter(event_rewriter_filter_.get());
[email protected]0b0b0742012-02-16 13:23:45404
[email protected]c16b9422012-06-06 21:51:11405 DCHECK_EQ(2U, GetEnvEventFilterCount());
[email protected]9ae32df2012-07-26 03:25:18406 overlay_filter_.reset(new internal::OverlayEventFilter);
407 AddEnvEventFilter(overlay_filter_.get());
408 AddShellObserver(overlay_filter_.get());
[email protected]0b0b0742012-02-16 13:23:45409
[email protected]c16b9422012-06-06 21:51:11410 DCHECK_EQ(3U, GetEnvEventFilterCount());
[email protected]0caad5882012-06-03 15:07:06411 input_method_filter_.reset(new aura::shared::InputMethodEventFilter());
[email protected]1aad3322012-06-06 06:37:09412 AddEnvEventFilter(input_method_filter_.get());
[email protected]c16b9422012-06-06 21:51:11413
[email protected]21472b12012-02-17 00:30:05414#if !defined(OS_MACOSX)
415 accelerator_filter_.reset(new internal::AcceleratorFilter);
[email protected]1aad3322012-06-06 06:37:09416 AddEnvEventFilter(accelerator_filter_.get());
[email protected]21472b12012-02-17 00:30:05417#endif
[email protected]fcbbf082012-01-20 06:07:15418
[email protected]435b212e2012-04-05 19:43:37419 system_gesture_filter_.reset(new internal::SystemGestureEventFilter);
[email protected]1aad3322012-06-06 06:37:09420 AddEnvEventFilter(system_gesture_filter_.get());
[email protected]435b212e2012-04-05 19:43:37421
[email protected]60a978b72012-06-08 00:29:18422 capture_controller_.reset(new internal::CaptureController);
[email protected]87b0d82e2011-10-07 21:02:59423
[email protected]871e9cc2012-06-17 22:41:55424 internal::RootWindowController* root_window_controller =
425 new internal::RootWindowController(root_window);
426 root_window_controller->CreateContainers();
427
[email protected]73074742012-05-17 01:44:41428 CommandLine* command_line = CommandLine::ForCurrentProcess();
429
430 if (command_line->HasSwitch(switches::kAshTouchHud)) {
431 touch_observer_hud_.reset(new internal::TouchObserverHUD);
[email protected]1aad3322012-06-06 06:37:09432 AddEnvEventFilter(touch_observer_hud_.get());
[email protected]73074742012-05-17 01:44:41433 }
[email protected]d90b8392012-06-13 09:34:56434
435 // Create Controllers that may need root window.
436 // TODO(oshima): Move as many controllers before creating
437 // RootWindowController as possible.
[email protected]ee1e1a22011-12-15 01:51:10438 stacking_controller_.reset(new internal::StackingController);
[email protected]d90b8392012-06-13 09:34:56439 visibility_controller_.reset(new internal::VisibilityController);
440 drag_drop_controller_.reset(new internal::DragDropController);
[email protected]d90b8392012-06-13 09:34:56441 if (delegate_.get())
442 user_action_client_.reset(delegate_->CreateUserActionClient());
443 window_modality_controller_.reset(new internal::WindowModalityController);
444 AddEnvEventFilter(window_modality_controller_.get());
[email protected]488b42042011-11-15 00:20:18445
[email protected]9613eacf2012-06-22 02:18:05446 magnification_controller_.reset(
447 internal::MagnificationController::CreateInstance());
448
[email protected]2e236a52012-06-27 22:21:47449 if (internal::DisplayController::IsExtendedDesktopEnabled()) {
[email protected]78d96302012-06-22 00:58:07450 mouse_cursor_filter_.reset(
[email protected]2e236a52012-06-27 22:21:47451 new internal::MouseCursorEventFilter(display_controller_.get()));
[email protected]78d96302012-06-22 00:58:07452 AddEnvEventFilter(mouse_cursor_filter_.get());
453 }
454
[email protected]d90b8392012-06-13 09:34:56455 high_contrast_controller_.reset(new HighContrastController);
456 video_detector_.reset(new VideoDetector);
457 window_cycle_controller_.reset(new WindowCycleController);
[email protected]b0079a92012-01-25 20:13:38458
[email protected]54a37cdc2012-07-25 19:16:01459 tooltip_controller_.reset(new internal::TooltipController(
460 drag_drop_controller_.get()));
461 AddEnvEventFilter(tooltip_controller_.get());
462
[email protected]be65be362012-06-15 07:38:23463 InitRootWindowController(root_window_controller);
[email protected]262f8bd2012-03-23 19:30:27464
[email protected]d90b8392012-06-13 09:34:56465 // Initialize Primary RootWindow specific items.
[email protected]aa54218b2012-06-12 16:51:42466 status_area_widget_ = new internal::StatusAreaWidget();
467 status_area_widget_->CreateTrayViews(delegate_.get());
[email protected]6d6546e2012-05-30 23:12:02468 status_area_widget_->Show();
[email protected]bfb411312012-02-27 20:59:27469
[email protected]d90b8392012-06-13 09:34:56470 focus_cycler_.reset(new internal::FocusCycler());
471 focus_cycler_->AddWidget(status_area_widget_);
472
[email protected]e70cf0ed2012-03-15 16:24:47473 // This controller needs to be set before SetupManagedWindowMode.
[email protected]6e3b31b2012-06-12 23:06:38474 desktop_background_controller_.reset(new DesktopBackgroundController());
[email protected]10b22612012-03-22 17:07:55475 if (delegate_.get())
476 user_wallpaper_delegate_.reset(delegate_->CreateUserWallpaperDelegate());
477 if (!user_wallpaper_delegate_.get())
478 user_wallpaper_delegate_.reset(new DummyUserWallpaperDelegate());
[email protected]e70cf0ed2012-03-15 16:24:47479
[email protected]be65be362012-06-15 07:38:23480 InitLayoutManagersForPrimaryDisplay(root_window_controller);
[email protected]ca4ed122011-10-26 05:40:01481
[email protected]e4a181cc2012-03-17 02:20:57482 if (!command_line->HasSwitch(switches::kAuraNoShadows)) {
483 resize_shadow_controller_.reset(new internal::ResizeShadowController());
[email protected]a54e65b2011-11-21 22:03:34484 shadow_controller_.reset(new internal::ShadowController());
[email protected]e4a181cc2012-03-17 02:20:57485 }
[email protected]a54e65b2011-11-21 22:03:34486
[email protected]1720a442012-03-25 22:03:47487 if (!delegate_.get() || delegate_->IsUserLoggedIn())
[email protected]d9456cb2012-03-21 16:41:04488 CreateLauncher();
[email protected]3d29912a2012-02-07 07:41:51489
[email protected]d90b8392012-06-13 09:34:56490 // Force Layout
[email protected]be65be362012-06-15 07:38:23491 root_window_controller->root_window_layout()->OnWindowResized();
[email protected]084b6bb2011-11-17 05:18:16492
[email protected]60b5b862012-04-27 18:56:34493 // It needs to be created after OnWindowResized has been called, otherwise the
494 // widget will not paint when restoring after a browser crash.
[email protected]0c4f87d2012-06-12 02:00:35495 user_wallpaper_delegate_->InitializeWallpaper();
[email protected]60b5b862012-04-27 18:56:34496
[email protected]e0d22e82012-01-04 00:46:57497 power_button_controller_.reset(new PowerButtonController);
[email protected]82d3954ae2012-04-20 09:02:22498 AddShellObserver(power_button_controller_.get());
[email protected]d90b8392012-06-13 09:34:56499
[email protected]2e236a52012-06-27 22:21:47500 display_controller_->InitSecondaryDisplays();
[email protected]be65be362012-06-15 07:38:23501
[email protected]d90b8392012-06-13 09:34:56502 if (initially_hide_cursor_)
[email protected]4b8003c2012-07-26 00:54:19503 cursor_manager_.ShowCursor(false);
[email protected]87b0d82e2011-10-07 21:02:59504}
505
[email protected]1aad3322012-06-06 06:37:09506void Shell::AddEnvEventFilter(aura::EventFilter* filter) {
507 env_filter_->AddFilter(filter);
[email protected]e29014c2011-11-16 18:25:51508}
509
[email protected]1aad3322012-06-06 06:37:09510void Shell::RemoveEnvEventFilter(aura::EventFilter* filter) {
511 env_filter_->RemoveFilter(filter);
[email protected]e29014c2011-11-16 18:25:51512}
513
[email protected]1aad3322012-06-06 06:37:09514size_t Shell::GetEnvEventFilterCount() const {
515 return env_filter_->GetFilterCount();
[email protected]2c456102011-12-26 06:26:34516}
517
[email protected]b5f30602012-01-30 15:16:57518void Shell::ShowBackgroundMenu(views::Widget* widget,
519 const gfx::Point& location) {
[email protected]0cfc18e2012-04-11 18:17:47520 if (shell_context_menu_.get())
521 shell_context_menu_->ShowMenu(widget, location);
[email protected]46ca3632011-11-03 03:33:42522}
523
[email protected]ae4987d2011-11-21 22:52:44524void Shell::ToggleAppList() {
[email protected]0039db92012-05-09 04:11:45525 if (!app_list_controller_.get())
526 app_list_controller_.reset(new internal::AppListController);
527 app_list_controller_->SetVisible(!app_list_controller_->IsVisible());
[email protected]ae4987d2011-11-21 22:52:44528}
529
[email protected]7510d1082012-03-30 21:58:34530bool Shell::GetAppListTargetVisibility() const {
[email protected]0039db92012-05-09 04:11:45531 return app_list_controller_.get() &&
532 app_list_controller_->GetTargetVisibility();
[email protected]7510d1082012-03-30 21:58:34533}
534
[email protected]1e51a9d2012-04-09 23:31:11535aura::Window* Shell::GetAppListWindow() {
[email protected]0039db92012-05-09 04:11:45536 return app_list_controller_.get() ? app_list_controller_->GetWindow() : NULL;
[email protected]1e51a9d2012-04-09 23:31:11537}
538
[email protected]f7eb89c2011-12-13 09:48:54539bool Shell::IsScreenLocked() const {
[email protected]262f8bd2012-03-23 19:30:27540 return !delegate_.get() || delegate_->IsScreenLocked();
[email protected]f7eb89c2011-12-13 09:48:54541}
542
[email protected]40c4cbb2012-01-10 23:26:07543bool Shell::IsModalWindowOpen() const {
[email protected]7b0f7502012-06-11 00:12:39544 // TODO(oshima): Walk though all root windows.
[email protected]e73bd7802012-02-17 20:10:34545 const aura::Window* modal_container = GetContainer(
[email protected]7b0f7502012-06-11 00:12:39546 GetPrimaryRootWindow(),
[email protected]e73bd7802012-02-17 20:10:34547 internal::kShellWindowId_SystemModalContainer);
[email protected]40c4cbb2012-01-10 23:26:07548 return !modal_container->children().empty();
549}
550
[email protected]57b8bb352012-01-11 05:11:46551views::NonClientFrameView* Shell::CreateDefaultNonClientFrameView(
552 views::Widget* widget) {
553 if (CommandLine::ForCurrentProcess()->HasSwitch(
554 switches::kAuraGoogleDialogFrames)) {
555 return new internal::DialogFrameView;
556 }
[email protected]c73d1332012-03-08 17:11:04557 // Use translucent-style window frames for dialogs.
[email protected]95c6cc42012-03-08 20:53:15558 CustomFrameViewAsh* frame_view = new CustomFrameViewAsh;
[email protected]c73d1332012-03-08 17:11:04559 frame_view->Init(widget);
560 return frame_view;
[email protected]57b8bb352012-01-11 05:11:46561}
562
[email protected]3d29912a2012-02-07 07:41:51563void Shell::RotateFocus(Direction direction) {
564 focus_cycler_->RotateFocus(
565 direction == FORWARD ? internal::FocusCycler::FORWARD :
566 internal::FocusCycler::BACKWARD);
567}
568
[email protected]2e236a52012-06-27 22:21:47569void Shell::SetDisplayWorkAreaInsets(Window* contains,
[email protected]8a45c972012-03-14 18:22:44570 const gfx::Insets& insets) {
[email protected]2e236a52012-06-27 22:21:47571 internal::MultiDisplayManager* display_manager =
572 static_cast<internal::MultiDisplayManager*>(
573 aura::Env::GetInstance()->display_manager());
574 if (!display_manager->UpdateWorkAreaOfDisplayNearestWindow(contains, insets))
[email protected]1a2145b2012-03-13 21:09:17575 return;
[email protected]1a2145b2012-03-13 21:09:17576 FOR_EACH_OBSERVER(ShellObserver, observers_,
[email protected]2e236a52012-06-27 22:21:47577 OnDisplayWorkAreaInsetsChanged());
[email protected]1a2145b2012-03-13 21:09:17578}
579
[email protected]82d3954ae2012-04-20 09:02:22580void Shell::OnLoginStateChanged(user::LoginStatus status) {
581 FOR_EACH_OBSERVER(ShellObserver, observers_, OnLoginStateChanged(status));
582}
583
584void Shell::OnAppTerminating() {
585 FOR_EACH_OBSERVER(ShellObserver, observers_, OnAppTerminating());
586}
587
588void Shell::OnLockStateChanged(bool locked) {
589 FOR_EACH_OBSERVER(ShellObserver, observers_, OnLockStateChanged(locked));
590}
591
[email protected]d9456cb2012-03-21 16:41:04592void Shell::CreateLauncher() {
593 if (launcher_.get())
594 return;
595
[email protected]d90b8392012-06-13 09:34:56596 aura::Window* default_container =
597 GetPrimaryRootWindowController()->
598 GetContainer(internal::kShellWindowId_DefaultContainer);
[email protected]cbc278f2012-07-10 03:40:21599 launcher_.reset(new Launcher(default_container, shelf_));
[email protected]d9456cb2012-03-21 16:41:04600
601 launcher_->SetFocusCycler(focus_cycler_.get());
602 shelf_->SetLauncher(launcher_.get());
[email protected]7cf8dd62012-04-22 05:14:58603 if (panel_layout_manager_)
604 panel_layout_manager_->SetLauncher(launcher_.get());
[email protected]d9456cb2012-03-21 16:41:04605
[email protected]7e1df2f62012-07-19 19:17:18606 if (delegate())
607 launcher_->SetVisible(delegate()->IsSessionStarted());
[email protected]d9456cb2012-03-21 16:41:04608 launcher_->widget()->Show();
609}
610
[email protected]7e1df2f62012-07-19 19:17:18611void Shell::ShowLauncher() {
612 if (!launcher_.get())
613 return;
614 launcher_->SetVisible(true);
615}
616
[email protected]1a2145b2012-03-13 21:09:17617void Shell::AddShellObserver(ShellObserver* observer) {
618 observers_.AddObserver(observer);
619}
620
621void Shell::RemoveShellObserver(ShellObserver* observer) {
622 observers_.RemoveObserver(observer);
623}
624
[email protected]c758fbf2012-03-25 22:53:59625void Shell::UpdateShelfVisibility() {
626 shelf_->UpdateVisibilityState();
627}
628
[email protected]09f3fc82012-03-26 23:26:56629void Shell::SetShelfAutoHideBehavior(ShelfAutoHideBehavior behavior) {
630 shelf_->SetAutoHideBehavior(behavior);
[email protected]c758fbf2012-03-25 22:53:59631}
632
[email protected]09f3fc82012-03-26 23:26:56633ShelfAutoHideBehavior Shell::GetShelfAutoHideBehavior() const {
634 return shelf_->auto_hide_behavior();
[email protected]c758fbf2012-03-25 22:53:59635}
636
[email protected]55444502012-05-10 15:43:53637void Shell::SetShelfAlignment(ShelfAlignment alignment) {
[email protected]c2d58b42012-05-30 08:11:29638 if (!shelf_->SetAlignment(alignment))
639 return;
[email protected]a5c63ce82012-07-18 18:48:57640 FOR_EACH_OBSERVER(ShellObserver, observers_, OnShelfAlignmentChanged());
[email protected]55444502012-05-10 15:43:53641}
642
643ShelfAlignment Shell::GetShelfAlignment() {
644 return shelf_->alignment();
645}
646
[email protected]d90b8392012-06-13 09:34:56647void Shell::SetDimming(bool should_dim) {
[email protected]be65be362012-06-15 07:38:23648 RootWindowControllerList controllers = GetAllRootWindowControllers();
649 for (RootWindowControllerList::iterator iter = controllers.begin();
650 iter != controllers.end(); ++iter)
651 (*iter)->screen_dimmer()->SetDimming(should_dim);
[email protected]d90b8392012-06-13 09:34:56652}
653
[email protected]aa54218b2012-06-12 16:51:42654SystemTrayDelegate* Shell::tray_delegate() {
655 return status_area_widget_->system_tray_delegate();
656}
657
658SystemTray* Shell::system_tray() {
659 return status_area_widget_->system_tray();
660}
661
[email protected]85d43f02012-03-14 21:11:19662int Shell::GetGridSize() const {
[email protected]f4bb9fde2012-08-03 19:33:50663 return
664 GetPrimaryRootWindowController()->workspace_controller()->GetGridSize();
[email protected]9628e0af2012-04-12 20:40:56665}
666
[email protected]2e236a52012-06-27 22:21:47667void Shell::InitRootWindowForSecondaryDisplay(aura::RootWindow* root) {
[email protected]a857dbe2012-05-30 22:10:14668 root->set_focus_manager(focus_manager_.get());
[email protected]2e236a52012-06-27 22:21:47669 if (internal::DisplayController::IsExtendedDesktopEnabled()) {
[email protected]be65be362012-06-15 07:38:23670 internal::RootWindowController* controller =
671 new internal::RootWindowController(root);
672 controller->CreateContainers();
673 InitRootWindowController(controller);
674 controller->root_window_layout()->OnWindowResized();
[email protected]37f27b622012-06-21 20:42:54675 desktop_background_controller_->OnRootWindowAdded(root);
[email protected]be65be362012-06-15 07:38:23676 root->ShowRootWindow();
677 // Activate new root for testing.
678 active_root_window_ = root;
679 } else {
680 root->SetFocusWhenShown(false);
681 root->SetLayoutManager(new internal::RootWindowLayoutManager(root));
682 aura::Window* container = new aura::Window(NULL);
[email protected]2e236a52012-06-27 22:21:47683 container->SetName("SecondaryDisplayContainer");
[email protected]be65be362012-06-15 07:38:23684 container->Init(ui::LAYER_NOT_DRAWN);
685 root->AddChild(container);
686 container->SetLayoutManager(new internal::BaseLayoutManager(root));
[email protected]2e236a52012-06-27 22:21:47687 CreateSecondaryDisplayWidget(container);
[email protected]be65be362012-06-15 07:38:23688 container->Show();
689 root->layout_manager()->OnWindowResized();
690 root->ShowRootWindow();
691 aura::client::SetCaptureClient(root, capture_controller_.get());
[email protected]8d625fb2012-07-18 16:40:06692 aura::client::SetScreenPositionClient(
693 root, screen_position_controller_.get());
[email protected]be65be362012-06-15 07:38:23694 }
[email protected]a857dbe2012-05-30 22:10:14695}
696
[email protected]be65be362012-06-15 07:38:23697void Shell::InitRootWindowController(
698 internal::RootWindowController* controller) {
699 aura::RootWindow* root_window = controller->root_window();
[email protected]d90b8392012-06-13 09:34:56700 DCHECK(activation_controller_.get());
701 DCHECK(visibility_controller_.get());
702 DCHECK(drag_drop_controller_.get());
703 DCHECK(capture_controller_.get());
704
705 root_window->set_focus_manager(focus_manager_.get());
706 input_method_filter_->SetInputMethodPropertyInRootWindow(root_window);
707 aura::client::SetActivationClient(root_window, activation_controller_.get());
708 aura::client::SetVisibilityClient(root_window, visibility_controller_.get());
709 aura::client::SetDragDropClient(root_window, drag_drop_controller_.get());
[email protected]d90b8392012-06-13 09:34:56710 aura::client::SetCaptureClient(root_window, capture_controller_.get());
[email protected]8d625fb2012-07-18 16:40:06711 aura::client::SetScreenPositionClient(root_window,
712 screen_position_controller_.get());
[email protected]4b8003c2012-07-26 00:54:19713 aura::client::SetCursorClient(root_window, &cursor_manager_);
[email protected]54a37cdc2012-07-25 19:16:01714 aura::client::SetTooltipClient(root_window, tooltip_controller_.get());
[email protected]d90b8392012-06-13 09:34:56715
716 if (nested_dispatcher_controller_.get()) {
717 aura::client::SetDispatcherClient(root_window,
718 nested_dispatcher_controller_.get());
719 }
720 if (user_action_client_.get())
721 aura::client::SetUserActionClient(root_window, user_action_client_.get());
722
723 root_window->SetCursor(ui::kCursorPointer);
[email protected]be65be362012-06-15 07:38:23724 controller->InitLayoutManagers();
[email protected]f059c6942012-07-21 14:27:57725
726 // TODO(oshima): Move the instance to RootWindowController when
727 // the extended desktop is enabled by default.
728 internal::AlwaysOnTopController* always_on_top_controller =
729 new internal::AlwaysOnTopController;
730 always_on_top_controller->SetContainers(
731 root_window->GetChildById(internal::kShellWindowId_DefaultContainer),
732 root_window->GetChildById(internal::kShellWindowId_AlwaysOnTopContainer));
733 root_window->SetProperty(internal::kAlwaysOnTopControllerKey,
734 always_on_top_controller);
[email protected]d90b8392012-06-13 09:34:56735}
736
[email protected]46ca3632011-11-03 03:33:42737////////////////////////////////////////////////////////////////////////////////
738// Shell, private:
739
[email protected]d90b8392012-06-13 09:34:56740void Shell::InitLayoutManagersForPrimaryDisplay(
741 internal::RootWindowController* controller) {
[email protected]6d6546e2012-05-30 23:12:02742 DCHECK(status_area_widget_);
[email protected]b0079a92012-01-25 20:13:38743
[email protected]b0079a92012-01-25 20:13:38744 internal::ShelfLayoutManager* shelf_layout_manager =
[email protected]6d6546e2012-05-30 23:12:02745 new internal::ShelfLayoutManager(status_area_widget_);
[email protected]d90b8392012-06-13 09:34:56746 controller->GetContainer(internal::kShellWindowId_LauncherContainer)->
[email protected]b0079a92012-01-25 20:13:38747 SetLayoutManager(shelf_layout_manager);
[email protected]4e437632012-02-13 22:39:40748 shelf_ = shelf_layout_manager;
[email protected]b0079a92012-01-25 20:13:38749
750 internal::StatusAreaLayoutManager* status_area_layout_manager =
751 new internal::StatusAreaLayoutManager(shelf_layout_manager);
[email protected]d90b8392012-06-13 09:34:56752 controller->GetContainer(internal::kShellWindowId_StatusContainer)->
[email protected]b0079a92012-01-25 20:13:38753 SetLayoutManager(status_area_layout_manager);
754
[email protected]f4bb9fde2012-08-03 19:33:50755 shelf_layout_manager->set_workspace_controller(
756 controller->workspace_controller());
[email protected]fa0c3f22012-03-05 17:55:13757
[email protected]d90b8392012-06-13 09:34:56758 // TODO(oshima): Support multiple displays.
[email protected]f4bb9fde2012-08-03 19:33:50759 controller->workspace_controller()->SetShelf(shelf());
[email protected]c066b8d2012-03-26 00:23:16760
[email protected]7cf8dd62012-04-22 05:14:58761 // Create Panel layout manager
[email protected]87d722a2012-07-12 15:38:33762 aura::Window* panel_container = GetContainer(
763 GetPrimaryRootWindow(),
764 internal::kShellWindowId_PanelContainer);
765 panel_layout_manager_ =
766 new internal::PanelLayoutManager(panel_container);
767 panel_container->SetEventFilter(
768 new internal::PanelWindowEventFilter(
769 panel_container, panel_layout_manager_));
770 panel_container->SetLayoutManager(panel_layout_manager_);
[email protected]cac10fc62011-10-07 23:22:56771}
772
[email protected]f4bb9fde2012-08-03 19:33:50773// TODO: this is only used in tests, move with test.
[email protected]ad0c8722012-03-02 20:17:45774void Shell::DisableWorkspaceGridLayout() {
[email protected]be65be362012-06-15 07:38:23775 RootWindowControllerList controllers = GetAllRootWindowControllers();
776 for (RootWindowControllerList::iterator iter = controllers.begin();
777 iter != controllers.end(); ++iter)
[email protected]f4bb9fde2012-08-03 19:33:50778 (*iter)->workspace_controller()->SetGridSize(0);
[email protected]ad0c8722012-03-02 20:17:45779}
780
[email protected]1aad3322012-06-06 06:37:09781void Shell::SetCursor(gfx::NativeCursor cursor) {
[email protected]be65be362012-06-15 07:38:23782 RootWindowList root_windows = GetAllRootWindows();
783 for (RootWindowList::iterator iter = root_windows.begin();
784 iter != root_windows.end(); ++iter)
785 (*iter)->SetCursor(cursor);
[email protected]1aad3322012-06-06 06:37:09786}
787
788void Shell::ShowCursor(bool visible) {
[email protected]be65be362012-06-15 07:38:23789 RootWindowList root_windows = GetAllRootWindows();
790 for (RootWindowList::iterator iter = root_windows.begin();
791 iter != root_windows.end(); ++iter)
792 (*iter)->ShowCursor(visible);
[email protected]1aad3322012-06-06 06:37:09793}
794
[email protected]55f593352011-12-24 05:42:46795} // namespace ash