[email protected] | e0d22e8 | 2012-01-04 00:46:57 | [diff] [blame] | 1 | // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
[email protected] | 87b0d82e | 2011-10-07 21:02:59 | [diff] [blame] | 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
| 4 | |
[email protected] | b65bdda | 2011-12-23 23:35:31 | [diff] [blame] | 5 | #include "ash/shell.h" |
[email protected] | 87b0d82e | 2011-10-07 21:02:59 | [diff] [blame] | 6 | |
[email protected] | f7eb89c | 2011-12-13 09:48:54 | [diff] [blame] | 7 | #include <algorithm> |
[email protected] | 0039db9 | 2012-05-09 04:11:45 | [diff] [blame] | 8 | #include <string> |
[email protected] | f7eb89c | 2011-12-13 09:48:54 | [diff] [blame] | 9 | |
[email protected] | e7293fa | 2012-05-17 04:42:33 | [diff] [blame] | 10 | #include "ash/accelerators/focus_manager_factory.h" |
[email protected] | b65bdda | 2011-12-23 23:35:31 | [diff] [blame] | 11 | #include "ash/ash_switches.h" |
[email protected] | e70cf0ed | 2012-03-15 16:24:47 | [diff] [blame] | 12 | #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] | 2f74428 | 2011-12-23 22:40:52 | [diff] [blame] | 15 | #include "ash/drag_drop/drag_drop_controller.h" |
[email protected] | 3d29912a | 2012-02-07 07:41:51 | [diff] [blame] | 16 | #include "ash/focus_cycler.h" |
[email protected] | f48075d | 2012-05-24 11:06:51 | [diff] [blame] | 17 | #include "ash/high_contrast/high_contrast_controller.h" |
[email protected] | 7634f96 | 2011-12-23 21:35:52 | [diff] [blame] | 18 | #include "ash/launcher/launcher.h" |
[email protected] | c1c67017 | 2012-04-26 04:20:26 | [diff] [blame] | 19 | #include "ash/magnifier/magnification_controller.h" |
[email protected] | 2e236a5 | 2012-06-27 22:21:47 | [diff] [blame] | 20 | #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] | 8d625fb | 2012-07-18 16:40:06 | [diff] [blame] | 23 | #include "ash/display/screen_position_controller.h" |
[email protected] | 2e236a5 | 2012-06-27 22:21:47 | [diff] [blame] | 24 | #include "ash/display/secondary_display_view.h" |
[email protected] | d90b839 | 2012-06-13 09:34:56 | [diff] [blame] | 25 | #include "ash/root_window_controller.h" |
[email protected] | 1a2145b | 2012-03-13 21:09:17 | [diff] [blame] | 26 | #include "ash/screen_ash.h" |
[email protected] | 0cfc18e | 2012-04-11 18:17:47 | [diff] [blame] | 27 | #include "ash/shell_context_menu.h" |
[email protected] | b65bdda | 2011-12-23 23:35:31 | [diff] [blame] | 28 | #include "ash/shell_delegate.h" |
| 29 | #include "ash/shell_factory.h" |
| 30 | #include "ash/shell_window_ids.h" |
[email protected] | 6d6546e | 2012-05-30 23:12:02 | [diff] [blame] | 31 | #include "ash/system/status_area_widget.h" |
[email protected] | bfb41131 | 2012-02-27 20:59:27 | [diff] [blame] | 32 | #include "ash/system/tray/system_tray.h" |
[email protected] | 2f74428 | 2011-12-23 22:40:52 | [diff] [blame] | 33 | #include "ash/tooltips/tooltip_controller.h" |
[email protected] | 7307474 | 2012-05-17 01:44:41 | [diff] [blame] | 34 | #include "ash/touch/touch_observer_hud.h" |
[email protected] | 7634f96 | 2011-12-23 21:35:52 | [diff] [blame] | 35 | #include "ash/wm/activation_controller.h" |
[email protected] | f059c694 | 2012-07-21 14:27:57 | [diff] [blame] | 36 | #include "ash/wm/always_on_top_controller.h" |
[email protected] | 0039db9 | 2012-05-09 04:11:45 | [diff] [blame] | 37 | #include "ash/wm/app_list_controller.h" |
[email protected] | 8812588c | 2012-01-30 21:19:03 | [diff] [blame] | 38 | #include "ash/wm/base_layout_manager.h" |
[email protected] | 60a978b7 | 2012-06-08 00:29:18 | [diff] [blame] | 39 | #include "ash/wm/capture_controller.h" |
[email protected] | 9d4d171 | 2012-03-06 06:55:25 | [diff] [blame] | 40 | #include "ash/wm/custom_frame_view_ash.h" |
[email protected] | 57b8bb35 | 2012-01-11 05:11:46 | [diff] [blame] | 41 | #include "ash/wm/dialog_frame_view.h" |
[email protected] | 262f8bd | 2012-03-23 19:30:27 | [diff] [blame] | 42 | #include "ash/wm/event_client_impl.h" |
[email protected] | b9d224c | 2012-07-13 01:09:03 | [diff] [blame] | 43 | #include "ash/wm/event_rewriter_event_filter.h" |
[email protected] | 9ae32df | 2012-07-26 03:25:18 | [diff] [blame] | 44 | #include "ash/wm/overlay_event_filter.h" |
[email protected] | 6b85493 | 2012-02-04 16:44:27 | [diff] [blame] | 45 | #include "ash/wm/panel_layout_manager.h" |
[email protected] | c783955 | 2012-04-03 21:14:36 | [diff] [blame] | 46 | #include "ash/wm/panel_window_event_filter.h" |
[email protected] | e0d22e8 | 2012-01-04 00:46:57 | [diff] [blame] | 47 | #include "ash/wm/power_button_controller.h" |
[email protected] | 7ae52500 | 2012-07-26 23:55:10 | [diff] [blame] | 48 | #include "ash/wm/property_util.h" |
[email protected] | e4a181cc | 2012-03-17 02:20:57 | [diff] [blame] | 49 | #include "ash/wm/resize_shadow_controller.h" |
[email protected] | a3301dc | 2011-12-23 16:34:51 | [diff] [blame] | 50 | #include "ash/wm/root_window_layout_manager.h" |
[email protected] | 4299321 | 2012-04-30 23:42:04 | [diff] [blame] | 51 | #include "ash/wm/screen_dimmer.h" |
[email protected] | 7585967 | 2011-12-23 01:04:56 | [diff] [blame] | 52 | #include "ash/wm/shadow_controller.h" |
[email protected] | 7634f96 | 2011-12-23 21:35:52 | [diff] [blame] | 53 | #include "ash/wm/shelf_layout_manager.h" |
[email protected] | 7585967 | 2011-12-23 01:04:56 | [diff] [blame] | 54 | #include "ash/wm/stacking_controller.h" |
[email protected] | 7634f96 | 2011-12-23 21:35:52 | [diff] [blame] | 55 | #include "ash/wm/status_area_layout_manager.h" |
[email protected] | 435b212e | 2012-04-05 19:43:37 | [diff] [blame] | 56 | #include "ash/wm/system_gesture_event_filter.h" |
[email protected] | 4244d699 | 2012-01-23 17:14:33 | [diff] [blame] | 57 | #include "ash/wm/system_modal_container_layout_manager.h" |
[email protected] | a3301dc | 2011-12-23 16:34:51 | [diff] [blame] | 58 | #include "ash/wm/toplevel_window_event_filter.h" |
[email protected] | c16b942 | 2012-06-06 21:51:11 | [diff] [blame] | 59 | #include "ash/wm/user_activity_detector.h" |
[email protected] | 9633a9d2 | 2012-01-21 16:40:58 | [diff] [blame] | 60 | #include "ash/wm/video_detector.h" |
[email protected] | ddd91e9 | 2012-01-27 16:03:48 | [diff] [blame] | 61 | #include "ash/wm/visibility_controller.h" |
[email protected] | 40c4cbb | 2012-01-10 23:26:07 | [diff] [blame] | 62 | #include "ash/wm/window_cycle_controller.h" |
[email protected] | 8037357 | 2012-01-06 23:14:30 | [diff] [blame] | 63 | #include "ash/wm/window_modality_controller.h" |
[email protected] | 40c4cbb | 2012-01-10 23:26:07 | [diff] [blame] | 64 | #include "ash/wm/window_util.h" |
[email protected] | f059c694 | 2012-07-21 14:27:57 | [diff] [blame] | 65 | #include "ash/wm/window_properties.h" |
[email protected] | 9633a9d2 | 2012-01-21 16:40:58 | [diff] [blame] | 66 | #include "ash/wm/workspace/workspace_event_filter.h" |
| 67 | #include "ash/wm/workspace/workspace_layout_manager.h" |
[email protected] | c783955 | 2012-04-03 21:14:36 | [diff] [blame] | 68 | #include "ash/wm/workspace_controller.h" |
[email protected] | f296be7 | 2011-10-11 15:40:00 | [diff] [blame] | 69 | #include "base/bind.h" |
[email protected] | 46ca363 | 2011-11-03 03:33:42 | [diff] [blame] | 70 | #include "base/command_line.h" |
[email protected] | 7c0c96f4 | 2012-03-14 01:04:27 | [diff] [blame] | 71 | #include "grit/ui_resources.h" |
[email protected] | 2c45610 | 2011-12-26 06:26:34 | [diff] [blame] | 72 | #include "ui/aura/client/aura_constants.h" |
[email protected] | c2885361 | 2012-05-31 22:43:44 | [diff] [blame] | 73 | #include "ui/aura/client/user_action_client.h" |
[email protected] | 8a45c97 | 2012-03-14 18:22:44 | [diff] [blame] | 74 | #include "ui/aura/env.h" |
[email protected] | a857dbe | 2012-05-30 22:10:14 | [diff] [blame] | 75 | #include "ui/aura/focus_manager.h" |
[email protected] | 4bb1650 | 2011-12-06 14:44:58 | [diff] [blame] | 76 | #include "ui/aura/layout_manager.h" |
[email protected] | 2e236a5 | 2012-06-27 22:21:47 | [diff] [blame] | 77 | #include "ui/aura/display_manager.h" |
[email protected] | 2c45610 | 2011-12-26 06:26:34 | [diff] [blame] | 78 | #include "ui/aura/root_window.h" |
[email protected] | 1aad332 | 2012-06-06 06:37:09 | [diff] [blame] | 79 | #include "ui/aura/shared/compound_event_filter.h" |
[email protected] | 0e46c27 | 2012-05-15 18:15:23 | [diff] [blame] | 80 | #include "ui/aura/shared/input_method_event_filter.h" |
[email protected] | 536f808 | 2012-03-16 09:30:33 | [diff] [blame] | 81 | #include "ui/aura/ui_controls_aura.h" |
[email protected] | 87b0d82e | 2011-10-07 21:02:59 | [diff] [blame] | 82 | #include "ui/aura/window.h" |
[email protected] | 116302fc | 2012-05-05 21:45:41 | [diff] [blame] | 83 | #include "ui/compositor/layer.h" |
| 84 | #include "ui/compositor/layer_animator.h" |
[email protected] | 7da9c4c | 2012-06-12 14:43:01 | [diff] [blame] | 85 | #include "ui/gfx/display.h" |
[email protected] | 9ec0f45 | 2012-05-31 15:58:53 | [diff] [blame] | 86 | #include "ui/gfx/image/image_skia.h" |
[email protected] | b82c42c4 | 2012-04-25 20:03:41 | [diff] [blame] | 87 | #include "ui/gfx/screen.h" |
[email protected] | b063928 | 2011-12-22 21:12:27 | [diff] [blame] | 88 | #include "ui/gfx/size.h" |
[email protected] | 536f808 | 2012-03-16 09:30:33 | [diff] [blame] | 89 | #include "ui/ui_controls/ui_controls.h" |
[email protected] | e7293fa | 2012-05-17 04:42:33 | [diff] [blame] | 90 | #include "ui/views/focus/focus_manager_factory.h" |
[email protected] | c13be0d | 2011-11-22 02:09:58 | [diff] [blame] | 91 | #include "ui/views/widget/native_widget_aura.h" |
| 92 | #include "ui/views/widget/widget.h" |
[email protected] | 87b0d82e | 2011-10-07 21:02:59 | [diff] [blame] | 93 | |
[email protected] | 6e9f6aa | 2012-02-09 04:16:20 | [diff] [blame] | 94 | #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] | 70b3e7d5 | 2012-06-02 22:12:25 | [diff] [blame] | 100 | #if defined(OS_CHROMEOS) |
[email protected] | 196e945 | 2012-08-01 06:42:51 | [diff] [blame] | 101 | #include "ash/display/output_configurator_animation.h" |
[email protected] | 2e236a5 | 2012-06-27 22:21:47 | [diff] [blame] | 102 | #include "chromeos/display/output_configurator.h" |
[email protected] | 70b3e7d5 | 2012-06-02 22:12:25 | [diff] [blame] | 103 | #include "ui/aura/dispatcher_linux.h" |
| 104 | #endif // defined(OS_CHROMEOS) |
| 105 | |
[email protected] | 55f59335 | 2011-12-24 05:42:46 | [diff] [blame] | 106 | namespace ash { |
[email protected] | 87b0d82e | 2011-10-07 21:02:59 | [diff] [blame] | 107 | |
| 108 | namespace { |
[email protected] | 671a2ae | 2011-10-13 21:53:23 | [diff] [blame] | 109 | |
[email protected] | 615922f | 2012-02-07 02:41:15 | [diff] [blame] | 110 | using aura::Window; |
[email protected] | 3f02dc5 | 2011-10-21 19:36:45 | [diff] [blame] | 111 | using views::Widget; |
| 112 | |
[email protected] | 10b2261 | 2012-03-22 17:07:55 | [diff] [blame] | 113 | // This dummy class is used for shell unit tests. We dont have chrome delegate |
| 114 | // in these tests. |
[email protected] | 5c54324 | 2012-03-24 16:25:42 | [diff] [blame] | 115 | class DummyUserWallpaperDelegate : public UserWallpaperDelegate { |
[email protected] | 10b2261 | 2012-03-22 17:07:55 | [diff] [blame] | 116 | public: |
| 117 | DummyUserWallpaperDelegate() {} |
| 118 | |
| 119 | virtual ~DummyUserWallpaperDelegate() {} |
| 120 | |
[email protected] | 815d0c38 | 2012-07-21 08:13:44 | [diff] [blame] | 121 | virtual ash::WindowVisibilityAnimationType GetAnimationType() OVERRIDE { |
| 122 | return WINDOW_VISIBILITY_ANIMATION_TYPE_FADE; |
| 123 | } |
| 124 | |
[email protected] | 0c4f87d | 2012-06-12 02:00:35 | [diff] [blame] | 125 | virtual void InitializeWallpaper() OVERRIDE { |
[email protected] | d5003473 | 2012-06-04 19:11:04 | [diff] [blame] | 126 | ash::Shell::GetInstance()->desktop_background_controller()-> |
| 127 | CreateEmptyWallpaper(); |
[email protected] | 10b2261 | 2012-03-22 17:07:55 | [diff] [blame] | 128 | } |
| 129 | |
[email protected] | 5c54324 | 2012-03-24 16:25:42 | [diff] [blame] | 130 | virtual void OpenSetWallpaperPage() OVERRIDE { |
| 131 | } |
| 132 | |
[email protected] | 0cfc18e | 2012-04-11 18:17:47 | [diff] [blame] | 133 | virtual bool CanOpenSetWallpaperPage() OVERRIDE { |
| 134 | return false; |
| 135 | } |
| 136 | |
[email protected] | 07a2fa6 | 2012-06-26 10:39:38 | [diff] [blame] | 137 | virtual void OnWallpaperAnimationFinished() OVERRIDE { |
| 138 | } |
| 139 | |
[email protected] | 10b2261 | 2012-03-22 17:07:55 | [diff] [blame] | 140 | private: |
[email protected] | 0039db9 | 2012-05-09 04:11:45 | [diff] [blame] | 141 | DISALLOW_COPY_AND_ASSIGN(DummyUserWallpaperDelegate); |
[email protected] | 10b2261 | 2012-03-22 17:07:55 | [diff] [blame] | 142 | }; |
| 143 | |
[email protected] | 87b0d82e | 2011-10-07 21:02:59 | [diff] [blame] | 144 | } // namespace |
| 145 | |
[email protected] | cac10fc6 | 2011-10-07 23:22:56 | [diff] [blame] | 146 | // static |
| 147 | Shell* Shell::instance_ = NULL; |
[email protected] | 2b4cd30 | 2012-02-24 20:21:13 | [diff] [blame] | 148 | // static |
[email protected] | 9488d4d | 2012-02-29 18:32:37 | [diff] [blame] | 149 | bool Shell::initially_hide_cursor_ = false; |
[email protected] | 2b4cd30 | 2012-02-24 20:21:13 | [diff] [blame] | 150 | |
| 151 | //////////////////////////////////////////////////////////////////////////////// |
| 152 | // Shell::TestApi |
| 153 | |
| 154 | Shell::TestApi::TestApi(Shell* shell) : shell_(shell) {} |
| 155 | |
[email protected] | 2b4cd30 | 2012-02-24 20:21:13 | [diff] [blame] | 156 | internal::RootWindowLayoutManager* Shell::TestApi::root_window_layout() { |
[email protected] | d90b839 | 2012-06-13 09:34:56 | [diff] [blame] | 157 | return shell_->GetPrimaryRootWindowController()->root_window_layout(); |
[email protected] | 2b4cd30 | 2012-02-24 20:21:13 | [diff] [blame] | 158 | } |
[email protected] | cac10fc6 | 2011-10-07 23:22:56 | [diff] [blame] | 159 | |
[email protected] | 0e46c27 | 2012-05-15 18:15:23 | [diff] [blame] | 160 | aura::shared::InputMethodEventFilter* |
| 161 | Shell::TestApi::input_method_event_filter() { |
[email protected] | db913160 | 2012-02-29 19:06:32 | [diff] [blame] | 162 | return shell_->input_method_filter_.get(); |
| 163 | } |
| 164 | |
[email protected] | 435b212e | 2012-04-05 19:43:37 | [diff] [blame] | 165 | internal::SystemGestureEventFilter* |
| 166 | Shell::TestApi::system_gesture_event_filter() { |
| 167 | return shell_->system_gesture_filter_.get(); |
| 168 | } |
| 169 | |
[email protected] | db913160 | 2012-02-29 19:06:32 | [diff] [blame] | 170 | internal::WorkspaceController* Shell::TestApi::workspace_controller() { |
[email protected] | d90b839 | 2012-06-13 09:34:56 | [diff] [blame] | 171 | return shell_->GetPrimaryRootWindowController()->workspace_controller(); |
[email protected] | db913160 | 2012-02-29 19:06:32 | [diff] [blame] | 172 | } |
| 173 | |
[email protected] | cac10fc6 | 2011-10-07 23:22:56 | [diff] [blame] | 174 | //////////////////////////////////////////////////////////////////////////////// |
| 175 | // Shell, public: |
| 176 | |
[email protected] | 3266c2b9 | 2011-11-14 00:06:08 | [diff] [blame] | 177 | Shell::Shell(ShellDelegate* delegate) |
[email protected] | d90b839 | 2012-06-13 09:34:56 | [diff] [blame] | 178 | : screen_(new ScreenAsh), |
[email protected] | be65be36 | 2012-06-15 07:38:23 | [diff] [blame] | 179 | active_root_window_(NULL), |
[email protected] | 1aad332 | 2012-06-06 06:37:09 | [diff] [blame] | 180 | env_filter_(NULL), |
[email protected] | 9c66adc | 2012-01-05 02:10:16 | [diff] [blame] | 181 | delegate_(delegate), |
[email protected] | 70b3e7d5 | 2012-06-02 22:12:25 | [diff] [blame] | 182 | #if defined(OS_CHROMEOS) |
[email protected] | fb792f3 | 2012-08-01 01:07:01 | [diff] [blame] | 183 | output_configurator_(new chromeos::OutputConfigurator( |
| 184 | internal::DisplayController::IsExtendedDesktopEnabled())), |
[email protected] | 196e945 | 2012-08-01 06:42:51 | [diff] [blame] | 185 | output_configurator_animation_( |
| 186 | new internal::OutputConfiguratorAnimation()), |
[email protected] | 70b3e7d5 | 2012-06-02 22:12:25 | [diff] [blame] | 187 | #endif // defined(OS_CHROMEOS) |
[email protected] | 4e43763 | 2012-02-13 22:39:40 | [diff] [blame] | 188 | shelf_(NULL), |
[email protected] | 7cf8dd6 | 2012-04-22 05:14:58 | [diff] [blame] | 189 | panel_layout_manager_(NULL), |
[email protected] | 6d6546e | 2012-05-30 23:12:02 | [diff] [blame] | 190 | status_area_widget_(NULL), |
| 191 | browser_context_(NULL) { |
[email protected] | 1a2145b | 2012-03-13 21:09:17 | [diff] [blame] | 192 | gfx::Screen::SetInstance(screen_); |
[email protected] | 054b2d7 | 2012-06-08 04:52:25 | [diff] [blame] | 193 | ui_controls::InstallUIControlsAura(internal::CreateUIControls()); |
[email protected] | 70b3e7d5 | 2012-06-02 22:12:25 | [diff] [blame] | 194 | #if defined(OS_CHROMEOS) |
[email protected] | 196e945 | 2012-08-01 06:42:51 | [diff] [blame] | 195 | output_configurator_->AddObserver(output_configurator_animation_.get()); |
[email protected] | 70b3e7d5 | 2012-06-02 22:12:25 | [diff] [blame] | 196 | static_cast<aura::DispatcherLinux*>( |
| 197 | aura::Env::GetInstance()->GetDispatcher())->AddDispatcherForRootWindow( |
| 198 | output_configurator()); |
| 199 | #endif // defined(OS_CHROMEOS) |
[email protected] | 87b0d82e | 2011-10-07 21:02:59 | [diff] [blame] | 200 | } |
| 201 | |
| 202 | Shell::~Shell() { |
[email protected] | e7293fa | 2012-05-17 04:42:33 | [diff] [blame] | 203 | views::FocusManagerFactory::Install(NULL); |
[email protected] | cb3b8b2 | 2012-06-27 23:26:37 | [diff] [blame] | 204 | |
| 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] | 4b8003c | 2012-07-26 00:54:19 | [diff] [blame] | 211 | cursor_manager_.set_delegate(NULL); |
[email protected] | e7293fa | 2012-05-17 04:42:33 | [diff] [blame] | 212 | |
[email protected] | 9861f175 | 2012-06-01 07:16:14 | [diff] [blame] | 213 | // Please keep in same order as in Init() because it's easy to miss one. |
[email protected] | c16b942 | 2012-06-06 21:51:11 | [diff] [blame] | 214 | RemoveEnvEventFilter(user_activity_detector_.get()); |
[email protected] | b9d224c | 2012-07-13 01:09:03 | [diff] [blame] | 215 | RemoveEnvEventFilter(event_rewriter_filter_.get()); |
[email protected] | 9ae32df | 2012-07-26 03:25:18 | [diff] [blame] | 216 | RemoveEnvEventFilter(overlay_filter_.get()); |
[email protected] | 1aad332 | 2012-06-06 06:37:09 | [diff] [blame] | 217 | RemoveEnvEventFilter(input_method_filter_.get()); |
| 218 | RemoveEnvEventFilter(window_modality_controller_.get()); |
[email protected] | 78d9630 | 2012-06-22 00:58:07 | [diff] [blame] | 219 | if (mouse_cursor_filter_.get()) |
| 220 | RemoveEnvEventFilter(mouse_cursor_filter_.get()); |
[email protected] | 1aad332 | 2012-06-06 06:37:09 | [diff] [blame] | 221 | RemoveEnvEventFilter(system_gesture_filter_.get()); |
[email protected] | 6e9f6aa | 2012-02-09 04:16:20 | [diff] [blame] | 222 | #if !defined(OS_MACOSX) |
[email protected] | 1aad332 | 2012-06-06 06:37:09 | [diff] [blame] | 223 | RemoveEnvEventFilter(accelerator_filter_.get()); |
[email protected] | 6e9f6aa | 2012-02-09 04:16:20 | [diff] [blame] | 224 | #endif |
[email protected] | 7307474 | 2012-05-17 01:44:41 | [diff] [blame] | 225 | if (touch_observer_hud_.get()) |
[email protected] | 1aad332 | 2012-06-06 06:37:09 | [diff] [blame] | 226 | RemoveEnvEventFilter(touch_observer_hud_.get()); |
[email protected] | 745816be | 2011-11-22 05:08:30 | [diff] [blame] | 227 | |
[email protected] | 931f4f4 | 2012-02-10 23:49:42 | [diff] [blame] | 228 | // TooltipController is deleted with the Shell so removing its references. |
[email protected] | 1aad332 | 2012-06-06 06:37:09 | [diff] [blame] | 229 | RemoveEnvEventFilter(tooltip_controller_.get()); |
[email protected] | ef589af | 2011-12-03 01:07:15 | [diff] [blame] | 230 | |
[email protected] | aa54218b | 2012-06-12 16:51:42 | [diff] [blame] | 231 | // The status area needs to be shut down before the windows are destroyed. |
| 232 | status_area_widget_->Shutdown(); |
[email protected] | bfb41131 | 2012-02-27 20:59:27 | [diff] [blame] | 233 | |
[email protected] | f5f3c75 | 2012-06-07 05:16:02 | [diff] [blame] | 234 | // 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] | be65be36 | 2012-06-15 07:38:23 | [diff] [blame] | 240 | // Destroy all child windows including widgets. |
[email protected] | 2e236a5 | 2012-06-27 22:21:47 | [diff] [blame] | 241 | display_controller_->CloseChildWindows(); |
[email protected] | ef589af | 2011-12-03 01:07:15 | [diff] [blame] | 242 | |
[email protected] | 40c4cbb | 2012-01-10 23:26:07 | [diff] [blame] | 243 | // These need a valid Shell instance to clean up properly, so explicitly |
| 244 | // delete them before invalidating the instance. |
[email protected] | 58482fa | 2012-03-02 14:57:39 | [diff] [blame] | 245 | // Alphabetical. |
[email protected] | 084b6bb | 2011-11-17 05:18:16 | [diff] [blame] | 246 | drag_drop_controller_.reset(); |
[email protected] | c1c67017 | 2012-04-26 04:20:26 | [diff] [blame] | 247 | magnification_controller_.reset(); |
[email protected] | aa47650 | 2012-05-01 18:03:19 | [diff] [blame] | 248 | power_button_controller_.reset(); |
[email protected] | e4a181cc | 2012-03-17 02:20:57 | [diff] [blame] | 249 | resize_shadow_controller_.reset(); |
[email protected] | 58482fa | 2012-03-02 14:57:39 | [diff] [blame] | 250 | shadow_controller_.reset(); |
[email protected] | fd162f7 | 2012-04-14 03:24:53 | [diff] [blame] | 251 | tooltip_controller_.reset(); |
[email protected] | aa47650 | 2012-05-01 18:03:19 | [diff] [blame] | 252 | window_cycle_controller_.reset(); |
[email protected] | 60a978b7 | 2012-06-08 00:29:18 | [diff] [blame] | 253 | capture_controller_.reset(); |
[email protected] | 60a978b7 | 2012-06-08 00:29:18 | [diff] [blame] | 254 | nested_dispatcher_controller_.reset(); |
[email protected] | 60a978b7 | 2012-06-08 00:29:18 | [diff] [blame] | 255 | user_action_client_.reset(); |
[email protected] | 60a978b7 | 2012-06-08 00:29:18 | [diff] [blame] | 256 | visibility_controller_.reset(); |
[email protected] | 084b6bb | 2011-11-17 05:18:16 | [diff] [blame] | 257 | |
[email protected] | be65be36 | 2012-06-15 07:38:23 | [diff] [blame] | 258 | // This also deletes all RootWindows. |
[email protected] | 2e236a5 | 2012-06-27 22:21:47 | [diff] [blame] | 259 | display_controller_.reset(); |
[email protected] | 8d625fb | 2012-07-18 16:40:06 | [diff] [blame] | 260 | screen_position_controller_.reset(); |
[email protected] | d90b839 | 2012-06-13 09:34:56 | [diff] [blame] | 261 | |
[email protected] | 0a704f0 | 2012-02-15 17:49:43 | [diff] [blame] | 262 | // 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] | 764864e | 2012-06-11 19:16:16 | [diff] [blame] | 269 | // Delete the activation controller after other controllers and launcher |
| 270 | // because they might have registered ActivationChangeObserver. |
[email protected] | 764864e | 2012-06-11 19:16:16 | [diff] [blame] | 271 | activation_controller_.reset(); |
| 272 | |
[email protected] | 488b4204 | 2011-11-15 00:20:18 | [diff] [blame] | 273 | DCHECK(instance_ == this); |
| 274 | instance_ = NULL; |
[email protected] | 70b3e7d5 | 2012-06-02 22:12:25 | [diff] [blame] | 275 | |
| 276 | #if defined(OS_CHROMEOS) |
[email protected] | 196e945 | 2012-08-01 06:42:51 | [diff] [blame] | 277 | output_configurator_->RemoveObserver(output_configurator_animation_.get()); |
[email protected] | 70b3e7d5 | 2012-06-02 22:12:25 | [diff] [blame] | 278 | // 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] | 87b0d82e | 2011-10-07 21:02:59 | [diff] [blame] | 283 | } |
| 284 | |
[email protected] | cac10fc6 | 2011-10-07 23:22:56 | [diff] [blame] | 285 | // static |
[email protected] | 3266c2b9 | 2011-11-14 00:06:08 | [diff] [blame] | 286 | Shell* Shell::CreateInstance(ShellDelegate* delegate) { |
| 287 | CHECK(!instance_); |
[email protected] | 2e236a5 | 2012-06-27 22:21:47 | [diff] [blame] | 288 | aura::Env::GetInstance()->SetDisplayManager( |
| 289 | new internal::MultiDisplayManager()); |
[email protected] | 3266c2b9 | 2011-11-14 00:06:08 | [diff] [blame] | 290 | instance_ = new Shell(delegate); |
| 291 | instance_->Init(); |
| 292 | return instance_; |
| 293 | } |
| 294 | |
| 295 | // static |
[email protected] | cac10fc6 | 2011-10-07 23:22:56 | [diff] [blame] | 296 | Shell* Shell::GetInstance() { |
[email protected] | 3266c2b9 | 2011-11-14 00:06:08 | [diff] [blame] | 297 | DCHECK(instance_); |
[email protected] | cac10fc6 | 2011-10-07 23:22:56 | [diff] [blame] | 298 | return instance_; |
| 299 | } |
| 300 | |
[email protected] | 6377a00 | 2011-11-10 20:26:47 | [diff] [blame] | 301 | // static |
[email protected] | b3b7bcd | 2012-03-06 19:35:45 | [diff] [blame] | 302 | bool Shell::HasInstance() { |
| 303 | return !!instance_; |
| 304 | } |
| 305 | |
| 306 | // static |
[email protected] | ef589af | 2011-12-03 01:07:15 | [diff] [blame] | 307 | void Shell::DeleteInstance() { |
[email protected] | 6377a00 | 2011-11-10 20:26:47 | [diff] [blame] | 308 | delete instance_; |
| 309 | instance_ = NULL; |
| 310 | } |
| 311 | |
[email protected] | e73bd780 | 2012-02-17 20:10:34 | [diff] [blame] | 312 | // static |
[email protected] | d90b839 | 2012-06-13 09:34:56 | [diff] [blame] | 313 | internal::RootWindowController* Shell::GetPrimaryRootWindowController() { |
[email protected] | 7ae52500 | 2012-07-26 23:55:10 | [diff] [blame] | 314 | return GetRootWindowController(GetPrimaryRootWindow()); |
[email protected] | be65be36 | 2012-06-15 07:38:23 | [diff] [blame] | 315 | } |
| 316 | |
| 317 | // static |
| 318 | Shell::RootWindowControllerList Shell::GetAllRootWindowControllers() { |
[email protected] | 2e236a5 | 2012-06-27 22:21:47 | [diff] [blame] | 319 | return Shell::GetInstance()->display_controller()-> |
[email protected] | be65be36 | 2012-06-15 07:38:23 | [diff] [blame] | 320 | GetAllRootWindowControllers(); |
[email protected] | d90b839 | 2012-06-13 09:34:56 | [diff] [blame] | 321 | } |
| 322 | |
| 323 | // static |
[email protected] | 42713f7 | 2012-05-25 00:41:50 | [diff] [blame] | 324 | aura::RootWindow* Shell::GetPrimaryRootWindow() { |
[email protected] | 2e236a5 | 2012-06-27 22:21:47 | [diff] [blame] | 325 | return GetInstance()->display_controller()->GetPrimaryRootWindow(); |
[email protected] | e73bd780 | 2012-02-17 20:10:34 | [diff] [blame] | 326 | } |
| 327 | |
[email protected] | 7b0f750 | 2012-06-11 00:12:39 | [diff] [blame] | 328 | // static |
[email protected] | a857dbe | 2012-05-30 22:10:14 | [diff] [blame] | 329 | aura::RootWindow* Shell::GetActiveRootWindow() { |
| 330 | return GetInstance()->active_root_window_; |
| 331 | } |
| 332 | |
[email protected] | 7b0f750 | 2012-06-11 00:12:39 | [diff] [blame] | 333 | // static |
[email protected] | f18e8452 | 2012-06-05 00:34:18 | [diff] [blame] | 334 | aura::RootWindow* Shell::GetRootWindowAt(const gfx::Point& point) { |
[email protected] | f1ddc1d | 2012-07-09 17:26:19 | [diff] [blame] | 335 | const gfx::Display& display = gfx::Screen::GetDisplayNearestPoint(point); |
| 336 | return Shell::GetInstance()->display_controller()-> |
| 337 | GetRootWindowForDisplayId(display.id()); |
[email protected] | f18e8452 | 2012-06-05 00:34:18 | [diff] [blame] | 338 | } |
| 339 | |
[email protected] | 7b0f750 | 2012-06-11 00:12:39 | [diff] [blame] | 340 | // static |
[email protected] | 20c5976 | 2012-06-23 01:10:24 | [diff] [blame] | 341 | aura::RootWindow* Shell::GetRootWindowMatching(const gfx::Rect& rect) { |
[email protected] | f1ddc1d | 2012-07-09 17:26:19 | [diff] [blame] | 342 | const gfx::Display& display = gfx::Screen::GetDisplayMatching(rect); |
| 343 | return Shell::GetInstance()->display_controller()-> |
| 344 | GetRootWindowForDisplayId(display.id()); |
[email protected] | 20c5976 | 2012-06-23 01:10:24 | [diff] [blame] | 345 | } |
| 346 | |
| 347 | // static |
[email protected] | be65be36 | 2012-06-15 07:38:23 | [diff] [blame] | 348 | Shell::RootWindowList Shell::GetAllRootWindows() { |
[email protected] | 2e236a5 | 2012-06-27 22:21:47 | [diff] [blame] | 349 | return Shell::GetInstance()->display_controller()-> |
[email protected] | be65be36 | 2012-06-15 07:38:23 | [diff] [blame] | 350 | GetAllRootWindows(); |
| 351 | } |
| 352 | |
| 353 | // static |
[email protected] | 7b0f750 | 2012-06-11 00:12:39 | [diff] [blame] | 354 | aura::Window* Shell::GetContainer(aura::RootWindow* root_window, |
| 355 | int container_id) { |
| 356 | return root_window->GetChildById(container_id); |
| 357 | } |
| 358 | |
| 359 | // static |
| 360 | std::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] | 87b0d82e | 2011-10-07 21:02:59 | [diff] [blame] | 369 | void Shell::Init() { |
[email protected] | c9301e3 | 2012-05-23 08:34:58 | [diff] [blame] | 370 | // 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] | 1aad332 | 2012-06-06 06:37:09 | [diff] [blame] | 374 | 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] | 4b8003c | 2012-07-26 00:54:19 | [diff] [blame] | 378 | cursor_manager_.set_delegate(this); |
[email protected] | a857dbe | 2012-05-30 22:10:14 | [diff] [blame] | 379 | |
| 380 | focus_manager_.reset(new aura::FocusManager); |
[email protected] | be65be36 | 2012-06-15 07:38:23 | [diff] [blame] | 381 | activation_controller_.reset( |
| 382 | new internal::ActivationController(focus_manager_.get())); |
| 383 | |
[email protected] | 8d625fb | 2012-07-18 16:40:06 | [diff] [blame] | 384 | screen_position_controller_.reset(new internal::ScreenPositionController); |
[email protected] | 2e236a5 | 2012-06-27 22:21:47 | [diff] [blame] | 385 | display_controller_.reset(new internal::DisplayController); |
| 386 | display_controller_->InitPrimaryDisplay(); |
| 387 | aura::RootWindow* root_window = display_controller_->GetPrimaryRootWindow(); |
[email protected] | be65be36 | 2012-06-15 07:38:23 | [diff] [blame] | 388 | active_root_window_ = root_window; |
[email protected] | a857dbe | 2012-05-30 22:10:14 | [diff] [blame] | 389 | |
[email protected] | 58482fa | 2012-03-02 14:57:39 | [diff] [blame] | 390 | #if !defined(OS_MACOSX) |
| 391 | nested_dispatcher_controller_.reset(new NestedDispatcherController); |
| 392 | accelerator_controller_.reset(new AcceleratorController); |
| 393 | #endif |
[email protected] | 0cfc18e | 2012-04-11 18:17:47 | [diff] [blame] | 394 | shell_context_menu_.reset(new internal::ShellContextMenu); |
[email protected] | 58482fa | 2012-03-02 14:57:39 | [diff] [blame] | 395 | |
[email protected] | c16b942 | 2012-06-06 21:51:11 | [diff] [blame] | 396 | // The order in which event filters are added is significant. |
[email protected] | 1aad332 | 2012-06-06 06:37:09 | [diff] [blame] | 397 | DCHECK(!GetEnvEventFilterCount()); |
[email protected] | c16b942 | 2012-06-06 21:51:11 | [diff] [blame] | 398 | user_activity_detector_.reset(new UserActivityDetector); |
| 399 | AddEnvEventFilter(user_activity_detector_.get()); |
| 400 | |
| 401 | DCHECK_EQ(1U, GetEnvEventFilterCount()); |
[email protected] | b9d224c | 2012-07-13 01:09:03 | [diff] [blame] | 402 | event_rewriter_filter_.reset(new internal::EventRewriterEventFilter); |
| 403 | AddEnvEventFilter(event_rewriter_filter_.get()); |
[email protected] | 0b0b074 | 2012-02-16 13:23:45 | [diff] [blame] | 404 | |
[email protected] | c16b942 | 2012-06-06 21:51:11 | [diff] [blame] | 405 | DCHECK_EQ(2U, GetEnvEventFilterCount()); |
[email protected] | 9ae32df | 2012-07-26 03:25:18 | [diff] [blame] | 406 | overlay_filter_.reset(new internal::OverlayEventFilter); |
| 407 | AddEnvEventFilter(overlay_filter_.get()); |
| 408 | AddShellObserver(overlay_filter_.get()); |
[email protected] | 0b0b074 | 2012-02-16 13:23:45 | [diff] [blame] | 409 | |
[email protected] | c16b942 | 2012-06-06 21:51:11 | [diff] [blame] | 410 | DCHECK_EQ(3U, GetEnvEventFilterCount()); |
[email protected] | 0caad588 | 2012-06-03 15:07:06 | [diff] [blame] | 411 | input_method_filter_.reset(new aura::shared::InputMethodEventFilter()); |
[email protected] | 1aad332 | 2012-06-06 06:37:09 | [diff] [blame] | 412 | AddEnvEventFilter(input_method_filter_.get()); |
[email protected] | c16b942 | 2012-06-06 21:51:11 | [diff] [blame] | 413 | |
[email protected] | 21472b1 | 2012-02-17 00:30:05 | [diff] [blame] | 414 | #if !defined(OS_MACOSX) |
| 415 | accelerator_filter_.reset(new internal::AcceleratorFilter); |
[email protected] | 1aad332 | 2012-06-06 06:37:09 | [diff] [blame] | 416 | AddEnvEventFilter(accelerator_filter_.get()); |
[email protected] | 21472b1 | 2012-02-17 00:30:05 | [diff] [blame] | 417 | #endif |
[email protected] | fcbbf08 | 2012-01-20 06:07:15 | [diff] [blame] | 418 | |
[email protected] | 435b212e | 2012-04-05 19:43:37 | [diff] [blame] | 419 | system_gesture_filter_.reset(new internal::SystemGestureEventFilter); |
[email protected] | 1aad332 | 2012-06-06 06:37:09 | [diff] [blame] | 420 | AddEnvEventFilter(system_gesture_filter_.get()); |
[email protected] | 435b212e | 2012-04-05 19:43:37 | [diff] [blame] | 421 | |
[email protected] | 60a978b7 | 2012-06-08 00:29:18 | [diff] [blame] | 422 | capture_controller_.reset(new internal::CaptureController); |
[email protected] | 87b0d82e | 2011-10-07 21:02:59 | [diff] [blame] | 423 | |
[email protected] | 871e9cc | 2012-06-17 22:41:55 | [diff] [blame] | 424 | internal::RootWindowController* root_window_controller = |
| 425 | new internal::RootWindowController(root_window); |
| 426 | root_window_controller->CreateContainers(); |
| 427 | |
[email protected] | 7307474 | 2012-05-17 01:44:41 | [diff] [blame] | 428 | CommandLine* command_line = CommandLine::ForCurrentProcess(); |
| 429 | |
| 430 | if (command_line->HasSwitch(switches::kAshTouchHud)) { |
| 431 | touch_observer_hud_.reset(new internal::TouchObserverHUD); |
[email protected] | 1aad332 | 2012-06-06 06:37:09 | [diff] [blame] | 432 | AddEnvEventFilter(touch_observer_hud_.get()); |
[email protected] | 7307474 | 2012-05-17 01:44:41 | [diff] [blame] | 433 | } |
[email protected] | d90b839 | 2012-06-13 09:34:56 | [diff] [blame] | 434 | |
| 435 | // Create Controllers that may need root window. |
| 436 | // TODO(oshima): Move as many controllers before creating |
| 437 | // RootWindowController as possible. |
[email protected] | ee1e1a2 | 2011-12-15 01:51:10 | [diff] [blame] | 438 | stacking_controller_.reset(new internal::StackingController); |
[email protected] | d90b839 | 2012-06-13 09:34:56 | [diff] [blame] | 439 | visibility_controller_.reset(new internal::VisibilityController); |
| 440 | drag_drop_controller_.reset(new internal::DragDropController); |
[email protected] | d90b839 | 2012-06-13 09:34:56 | [diff] [blame] | 441 | 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] | 488b4204 | 2011-11-15 00:20:18 | [diff] [blame] | 445 | |
[email protected] | 9613eacf | 2012-06-22 02:18:05 | [diff] [blame] | 446 | magnification_controller_.reset( |
| 447 | internal::MagnificationController::CreateInstance()); |
| 448 | |
[email protected] | 2e236a5 | 2012-06-27 22:21:47 | [diff] [blame] | 449 | if (internal::DisplayController::IsExtendedDesktopEnabled()) { |
[email protected] | 78d9630 | 2012-06-22 00:58:07 | [diff] [blame] | 450 | mouse_cursor_filter_.reset( |
[email protected] | 2e236a5 | 2012-06-27 22:21:47 | [diff] [blame] | 451 | new internal::MouseCursorEventFilter(display_controller_.get())); |
[email protected] | 78d9630 | 2012-06-22 00:58:07 | [diff] [blame] | 452 | AddEnvEventFilter(mouse_cursor_filter_.get()); |
| 453 | } |
| 454 | |
[email protected] | d90b839 | 2012-06-13 09:34:56 | [diff] [blame] | 455 | high_contrast_controller_.reset(new HighContrastController); |
| 456 | video_detector_.reset(new VideoDetector); |
| 457 | window_cycle_controller_.reset(new WindowCycleController); |
[email protected] | b0079a9 | 2012-01-25 20:13:38 | [diff] [blame] | 458 | |
[email protected] | 54a37cdc | 2012-07-25 19:16:01 | [diff] [blame] | 459 | tooltip_controller_.reset(new internal::TooltipController( |
| 460 | drag_drop_controller_.get())); |
| 461 | AddEnvEventFilter(tooltip_controller_.get()); |
| 462 | |
[email protected] | be65be36 | 2012-06-15 07:38:23 | [diff] [blame] | 463 | InitRootWindowController(root_window_controller); |
[email protected] | 262f8bd | 2012-03-23 19:30:27 | [diff] [blame] | 464 | |
[email protected] | d90b839 | 2012-06-13 09:34:56 | [diff] [blame] | 465 | // Initialize Primary RootWindow specific items. |
[email protected] | aa54218b | 2012-06-12 16:51:42 | [diff] [blame] | 466 | status_area_widget_ = new internal::StatusAreaWidget(); |
| 467 | status_area_widget_->CreateTrayViews(delegate_.get()); |
[email protected] | 6d6546e | 2012-05-30 23:12:02 | [diff] [blame] | 468 | status_area_widget_->Show(); |
[email protected] | bfb41131 | 2012-02-27 20:59:27 | [diff] [blame] | 469 | |
[email protected] | d90b839 | 2012-06-13 09:34:56 | [diff] [blame] | 470 | focus_cycler_.reset(new internal::FocusCycler()); |
| 471 | focus_cycler_->AddWidget(status_area_widget_); |
| 472 | |
[email protected] | e70cf0ed | 2012-03-15 16:24:47 | [diff] [blame] | 473 | // This controller needs to be set before SetupManagedWindowMode. |
[email protected] | 6e3b31b | 2012-06-12 23:06:38 | [diff] [blame] | 474 | desktop_background_controller_.reset(new DesktopBackgroundController()); |
[email protected] | 10b2261 | 2012-03-22 17:07:55 | [diff] [blame] | 475 | 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] | e70cf0ed | 2012-03-15 16:24:47 | [diff] [blame] | 479 | |
[email protected] | be65be36 | 2012-06-15 07:38:23 | [diff] [blame] | 480 | InitLayoutManagersForPrimaryDisplay(root_window_controller); |
[email protected] | ca4ed12 | 2011-10-26 05:40:01 | [diff] [blame] | 481 | |
[email protected] | e4a181cc | 2012-03-17 02:20:57 | [diff] [blame] | 482 | if (!command_line->HasSwitch(switches::kAuraNoShadows)) { |
| 483 | resize_shadow_controller_.reset(new internal::ResizeShadowController()); |
[email protected] | a54e65b | 2011-11-21 22:03:34 | [diff] [blame] | 484 | shadow_controller_.reset(new internal::ShadowController()); |
[email protected] | e4a181cc | 2012-03-17 02:20:57 | [diff] [blame] | 485 | } |
[email protected] | a54e65b | 2011-11-21 22:03:34 | [diff] [blame] | 486 | |
[email protected] | 1720a44 | 2012-03-25 22:03:47 | [diff] [blame] | 487 | if (!delegate_.get() || delegate_->IsUserLoggedIn()) |
[email protected] | d9456cb | 2012-03-21 16:41:04 | [diff] [blame] | 488 | CreateLauncher(); |
[email protected] | 3d29912a | 2012-02-07 07:41:51 | [diff] [blame] | 489 | |
[email protected] | d90b839 | 2012-06-13 09:34:56 | [diff] [blame] | 490 | // Force Layout |
[email protected] | be65be36 | 2012-06-15 07:38:23 | [diff] [blame] | 491 | root_window_controller->root_window_layout()->OnWindowResized(); |
[email protected] | 084b6bb | 2011-11-17 05:18:16 | [diff] [blame] | 492 | |
[email protected] | 60b5b86 | 2012-04-27 18:56:34 | [diff] [blame] | 493 | // 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] | 0c4f87d | 2012-06-12 02:00:35 | [diff] [blame] | 495 | user_wallpaper_delegate_->InitializeWallpaper(); |
[email protected] | 60b5b86 | 2012-04-27 18:56:34 | [diff] [blame] | 496 | |
[email protected] | e0d22e8 | 2012-01-04 00:46:57 | [diff] [blame] | 497 | power_button_controller_.reset(new PowerButtonController); |
[email protected] | 82d3954ae | 2012-04-20 09:02:22 | [diff] [blame] | 498 | AddShellObserver(power_button_controller_.get()); |
[email protected] | d90b839 | 2012-06-13 09:34:56 | [diff] [blame] | 499 | |
[email protected] | 2e236a5 | 2012-06-27 22:21:47 | [diff] [blame] | 500 | display_controller_->InitSecondaryDisplays(); |
[email protected] | be65be36 | 2012-06-15 07:38:23 | [diff] [blame] | 501 | |
[email protected] | d90b839 | 2012-06-13 09:34:56 | [diff] [blame] | 502 | if (initially_hide_cursor_) |
[email protected] | 4b8003c | 2012-07-26 00:54:19 | [diff] [blame] | 503 | cursor_manager_.ShowCursor(false); |
[email protected] | 87b0d82e | 2011-10-07 21:02:59 | [diff] [blame] | 504 | } |
| 505 | |
[email protected] | 1aad332 | 2012-06-06 06:37:09 | [diff] [blame] | 506 | void Shell::AddEnvEventFilter(aura::EventFilter* filter) { |
| 507 | env_filter_->AddFilter(filter); |
[email protected] | e29014c | 2011-11-16 18:25:51 | [diff] [blame] | 508 | } |
| 509 | |
[email protected] | 1aad332 | 2012-06-06 06:37:09 | [diff] [blame] | 510 | void Shell::RemoveEnvEventFilter(aura::EventFilter* filter) { |
| 511 | env_filter_->RemoveFilter(filter); |
[email protected] | e29014c | 2011-11-16 18:25:51 | [diff] [blame] | 512 | } |
| 513 | |
[email protected] | 1aad332 | 2012-06-06 06:37:09 | [diff] [blame] | 514 | size_t Shell::GetEnvEventFilterCount() const { |
| 515 | return env_filter_->GetFilterCount(); |
[email protected] | 2c45610 | 2011-12-26 06:26:34 | [diff] [blame] | 516 | } |
| 517 | |
[email protected] | b5f3060 | 2012-01-30 15:16:57 | [diff] [blame] | 518 | void Shell::ShowBackgroundMenu(views::Widget* widget, |
| 519 | const gfx::Point& location) { |
[email protected] | 0cfc18e | 2012-04-11 18:17:47 | [diff] [blame] | 520 | if (shell_context_menu_.get()) |
| 521 | shell_context_menu_->ShowMenu(widget, location); |
[email protected] | 46ca363 | 2011-11-03 03:33:42 | [diff] [blame] | 522 | } |
| 523 | |
[email protected] | ae4987d | 2011-11-21 22:52:44 | [diff] [blame] | 524 | void Shell::ToggleAppList() { |
[email protected] | 0039db9 | 2012-05-09 04:11:45 | [diff] [blame] | 525 | if (!app_list_controller_.get()) |
| 526 | app_list_controller_.reset(new internal::AppListController); |
| 527 | app_list_controller_->SetVisible(!app_list_controller_->IsVisible()); |
[email protected] | ae4987d | 2011-11-21 22:52:44 | [diff] [blame] | 528 | } |
| 529 | |
[email protected] | 7510d108 | 2012-03-30 21:58:34 | [diff] [blame] | 530 | bool Shell::GetAppListTargetVisibility() const { |
[email protected] | 0039db9 | 2012-05-09 04:11:45 | [diff] [blame] | 531 | return app_list_controller_.get() && |
| 532 | app_list_controller_->GetTargetVisibility(); |
[email protected] | 7510d108 | 2012-03-30 21:58:34 | [diff] [blame] | 533 | } |
| 534 | |
[email protected] | 1e51a9d | 2012-04-09 23:31:11 | [diff] [blame] | 535 | aura::Window* Shell::GetAppListWindow() { |
[email protected] | 0039db9 | 2012-05-09 04:11:45 | [diff] [blame] | 536 | return app_list_controller_.get() ? app_list_controller_->GetWindow() : NULL; |
[email protected] | 1e51a9d | 2012-04-09 23:31:11 | [diff] [blame] | 537 | } |
| 538 | |
[email protected] | f7eb89c | 2011-12-13 09:48:54 | [diff] [blame] | 539 | bool Shell::IsScreenLocked() const { |
[email protected] | 262f8bd | 2012-03-23 19:30:27 | [diff] [blame] | 540 | return !delegate_.get() || delegate_->IsScreenLocked(); |
[email protected] | f7eb89c | 2011-12-13 09:48:54 | [diff] [blame] | 541 | } |
| 542 | |
[email protected] | 40c4cbb | 2012-01-10 23:26:07 | [diff] [blame] | 543 | bool Shell::IsModalWindowOpen() const { |
[email protected] | 7b0f750 | 2012-06-11 00:12:39 | [diff] [blame] | 544 | // TODO(oshima): Walk though all root windows. |
[email protected] | e73bd780 | 2012-02-17 20:10:34 | [diff] [blame] | 545 | const aura::Window* modal_container = GetContainer( |
[email protected] | 7b0f750 | 2012-06-11 00:12:39 | [diff] [blame] | 546 | GetPrimaryRootWindow(), |
[email protected] | e73bd780 | 2012-02-17 20:10:34 | [diff] [blame] | 547 | internal::kShellWindowId_SystemModalContainer); |
[email protected] | 40c4cbb | 2012-01-10 23:26:07 | [diff] [blame] | 548 | return !modal_container->children().empty(); |
| 549 | } |
| 550 | |
[email protected] | 57b8bb35 | 2012-01-11 05:11:46 | [diff] [blame] | 551 | views::NonClientFrameView* Shell::CreateDefaultNonClientFrameView( |
| 552 | views::Widget* widget) { |
| 553 | if (CommandLine::ForCurrentProcess()->HasSwitch( |
| 554 | switches::kAuraGoogleDialogFrames)) { |
| 555 | return new internal::DialogFrameView; |
| 556 | } |
[email protected] | c73d133 | 2012-03-08 17:11:04 | [diff] [blame] | 557 | // Use translucent-style window frames for dialogs. |
[email protected] | 95c6cc4 | 2012-03-08 20:53:15 | [diff] [blame] | 558 | CustomFrameViewAsh* frame_view = new CustomFrameViewAsh; |
[email protected] | c73d133 | 2012-03-08 17:11:04 | [diff] [blame] | 559 | frame_view->Init(widget); |
| 560 | return frame_view; |
[email protected] | 57b8bb35 | 2012-01-11 05:11:46 | [diff] [blame] | 561 | } |
| 562 | |
[email protected] | 3d29912a | 2012-02-07 07:41:51 | [diff] [blame] | 563 | void Shell::RotateFocus(Direction direction) { |
| 564 | focus_cycler_->RotateFocus( |
| 565 | direction == FORWARD ? internal::FocusCycler::FORWARD : |
| 566 | internal::FocusCycler::BACKWARD); |
| 567 | } |
| 568 | |
[email protected] | 2e236a5 | 2012-06-27 22:21:47 | [diff] [blame] | 569 | void Shell::SetDisplayWorkAreaInsets(Window* contains, |
[email protected] | 8a45c97 | 2012-03-14 18:22:44 | [diff] [blame] | 570 | const gfx::Insets& insets) { |
[email protected] | 2e236a5 | 2012-06-27 22:21:47 | [diff] [blame] | 571 | internal::MultiDisplayManager* display_manager = |
| 572 | static_cast<internal::MultiDisplayManager*>( |
| 573 | aura::Env::GetInstance()->display_manager()); |
| 574 | if (!display_manager->UpdateWorkAreaOfDisplayNearestWindow(contains, insets)) |
[email protected] | 1a2145b | 2012-03-13 21:09:17 | [diff] [blame] | 575 | return; |
[email protected] | 1a2145b | 2012-03-13 21:09:17 | [diff] [blame] | 576 | FOR_EACH_OBSERVER(ShellObserver, observers_, |
[email protected] | 2e236a5 | 2012-06-27 22:21:47 | [diff] [blame] | 577 | OnDisplayWorkAreaInsetsChanged()); |
[email protected] | 1a2145b | 2012-03-13 21:09:17 | [diff] [blame] | 578 | } |
| 579 | |
[email protected] | 82d3954ae | 2012-04-20 09:02:22 | [diff] [blame] | 580 | void Shell::OnLoginStateChanged(user::LoginStatus status) { |
| 581 | FOR_EACH_OBSERVER(ShellObserver, observers_, OnLoginStateChanged(status)); |
| 582 | } |
| 583 | |
| 584 | void Shell::OnAppTerminating() { |
| 585 | FOR_EACH_OBSERVER(ShellObserver, observers_, OnAppTerminating()); |
| 586 | } |
| 587 | |
| 588 | void Shell::OnLockStateChanged(bool locked) { |
| 589 | FOR_EACH_OBSERVER(ShellObserver, observers_, OnLockStateChanged(locked)); |
| 590 | } |
| 591 | |
[email protected] | d9456cb | 2012-03-21 16:41:04 | [diff] [blame] | 592 | void Shell::CreateLauncher() { |
| 593 | if (launcher_.get()) |
| 594 | return; |
| 595 | |
[email protected] | d90b839 | 2012-06-13 09:34:56 | [diff] [blame] | 596 | aura::Window* default_container = |
| 597 | GetPrimaryRootWindowController()-> |
| 598 | GetContainer(internal::kShellWindowId_DefaultContainer); |
[email protected] | cbc278f | 2012-07-10 03:40:21 | [diff] [blame] | 599 | launcher_.reset(new Launcher(default_container, shelf_)); |
[email protected] | d9456cb | 2012-03-21 16:41:04 | [diff] [blame] | 600 | |
| 601 | launcher_->SetFocusCycler(focus_cycler_.get()); |
| 602 | shelf_->SetLauncher(launcher_.get()); |
[email protected] | 7cf8dd6 | 2012-04-22 05:14:58 | [diff] [blame] | 603 | if (panel_layout_manager_) |
| 604 | panel_layout_manager_->SetLauncher(launcher_.get()); |
[email protected] | d9456cb | 2012-03-21 16:41:04 | [diff] [blame] | 605 | |
[email protected] | 7e1df2f6 | 2012-07-19 19:17:18 | [diff] [blame] | 606 | if (delegate()) |
| 607 | launcher_->SetVisible(delegate()->IsSessionStarted()); |
[email protected] | d9456cb | 2012-03-21 16:41:04 | [diff] [blame] | 608 | launcher_->widget()->Show(); |
| 609 | } |
| 610 | |
[email protected] | 7e1df2f6 | 2012-07-19 19:17:18 | [diff] [blame] | 611 | void Shell::ShowLauncher() { |
| 612 | if (!launcher_.get()) |
| 613 | return; |
| 614 | launcher_->SetVisible(true); |
| 615 | } |
| 616 | |
[email protected] | 1a2145b | 2012-03-13 21:09:17 | [diff] [blame] | 617 | void Shell::AddShellObserver(ShellObserver* observer) { |
| 618 | observers_.AddObserver(observer); |
| 619 | } |
| 620 | |
| 621 | void Shell::RemoveShellObserver(ShellObserver* observer) { |
| 622 | observers_.RemoveObserver(observer); |
| 623 | } |
| 624 | |
[email protected] | c758fbf | 2012-03-25 22:53:59 | [diff] [blame] | 625 | void Shell::UpdateShelfVisibility() { |
| 626 | shelf_->UpdateVisibilityState(); |
| 627 | } |
| 628 | |
[email protected] | 09f3fc8 | 2012-03-26 23:26:56 | [diff] [blame] | 629 | void Shell::SetShelfAutoHideBehavior(ShelfAutoHideBehavior behavior) { |
| 630 | shelf_->SetAutoHideBehavior(behavior); |
[email protected] | c758fbf | 2012-03-25 22:53:59 | [diff] [blame] | 631 | } |
| 632 | |
[email protected] | 09f3fc8 | 2012-03-26 23:26:56 | [diff] [blame] | 633 | ShelfAutoHideBehavior Shell::GetShelfAutoHideBehavior() const { |
| 634 | return shelf_->auto_hide_behavior(); |
[email protected] | c758fbf | 2012-03-25 22:53:59 | [diff] [blame] | 635 | } |
| 636 | |
[email protected] | 5544450 | 2012-05-10 15:43:53 | [diff] [blame] | 637 | void Shell::SetShelfAlignment(ShelfAlignment alignment) { |
[email protected] | c2d58b4 | 2012-05-30 08:11:29 | [diff] [blame] | 638 | if (!shelf_->SetAlignment(alignment)) |
| 639 | return; |
[email protected] | a5c63ce8 | 2012-07-18 18:48:57 | [diff] [blame] | 640 | FOR_EACH_OBSERVER(ShellObserver, observers_, OnShelfAlignmentChanged()); |
[email protected] | 5544450 | 2012-05-10 15:43:53 | [diff] [blame] | 641 | } |
| 642 | |
| 643 | ShelfAlignment Shell::GetShelfAlignment() { |
| 644 | return shelf_->alignment(); |
| 645 | } |
| 646 | |
[email protected] | d90b839 | 2012-06-13 09:34:56 | [diff] [blame] | 647 | void Shell::SetDimming(bool should_dim) { |
[email protected] | be65be36 | 2012-06-15 07:38:23 | [diff] [blame] | 648 | RootWindowControllerList controllers = GetAllRootWindowControllers(); |
| 649 | for (RootWindowControllerList::iterator iter = controllers.begin(); |
| 650 | iter != controllers.end(); ++iter) |
| 651 | (*iter)->screen_dimmer()->SetDimming(should_dim); |
[email protected] | d90b839 | 2012-06-13 09:34:56 | [diff] [blame] | 652 | } |
| 653 | |
[email protected] | aa54218b | 2012-06-12 16:51:42 | [diff] [blame] | 654 | SystemTrayDelegate* Shell::tray_delegate() { |
| 655 | return status_area_widget_->system_tray_delegate(); |
| 656 | } |
| 657 | |
| 658 | SystemTray* Shell::system_tray() { |
| 659 | return status_area_widget_->system_tray(); |
| 660 | } |
| 661 | |
[email protected] | 85d43f0 | 2012-03-14 21:11:19 | [diff] [blame] | 662 | int Shell::GetGridSize() const { |
[email protected] | f4bb9fde | 2012-08-03 19:33:50 | [diff] [blame] | 663 | return |
| 664 | GetPrimaryRootWindowController()->workspace_controller()->GetGridSize(); |
[email protected] | 9628e0af | 2012-04-12 20:40:56 | [diff] [blame] | 665 | } |
| 666 | |
[email protected] | 2e236a5 | 2012-06-27 22:21:47 | [diff] [blame] | 667 | void Shell::InitRootWindowForSecondaryDisplay(aura::RootWindow* root) { |
[email protected] | a857dbe | 2012-05-30 22:10:14 | [diff] [blame] | 668 | root->set_focus_manager(focus_manager_.get()); |
[email protected] | 2e236a5 | 2012-06-27 22:21:47 | [diff] [blame] | 669 | if (internal::DisplayController::IsExtendedDesktopEnabled()) { |
[email protected] | be65be36 | 2012-06-15 07:38:23 | [diff] [blame] | 670 | internal::RootWindowController* controller = |
| 671 | new internal::RootWindowController(root); |
| 672 | controller->CreateContainers(); |
| 673 | InitRootWindowController(controller); |
| 674 | controller->root_window_layout()->OnWindowResized(); |
[email protected] | 37f27b62 | 2012-06-21 20:42:54 | [diff] [blame] | 675 | desktop_background_controller_->OnRootWindowAdded(root); |
[email protected] | be65be36 | 2012-06-15 07:38:23 | [diff] [blame] | 676 | 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] | 2e236a5 | 2012-06-27 22:21:47 | [diff] [blame] | 683 | container->SetName("SecondaryDisplayContainer"); |
[email protected] | be65be36 | 2012-06-15 07:38:23 | [diff] [blame] | 684 | container->Init(ui::LAYER_NOT_DRAWN); |
| 685 | root->AddChild(container); |
| 686 | container->SetLayoutManager(new internal::BaseLayoutManager(root)); |
[email protected] | 2e236a5 | 2012-06-27 22:21:47 | [diff] [blame] | 687 | CreateSecondaryDisplayWidget(container); |
[email protected] | be65be36 | 2012-06-15 07:38:23 | [diff] [blame] | 688 | container->Show(); |
| 689 | root->layout_manager()->OnWindowResized(); |
| 690 | root->ShowRootWindow(); |
| 691 | aura::client::SetCaptureClient(root, capture_controller_.get()); |
[email protected] | 8d625fb | 2012-07-18 16:40:06 | [diff] [blame] | 692 | aura::client::SetScreenPositionClient( |
| 693 | root, screen_position_controller_.get()); |
[email protected] | be65be36 | 2012-06-15 07:38:23 | [diff] [blame] | 694 | } |
[email protected] | a857dbe | 2012-05-30 22:10:14 | [diff] [blame] | 695 | } |
| 696 | |
[email protected] | be65be36 | 2012-06-15 07:38:23 | [diff] [blame] | 697 | void Shell::InitRootWindowController( |
| 698 | internal::RootWindowController* controller) { |
| 699 | aura::RootWindow* root_window = controller->root_window(); |
[email protected] | d90b839 | 2012-06-13 09:34:56 | [diff] [blame] | 700 | 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] | d90b839 | 2012-06-13 09:34:56 | [diff] [blame] | 710 | aura::client::SetCaptureClient(root_window, capture_controller_.get()); |
[email protected] | 8d625fb | 2012-07-18 16:40:06 | [diff] [blame] | 711 | aura::client::SetScreenPositionClient(root_window, |
| 712 | screen_position_controller_.get()); |
[email protected] | 4b8003c | 2012-07-26 00:54:19 | [diff] [blame] | 713 | aura::client::SetCursorClient(root_window, &cursor_manager_); |
[email protected] | 54a37cdc | 2012-07-25 19:16:01 | [diff] [blame] | 714 | aura::client::SetTooltipClient(root_window, tooltip_controller_.get()); |
[email protected] | d90b839 | 2012-06-13 09:34:56 | [diff] [blame] | 715 | |
| 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] | be65be36 | 2012-06-15 07:38:23 | [diff] [blame] | 724 | controller->InitLayoutManagers(); |
[email protected] | f059c694 | 2012-07-21 14:27:57 | [diff] [blame] | 725 | |
| 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] | d90b839 | 2012-06-13 09:34:56 | [diff] [blame] | 735 | } |
| 736 | |
[email protected] | 46ca363 | 2011-11-03 03:33:42 | [diff] [blame] | 737 | //////////////////////////////////////////////////////////////////////////////// |
| 738 | // Shell, private: |
| 739 | |
[email protected] | d90b839 | 2012-06-13 09:34:56 | [diff] [blame] | 740 | void Shell::InitLayoutManagersForPrimaryDisplay( |
| 741 | internal::RootWindowController* controller) { |
[email protected] | 6d6546e | 2012-05-30 23:12:02 | [diff] [blame] | 742 | DCHECK(status_area_widget_); |
[email protected] | b0079a9 | 2012-01-25 20:13:38 | [diff] [blame] | 743 | |
[email protected] | b0079a9 | 2012-01-25 20:13:38 | [diff] [blame] | 744 | internal::ShelfLayoutManager* shelf_layout_manager = |
[email protected] | 6d6546e | 2012-05-30 23:12:02 | [diff] [blame] | 745 | new internal::ShelfLayoutManager(status_area_widget_); |
[email protected] | d90b839 | 2012-06-13 09:34:56 | [diff] [blame] | 746 | controller->GetContainer(internal::kShellWindowId_LauncherContainer)-> |
[email protected] | b0079a9 | 2012-01-25 20:13:38 | [diff] [blame] | 747 | SetLayoutManager(shelf_layout_manager); |
[email protected] | 4e43763 | 2012-02-13 22:39:40 | [diff] [blame] | 748 | shelf_ = shelf_layout_manager; |
[email protected] | b0079a9 | 2012-01-25 20:13:38 | [diff] [blame] | 749 | |
| 750 | internal::StatusAreaLayoutManager* status_area_layout_manager = |
| 751 | new internal::StatusAreaLayoutManager(shelf_layout_manager); |
[email protected] | d90b839 | 2012-06-13 09:34:56 | [diff] [blame] | 752 | controller->GetContainer(internal::kShellWindowId_StatusContainer)-> |
[email protected] | b0079a9 | 2012-01-25 20:13:38 | [diff] [blame] | 753 | SetLayoutManager(status_area_layout_manager); |
| 754 | |
[email protected] | f4bb9fde | 2012-08-03 19:33:50 | [diff] [blame] | 755 | shelf_layout_manager->set_workspace_controller( |
| 756 | controller->workspace_controller()); |
[email protected] | fa0c3f2 | 2012-03-05 17:55:13 | [diff] [blame] | 757 | |
[email protected] | d90b839 | 2012-06-13 09:34:56 | [diff] [blame] | 758 | // TODO(oshima): Support multiple displays. |
[email protected] | f4bb9fde | 2012-08-03 19:33:50 | [diff] [blame] | 759 | controller->workspace_controller()->SetShelf(shelf()); |
[email protected] | c066b8d | 2012-03-26 00:23:16 | [diff] [blame] | 760 | |
[email protected] | 7cf8dd6 | 2012-04-22 05:14:58 | [diff] [blame] | 761 | // Create Panel layout manager |
[email protected] | 87d722a | 2012-07-12 15:38:33 | [diff] [blame] | 762 | 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] | cac10fc6 | 2011-10-07 23:22:56 | [diff] [blame] | 771 | } |
| 772 | |
[email protected] | f4bb9fde | 2012-08-03 19:33:50 | [diff] [blame] | 773 | // TODO: this is only used in tests, move with test. |
[email protected] | ad0c872 | 2012-03-02 20:17:45 | [diff] [blame] | 774 | void Shell::DisableWorkspaceGridLayout() { |
[email protected] | be65be36 | 2012-06-15 07:38:23 | [diff] [blame] | 775 | RootWindowControllerList controllers = GetAllRootWindowControllers(); |
| 776 | for (RootWindowControllerList::iterator iter = controllers.begin(); |
| 777 | iter != controllers.end(); ++iter) |
[email protected] | f4bb9fde | 2012-08-03 19:33:50 | [diff] [blame] | 778 | (*iter)->workspace_controller()->SetGridSize(0); |
[email protected] | ad0c872 | 2012-03-02 20:17:45 | [diff] [blame] | 779 | } |
| 780 | |
[email protected] | 1aad332 | 2012-06-06 06:37:09 | [diff] [blame] | 781 | void Shell::SetCursor(gfx::NativeCursor cursor) { |
[email protected] | be65be36 | 2012-06-15 07:38:23 | [diff] [blame] | 782 | RootWindowList root_windows = GetAllRootWindows(); |
| 783 | for (RootWindowList::iterator iter = root_windows.begin(); |
| 784 | iter != root_windows.end(); ++iter) |
| 785 | (*iter)->SetCursor(cursor); |
[email protected] | 1aad332 | 2012-06-06 06:37:09 | [diff] [blame] | 786 | } |
| 787 | |
| 788 | void Shell::ShowCursor(bool visible) { |
[email protected] | be65be36 | 2012-06-15 07:38:23 | [diff] [blame] | 789 | RootWindowList root_windows = GetAllRootWindows(); |
| 790 | for (RootWindowList::iterator iter = root_windows.begin(); |
| 791 | iter != root_windows.end(); ++iter) |
| 792 | (*iter)->ShowCursor(visible); |
[email protected] | 1aad332 | 2012-06-06 06:37:09 | [diff] [blame] | 793 | } |
| 794 | |
[email protected] | 55f59335 | 2011-12-24 05:42:46 | [diff] [blame] | 795 | } // namespace ash |