blob: 7eba6fe141e555d9b6df39b6f1bb391bfb8cc92b [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]8b04a1652012-08-04 02:59:49140 virtual void OnWallpaperBootAnimationFinished() OVERRIDE {
141 }
142
[email protected]10b22612012-03-22 17:07:55143 private:
[email protected]0039db92012-05-09 04:11:45144 DISALLOW_COPY_AND_ASSIGN(DummyUserWallpaperDelegate);
[email protected]10b22612012-03-22 17:07:55145};
146
[email protected]87b0d82e2011-10-07 21:02:59147} // namespace
148
[email protected]cac10fc62011-10-07 23:22:56149// static
150Shell* Shell::instance_ = NULL;
[email protected]2b4cd302012-02-24 20:21:13151// static
[email protected]9488d4d2012-02-29 18:32:37152bool Shell::initially_hide_cursor_ = false;
[email protected]2b4cd302012-02-24 20:21:13153
154////////////////////////////////////////////////////////////////////////////////
155// Shell::TestApi
156
157Shell::TestApi::TestApi(Shell* shell) : shell_(shell) {}
158
[email protected]2b4cd302012-02-24 20:21:13159internal::RootWindowLayoutManager* Shell::TestApi::root_window_layout() {
[email protected]d90b8392012-06-13 09:34:56160 return shell_->GetPrimaryRootWindowController()->root_window_layout();
[email protected]2b4cd302012-02-24 20:21:13161}
[email protected]cac10fc62011-10-07 23:22:56162
[email protected]0e46c272012-05-15 18:15:23163aura::shared::InputMethodEventFilter*
164 Shell::TestApi::input_method_event_filter() {
[email protected]db9131602012-02-29 19:06:32165 return shell_->input_method_filter_.get();
166}
167
[email protected]435b212e2012-04-05 19:43:37168internal::SystemGestureEventFilter*
169 Shell::TestApi::system_gesture_event_filter() {
170 return shell_->system_gesture_filter_.get();
171}
172
[email protected]db9131602012-02-29 19:06:32173internal::WorkspaceController* Shell::TestApi::workspace_controller() {
[email protected]d90b8392012-06-13 09:34:56174 return shell_->GetPrimaryRootWindowController()->workspace_controller();
[email protected]db9131602012-02-29 19:06:32175}
176
[email protected]cac10fc62011-10-07 23:22:56177////////////////////////////////////////////////////////////////////////////////
178// Shell, public:
179
[email protected]3266c2b92011-11-14 00:06:08180Shell::Shell(ShellDelegate* delegate)
[email protected]d90b8392012-06-13 09:34:56181 : screen_(new ScreenAsh),
[email protected]be65be362012-06-15 07:38:23182 active_root_window_(NULL),
[email protected]1aad3322012-06-06 06:37:09183 env_filter_(NULL),
[email protected]9c66adc2012-01-05 02:10:16184 delegate_(delegate),
[email protected]70b3e7d52012-06-02 22:12:25185#if defined(OS_CHROMEOS)
[email protected]fb792f32012-08-01 01:07:01186 output_configurator_(new chromeos::OutputConfigurator(
187 internal::DisplayController::IsExtendedDesktopEnabled())),
[email protected]196e9452012-08-01 06:42:51188 output_configurator_animation_(
189 new internal::OutputConfiguratorAnimation()),
[email protected]70b3e7d52012-06-02 22:12:25190#endif // defined(OS_CHROMEOS)
[email protected]4e437632012-02-13 22:39:40191 shelf_(NULL),
[email protected]7cf8dd62012-04-22 05:14:58192 panel_layout_manager_(NULL),
[email protected]6d6546e2012-05-30 23:12:02193 status_area_widget_(NULL),
194 browser_context_(NULL) {
[email protected]1a2145b2012-03-13 21:09:17195 gfx::Screen::SetInstance(screen_);
[email protected]054b2d72012-06-08 04:52:25196 ui_controls::InstallUIControlsAura(internal::CreateUIControls());
[email protected]70b3e7d52012-06-02 22:12:25197#if defined(OS_CHROMEOS)
[email protected]196e9452012-08-01 06:42:51198 output_configurator_->AddObserver(output_configurator_animation_.get());
[email protected]70b3e7d52012-06-02 22:12:25199 static_cast<aura::DispatcherLinux*>(
200 aura::Env::GetInstance()->GetDispatcher())->AddDispatcherForRootWindow(
201 output_configurator());
202#endif // defined(OS_CHROMEOS)
[email protected]87b0d82e2011-10-07 21:02:59203}
204
205Shell::~Shell() {
[email protected]e7293fa2012-05-17 04:42:33206 views::FocusManagerFactory::Install(NULL);
[email protected]cb3b8b22012-06-27 23:26:37207
208 // Remove the focus from any window. This will prevent overhead and side
209 // effects (e.g. crashes) from changing focus during shutdown.
210 // See bug crbug.com/134502.
211 if (active_root_window_)
212 active_root_window_->GetFocusManager()->SetFocusedWindow(NULL, NULL);
213
[email protected]4b8003c2012-07-26 00:54:19214 cursor_manager_.set_delegate(NULL);
[email protected]e7293fa2012-05-17 04:42:33215
[email protected]9861f1752012-06-01 07:16:14216 // Please keep in same order as in Init() because it's easy to miss one.
[email protected]c16b9422012-06-06 21:51:11217 RemoveEnvEventFilter(user_activity_detector_.get());
[email protected]b9d224c2012-07-13 01:09:03218 RemoveEnvEventFilter(event_rewriter_filter_.get());
[email protected]9ae32df2012-07-26 03:25:18219 RemoveEnvEventFilter(overlay_filter_.get());
[email protected]1aad3322012-06-06 06:37:09220 RemoveEnvEventFilter(input_method_filter_.get());
221 RemoveEnvEventFilter(window_modality_controller_.get());
[email protected]78d96302012-06-22 00:58:07222 if (mouse_cursor_filter_.get())
223 RemoveEnvEventFilter(mouse_cursor_filter_.get());
[email protected]1aad3322012-06-06 06:37:09224 RemoveEnvEventFilter(system_gesture_filter_.get());
[email protected]6e9f6aa2012-02-09 04:16:20225#if !defined(OS_MACOSX)
[email protected]1aad3322012-06-06 06:37:09226 RemoveEnvEventFilter(accelerator_filter_.get());
[email protected]6e9f6aa2012-02-09 04:16:20227#endif
[email protected]73074742012-05-17 01:44:41228 if (touch_observer_hud_.get())
[email protected]1aad3322012-06-06 06:37:09229 RemoveEnvEventFilter(touch_observer_hud_.get());
[email protected]745816be2011-11-22 05:08:30230
[email protected]931f4f42012-02-10 23:49:42231 // TooltipController is deleted with the Shell so removing its references.
[email protected]1aad3322012-06-06 06:37:09232 RemoveEnvEventFilter(tooltip_controller_.get());
[email protected]ef589af2011-12-03 01:07:15233
[email protected]aa54218b2012-06-12 16:51:42234 // The status area needs to be shut down before the windows are destroyed.
235 status_area_widget_->Shutdown();
[email protected]bfb411312012-02-27 20:59:27236
[email protected]f5f3c752012-06-07 05:16:02237 // AppList needs to be released before shelf layout manager, which is
238 // destroyed with launcher container in the loop below. However, app list
239 // container is now on top of launcher container and released after it.
240 // TODO(xiyuan): Move it back when app list container is no longer needed.
241 app_list_controller_.reset();
242
[email protected]be65be362012-06-15 07:38:23243 // Destroy all child windows including widgets.
[email protected]2e236a52012-06-27 22:21:47244 display_controller_->CloseChildWindows();
[email protected]ef589af2011-12-03 01:07:15245
[email protected]40c4cbb2012-01-10 23:26:07246 // These need a valid Shell instance to clean up properly, so explicitly
247 // delete them before invalidating the instance.
[email protected]58482fa2012-03-02 14:57:39248 // Alphabetical.
[email protected]084b6bb2011-11-17 05:18:16249 drag_drop_controller_.reset();
[email protected]c1c670172012-04-26 04:20:26250 magnification_controller_.reset();
[email protected]aa476502012-05-01 18:03:19251 power_button_controller_.reset();
[email protected]e4a181cc2012-03-17 02:20:57252 resize_shadow_controller_.reset();
[email protected]58482fa2012-03-02 14:57:39253 shadow_controller_.reset();
[email protected]fd162f72012-04-14 03:24:53254 tooltip_controller_.reset();
[email protected]aa476502012-05-01 18:03:19255 window_cycle_controller_.reset();
[email protected]60a978b72012-06-08 00:29:18256 capture_controller_.reset();
[email protected]60a978b72012-06-08 00:29:18257 nested_dispatcher_controller_.reset();
[email protected]60a978b72012-06-08 00:29:18258 user_action_client_.reset();
[email protected]60a978b72012-06-08 00:29:18259 visibility_controller_.reset();
[email protected]084b6bb2011-11-17 05:18:16260
[email protected]be65be362012-06-15 07:38:23261 // This also deletes all RootWindows.
[email protected]2e236a52012-06-27 22:21:47262 display_controller_.reset();
[email protected]8d625fb2012-07-18 16:40:06263 screen_position_controller_.reset();
[email protected]d90b8392012-06-13 09:34:56264
[email protected]0a704f02012-02-15 17:49:43265 // Launcher widget has a InputMethodBridge that references to
266 // input_method_filter_'s input_method_. So explicitly release launcher_
267 // before input_method_filter_. And this needs to be after we delete all
268 // containers in case there are still live browser windows which access
269 // LauncherModel during close.
270 launcher_.reset();
271
[email protected]764864e2012-06-11 19:16:16272 // Delete the activation controller after other controllers and launcher
273 // because they might have registered ActivationChangeObserver.
[email protected]764864e2012-06-11 19:16:16274 activation_controller_.reset();
275
[email protected]488b42042011-11-15 00:20:18276 DCHECK(instance_ == this);
277 instance_ = NULL;
[email protected]70b3e7d52012-06-02 22:12:25278
279#if defined(OS_CHROMEOS)
[email protected]196e9452012-08-01 06:42:51280 output_configurator_->RemoveObserver(output_configurator_animation_.get());
[email protected]70b3e7d52012-06-02 22:12:25281 // Remove OutputConfigurator from Dispatcher.
282 static_cast<aura::DispatcherLinux*>(
283 aura::Env::GetInstance()->GetDispatcher())->RemoveDispatcherForRootWindow(
284 output_configurator());
285#endif // defined(OS_CHROMEOS)
[email protected]87b0d82e2011-10-07 21:02:59286}
287
[email protected]cac10fc62011-10-07 23:22:56288// static
[email protected]3266c2b92011-11-14 00:06:08289Shell* Shell::CreateInstance(ShellDelegate* delegate) {
290 CHECK(!instance_);
[email protected]2e236a52012-06-27 22:21:47291 aura::Env::GetInstance()->SetDisplayManager(
292 new internal::MultiDisplayManager());
[email protected]3266c2b92011-11-14 00:06:08293 instance_ = new Shell(delegate);
294 instance_->Init();
295 return instance_;
296}
297
298// static
[email protected]cac10fc62011-10-07 23:22:56299Shell* Shell::GetInstance() {
[email protected]3266c2b92011-11-14 00:06:08300 DCHECK(instance_);
[email protected]cac10fc62011-10-07 23:22:56301 return instance_;
302}
303
[email protected]6377a002011-11-10 20:26:47304// static
[email protected]b3b7bcd2012-03-06 19:35:45305bool Shell::HasInstance() {
306 return !!instance_;
307}
308
309// static
[email protected]ef589af2011-12-03 01:07:15310void Shell::DeleteInstance() {
[email protected]6377a002011-11-10 20:26:47311 delete instance_;
312 instance_ = NULL;
313}
314
[email protected]e73bd7802012-02-17 20:10:34315// static
[email protected]d90b8392012-06-13 09:34:56316internal::RootWindowController* Shell::GetPrimaryRootWindowController() {
[email protected]7ae525002012-07-26 23:55:10317 return GetRootWindowController(GetPrimaryRootWindow());
[email protected]be65be362012-06-15 07:38:23318}
319
320// static
321Shell::RootWindowControllerList Shell::GetAllRootWindowControllers() {
[email protected]2e236a52012-06-27 22:21:47322 return Shell::GetInstance()->display_controller()->
[email protected]be65be362012-06-15 07:38:23323 GetAllRootWindowControllers();
[email protected]d90b8392012-06-13 09:34:56324}
325
326// static
[email protected]42713f72012-05-25 00:41:50327aura::RootWindow* Shell::GetPrimaryRootWindow() {
[email protected]2e236a52012-06-27 22:21:47328 return GetInstance()->display_controller()->GetPrimaryRootWindow();
[email protected]e73bd7802012-02-17 20:10:34329}
330
[email protected]7b0f7502012-06-11 00:12:39331// static
[email protected]a857dbe2012-05-30 22:10:14332aura::RootWindow* Shell::GetActiveRootWindow() {
333 return GetInstance()->active_root_window_;
334}
335
[email protected]7b0f7502012-06-11 00:12:39336// static
[email protected]be65be362012-06-15 07:38:23337Shell::RootWindowList Shell::GetAllRootWindows() {
[email protected]2e236a52012-06-27 22:21:47338 return Shell::GetInstance()->display_controller()->
[email protected]be65be362012-06-15 07:38:23339 GetAllRootWindows();
340}
341
342// static
[email protected]7b0f7502012-06-11 00:12:39343aura::Window* Shell::GetContainer(aura::RootWindow* root_window,
344 int container_id) {
345 return root_window->GetChildById(container_id);
346}
347
348// static
349std::vector<aura::Window*> Shell::GetAllContainers(int container_id) {
350 // TODO(oshima): Support multiple root windows.
351 std::vector<aura::Window*> containers;
352 aura::Window* container = GetPrimaryRootWindow()->GetChildById(container_id);
353 if (container)
354 containers.push_back(container);
355 return containers;
356}
357
[email protected]87b0d82e2011-10-07 21:02:59358void Shell::Init() {
[email protected]c9301e32012-05-23 08:34:58359 // Install the custom factory first so that views::FocusManagers for Tray,
360 // Launcher, and WallPaper could be created by the factory.
361 views::FocusManagerFactory::Install(new AshFocusManagerFactory);
362
[email protected]1aad3322012-06-06 06:37:09363 env_filter_ = new aura::shared::CompoundEventFilter;
364 // Pass ownership of the filter to the Env.
365 aura::Env::GetInstance()->SetEventFilter(env_filter_);
366
[email protected]4b8003c2012-07-26 00:54:19367 cursor_manager_.set_delegate(this);
[email protected]a857dbe2012-05-30 22:10:14368
369 focus_manager_.reset(new aura::FocusManager);
[email protected]be65be362012-06-15 07:38:23370 activation_controller_.reset(
371 new internal::ActivationController(focus_manager_.get()));
372
[email protected]8d625fb2012-07-18 16:40:06373 screen_position_controller_.reset(new internal::ScreenPositionController);
[email protected]2e236a52012-06-27 22:21:47374 display_controller_.reset(new internal::DisplayController);
375 display_controller_->InitPrimaryDisplay();
376 aura::RootWindow* root_window = display_controller_->GetPrimaryRootWindow();
[email protected]be65be362012-06-15 07:38:23377 active_root_window_ = root_window;
[email protected]a857dbe2012-05-30 22:10:14378
[email protected]58482fa2012-03-02 14:57:39379#if !defined(OS_MACOSX)
380 nested_dispatcher_controller_.reset(new NestedDispatcherController);
381 accelerator_controller_.reset(new AcceleratorController);
382#endif
[email protected]0cfc18e2012-04-11 18:17:47383 shell_context_menu_.reset(new internal::ShellContextMenu);
[email protected]58482fa2012-03-02 14:57:39384
[email protected]c16b9422012-06-06 21:51:11385 // The order in which event filters are added is significant.
[email protected]1aad3322012-06-06 06:37:09386 DCHECK(!GetEnvEventFilterCount());
[email protected]c16b9422012-06-06 21:51:11387 user_activity_detector_.reset(new UserActivityDetector);
388 AddEnvEventFilter(user_activity_detector_.get());
389
390 DCHECK_EQ(1U, GetEnvEventFilterCount());
[email protected]b9d224c2012-07-13 01:09:03391 event_rewriter_filter_.reset(new internal::EventRewriterEventFilter);
392 AddEnvEventFilter(event_rewriter_filter_.get());
[email protected]0b0b0742012-02-16 13:23:45393
[email protected]c16b9422012-06-06 21:51:11394 DCHECK_EQ(2U, GetEnvEventFilterCount());
[email protected]9ae32df2012-07-26 03:25:18395 overlay_filter_.reset(new internal::OverlayEventFilter);
396 AddEnvEventFilter(overlay_filter_.get());
397 AddShellObserver(overlay_filter_.get());
[email protected]0b0b0742012-02-16 13:23:45398
[email protected]c16b9422012-06-06 21:51:11399 DCHECK_EQ(3U, GetEnvEventFilterCount());
[email protected]0caad5882012-06-03 15:07:06400 input_method_filter_.reset(new aura::shared::InputMethodEventFilter());
[email protected]1aad3322012-06-06 06:37:09401 AddEnvEventFilter(input_method_filter_.get());
[email protected]c16b9422012-06-06 21:51:11402
[email protected]21472b12012-02-17 00:30:05403#if !defined(OS_MACOSX)
404 accelerator_filter_.reset(new internal::AcceleratorFilter);
[email protected]1aad3322012-06-06 06:37:09405 AddEnvEventFilter(accelerator_filter_.get());
[email protected]21472b12012-02-17 00:30:05406#endif
[email protected]fcbbf082012-01-20 06:07:15407
[email protected]435b212e2012-04-05 19:43:37408 system_gesture_filter_.reset(new internal::SystemGestureEventFilter);
[email protected]1aad3322012-06-06 06:37:09409 AddEnvEventFilter(system_gesture_filter_.get());
[email protected]435b212e2012-04-05 19:43:37410
[email protected]60a978b72012-06-08 00:29:18411 capture_controller_.reset(new internal::CaptureController);
[email protected]87b0d82e2011-10-07 21:02:59412
[email protected]871e9cc2012-06-17 22:41:55413 internal::RootWindowController* root_window_controller =
414 new internal::RootWindowController(root_window);
415 root_window_controller->CreateContainers();
416
[email protected]73074742012-05-17 01:44:41417 CommandLine* command_line = CommandLine::ForCurrentProcess();
418
419 if (command_line->HasSwitch(switches::kAshTouchHud)) {
420 touch_observer_hud_.reset(new internal::TouchObserverHUD);
[email protected]1aad3322012-06-06 06:37:09421 AddEnvEventFilter(touch_observer_hud_.get());
[email protected]73074742012-05-17 01:44:41422 }
[email protected]d90b8392012-06-13 09:34:56423
[email protected]0518d0d2012-08-26 11:59:04424 if (internal::DisplayController::IsExtendedDesktopEnabled()) {
425 mouse_cursor_filter_.reset(
426 new internal::MouseCursorEventFilter(display_controller_.get()));
427 AddEnvEventFilter(mouse_cursor_filter_.get());
428 }
429
[email protected]d90b8392012-06-13 09:34:56430 // Create Controllers that may need root window.
431 // TODO(oshima): Move as many controllers before creating
432 // RootWindowController as possible.
[email protected]ee1e1a22011-12-15 01:51:10433 stacking_controller_.reset(new internal::StackingController);
[email protected]d90b8392012-06-13 09:34:56434 visibility_controller_.reset(new internal::VisibilityController);
435 drag_drop_controller_.reset(new internal::DragDropController);
[email protected]d90b8392012-06-13 09:34:56436 if (delegate_.get())
437 user_action_client_.reset(delegate_->CreateUserActionClient());
438 window_modality_controller_.reset(new internal::WindowModalityController);
439 AddEnvEventFilter(window_modality_controller_.get());
[email protected]488b42042011-11-15 00:20:18440
[email protected]9613eacf2012-06-22 02:18:05441 magnification_controller_.reset(
442 internal::MagnificationController::CreateInstance());
443
[email protected]d90b8392012-06-13 09:34:56444 high_contrast_controller_.reset(new HighContrastController);
445 video_detector_.reset(new VideoDetector);
[email protected]8fef7432012-08-06 15:34:25446 window_cycle_controller_.reset(
447 new WindowCycleController(activation_controller_.get()));
[email protected]b0079a92012-01-25 20:13:38448
[email protected]54a37cdc2012-07-25 19:16:01449 tooltip_controller_.reset(new internal::TooltipController(
450 drag_drop_controller_.get()));
451 AddEnvEventFilter(tooltip_controller_.get());
452
[email protected]be65be362012-06-15 07:38:23453 InitRootWindowController(root_window_controller);
[email protected]262f8bd2012-03-23 19:30:27454
[email protected]d90b8392012-06-13 09:34:56455 // Initialize Primary RootWindow specific items.
[email protected]aa54218b2012-06-12 16:51:42456 status_area_widget_ = new internal::StatusAreaWidget();
457 status_area_widget_->CreateTrayViews(delegate_.get());
[email protected]6d6546e2012-05-30 23:12:02458 status_area_widget_->Show();
[email protected]bfb411312012-02-27 20:59:27459
[email protected]d90b8392012-06-13 09:34:56460 focus_cycler_.reset(new internal::FocusCycler());
461 focus_cycler_->AddWidget(status_area_widget_);
462
[email protected]e70cf0ed2012-03-15 16:24:47463 // This controller needs to be set before SetupManagedWindowMode.
[email protected]6e3b31b2012-06-12 23:06:38464 desktop_background_controller_.reset(new DesktopBackgroundController());
[email protected]10b22612012-03-22 17:07:55465 if (delegate_.get())
466 user_wallpaper_delegate_.reset(delegate_->CreateUserWallpaperDelegate());
467 if (!user_wallpaper_delegate_.get())
468 user_wallpaper_delegate_.reset(new DummyUserWallpaperDelegate());
[email protected]e70cf0ed2012-03-15 16:24:47469
[email protected]be65be362012-06-15 07:38:23470 InitLayoutManagersForPrimaryDisplay(root_window_controller);
[email protected]ca4ed122011-10-26 05:40:01471
[email protected]e4a181cc2012-03-17 02:20:57472 if (!command_line->HasSwitch(switches::kAuraNoShadows)) {
473 resize_shadow_controller_.reset(new internal::ResizeShadowController());
[email protected]a54e65b2011-11-21 22:03:34474 shadow_controller_.reset(new internal::ShadowController());
[email protected]e4a181cc2012-03-17 02:20:57475 }
[email protected]a54e65b2011-11-21 22:03:34476
[email protected]1720a442012-03-25 22:03:47477 if (!delegate_.get() || delegate_->IsUserLoggedIn())
[email protected]d9456cb2012-03-21 16:41:04478 CreateLauncher();
[email protected]3d29912a2012-02-07 07:41:51479
[email protected]d90b8392012-06-13 09:34:56480 // Force Layout
[email protected]be65be362012-06-15 07:38:23481 root_window_controller->root_window_layout()->OnWindowResized();
[email protected]084b6bb2011-11-17 05:18:16482
[email protected]60b5b862012-04-27 18:56:34483 // It needs to be created after OnWindowResized has been called, otherwise the
484 // widget will not paint when restoring after a browser crash.
[email protected]0c4f87d2012-06-12 02:00:35485 user_wallpaper_delegate_->InitializeWallpaper();
[email protected]60b5b862012-04-27 18:56:34486
[email protected]e0d22e82012-01-04 00:46:57487 power_button_controller_.reset(new PowerButtonController);
[email protected]82d3954ae2012-04-20 09:02:22488 AddShellObserver(power_button_controller_.get());
[email protected]d90b8392012-06-13 09:34:56489
[email protected]2e236a52012-06-27 22:21:47490 display_controller_->InitSecondaryDisplays();
[email protected]be65be362012-06-15 07:38:23491
[email protected]d90b8392012-06-13 09:34:56492 if (initially_hide_cursor_)
[email protected]4b8003c2012-07-26 00:54:19493 cursor_manager_.ShowCursor(false);
[email protected]87b0d82e2011-10-07 21:02:59494}
495
[email protected]1aad3322012-06-06 06:37:09496void Shell::AddEnvEventFilter(aura::EventFilter* filter) {
497 env_filter_->AddFilter(filter);
[email protected]e29014c2011-11-16 18:25:51498}
499
[email protected]1aad3322012-06-06 06:37:09500void Shell::RemoveEnvEventFilter(aura::EventFilter* filter) {
501 env_filter_->RemoveFilter(filter);
[email protected]e29014c2011-11-16 18:25:51502}
503
[email protected]1aad3322012-06-06 06:37:09504size_t Shell::GetEnvEventFilterCount() const {
505 return env_filter_->GetFilterCount();
[email protected]2c456102011-12-26 06:26:34506}
507
[email protected]b5f30602012-01-30 15:16:57508void Shell::ShowBackgroundMenu(views::Widget* widget,
509 const gfx::Point& location) {
[email protected]f60c6232012-08-24 18:55:03510 // No context menus if user have not logged in.
511 if (!delegate_.get() || !delegate_->IsUserLoggedIn())
512 return;
513 // No context menus when screen is locked.
514 if (IsScreenLocked())
515 return;
[email protected]0cfc18e2012-04-11 18:17:47516 if (shell_context_menu_.get())
517 shell_context_menu_->ShowMenu(widget, location);
[email protected]46ca3632011-11-03 03:33:42518}
519
[email protected]ae4987d2011-11-21 22:52:44520void Shell::ToggleAppList() {
[email protected]0039db92012-05-09 04:11:45521 if (!app_list_controller_.get())
522 app_list_controller_.reset(new internal::AppListController);
523 app_list_controller_->SetVisible(!app_list_controller_->IsVisible());
[email protected]ae4987d2011-11-21 22:52:44524}
525
[email protected]7510d1082012-03-30 21:58:34526bool Shell::GetAppListTargetVisibility() const {
[email protected]0039db92012-05-09 04:11:45527 return app_list_controller_.get() &&
528 app_list_controller_->GetTargetVisibility();
[email protected]7510d1082012-03-30 21:58:34529}
530
[email protected]1e51a9d2012-04-09 23:31:11531aura::Window* Shell::GetAppListWindow() {
[email protected]0039db92012-05-09 04:11:45532 return app_list_controller_.get() ? app_list_controller_->GetWindow() : NULL;
[email protected]1e51a9d2012-04-09 23:31:11533}
534
[email protected]f7eb89c2011-12-13 09:48:54535bool Shell::IsScreenLocked() const {
[email protected]262f8bd2012-03-23 19:30:27536 return !delegate_.get() || delegate_->IsScreenLocked();
[email protected]f7eb89c2011-12-13 09:48:54537}
538
[email protected]40c4cbb2012-01-10 23:26:07539bool Shell::IsModalWindowOpen() const {
[email protected]7b0f7502012-06-11 00:12:39540 // TODO(oshima): Walk though all root windows.
[email protected]e73bd7802012-02-17 20:10:34541 const aura::Window* modal_container = GetContainer(
[email protected]7b0f7502012-06-11 00:12:39542 GetPrimaryRootWindow(),
[email protected]e73bd7802012-02-17 20:10:34543 internal::kShellWindowId_SystemModalContainer);
[email protected]40c4cbb2012-01-10 23:26:07544 return !modal_container->children().empty();
545}
546
[email protected]57b8bb352012-01-11 05:11:46547views::NonClientFrameView* Shell::CreateDefaultNonClientFrameView(
548 views::Widget* widget) {
549 if (CommandLine::ForCurrentProcess()->HasSwitch(
550 switches::kAuraGoogleDialogFrames)) {
551 return new internal::DialogFrameView;
552 }
[email protected]c73d1332012-03-08 17:11:04553 // Use translucent-style window frames for dialogs.
[email protected]95c6cc42012-03-08 20:53:15554 CustomFrameViewAsh* frame_view = new CustomFrameViewAsh;
[email protected]c73d1332012-03-08 17:11:04555 frame_view->Init(widget);
556 return frame_view;
[email protected]57b8bb352012-01-11 05:11:46557}
558
[email protected]3d29912a2012-02-07 07:41:51559void Shell::RotateFocus(Direction direction) {
560 focus_cycler_->RotateFocus(
561 direction == FORWARD ? internal::FocusCycler::FORWARD :
562 internal::FocusCycler::BACKWARD);
563}
564
[email protected]2e236a52012-06-27 22:21:47565void Shell::SetDisplayWorkAreaInsets(Window* contains,
[email protected]8a45c972012-03-14 18:22:44566 const gfx::Insets& insets) {
[email protected]2e236a52012-06-27 22:21:47567 internal::MultiDisplayManager* display_manager =
568 static_cast<internal::MultiDisplayManager*>(
569 aura::Env::GetInstance()->display_manager());
570 if (!display_manager->UpdateWorkAreaOfDisplayNearestWindow(contains, insets))
[email protected]1a2145b2012-03-13 21:09:17571 return;
[email protected]1a2145b2012-03-13 21:09:17572 FOR_EACH_OBSERVER(ShellObserver, observers_,
[email protected]2e236a52012-06-27 22:21:47573 OnDisplayWorkAreaInsetsChanged());
[email protected]1a2145b2012-03-13 21:09:17574}
575
[email protected]82d3954ae2012-04-20 09:02:22576void Shell::OnLoginStateChanged(user::LoginStatus status) {
577 FOR_EACH_OBSERVER(ShellObserver, observers_, OnLoginStateChanged(status));
578}
579
580void Shell::OnAppTerminating() {
581 FOR_EACH_OBSERVER(ShellObserver, observers_, OnAppTerminating());
582}
583
584void Shell::OnLockStateChanged(bool locked) {
585 FOR_EACH_OBSERVER(ShellObserver, observers_, OnLockStateChanged(locked));
586}
587
[email protected]d9456cb2012-03-21 16:41:04588void Shell::CreateLauncher() {
589 if (launcher_.get())
590 return;
591
[email protected]d90b8392012-06-13 09:34:56592 aura::Window* default_container =
593 GetPrimaryRootWindowController()->
594 GetContainer(internal::kShellWindowId_DefaultContainer);
[email protected]cbc278f2012-07-10 03:40:21595 launcher_.reset(new Launcher(default_container, shelf_));
[email protected]d9456cb2012-03-21 16:41:04596
597 launcher_->SetFocusCycler(focus_cycler_.get());
598 shelf_->SetLauncher(launcher_.get());
[email protected]7cf8dd62012-04-22 05:14:58599 if (panel_layout_manager_)
600 panel_layout_manager_->SetLauncher(launcher_.get());
[email protected]d9456cb2012-03-21 16:41:04601
[email protected]7e1df2f62012-07-19 19:17:18602 if (delegate())
603 launcher_->SetVisible(delegate()->IsSessionStarted());
[email protected]d9456cb2012-03-21 16:41:04604 launcher_->widget()->Show();
605}
606
[email protected]7e1df2f62012-07-19 19:17:18607void Shell::ShowLauncher() {
608 if (!launcher_.get())
609 return;
610 launcher_->SetVisible(true);
611}
612
[email protected]1a2145b2012-03-13 21:09:17613void Shell::AddShellObserver(ShellObserver* observer) {
614 observers_.AddObserver(observer);
615}
616
617void Shell::RemoveShellObserver(ShellObserver* observer) {
618 observers_.RemoveObserver(observer);
619}
620
[email protected]c758fbf2012-03-25 22:53:59621void Shell::UpdateShelfVisibility() {
622 shelf_->UpdateVisibilityState();
623}
624
[email protected]09f3fc82012-03-26 23:26:56625void Shell::SetShelfAutoHideBehavior(ShelfAutoHideBehavior behavior) {
626 shelf_->SetAutoHideBehavior(behavior);
[email protected]c758fbf2012-03-25 22:53:59627}
628
[email protected]09f3fc82012-03-26 23:26:56629ShelfAutoHideBehavior Shell::GetShelfAutoHideBehavior() const {
630 return shelf_->auto_hide_behavior();
[email protected]c758fbf2012-03-25 22:53:59631}
632
[email protected]55444502012-05-10 15:43:53633void Shell::SetShelfAlignment(ShelfAlignment alignment) {
[email protected]c2d58b42012-05-30 08:11:29634 if (!shelf_->SetAlignment(alignment))
635 return;
[email protected]a5c63ce82012-07-18 18:48:57636 FOR_EACH_OBSERVER(ShellObserver, observers_, OnShelfAlignmentChanged());
[email protected]55444502012-05-10 15:43:53637}
638
639ShelfAlignment Shell::GetShelfAlignment() {
640 return shelf_->alignment();
641}
642
[email protected]d90b8392012-06-13 09:34:56643void Shell::SetDimming(bool should_dim) {
[email protected]be65be362012-06-15 07:38:23644 RootWindowControllerList controllers = GetAllRootWindowControllers();
645 for (RootWindowControllerList::iterator iter = controllers.begin();
646 iter != controllers.end(); ++iter)
647 (*iter)->screen_dimmer()->SetDimming(should_dim);
[email protected]d90b8392012-06-13 09:34:56648}
649
[email protected]aa54218b2012-06-12 16:51:42650SystemTrayDelegate* Shell::tray_delegate() {
651 return status_area_widget_->system_tray_delegate();
652}
653
654SystemTray* Shell::system_tray() {
655 return status_area_widget_->system_tray();
656}
657
[email protected]85d43f02012-03-14 21:11:19658int Shell::GetGridSize() const {
[email protected]f4bb9fde2012-08-03 19:33:50659 return
660 GetPrimaryRootWindowController()->workspace_controller()->GetGridSize();
[email protected]9628e0af2012-04-12 20:40:56661}
662
[email protected]2e236a52012-06-27 22:21:47663void Shell::InitRootWindowForSecondaryDisplay(aura::RootWindow* root) {
[email protected]a857dbe2012-05-30 22:10:14664 root->set_focus_manager(focus_manager_.get());
[email protected]2e236a52012-06-27 22:21:47665 if (internal::DisplayController::IsExtendedDesktopEnabled()) {
[email protected]be65be362012-06-15 07:38:23666 internal::RootWindowController* controller =
667 new internal::RootWindowController(root);
668 controller->CreateContainers();
669 InitRootWindowController(controller);
670 controller->root_window_layout()->OnWindowResized();
[email protected]37f27b622012-06-21 20:42:54671 desktop_background_controller_->OnRootWindowAdded(root);
[email protected]be65be362012-06-15 07:38:23672 root->ShowRootWindow();
673 // Activate new root for testing.
674 active_root_window_ = root;
675 } else {
676 root->SetFocusWhenShown(false);
677 root->SetLayoutManager(new internal::RootWindowLayoutManager(root));
678 aura::Window* container = new aura::Window(NULL);
[email protected]2e236a52012-06-27 22:21:47679 container->SetName("SecondaryDisplayContainer");
[email protected]be65be362012-06-15 07:38:23680 container->Init(ui::LAYER_NOT_DRAWN);
681 root->AddChild(container);
682 container->SetLayoutManager(new internal::BaseLayoutManager(root));
[email protected]2e236a52012-06-27 22:21:47683 CreateSecondaryDisplayWidget(container);
[email protected]be65be362012-06-15 07:38:23684 container->Show();
685 root->layout_manager()->OnWindowResized();
[email protected]be65be362012-06-15 07:38:23686 aura::client::SetCaptureClient(root, capture_controller_.get());
[email protected]8d625fb2012-07-18 16:40:06687 aura::client::SetScreenPositionClient(
688 root, screen_position_controller_.get());
[email protected]9946b672012-08-24 21:05:15689 root->ShowRootWindow();
[email protected]be65be362012-06-15 07:38:23690 }
[email protected]a857dbe2012-05-30 22:10:14691}
692
[email protected]be65be362012-06-15 07:38:23693void Shell::InitRootWindowController(
694 internal::RootWindowController* controller) {
695 aura::RootWindow* root_window = controller->root_window();
[email protected]d90b8392012-06-13 09:34:56696 DCHECK(activation_controller_.get());
697 DCHECK(visibility_controller_.get());
698 DCHECK(drag_drop_controller_.get());
699 DCHECK(capture_controller_.get());
[email protected]8fef7432012-08-06 15:34:25700 DCHECK(window_cycle_controller_.get());
[email protected]d90b8392012-06-13 09:34:56701
702 root_window->set_focus_manager(focus_manager_.get());
703 input_method_filter_->SetInputMethodPropertyInRootWindow(root_window);
704 aura::client::SetActivationClient(root_window, activation_controller_.get());
705 aura::client::SetVisibilityClient(root_window, visibility_controller_.get());
706 aura::client::SetDragDropClient(root_window, drag_drop_controller_.get());
[email protected]d90b8392012-06-13 09:34:56707 aura::client::SetCaptureClient(root_window, capture_controller_.get());
[email protected]8d625fb2012-07-18 16:40:06708 aura::client::SetScreenPositionClient(root_window,
709 screen_position_controller_.get());
[email protected]4b8003c2012-07-26 00:54:19710 aura::client::SetCursorClient(root_window, &cursor_manager_);
[email protected]54a37cdc2012-07-25 19:16:01711 aura::client::SetTooltipClient(root_window, tooltip_controller_.get());
[email protected]d90b8392012-06-13 09:34:56712
713 if (nested_dispatcher_controller_.get()) {
714 aura::client::SetDispatcherClient(root_window,
715 nested_dispatcher_controller_.get());
716 }
717 if (user_action_client_.get())
718 aura::client::SetUserActionClient(root_window, user_action_client_.get());
719
720 root_window->SetCursor(ui::kCursorPointer);
[email protected]be65be362012-06-15 07:38:23721 controller->InitLayoutManagers();
[email protected]f059c6942012-07-21 14:27:57722
723 // TODO(oshima): Move the instance to RootWindowController when
724 // the extended desktop is enabled by default.
725 internal::AlwaysOnTopController* always_on_top_controller =
726 new internal::AlwaysOnTopController;
727 always_on_top_controller->SetContainers(
728 root_window->GetChildById(internal::kShellWindowId_DefaultContainer),
729 root_window->GetChildById(internal::kShellWindowId_AlwaysOnTopContainer));
730 root_window->SetProperty(internal::kAlwaysOnTopControllerKey,
731 always_on_top_controller);
[email protected]8fef7432012-08-06 15:34:25732
733 window_cycle_controller_->OnRootWindowAdded(root_window);
[email protected]d90b8392012-06-13 09:34:56734}
735
[email protected]46ca3632011-11-03 03:33:42736////////////////////////////////////////////////////////////////////////////////
737// Shell, private:
738
[email protected]d90b8392012-06-13 09:34:56739void Shell::InitLayoutManagersForPrimaryDisplay(
740 internal::RootWindowController* controller) {
[email protected]6d6546e2012-05-30 23:12:02741 DCHECK(status_area_widget_);
[email protected]b0079a92012-01-25 20:13:38742
[email protected]b0079a92012-01-25 20:13:38743 internal::ShelfLayoutManager* shelf_layout_manager =
[email protected]6d6546e2012-05-30 23:12:02744 new internal::ShelfLayoutManager(status_area_widget_);
[email protected]d90b8392012-06-13 09:34:56745 controller->GetContainer(internal::kShellWindowId_LauncherContainer)->
[email protected]b0079a92012-01-25 20:13:38746 SetLayoutManager(shelf_layout_manager);
[email protected]4e437632012-02-13 22:39:40747 shelf_ = shelf_layout_manager;
[email protected]b0079a92012-01-25 20:13:38748
749 internal::StatusAreaLayoutManager* status_area_layout_manager =
750 new internal::StatusAreaLayoutManager(shelf_layout_manager);
[email protected]d90b8392012-06-13 09:34:56751 controller->GetContainer(internal::kShellWindowId_StatusContainer)->
[email protected]b0079a92012-01-25 20:13:38752 SetLayoutManager(status_area_layout_manager);
753
[email protected]f4bb9fde2012-08-03 19:33:50754 shelf_layout_manager->set_workspace_controller(
755 controller->workspace_controller());
[email protected]fa0c3f22012-03-05 17:55:13756
[email protected]d90b8392012-06-13 09:34:56757 // TODO(oshima): Support multiple displays.
[email protected]f4bb9fde2012-08-03 19:33:50758 controller->workspace_controller()->SetShelf(shelf());
[email protected]c066b8d2012-03-26 00:23:16759
[email protected]7cf8dd62012-04-22 05:14:58760 // Create Panel layout manager
[email protected]87d722a2012-07-12 15:38:33761 aura::Window* panel_container = GetContainer(
762 GetPrimaryRootWindow(),
763 internal::kShellWindowId_PanelContainer);
764 panel_layout_manager_ =
765 new internal::PanelLayoutManager(panel_container);
766 panel_container->SetEventFilter(
767 new internal::PanelWindowEventFilter(
768 panel_container, panel_layout_manager_));
769 panel_container->SetLayoutManager(panel_layout_manager_);
[email protected]cac10fc62011-10-07 23:22:56770}
771
[email protected]f4bb9fde2012-08-03 19:33:50772// TODO: this is only used in tests, move with test.
[email protected]ad0c8722012-03-02 20:17:45773void Shell::DisableWorkspaceGridLayout() {
[email protected]be65be362012-06-15 07:38:23774 RootWindowControllerList controllers = GetAllRootWindowControllers();
775 for (RootWindowControllerList::iterator iter = controllers.begin();
776 iter != controllers.end(); ++iter)
[email protected]f4bb9fde2012-08-03 19:33:50777 (*iter)->workspace_controller()->SetGridSize(0);
[email protected]ad0c8722012-03-02 20:17:45778}
779
[email protected]1aad3322012-06-06 06:37:09780void Shell::SetCursor(gfx::NativeCursor cursor) {
[email protected]be65be362012-06-15 07:38:23781 RootWindowList root_windows = GetAllRootWindows();
782 for (RootWindowList::iterator iter = root_windows.begin();
783 iter != root_windows.end(); ++iter)
784 (*iter)->SetCursor(cursor);
[email protected]1aad3322012-06-06 06:37:09785}
786
787void Shell::ShowCursor(bool visible) {
[email protected]be65be362012-06-15 07:38:23788 RootWindowList root_windows = GetAllRootWindows();
789 for (RootWindowList::iterator iter = root_windows.begin();
790 iter != root_windows.end(); ++iter)
791 (*iter)->ShowCursor(visible);
[email protected]1aad3322012-06-06 06:37:09792}
793
[email protected]55f593352011-12-24 05:42:46794} // namespace ash