[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] | 8b04a165 | 2012-08-04 02:59:49 | [diff] [blame] | 140 | virtual void OnWallpaperBootAnimationFinished() OVERRIDE { |
| 141 | } |
| 142 | |
[email protected] | 10b2261 | 2012-03-22 17:07:55 | [diff] [blame] | 143 | private: |
[email protected] | 0039db9 | 2012-05-09 04:11:45 | [diff] [blame] | 144 | DISALLOW_COPY_AND_ASSIGN(DummyUserWallpaperDelegate); |
[email protected] | 10b2261 | 2012-03-22 17:07:55 | [diff] [blame] | 145 | }; |
| 146 | |
[email protected] | 87b0d82e | 2011-10-07 21:02:59 | [diff] [blame] | 147 | } // namespace |
| 148 | |
[email protected] | cac10fc6 | 2011-10-07 23:22:56 | [diff] [blame] | 149 | // static |
| 150 | Shell* Shell::instance_ = NULL; |
[email protected] | 2b4cd30 | 2012-02-24 20:21:13 | [diff] [blame] | 151 | // static |
[email protected] | 9488d4d | 2012-02-29 18:32:37 | [diff] [blame] | 152 | bool Shell::initially_hide_cursor_ = false; |
[email protected] | 2b4cd30 | 2012-02-24 20:21:13 | [diff] [blame] | 153 | |
| 154 | //////////////////////////////////////////////////////////////////////////////// |
| 155 | // Shell::TestApi |
| 156 | |
| 157 | Shell::TestApi::TestApi(Shell* shell) : shell_(shell) {} |
| 158 | |
[email protected] | 2b4cd30 | 2012-02-24 20:21:13 | [diff] [blame] | 159 | internal::RootWindowLayoutManager* Shell::TestApi::root_window_layout() { |
[email protected] | d90b839 | 2012-06-13 09:34:56 | [diff] [blame] | 160 | return shell_->GetPrimaryRootWindowController()->root_window_layout(); |
[email protected] | 2b4cd30 | 2012-02-24 20:21:13 | [diff] [blame] | 161 | } |
[email protected] | cac10fc6 | 2011-10-07 23:22:56 | [diff] [blame] | 162 | |
[email protected] | 0e46c27 | 2012-05-15 18:15:23 | [diff] [blame] | 163 | aura::shared::InputMethodEventFilter* |
| 164 | Shell::TestApi::input_method_event_filter() { |
[email protected] | db913160 | 2012-02-29 19:06:32 | [diff] [blame] | 165 | return shell_->input_method_filter_.get(); |
| 166 | } |
| 167 | |
[email protected] | 435b212e | 2012-04-05 19:43:37 | [diff] [blame] | 168 | internal::SystemGestureEventFilter* |
| 169 | Shell::TestApi::system_gesture_event_filter() { |
| 170 | return shell_->system_gesture_filter_.get(); |
| 171 | } |
| 172 | |
[email protected] | db913160 | 2012-02-29 19:06:32 | [diff] [blame] | 173 | internal::WorkspaceController* Shell::TestApi::workspace_controller() { |
[email protected] | d90b839 | 2012-06-13 09:34:56 | [diff] [blame] | 174 | return shell_->GetPrimaryRootWindowController()->workspace_controller(); |
[email protected] | db913160 | 2012-02-29 19:06:32 | [diff] [blame] | 175 | } |
| 176 | |
[email protected] | cac10fc6 | 2011-10-07 23:22:56 | [diff] [blame] | 177 | //////////////////////////////////////////////////////////////////////////////// |
| 178 | // Shell, public: |
| 179 | |
[email protected] | 3266c2b9 | 2011-11-14 00:06:08 | [diff] [blame] | 180 | Shell::Shell(ShellDelegate* delegate) |
[email protected] | d90b839 | 2012-06-13 09:34:56 | [diff] [blame] | 181 | : screen_(new ScreenAsh), |
[email protected] | be65be36 | 2012-06-15 07:38:23 | [diff] [blame] | 182 | active_root_window_(NULL), |
[email protected] | 1aad332 | 2012-06-06 06:37:09 | [diff] [blame] | 183 | env_filter_(NULL), |
[email protected] | 9c66adc | 2012-01-05 02:10:16 | [diff] [blame] | 184 | delegate_(delegate), |
[email protected] | 70b3e7d5 | 2012-06-02 22:12:25 | [diff] [blame] | 185 | #if defined(OS_CHROMEOS) |
[email protected] | fb792f3 | 2012-08-01 01:07:01 | [diff] [blame] | 186 | output_configurator_(new chromeos::OutputConfigurator( |
| 187 | internal::DisplayController::IsExtendedDesktopEnabled())), |
[email protected] | 196e945 | 2012-08-01 06:42:51 | [diff] [blame] | 188 | output_configurator_animation_( |
| 189 | new internal::OutputConfiguratorAnimation()), |
[email protected] | 70b3e7d5 | 2012-06-02 22:12:25 | [diff] [blame] | 190 | #endif // defined(OS_CHROMEOS) |
[email protected] | 4e43763 | 2012-02-13 22:39:40 | [diff] [blame] | 191 | shelf_(NULL), |
[email protected] | 7cf8dd6 | 2012-04-22 05:14:58 | [diff] [blame] | 192 | panel_layout_manager_(NULL), |
[email protected] | 6d6546e | 2012-05-30 23:12:02 | [diff] [blame] | 193 | status_area_widget_(NULL), |
| 194 | browser_context_(NULL) { |
[email protected] | 1a2145b | 2012-03-13 21:09:17 | [diff] [blame] | 195 | gfx::Screen::SetInstance(screen_); |
[email protected] | 054b2d7 | 2012-06-08 04:52:25 | [diff] [blame] | 196 | ui_controls::InstallUIControlsAura(internal::CreateUIControls()); |
[email protected] | 70b3e7d5 | 2012-06-02 22:12:25 | [diff] [blame] | 197 | #if defined(OS_CHROMEOS) |
[email protected] | 196e945 | 2012-08-01 06:42:51 | [diff] [blame] | 198 | output_configurator_->AddObserver(output_configurator_animation_.get()); |
[email protected] | 70b3e7d5 | 2012-06-02 22:12:25 | [diff] [blame] | 199 | static_cast<aura::DispatcherLinux*>( |
| 200 | aura::Env::GetInstance()->GetDispatcher())->AddDispatcherForRootWindow( |
| 201 | output_configurator()); |
| 202 | #endif // defined(OS_CHROMEOS) |
[email protected] | 87b0d82e | 2011-10-07 21:02:59 | [diff] [blame] | 203 | } |
| 204 | |
| 205 | Shell::~Shell() { |
[email protected] | e7293fa | 2012-05-17 04:42:33 | [diff] [blame] | 206 | views::FocusManagerFactory::Install(NULL); |
[email protected] | cb3b8b2 | 2012-06-27 23:26:37 | [diff] [blame] | 207 | |
| 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] | 4b8003c | 2012-07-26 00:54:19 | [diff] [blame] | 214 | cursor_manager_.set_delegate(NULL); |
[email protected] | e7293fa | 2012-05-17 04:42:33 | [diff] [blame] | 215 | |
[email protected] | 9861f175 | 2012-06-01 07:16:14 | [diff] [blame] | 216 | // 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] | 217 | RemoveEnvEventFilter(user_activity_detector_.get()); |
[email protected] | b9d224c | 2012-07-13 01:09:03 | [diff] [blame] | 218 | RemoveEnvEventFilter(event_rewriter_filter_.get()); |
[email protected] | 9ae32df | 2012-07-26 03:25:18 | [diff] [blame] | 219 | RemoveEnvEventFilter(overlay_filter_.get()); |
[email protected] | 1aad332 | 2012-06-06 06:37:09 | [diff] [blame] | 220 | RemoveEnvEventFilter(input_method_filter_.get()); |
| 221 | RemoveEnvEventFilter(window_modality_controller_.get()); |
[email protected] | 78d9630 | 2012-06-22 00:58:07 | [diff] [blame] | 222 | if (mouse_cursor_filter_.get()) |
| 223 | RemoveEnvEventFilter(mouse_cursor_filter_.get()); |
[email protected] | 1aad332 | 2012-06-06 06:37:09 | [diff] [blame] | 224 | RemoveEnvEventFilter(system_gesture_filter_.get()); |
[email protected] | 6e9f6aa | 2012-02-09 04:16:20 | [diff] [blame] | 225 | #if !defined(OS_MACOSX) |
[email protected] | 1aad332 | 2012-06-06 06:37:09 | [diff] [blame] | 226 | RemoveEnvEventFilter(accelerator_filter_.get()); |
[email protected] | 6e9f6aa | 2012-02-09 04:16:20 | [diff] [blame] | 227 | #endif |
[email protected] | 7307474 | 2012-05-17 01:44:41 | [diff] [blame] | 228 | if (touch_observer_hud_.get()) |
[email protected] | 1aad332 | 2012-06-06 06:37:09 | [diff] [blame] | 229 | RemoveEnvEventFilter(touch_observer_hud_.get()); |
[email protected] | 745816be | 2011-11-22 05:08:30 | [diff] [blame] | 230 | |
[email protected] | 931f4f4 | 2012-02-10 23:49:42 | [diff] [blame] | 231 | // TooltipController is deleted with the Shell so removing its references. |
[email protected] | 1aad332 | 2012-06-06 06:37:09 | [diff] [blame] | 232 | RemoveEnvEventFilter(tooltip_controller_.get()); |
[email protected] | ef589af | 2011-12-03 01:07:15 | [diff] [blame] | 233 | |
[email protected] | aa54218b | 2012-06-12 16:51:42 | [diff] [blame] | 234 | // The status area needs to be shut down before the windows are destroyed. |
| 235 | status_area_widget_->Shutdown(); |
[email protected] | bfb41131 | 2012-02-27 20:59:27 | [diff] [blame] | 236 | |
[email protected] | f5f3c75 | 2012-06-07 05:16:02 | [diff] [blame] | 237 | // 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] | be65be36 | 2012-06-15 07:38:23 | [diff] [blame] | 243 | // Destroy all child windows including widgets. |
[email protected] | 2e236a5 | 2012-06-27 22:21:47 | [diff] [blame] | 244 | display_controller_->CloseChildWindows(); |
[email protected] | ef589af | 2011-12-03 01:07:15 | [diff] [blame] | 245 | |
[email protected] | 40c4cbb | 2012-01-10 23:26:07 | [diff] [blame] | 246 | // These need a valid Shell instance to clean up properly, so explicitly |
| 247 | // delete them before invalidating the instance. |
[email protected] | 58482fa | 2012-03-02 14:57:39 | [diff] [blame] | 248 | // Alphabetical. |
[email protected] | 084b6bb | 2011-11-17 05:18:16 | [diff] [blame] | 249 | drag_drop_controller_.reset(); |
[email protected] | c1c67017 | 2012-04-26 04:20:26 | [diff] [blame] | 250 | magnification_controller_.reset(); |
[email protected] | aa47650 | 2012-05-01 18:03:19 | [diff] [blame] | 251 | power_button_controller_.reset(); |
[email protected] | e4a181cc | 2012-03-17 02:20:57 | [diff] [blame] | 252 | resize_shadow_controller_.reset(); |
[email protected] | 58482fa | 2012-03-02 14:57:39 | [diff] [blame] | 253 | shadow_controller_.reset(); |
[email protected] | fd162f7 | 2012-04-14 03:24:53 | [diff] [blame] | 254 | tooltip_controller_.reset(); |
[email protected] | aa47650 | 2012-05-01 18:03:19 | [diff] [blame] | 255 | window_cycle_controller_.reset(); |
[email protected] | 60a978b7 | 2012-06-08 00:29:18 | [diff] [blame] | 256 | capture_controller_.reset(); |
[email protected] | 60a978b7 | 2012-06-08 00:29:18 | [diff] [blame] | 257 | nested_dispatcher_controller_.reset(); |
[email protected] | 60a978b7 | 2012-06-08 00:29:18 | [diff] [blame] | 258 | user_action_client_.reset(); |
[email protected] | 60a978b7 | 2012-06-08 00:29:18 | [diff] [blame] | 259 | visibility_controller_.reset(); |
[email protected] | 084b6bb | 2011-11-17 05:18:16 | [diff] [blame] | 260 | |
[email protected] | be65be36 | 2012-06-15 07:38:23 | [diff] [blame] | 261 | // This also deletes all RootWindows. |
[email protected] | 2e236a5 | 2012-06-27 22:21:47 | [diff] [blame] | 262 | display_controller_.reset(); |
[email protected] | 8d625fb | 2012-07-18 16:40:06 | [diff] [blame] | 263 | screen_position_controller_.reset(); |
[email protected] | d90b839 | 2012-06-13 09:34:56 | [diff] [blame] | 264 | |
[email protected] | 0a704f0 | 2012-02-15 17:49:43 | [diff] [blame] | 265 | // 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] | 764864e | 2012-06-11 19:16:16 | [diff] [blame] | 272 | // Delete the activation controller after other controllers and launcher |
| 273 | // because they might have registered ActivationChangeObserver. |
[email protected] | 764864e | 2012-06-11 19:16:16 | [diff] [blame] | 274 | activation_controller_.reset(); |
| 275 | |
[email protected] | 488b4204 | 2011-11-15 00:20:18 | [diff] [blame] | 276 | DCHECK(instance_ == this); |
| 277 | instance_ = NULL; |
[email protected] | 70b3e7d5 | 2012-06-02 22:12:25 | [diff] [blame] | 278 | |
| 279 | #if defined(OS_CHROMEOS) |
[email protected] | 196e945 | 2012-08-01 06:42:51 | [diff] [blame] | 280 | output_configurator_->RemoveObserver(output_configurator_animation_.get()); |
[email protected] | 70b3e7d5 | 2012-06-02 22:12:25 | [diff] [blame] | 281 | // 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] | 87b0d82e | 2011-10-07 21:02:59 | [diff] [blame] | 286 | } |
| 287 | |
[email protected] | cac10fc6 | 2011-10-07 23:22:56 | [diff] [blame] | 288 | // static |
[email protected] | 3266c2b9 | 2011-11-14 00:06:08 | [diff] [blame] | 289 | Shell* Shell::CreateInstance(ShellDelegate* delegate) { |
| 290 | CHECK(!instance_); |
[email protected] | 2e236a5 | 2012-06-27 22:21:47 | [diff] [blame] | 291 | aura::Env::GetInstance()->SetDisplayManager( |
| 292 | new internal::MultiDisplayManager()); |
[email protected] | 3266c2b9 | 2011-11-14 00:06:08 | [diff] [blame] | 293 | instance_ = new Shell(delegate); |
| 294 | instance_->Init(); |
| 295 | return instance_; |
| 296 | } |
| 297 | |
| 298 | // static |
[email protected] | cac10fc6 | 2011-10-07 23:22:56 | [diff] [blame] | 299 | Shell* Shell::GetInstance() { |
[email protected] | 3266c2b9 | 2011-11-14 00:06:08 | [diff] [blame] | 300 | DCHECK(instance_); |
[email protected] | cac10fc6 | 2011-10-07 23:22:56 | [diff] [blame] | 301 | return instance_; |
| 302 | } |
| 303 | |
[email protected] | 6377a00 | 2011-11-10 20:26:47 | [diff] [blame] | 304 | // static |
[email protected] | b3b7bcd | 2012-03-06 19:35:45 | [diff] [blame] | 305 | bool Shell::HasInstance() { |
| 306 | return !!instance_; |
| 307 | } |
| 308 | |
| 309 | // static |
[email protected] | ef589af | 2011-12-03 01:07:15 | [diff] [blame] | 310 | void Shell::DeleteInstance() { |
[email protected] | 6377a00 | 2011-11-10 20:26:47 | [diff] [blame] | 311 | delete instance_; |
| 312 | instance_ = NULL; |
| 313 | } |
| 314 | |
[email protected] | e73bd780 | 2012-02-17 20:10:34 | [diff] [blame] | 315 | // static |
[email protected] | d90b839 | 2012-06-13 09:34:56 | [diff] [blame] | 316 | internal::RootWindowController* Shell::GetPrimaryRootWindowController() { |
[email protected] | 7ae52500 | 2012-07-26 23:55:10 | [diff] [blame] | 317 | return GetRootWindowController(GetPrimaryRootWindow()); |
[email protected] | be65be36 | 2012-06-15 07:38:23 | [diff] [blame] | 318 | } |
| 319 | |
| 320 | // static |
| 321 | Shell::RootWindowControllerList Shell::GetAllRootWindowControllers() { |
[email protected] | 2e236a5 | 2012-06-27 22:21:47 | [diff] [blame] | 322 | return Shell::GetInstance()->display_controller()-> |
[email protected] | be65be36 | 2012-06-15 07:38:23 | [diff] [blame] | 323 | GetAllRootWindowControllers(); |
[email protected] | d90b839 | 2012-06-13 09:34:56 | [diff] [blame] | 324 | } |
| 325 | |
| 326 | // static |
[email protected] | 42713f7 | 2012-05-25 00:41:50 | [diff] [blame] | 327 | aura::RootWindow* Shell::GetPrimaryRootWindow() { |
[email protected] | 2e236a5 | 2012-06-27 22:21:47 | [diff] [blame] | 328 | return GetInstance()->display_controller()->GetPrimaryRootWindow(); |
[email protected] | e73bd780 | 2012-02-17 20:10:34 | [diff] [blame] | 329 | } |
| 330 | |
[email protected] | 7b0f750 | 2012-06-11 00:12:39 | [diff] [blame] | 331 | // static |
[email protected] | a857dbe | 2012-05-30 22:10:14 | [diff] [blame] | 332 | aura::RootWindow* Shell::GetActiveRootWindow() { |
| 333 | return GetInstance()->active_root_window_; |
| 334 | } |
| 335 | |
[email protected] | 7b0f750 | 2012-06-11 00:12:39 | [diff] [blame] | 336 | // static |
[email protected] | be65be36 | 2012-06-15 07:38:23 | [diff] [blame] | 337 | Shell::RootWindowList Shell::GetAllRootWindows() { |
[email protected] | 2e236a5 | 2012-06-27 22:21:47 | [diff] [blame] | 338 | return Shell::GetInstance()->display_controller()-> |
[email protected] | be65be36 | 2012-06-15 07:38:23 | [diff] [blame] | 339 | GetAllRootWindows(); |
| 340 | } |
| 341 | |
| 342 | // static |
[email protected] | 7b0f750 | 2012-06-11 00:12:39 | [diff] [blame] | 343 | aura::Window* Shell::GetContainer(aura::RootWindow* root_window, |
| 344 | int container_id) { |
| 345 | return root_window->GetChildById(container_id); |
| 346 | } |
| 347 | |
| 348 | // static |
| 349 | std::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] | 87b0d82e | 2011-10-07 21:02:59 | [diff] [blame] | 358 | void Shell::Init() { |
[email protected] | c9301e3 | 2012-05-23 08:34:58 | [diff] [blame] | 359 | // 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] | 1aad332 | 2012-06-06 06:37:09 | [diff] [blame] | 363 | 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] | 4b8003c | 2012-07-26 00:54:19 | [diff] [blame] | 367 | cursor_manager_.set_delegate(this); |
[email protected] | a857dbe | 2012-05-30 22:10:14 | [diff] [blame] | 368 | |
| 369 | focus_manager_.reset(new aura::FocusManager); |
[email protected] | be65be36 | 2012-06-15 07:38:23 | [diff] [blame] | 370 | activation_controller_.reset( |
| 371 | new internal::ActivationController(focus_manager_.get())); |
| 372 | |
[email protected] | 8d625fb | 2012-07-18 16:40:06 | [diff] [blame] | 373 | screen_position_controller_.reset(new internal::ScreenPositionController); |
[email protected] | 2e236a5 | 2012-06-27 22:21:47 | [diff] [blame] | 374 | display_controller_.reset(new internal::DisplayController); |
| 375 | display_controller_->InitPrimaryDisplay(); |
| 376 | aura::RootWindow* root_window = display_controller_->GetPrimaryRootWindow(); |
[email protected] | be65be36 | 2012-06-15 07:38:23 | [diff] [blame] | 377 | active_root_window_ = root_window; |
[email protected] | a857dbe | 2012-05-30 22:10:14 | [diff] [blame] | 378 | |
[email protected] | 58482fa | 2012-03-02 14:57:39 | [diff] [blame] | 379 | #if !defined(OS_MACOSX) |
| 380 | nested_dispatcher_controller_.reset(new NestedDispatcherController); |
| 381 | accelerator_controller_.reset(new AcceleratorController); |
| 382 | #endif |
[email protected] | 0cfc18e | 2012-04-11 18:17:47 | [diff] [blame] | 383 | shell_context_menu_.reset(new internal::ShellContextMenu); |
[email protected] | 58482fa | 2012-03-02 14:57:39 | [diff] [blame] | 384 | |
[email protected] | c16b942 | 2012-06-06 21:51:11 | [diff] [blame] | 385 | // The order in which event filters are added is significant. |
[email protected] | 1aad332 | 2012-06-06 06:37:09 | [diff] [blame] | 386 | DCHECK(!GetEnvEventFilterCount()); |
[email protected] | c16b942 | 2012-06-06 21:51:11 | [diff] [blame] | 387 | user_activity_detector_.reset(new UserActivityDetector); |
| 388 | AddEnvEventFilter(user_activity_detector_.get()); |
| 389 | |
| 390 | DCHECK_EQ(1U, GetEnvEventFilterCount()); |
[email protected] | b9d224c | 2012-07-13 01:09:03 | [diff] [blame] | 391 | event_rewriter_filter_.reset(new internal::EventRewriterEventFilter); |
| 392 | AddEnvEventFilter(event_rewriter_filter_.get()); |
[email protected] | 0b0b074 | 2012-02-16 13:23:45 | [diff] [blame] | 393 | |
[email protected] | c16b942 | 2012-06-06 21:51:11 | [diff] [blame] | 394 | DCHECK_EQ(2U, GetEnvEventFilterCount()); |
[email protected] | 9ae32df | 2012-07-26 03:25:18 | [diff] [blame] | 395 | overlay_filter_.reset(new internal::OverlayEventFilter); |
| 396 | AddEnvEventFilter(overlay_filter_.get()); |
| 397 | AddShellObserver(overlay_filter_.get()); |
[email protected] | 0b0b074 | 2012-02-16 13:23:45 | [diff] [blame] | 398 | |
[email protected] | c16b942 | 2012-06-06 21:51:11 | [diff] [blame] | 399 | DCHECK_EQ(3U, GetEnvEventFilterCount()); |
[email protected] | 0caad588 | 2012-06-03 15:07:06 | [diff] [blame] | 400 | input_method_filter_.reset(new aura::shared::InputMethodEventFilter()); |
[email protected] | 1aad332 | 2012-06-06 06:37:09 | [diff] [blame] | 401 | AddEnvEventFilter(input_method_filter_.get()); |
[email protected] | c16b942 | 2012-06-06 21:51:11 | [diff] [blame] | 402 | |
[email protected] | 21472b1 | 2012-02-17 00:30:05 | [diff] [blame] | 403 | #if !defined(OS_MACOSX) |
| 404 | accelerator_filter_.reset(new internal::AcceleratorFilter); |
[email protected] | 1aad332 | 2012-06-06 06:37:09 | [diff] [blame] | 405 | AddEnvEventFilter(accelerator_filter_.get()); |
[email protected] | 21472b1 | 2012-02-17 00:30:05 | [diff] [blame] | 406 | #endif |
[email protected] | fcbbf08 | 2012-01-20 06:07:15 | [diff] [blame] | 407 | |
[email protected] | 435b212e | 2012-04-05 19:43:37 | [diff] [blame] | 408 | system_gesture_filter_.reset(new internal::SystemGestureEventFilter); |
[email protected] | 1aad332 | 2012-06-06 06:37:09 | [diff] [blame] | 409 | AddEnvEventFilter(system_gesture_filter_.get()); |
[email protected] | 435b212e | 2012-04-05 19:43:37 | [diff] [blame] | 410 | |
[email protected] | 60a978b7 | 2012-06-08 00:29:18 | [diff] [blame] | 411 | capture_controller_.reset(new internal::CaptureController); |
[email protected] | 87b0d82e | 2011-10-07 21:02:59 | [diff] [blame] | 412 | |
[email protected] | 871e9cc | 2012-06-17 22:41:55 | [diff] [blame] | 413 | internal::RootWindowController* root_window_controller = |
| 414 | new internal::RootWindowController(root_window); |
| 415 | root_window_controller->CreateContainers(); |
| 416 | |
[email protected] | 7307474 | 2012-05-17 01:44:41 | [diff] [blame] | 417 | CommandLine* command_line = CommandLine::ForCurrentProcess(); |
| 418 | |
| 419 | if (command_line->HasSwitch(switches::kAshTouchHud)) { |
| 420 | touch_observer_hud_.reset(new internal::TouchObserverHUD); |
[email protected] | 1aad332 | 2012-06-06 06:37:09 | [diff] [blame] | 421 | AddEnvEventFilter(touch_observer_hud_.get()); |
[email protected] | 7307474 | 2012-05-17 01:44:41 | [diff] [blame] | 422 | } |
[email protected] | d90b839 | 2012-06-13 09:34:56 | [diff] [blame] | 423 | |
[email protected] | 0518d0d | 2012-08-26 11:59:04 | [diff] [blame] | 424 | 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] | d90b839 | 2012-06-13 09:34:56 | [diff] [blame] | 430 | // Create Controllers that may need root window. |
| 431 | // TODO(oshima): Move as many controllers before creating |
| 432 | // RootWindowController as possible. |
[email protected] | ee1e1a2 | 2011-12-15 01:51:10 | [diff] [blame] | 433 | stacking_controller_.reset(new internal::StackingController); |
[email protected] | d90b839 | 2012-06-13 09:34:56 | [diff] [blame] | 434 | visibility_controller_.reset(new internal::VisibilityController); |
| 435 | drag_drop_controller_.reset(new internal::DragDropController); |
[email protected] | d90b839 | 2012-06-13 09:34:56 | [diff] [blame] | 436 | 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] | 488b4204 | 2011-11-15 00:20:18 | [diff] [blame] | 440 | |
[email protected] | 9613eacf | 2012-06-22 02:18:05 | [diff] [blame] | 441 | magnification_controller_.reset( |
| 442 | internal::MagnificationController::CreateInstance()); |
| 443 | |
[email protected] | d90b839 | 2012-06-13 09:34:56 | [diff] [blame] | 444 | high_contrast_controller_.reset(new HighContrastController); |
| 445 | video_detector_.reset(new VideoDetector); |
[email protected] | 8fef743 | 2012-08-06 15:34:25 | [diff] [blame] | 446 | window_cycle_controller_.reset( |
| 447 | new WindowCycleController(activation_controller_.get())); |
[email protected] | b0079a9 | 2012-01-25 20:13:38 | [diff] [blame] | 448 | |
[email protected] | 54a37cdc | 2012-07-25 19:16:01 | [diff] [blame] | 449 | tooltip_controller_.reset(new internal::TooltipController( |
| 450 | drag_drop_controller_.get())); |
| 451 | AddEnvEventFilter(tooltip_controller_.get()); |
| 452 | |
[email protected] | be65be36 | 2012-06-15 07:38:23 | [diff] [blame] | 453 | InitRootWindowController(root_window_controller); |
[email protected] | 262f8bd | 2012-03-23 19:30:27 | [diff] [blame] | 454 | |
[email protected] | d90b839 | 2012-06-13 09:34:56 | [diff] [blame] | 455 | // Initialize Primary RootWindow specific items. |
[email protected] | aa54218b | 2012-06-12 16:51:42 | [diff] [blame] | 456 | status_area_widget_ = new internal::StatusAreaWidget(); |
| 457 | status_area_widget_->CreateTrayViews(delegate_.get()); |
[email protected] | 6d6546e | 2012-05-30 23:12:02 | [diff] [blame] | 458 | status_area_widget_->Show(); |
[email protected] | bfb41131 | 2012-02-27 20:59:27 | [diff] [blame] | 459 | |
[email protected] | d90b839 | 2012-06-13 09:34:56 | [diff] [blame] | 460 | focus_cycler_.reset(new internal::FocusCycler()); |
| 461 | focus_cycler_->AddWidget(status_area_widget_); |
| 462 | |
[email protected] | e70cf0ed | 2012-03-15 16:24:47 | [diff] [blame] | 463 | // This controller needs to be set before SetupManagedWindowMode. |
[email protected] | 6e3b31b | 2012-06-12 23:06:38 | [diff] [blame] | 464 | desktop_background_controller_.reset(new DesktopBackgroundController()); |
[email protected] | 10b2261 | 2012-03-22 17:07:55 | [diff] [blame] | 465 | 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] | e70cf0ed | 2012-03-15 16:24:47 | [diff] [blame] | 469 | |
[email protected] | be65be36 | 2012-06-15 07:38:23 | [diff] [blame] | 470 | InitLayoutManagersForPrimaryDisplay(root_window_controller); |
[email protected] | ca4ed12 | 2011-10-26 05:40:01 | [diff] [blame] | 471 | |
[email protected] | e4a181cc | 2012-03-17 02:20:57 | [diff] [blame] | 472 | if (!command_line->HasSwitch(switches::kAuraNoShadows)) { |
| 473 | resize_shadow_controller_.reset(new internal::ResizeShadowController()); |
[email protected] | a54e65b | 2011-11-21 22:03:34 | [diff] [blame] | 474 | shadow_controller_.reset(new internal::ShadowController()); |
[email protected] | e4a181cc | 2012-03-17 02:20:57 | [diff] [blame] | 475 | } |
[email protected] | a54e65b | 2011-11-21 22:03:34 | [diff] [blame] | 476 | |
[email protected] | 1720a44 | 2012-03-25 22:03:47 | [diff] [blame] | 477 | if (!delegate_.get() || delegate_->IsUserLoggedIn()) |
[email protected] | d9456cb | 2012-03-21 16:41:04 | [diff] [blame] | 478 | CreateLauncher(); |
[email protected] | 3d29912a | 2012-02-07 07:41:51 | [diff] [blame] | 479 | |
[email protected] | d90b839 | 2012-06-13 09:34:56 | [diff] [blame] | 480 | // Force Layout |
[email protected] | be65be36 | 2012-06-15 07:38:23 | [diff] [blame] | 481 | root_window_controller->root_window_layout()->OnWindowResized(); |
[email protected] | 084b6bb | 2011-11-17 05:18:16 | [diff] [blame] | 482 | |
[email protected] | 60b5b86 | 2012-04-27 18:56:34 | [diff] [blame] | 483 | // 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] | 0c4f87d | 2012-06-12 02:00:35 | [diff] [blame] | 485 | user_wallpaper_delegate_->InitializeWallpaper(); |
[email protected] | 60b5b86 | 2012-04-27 18:56:34 | [diff] [blame] | 486 | |
[email protected] | e0d22e8 | 2012-01-04 00:46:57 | [diff] [blame] | 487 | power_button_controller_.reset(new PowerButtonController); |
[email protected] | 82d3954ae | 2012-04-20 09:02:22 | [diff] [blame] | 488 | AddShellObserver(power_button_controller_.get()); |
[email protected] | d90b839 | 2012-06-13 09:34:56 | [diff] [blame] | 489 | |
[email protected] | 2e236a5 | 2012-06-27 22:21:47 | [diff] [blame] | 490 | display_controller_->InitSecondaryDisplays(); |
[email protected] | be65be36 | 2012-06-15 07:38:23 | [diff] [blame] | 491 | |
[email protected] | d90b839 | 2012-06-13 09:34:56 | [diff] [blame] | 492 | if (initially_hide_cursor_) |
[email protected] | 4b8003c | 2012-07-26 00:54:19 | [diff] [blame] | 493 | cursor_manager_.ShowCursor(false); |
[email protected] | 87b0d82e | 2011-10-07 21:02:59 | [diff] [blame] | 494 | } |
| 495 | |
[email protected] | 1aad332 | 2012-06-06 06:37:09 | [diff] [blame] | 496 | void Shell::AddEnvEventFilter(aura::EventFilter* filter) { |
| 497 | env_filter_->AddFilter(filter); |
[email protected] | e29014c | 2011-11-16 18:25:51 | [diff] [blame] | 498 | } |
| 499 | |
[email protected] | 1aad332 | 2012-06-06 06:37:09 | [diff] [blame] | 500 | void Shell::RemoveEnvEventFilter(aura::EventFilter* filter) { |
| 501 | env_filter_->RemoveFilter(filter); |
[email protected] | e29014c | 2011-11-16 18:25:51 | [diff] [blame] | 502 | } |
| 503 | |
[email protected] | 1aad332 | 2012-06-06 06:37:09 | [diff] [blame] | 504 | size_t Shell::GetEnvEventFilterCount() const { |
| 505 | return env_filter_->GetFilterCount(); |
[email protected] | 2c45610 | 2011-12-26 06:26:34 | [diff] [blame] | 506 | } |
| 507 | |
[email protected] | b5f3060 | 2012-01-30 15:16:57 | [diff] [blame] | 508 | void Shell::ShowBackgroundMenu(views::Widget* widget, |
| 509 | const gfx::Point& location) { |
[email protected] | f60c623 | 2012-08-24 18:55:03 | [diff] [blame] | 510 | // 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] | 0cfc18e | 2012-04-11 18:17:47 | [diff] [blame] | 516 | if (shell_context_menu_.get()) |
| 517 | shell_context_menu_->ShowMenu(widget, location); |
[email protected] | 46ca363 | 2011-11-03 03:33:42 | [diff] [blame] | 518 | } |
| 519 | |
[email protected] | ae4987d | 2011-11-21 22:52:44 | [diff] [blame] | 520 | void Shell::ToggleAppList() { |
[email protected] | 0039db9 | 2012-05-09 04:11:45 | [diff] [blame] | 521 | if (!app_list_controller_.get()) |
| 522 | app_list_controller_.reset(new internal::AppListController); |
| 523 | app_list_controller_->SetVisible(!app_list_controller_->IsVisible()); |
[email protected] | ae4987d | 2011-11-21 22:52:44 | [diff] [blame] | 524 | } |
| 525 | |
[email protected] | 7510d108 | 2012-03-30 21:58:34 | [diff] [blame] | 526 | bool Shell::GetAppListTargetVisibility() const { |
[email protected] | 0039db9 | 2012-05-09 04:11:45 | [diff] [blame] | 527 | return app_list_controller_.get() && |
| 528 | app_list_controller_->GetTargetVisibility(); |
[email protected] | 7510d108 | 2012-03-30 21:58:34 | [diff] [blame] | 529 | } |
| 530 | |
[email protected] | 1e51a9d | 2012-04-09 23:31:11 | [diff] [blame] | 531 | aura::Window* Shell::GetAppListWindow() { |
[email protected] | 0039db9 | 2012-05-09 04:11:45 | [diff] [blame] | 532 | return app_list_controller_.get() ? app_list_controller_->GetWindow() : NULL; |
[email protected] | 1e51a9d | 2012-04-09 23:31:11 | [diff] [blame] | 533 | } |
| 534 | |
[email protected] | f7eb89c | 2011-12-13 09:48:54 | [diff] [blame] | 535 | bool Shell::IsScreenLocked() const { |
[email protected] | 262f8bd | 2012-03-23 19:30:27 | [diff] [blame] | 536 | return !delegate_.get() || delegate_->IsScreenLocked(); |
[email protected] | f7eb89c | 2011-12-13 09:48:54 | [diff] [blame] | 537 | } |
| 538 | |
[email protected] | 40c4cbb | 2012-01-10 23:26:07 | [diff] [blame] | 539 | bool Shell::IsModalWindowOpen() const { |
[email protected] | 7b0f750 | 2012-06-11 00:12:39 | [diff] [blame] | 540 | // TODO(oshima): Walk though all root windows. |
[email protected] | e73bd780 | 2012-02-17 20:10:34 | [diff] [blame] | 541 | const aura::Window* modal_container = GetContainer( |
[email protected] | 7b0f750 | 2012-06-11 00:12:39 | [diff] [blame] | 542 | GetPrimaryRootWindow(), |
[email protected] | e73bd780 | 2012-02-17 20:10:34 | [diff] [blame] | 543 | internal::kShellWindowId_SystemModalContainer); |
[email protected] | 40c4cbb | 2012-01-10 23:26:07 | [diff] [blame] | 544 | return !modal_container->children().empty(); |
| 545 | } |
| 546 | |
[email protected] | 57b8bb35 | 2012-01-11 05:11:46 | [diff] [blame] | 547 | views::NonClientFrameView* Shell::CreateDefaultNonClientFrameView( |
| 548 | views::Widget* widget) { |
| 549 | if (CommandLine::ForCurrentProcess()->HasSwitch( |
| 550 | switches::kAuraGoogleDialogFrames)) { |
| 551 | return new internal::DialogFrameView; |
| 552 | } |
[email protected] | c73d133 | 2012-03-08 17:11:04 | [diff] [blame] | 553 | // Use translucent-style window frames for dialogs. |
[email protected] | 95c6cc4 | 2012-03-08 20:53:15 | [diff] [blame] | 554 | CustomFrameViewAsh* frame_view = new CustomFrameViewAsh; |
[email protected] | c73d133 | 2012-03-08 17:11:04 | [diff] [blame] | 555 | frame_view->Init(widget); |
| 556 | return frame_view; |
[email protected] | 57b8bb35 | 2012-01-11 05:11:46 | [diff] [blame] | 557 | } |
| 558 | |
[email protected] | 3d29912a | 2012-02-07 07:41:51 | [diff] [blame] | 559 | void Shell::RotateFocus(Direction direction) { |
| 560 | focus_cycler_->RotateFocus( |
| 561 | direction == FORWARD ? internal::FocusCycler::FORWARD : |
| 562 | internal::FocusCycler::BACKWARD); |
| 563 | } |
| 564 | |
[email protected] | 2e236a5 | 2012-06-27 22:21:47 | [diff] [blame] | 565 | void Shell::SetDisplayWorkAreaInsets(Window* contains, |
[email protected] | 8a45c97 | 2012-03-14 18:22:44 | [diff] [blame] | 566 | const gfx::Insets& insets) { |
[email protected] | 2e236a5 | 2012-06-27 22:21:47 | [diff] [blame] | 567 | internal::MultiDisplayManager* display_manager = |
| 568 | static_cast<internal::MultiDisplayManager*>( |
| 569 | aura::Env::GetInstance()->display_manager()); |
| 570 | if (!display_manager->UpdateWorkAreaOfDisplayNearestWindow(contains, insets)) |
[email protected] | 1a2145b | 2012-03-13 21:09:17 | [diff] [blame] | 571 | return; |
[email protected] | 1a2145b | 2012-03-13 21:09:17 | [diff] [blame] | 572 | FOR_EACH_OBSERVER(ShellObserver, observers_, |
[email protected] | 2e236a5 | 2012-06-27 22:21:47 | [diff] [blame] | 573 | OnDisplayWorkAreaInsetsChanged()); |
[email protected] | 1a2145b | 2012-03-13 21:09:17 | [diff] [blame] | 574 | } |
| 575 | |
[email protected] | 82d3954ae | 2012-04-20 09:02:22 | [diff] [blame] | 576 | void Shell::OnLoginStateChanged(user::LoginStatus status) { |
| 577 | FOR_EACH_OBSERVER(ShellObserver, observers_, OnLoginStateChanged(status)); |
| 578 | } |
| 579 | |
| 580 | void Shell::OnAppTerminating() { |
| 581 | FOR_EACH_OBSERVER(ShellObserver, observers_, OnAppTerminating()); |
| 582 | } |
| 583 | |
| 584 | void Shell::OnLockStateChanged(bool locked) { |
| 585 | FOR_EACH_OBSERVER(ShellObserver, observers_, OnLockStateChanged(locked)); |
| 586 | } |
| 587 | |
[email protected] | d9456cb | 2012-03-21 16:41:04 | [diff] [blame] | 588 | void Shell::CreateLauncher() { |
| 589 | if (launcher_.get()) |
| 590 | return; |
| 591 | |
[email protected] | d90b839 | 2012-06-13 09:34:56 | [diff] [blame] | 592 | aura::Window* default_container = |
| 593 | GetPrimaryRootWindowController()-> |
| 594 | GetContainer(internal::kShellWindowId_DefaultContainer); |
[email protected] | cbc278f | 2012-07-10 03:40:21 | [diff] [blame] | 595 | launcher_.reset(new Launcher(default_container, shelf_)); |
[email protected] | d9456cb | 2012-03-21 16:41:04 | [diff] [blame] | 596 | |
| 597 | launcher_->SetFocusCycler(focus_cycler_.get()); |
| 598 | shelf_->SetLauncher(launcher_.get()); |
[email protected] | 7cf8dd6 | 2012-04-22 05:14:58 | [diff] [blame] | 599 | if (panel_layout_manager_) |
| 600 | panel_layout_manager_->SetLauncher(launcher_.get()); |
[email protected] | d9456cb | 2012-03-21 16:41:04 | [diff] [blame] | 601 | |
[email protected] | 7e1df2f6 | 2012-07-19 19:17:18 | [diff] [blame] | 602 | if (delegate()) |
| 603 | launcher_->SetVisible(delegate()->IsSessionStarted()); |
[email protected] | d9456cb | 2012-03-21 16:41:04 | [diff] [blame] | 604 | launcher_->widget()->Show(); |
| 605 | } |
| 606 | |
[email protected] | 7e1df2f6 | 2012-07-19 19:17:18 | [diff] [blame] | 607 | void Shell::ShowLauncher() { |
| 608 | if (!launcher_.get()) |
| 609 | return; |
| 610 | launcher_->SetVisible(true); |
| 611 | } |
| 612 | |
[email protected] | 1a2145b | 2012-03-13 21:09:17 | [diff] [blame] | 613 | void Shell::AddShellObserver(ShellObserver* observer) { |
| 614 | observers_.AddObserver(observer); |
| 615 | } |
| 616 | |
| 617 | void Shell::RemoveShellObserver(ShellObserver* observer) { |
| 618 | observers_.RemoveObserver(observer); |
| 619 | } |
| 620 | |
[email protected] | c758fbf | 2012-03-25 22:53:59 | [diff] [blame] | 621 | void Shell::UpdateShelfVisibility() { |
| 622 | shelf_->UpdateVisibilityState(); |
| 623 | } |
| 624 | |
[email protected] | 09f3fc8 | 2012-03-26 23:26:56 | [diff] [blame] | 625 | void Shell::SetShelfAutoHideBehavior(ShelfAutoHideBehavior behavior) { |
| 626 | shelf_->SetAutoHideBehavior(behavior); |
[email protected] | c758fbf | 2012-03-25 22:53:59 | [diff] [blame] | 627 | } |
| 628 | |
[email protected] | 09f3fc8 | 2012-03-26 23:26:56 | [diff] [blame] | 629 | ShelfAutoHideBehavior Shell::GetShelfAutoHideBehavior() const { |
| 630 | return shelf_->auto_hide_behavior(); |
[email protected] | c758fbf | 2012-03-25 22:53:59 | [diff] [blame] | 631 | } |
| 632 | |
[email protected] | 5544450 | 2012-05-10 15:43:53 | [diff] [blame] | 633 | void Shell::SetShelfAlignment(ShelfAlignment alignment) { |
[email protected] | c2d58b4 | 2012-05-30 08:11:29 | [diff] [blame] | 634 | if (!shelf_->SetAlignment(alignment)) |
| 635 | return; |
[email protected] | a5c63ce8 | 2012-07-18 18:48:57 | [diff] [blame] | 636 | FOR_EACH_OBSERVER(ShellObserver, observers_, OnShelfAlignmentChanged()); |
[email protected] | 5544450 | 2012-05-10 15:43:53 | [diff] [blame] | 637 | } |
| 638 | |
| 639 | ShelfAlignment Shell::GetShelfAlignment() { |
| 640 | return shelf_->alignment(); |
| 641 | } |
| 642 | |
[email protected] | d90b839 | 2012-06-13 09:34:56 | [diff] [blame] | 643 | void Shell::SetDimming(bool should_dim) { |
[email protected] | be65be36 | 2012-06-15 07:38:23 | [diff] [blame] | 644 | RootWindowControllerList controllers = GetAllRootWindowControllers(); |
| 645 | for (RootWindowControllerList::iterator iter = controllers.begin(); |
| 646 | iter != controllers.end(); ++iter) |
| 647 | (*iter)->screen_dimmer()->SetDimming(should_dim); |
[email protected] | d90b839 | 2012-06-13 09:34:56 | [diff] [blame] | 648 | } |
| 649 | |
[email protected] | aa54218b | 2012-06-12 16:51:42 | [diff] [blame] | 650 | SystemTrayDelegate* Shell::tray_delegate() { |
| 651 | return status_area_widget_->system_tray_delegate(); |
| 652 | } |
| 653 | |
| 654 | SystemTray* Shell::system_tray() { |
| 655 | return status_area_widget_->system_tray(); |
| 656 | } |
| 657 | |
[email protected] | 85d43f0 | 2012-03-14 21:11:19 | [diff] [blame] | 658 | int Shell::GetGridSize() const { |
[email protected] | f4bb9fde | 2012-08-03 19:33:50 | [diff] [blame] | 659 | return |
| 660 | GetPrimaryRootWindowController()->workspace_controller()->GetGridSize(); |
[email protected] | 9628e0af | 2012-04-12 20:40:56 | [diff] [blame] | 661 | } |
| 662 | |
[email protected] | 2e236a5 | 2012-06-27 22:21:47 | [diff] [blame] | 663 | void Shell::InitRootWindowForSecondaryDisplay(aura::RootWindow* root) { |
[email protected] | a857dbe | 2012-05-30 22:10:14 | [diff] [blame] | 664 | root->set_focus_manager(focus_manager_.get()); |
[email protected] | 2e236a5 | 2012-06-27 22:21:47 | [diff] [blame] | 665 | if (internal::DisplayController::IsExtendedDesktopEnabled()) { |
[email protected] | be65be36 | 2012-06-15 07:38:23 | [diff] [blame] | 666 | internal::RootWindowController* controller = |
| 667 | new internal::RootWindowController(root); |
| 668 | controller->CreateContainers(); |
| 669 | InitRootWindowController(controller); |
| 670 | controller->root_window_layout()->OnWindowResized(); |
[email protected] | 37f27b62 | 2012-06-21 20:42:54 | [diff] [blame] | 671 | desktop_background_controller_->OnRootWindowAdded(root); |
[email protected] | be65be36 | 2012-06-15 07:38:23 | [diff] [blame] | 672 | 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] | 2e236a5 | 2012-06-27 22:21:47 | [diff] [blame] | 679 | container->SetName("SecondaryDisplayContainer"); |
[email protected] | be65be36 | 2012-06-15 07:38:23 | [diff] [blame] | 680 | container->Init(ui::LAYER_NOT_DRAWN); |
| 681 | root->AddChild(container); |
| 682 | container->SetLayoutManager(new internal::BaseLayoutManager(root)); |
[email protected] | 2e236a5 | 2012-06-27 22:21:47 | [diff] [blame] | 683 | CreateSecondaryDisplayWidget(container); |
[email protected] | be65be36 | 2012-06-15 07:38:23 | [diff] [blame] | 684 | container->Show(); |
| 685 | root->layout_manager()->OnWindowResized(); |
[email protected] | be65be36 | 2012-06-15 07:38:23 | [diff] [blame] | 686 | aura::client::SetCaptureClient(root, capture_controller_.get()); |
[email protected] | 8d625fb | 2012-07-18 16:40:06 | [diff] [blame] | 687 | aura::client::SetScreenPositionClient( |
| 688 | root, screen_position_controller_.get()); |
[email protected] | 9946b67 | 2012-08-24 21:05:15 | [diff] [blame] | 689 | root->ShowRootWindow(); |
[email protected] | be65be36 | 2012-06-15 07:38:23 | [diff] [blame] | 690 | } |
[email protected] | a857dbe | 2012-05-30 22:10:14 | [diff] [blame] | 691 | } |
| 692 | |
[email protected] | be65be36 | 2012-06-15 07:38:23 | [diff] [blame] | 693 | void Shell::InitRootWindowController( |
| 694 | internal::RootWindowController* controller) { |
| 695 | aura::RootWindow* root_window = controller->root_window(); |
[email protected] | d90b839 | 2012-06-13 09:34:56 | [diff] [blame] | 696 | DCHECK(activation_controller_.get()); |
| 697 | DCHECK(visibility_controller_.get()); |
| 698 | DCHECK(drag_drop_controller_.get()); |
| 699 | DCHECK(capture_controller_.get()); |
[email protected] | 8fef743 | 2012-08-06 15:34:25 | [diff] [blame] | 700 | DCHECK(window_cycle_controller_.get()); |
[email protected] | d90b839 | 2012-06-13 09:34:56 | [diff] [blame] | 701 | |
| 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] | d90b839 | 2012-06-13 09:34:56 | [diff] [blame] | 707 | aura::client::SetCaptureClient(root_window, capture_controller_.get()); |
[email protected] | 8d625fb | 2012-07-18 16:40:06 | [diff] [blame] | 708 | aura::client::SetScreenPositionClient(root_window, |
| 709 | screen_position_controller_.get()); |
[email protected] | 4b8003c | 2012-07-26 00:54:19 | [diff] [blame] | 710 | aura::client::SetCursorClient(root_window, &cursor_manager_); |
[email protected] | 54a37cdc | 2012-07-25 19:16:01 | [diff] [blame] | 711 | aura::client::SetTooltipClient(root_window, tooltip_controller_.get()); |
[email protected] | d90b839 | 2012-06-13 09:34:56 | [diff] [blame] | 712 | |
| 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] | be65be36 | 2012-06-15 07:38:23 | [diff] [blame] | 721 | controller->InitLayoutManagers(); |
[email protected] | f059c694 | 2012-07-21 14:27:57 | [diff] [blame] | 722 | |
| 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] | 8fef743 | 2012-08-06 15:34:25 | [diff] [blame] | 732 | |
| 733 | window_cycle_controller_->OnRootWindowAdded(root_window); |
[email protected] | d90b839 | 2012-06-13 09:34:56 | [diff] [blame] | 734 | } |
| 735 | |
[email protected] | 46ca363 | 2011-11-03 03:33:42 | [diff] [blame] | 736 | //////////////////////////////////////////////////////////////////////////////// |
| 737 | // Shell, private: |
| 738 | |
[email protected] | d90b839 | 2012-06-13 09:34:56 | [diff] [blame] | 739 | void Shell::InitLayoutManagersForPrimaryDisplay( |
| 740 | internal::RootWindowController* controller) { |
[email protected] | 6d6546e | 2012-05-30 23:12:02 | [diff] [blame] | 741 | DCHECK(status_area_widget_); |
[email protected] | b0079a9 | 2012-01-25 20:13:38 | [diff] [blame] | 742 | |
[email protected] | b0079a9 | 2012-01-25 20:13:38 | [diff] [blame] | 743 | internal::ShelfLayoutManager* shelf_layout_manager = |
[email protected] | 6d6546e | 2012-05-30 23:12:02 | [diff] [blame] | 744 | new internal::ShelfLayoutManager(status_area_widget_); |
[email protected] | d90b839 | 2012-06-13 09:34:56 | [diff] [blame] | 745 | controller->GetContainer(internal::kShellWindowId_LauncherContainer)-> |
[email protected] | b0079a9 | 2012-01-25 20:13:38 | [diff] [blame] | 746 | SetLayoutManager(shelf_layout_manager); |
[email protected] | 4e43763 | 2012-02-13 22:39:40 | [diff] [blame] | 747 | shelf_ = shelf_layout_manager; |
[email protected] | b0079a9 | 2012-01-25 20:13:38 | [diff] [blame] | 748 | |
| 749 | internal::StatusAreaLayoutManager* status_area_layout_manager = |
| 750 | new internal::StatusAreaLayoutManager(shelf_layout_manager); |
[email protected] | d90b839 | 2012-06-13 09:34:56 | [diff] [blame] | 751 | controller->GetContainer(internal::kShellWindowId_StatusContainer)-> |
[email protected] | b0079a9 | 2012-01-25 20:13:38 | [diff] [blame] | 752 | SetLayoutManager(status_area_layout_manager); |
| 753 | |
[email protected] | f4bb9fde | 2012-08-03 19:33:50 | [diff] [blame] | 754 | shelf_layout_manager->set_workspace_controller( |
| 755 | controller->workspace_controller()); |
[email protected] | fa0c3f2 | 2012-03-05 17:55:13 | [diff] [blame] | 756 | |
[email protected] | d90b839 | 2012-06-13 09:34:56 | [diff] [blame] | 757 | // TODO(oshima): Support multiple displays. |
[email protected] | f4bb9fde | 2012-08-03 19:33:50 | [diff] [blame] | 758 | controller->workspace_controller()->SetShelf(shelf()); |
[email protected] | c066b8d | 2012-03-26 00:23:16 | [diff] [blame] | 759 | |
[email protected] | 7cf8dd6 | 2012-04-22 05:14:58 | [diff] [blame] | 760 | // Create Panel layout manager |
[email protected] | 87d722a | 2012-07-12 15:38:33 | [diff] [blame] | 761 | 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] | cac10fc6 | 2011-10-07 23:22:56 | [diff] [blame] | 770 | } |
| 771 | |
[email protected] | f4bb9fde | 2012-08-03 19:33:50 | [diff] [blame] | 772 | // TODO: this is only used in tests, move with test. |
[email protected] | ad0c872 | 2012-03-02 20:17:45 | [diff] [blame] | 773 | void Shell::DisableWorkspaceGridLayout() { |
[email protected] | be65be36 | 2012-06-15 07:38:23 | [diff] [blame] | 774 | RootWindowControllerList controllers = GetAllRootWindowControllers(); |
| 775 | for (RootWindowControllerList::iterator iter = controllers.begin(); |
| 776 | iter != controllers.end(); ++iter) |
[email protected] | f4bb9fde | 2012-08-03 19:33:50 | [diff] [blame] | 777 | (*iter)->workspace_controller()->SetGridSize(0); |
[email protected] | ad0c872 | 2012-03-02 20:17:45 | [diff] [blame] | 778 | } |
| 779 | |
[email protected] | 1aad332 | 2012-06-06 06:37:09 | [diff] [blame] | 780 | void Shell::SetCursor(gfx::NativeCursor cursor) { |
[email protected] | be65be36 | 2012-06-15 07:38:23 | [diff] [blame] | 781 | RootWindowList root_windows = GetAllRootWindows(); |
| 782 | for (RootWindowList::iterator iter = root_windows.begin(); |
| 783 | iter != root_windows.end(); ++iter) |
| 784 | (*iter)->SetCursor(cursor); |
[email protected] | 1aad332 | 2012-06-06 06:37:09 | [diff] [blame] | 785 | } |
| 786 | |
| 787 | void Shell::ShowCursor(bool visible) { |
[email protected] | be65be36 | 2012-06-15 07:38:23 | [diff] [blame] | 788 | RootWindowList root_windows = GetAllRootWindows(); |
| 789 | for (RootWindowList::iterator iter = root_windows.begin(); |
| 790 | iter != root_windows.end(); ++iter) |
| 791 | (*iter)->ShowCursor(visible); |
[email protected] | 1aad332 | 2012-06-06 06:37:09 | [diff] [blame] | 792 | } |
| 793 | |
[email protected] | 55f59335 | 2011-12-24 05:42:46 | [diff] [blame] | 794 | } // namespace ash |