[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] | 02dbd1a | 2012-11-08 22:50:13 | [diff] [blame] | 12 | #include "ash/caps_lock_delegate.h" |
[email protected] | e70cf0ed | 2012-03-15 16:24:47 | [diff] [blame] | 13 | #include "ash/desktop_background/desktop_background_controller.h" |
[email protected] | e70cf0ed | 2012-03-15 16:24:47 | [diff] [blame] | 14 | #include "ash/desktop_background/desktop_background_view.h" |
[email protected] | 81abb103 | 2012-11-13 18:55:41 | [diff] [blame] | 15 | #include "ash/desktop_background/user_wallpaper_delegate.h" |
[email protected] | 2e236a5 | 2012-06-27 22:21:47 | [diff] [blame] | 16 | #include "ash/display/display_controller.h" |
[email protected] | 6bdf795 | 2012-11-14 10:10:58 | [diff] [blame] | 17 | #include "ash/display/display_manager.h" |
[email protected] | 682990f | 2013-01-10 06:49:11 | [diff] [blame] | 18 | #include "ash/display/event_transformation_handler.h" |
[email protected] | 9154587 | 2012-11-21 13:58:27 | [diff] [blame] | 19 | #include "ash/display/mouse_cursor_event_filter.h" |
[email protected] | 8d625fb | 2012-07-18 16:40:06 | [diff] [blame] | 20 | #include "ash/display/screen_position_controller.h" |
[email protected] | f4c92b38 | 2012-08-28 00:59:59 | [diff] [blame] | 21 | #include "ash/drag_drop/drag_drop_controller.h" |
| 22 | #include "ash/focus_cycler.h" |
| 23 | #include "ash/high_contrast/high_contrast_controller.h" |
[email protected] | fca90ea | 2012-12-14 04:13:30 | [diff] [blame] | 24 | #include "ash/host/root_window_host_factory.h" |
[email protected] | b913a3a | 2012-12-11 13:07:19 | [diff] [blame] | 25 | #include "ash/launcher/launcher_delegate.h" |
| 26 | #include "ash/launcher/launcher_model.h" |
[email protected] | f4c92b38 | 2012-08-28 00:59:59 | [diff] [blame] | 27 | #include "ash/magnifier/magnification_controller.h" |
[email protected] | 77f7c13 | 2012-11-15 06:52:54 | [diff] [blame] | 28 | #include "ash/magnifier/partial_magnification_controller.h" |
[email protected] | d90b839 | 2012-06-13 09:34:56 | [diff] [blame] | 29 | #include "ash/root_window_controller.h" |
[email protected] | 1a2145b | 2012-03-13 21:09:17 | [diff] [blame] | 30 | #include "ash/screen_ash.h" |
[email protected] | 478c6c3 | 2013-03-09 02:50:58 | [diff] [blame] | 31 | #include "ash/shelf/shelf_layout_manager.h" |
| 32 | #include "ash/shelf/shelf_widget.h" |
[email protected] | b65bdda | 2011-12-23 23:35:31 | [diff] [blame] | 33 | #include "ash/shell_delegate.h" |
| 34 | #include "ash/shell_factory.h" |
| 35 | #include "ash/shell_window_ids.h" |
[email protected] | 6d6546e | 2012-05-30 23:12:02 | [diff] [blame] | 36 | #include "ash/system/status_area_widget.h" |
[email protected] | 51ed599 | 2012-11-07 10:14:39 | [diff] [blame] | 37 | #include "ash/system/tray/system_tray_delegate.h" |
[email protected] | 83b2b84c | 2012-11-14 01:11:00 | [diff] [blame] | 38 | #include "ash/system/tray/system_tray_notifier.h" |
[email protected] | 7307474 | 2012-05-17 01:44:41 | [diff] [blame] | 39 | #include "ash/touch/touch_observer_hud.h" |
[email protected] | 7634f96 | 2011-12-23 21:35:52 | [diff] [blame] | 40 | #include "ash/wm/activation_controller.h" |
[email protected] | f059c694 | 2012-07-21 14:27:57 | [diff] [blame] | 41 | #include "ash/wm/always_on_top_controller.h" |
[email protected] | 0039db9 | 2012-05-09 04:11:45 | [diff] [blame] | 42 | #include "ash/wm/app_list_controller.h" |
[email protected] | dc0973937 | 2012-11-15 20:17:39 | [diff] [blame] | 43 | #include "ash/wm/ash_activation_controller.h" |
[email protected] | 39718b5 | 2012-12-03 17:24:56 | [diff] [blame] | 44 | #include "ash/wm/ash_focus_rules.h" |
[email protected] | c0ff034 | 2013-02-27 00:41:29 | [diff] [blame] | 45 | #include "ash/wm/ash_native_cursor_manager.h" |
[email protected] | 8812588c | 2012-01-30 21:19:03 | [diff] [blame] | 46 | #include "ash/wm/base_layout_manager.h" |
[email protected] | 60a978b7 | 2012-06-08 00:29:18 | [diff] [blame] | 47 | #include "ash/wm/capture_controller.h" |
[email protected] | 88d7112 | 2012-10-18 07:11:01 | [diff] [blame] | 48 | #include "ash/wm/coordinate_conversion.h" |
[email protected] | 9d4d171 | 2012-03-06 06:55:25 | [diff] [blame] | 49 | #include "ash/wm/custom_frame_view_ash.h" |
[email protected] | 262f8bd | 2012-03-23 19:30:27 | [diff] [blame] | 50 | #include "ash/wm/event_client_impl.h" |
[email protected] | b9d224c | 2012-07-13 01:09:03 | [diff] [blame] | 51 | #include "ash/wm/event_rewriter_event_filter.h" |
[email protected] | 9ae32df | 2012-07-26 03:25:18 | [diff] [blame] | 52 | #include "ash/wm/overlay_event_filter.h" |
[email protected] | e0d22e8 | 2012-01-04 00:46:57 | [diff] [blame] | 53 | #include "ash/wm/power_button_controller.h" |
[email protected] | 7ae52500 | 2012-07-26 23:55:10 | [diff] [blame] | 54 | #include "ash/wm/property_util.h" |
[email protected] | e4a181cc | 2012-03-17 02:20:57 | [diff] [blame] | 55 | #include "ash/wm/resize_shadow_controller.h" |
[email protected] | a3301dc | 2011-12-23 16:34:51 | [diff] [blame] | 56 | #include "ash/wm/root_window_layout_manager.h" |
[email protected] | 4299321 | 2012-04-30 23:42:04 | [diff] [blame] | 57 | #include "ash/wm/screen_dimmer.h" |
[email protected] | 222f40c | 2012-10-18 08:58:13 | [diff] [blame] | 58 | #include "ash/wm/session_state_controller.h" |
[email protected] | 839667d6 | 2012-10-23 19:38:57 | [diff] [blame] | 59 | #include "ash/wm/session_state_controller_impl.h" |
| 60 | #include "ash/wm/session_state_controller_impl2.h" |
[email protected] | 435b212e | 2012-04-05 19:43:37 | [diff] [blame] | 61 | #include "ash/wm/system_gesture_event_filter.h" |
[email protected] | c0ce80e | 2012-10-05 23:28:27 | [diff] [blame] | 62 | #include "ash/wm/system_modal_container_event_filter.h" |
[email protected] | 4244d699 | 2012-01-23 17:14:33 | [diff] [blame] | 63 | #include "ash/wm/system_modal_container_layout_manager.h" |
[email protected] | c16b942 | 2012-06-06 21:51:11 | [diff] [blame] | 64 | #include "ash/wm/user_activity_detector.h" |
[email protected] | 9633a9d2 | 2012-01-21 16:40:58 | [diff] [blame] | 65 | #include "ash/wm/video_detector.h" |
[email protected] | b5756e2 | 2012-11-30 01:32:02 | [diff] [blame] | 66 | #include "ash/wm/window_animations.h" |
[email protected] | 40c4cbb | 2012-01-10 23:26:07 | [diff] [blame] | 67 | #include "ash/wm/window_cycle_controller.h" |
[email protected] | f059c694 | 2012-07-21 14:27:57 | [diff] [blame] | 68 | #include "ash/wm/window_properties.h" |
[email protected] | f4c92b38 | 2012-08-28 00:59:59 | [diff] [blame] | 69 | #include "ash/wm/window_util.h" |
[email protected] | c783955 | 2012-04-03 21:14:36 | [diff] [blame] | 70 | #include "ash/wm/workspace_controller.h" |
[email protected] | f296be7 | 2011-10-11 15:40:00 | [diff] [blame] | 71 | #include "base/bind.h" |
[email protected] | 46ca363 | 2011-11-03 03:33:42 | [diff] [blame] | 72 | #include "base/command_line.h" |
[email protected] | b0a8faa | 2012-10-19 03:22:22 | [diff] [blame] | 73 | #include "base/debug/leak_annotations.h" |
[email protected] | 2c45610 | 2011-12-26 06:26:34 | [diff] [blame] | 74 | #include "ui/aura/client/aura_constants.h" |
[email protected] | c2885361 | 2012-05-31 22:43:44 | [diff] [blame] | 75 | #include "ui/aura/client/user_action_client.h" |
[email protected] | 8a45c97 | 2012-03-14 18:22:44 | [diff] [blame] | 76 | #include "ui/aura/env.h" |
[email protected] | a857dbe | 2012-05-30 22:10:14 | [diff] [blame] | 77 | #include "ui/aura/focus_manager.h" |
[email protected] | 4bb1650 | 2011-12-06 14:44:58 | [diff] [blame] | 78 | #include "ui/aura/layout_manager.h" |
[email protected] | 2c45610 | 2011-12-26 06:26:34 | [diff] [blame] | 79 | #include "ui/aura/root_window.h" |
[email protected] | 87b0d82e | 2011-10-07 21:02:59 | [diff] [blame] | 80 | #include "ui/aura/window.h" |
[email protected] | 2d481774 | 2012-12-17 20:16:18 | [diff] [blame] | 81 | #include "ui/base/ui_base_switches.h" |
[email protected] | 116302fc | 2012-05-05 21:45:41 | [diff] [blame] | 82 | #include "ui/compositor/layer.h" |
| 83 | #include "ui/compositor/layer_animator.h" |
[email protected] | 7da9c4c | 2012-06-12 14:43:01 | [diff] [blame] | 84 | #include "ui/gfx/display.h" |
[email protected] | 9ec0f45 | 2012-05-31 15:58:53 | [diff] [blame] | 85 | #include "ui/gfx/image/image_skia.h" |
[email protected] | b82c42c4 | 2012-04-25 20:03:41 | [diff] [blame] | 86 | #include "ui/gfx/screen.h" |
[email protected] | b063928 | 2011-12-22 21:12:27 | [diff] [blame] | 87 | #include "ui/gfx/size.h" |
[email protected] | 8393aa6 | 2013-01-23 19:40:10 | [diff] [blame] | 88 | #include "ui/message_center/message_center.h" |
[email protected] | 4a59e4e | 2012-11-12 21:15:40 | [diff] [blame] | 89 | #include "ui/views/corewm/compound_event_filter.h" |
[email protected] | 39718b5 | 2012-12-03 17:24:56 | [diff] [blame] | 90 | #include "ui/views/corewm/corewm_switches.h" |
| 91 | #include "ui/views/corewm/focus_controller.h" |
[email protected] | 4a59e4e | 2012-11-12 21:15:40 | [diff] [blame] | 92 | #include "ui/views/corewm/input_method_event_filter.h" |
[email protected] | 86f2b5e | 2012-11-14 20:37:00 | [diff] [blame] | 93 | #include "ui/views/corewm/shadow_controller.h" |
[email protected] | a1b7a82 | 2013-02-23 19:08:04 | [diff] [blame] | 94 | #include "ui/views/corewm/tooltip_controller.h" |
[email protected] | b5756e2 | 2012-11-30 01:32:02 | [diff] [blame] | 95 | #include "ui/views/corewm/visibility_controller.h" |
[email protected] | 0c2dc01 | 2012-12-02 00:00:23 | [diff] [blame] | 96 | #include "ui/views/corewm/window_modality_controller.h" |
[email protected] | e7293fa | 2012-05-17 04:42:33 | [diff] [blame] | 97 | #include "ui/views/focus/focus_manager_factory.h" |
[email protected] | c13be0d | 2011-11-22 02:09:58 | [diff] [blame] | 98 | #include "ui/views/widget/native_widget_aura.h" |
| 99 | #include "ui/views/widget/widget.h" |
[email protected] | fef157d1 | 2013-02-04 20:43:23 | [diff] [blame] | 100 | #include "ui/views/window/dialog_delegate.h" |
[email protected] | 87b0d82e | 2011-10-07 21:02:59 | [diff] [blame] | 101 | |
[email protected] | 6e9f6aa | 2012-02-09 04:16:20 | [diff] [blame] | 102 | #if !defined(OS_MACOSX) |
| 103 | #include "ash/accelerators/accelerator_controller.h" |
| 104 | #include "ash/accelerators/accelerator_filter.h" |
| 105 | #include "ash/accelerators/nested_dispatcher_controller.h" |
| 106 | #endif |
| 107 | |
[email protected] | 70b3e7d5 | 2012-06-02 22:12:25 | [diff] [blame] | 108 | #if defined(OS_CHROMEOS) |
[email protected] | 44d444c | 2013-01-30 01:47:44 | [diff] [blame] | 109 | #include "ash/ash_constants.h" |
[email protected] | 6bdf795 | 2012-11-14 10:10:58 | [diff] [blame] | 110 | #include "ash/display/display_change_observer_x11.h" |
[email protected] | 18b21b2e | 2013-03-01 20:56:23 | [diff] [blame] | 111 | #include "ash/display/display_error_dialog.h" |
[email protected] | 196e945 | 2012-08-01 06:42:51 | [diff] [blame] | 112 | #include "ash/display/output_configurator_animation.h" |
[email protected] | 6bdf795 | 2012-11-14 10:10:58 | [diff] [blame] | 113 | #include "base/chromeos/chromeos_version.h" |
[email protected] | 4168ad7 | 2012-08-30 16:57:21 | [diff] [blame] | 114 | #include "base/message_pump_aurax11.h" |
[email protected] | 2e236a5 | 2012-06-27 22:21:47 | [diff] [blame] | 115 | #include "chromeos/display/output_configurator.h" |
[email protected] | 7158db1 | 2012-10-15 22:19:31 | [diff] [blame] | 116 | #include "content/public/browser/gpu_data_manager.h" |
[email protected] | 963dd66 | 2013-01-31 06:48:35 | [diff] [blame] | 117 | #include "content/public/common/content_switches.h" |
[email protected] | 7158db1 | 2012-10-15 22:19:31 | [diff] [blame] | 118 | #include "content/public/common/gpu_feature_type.h" |
[email protected] | 70b3e7d5 | 2012-06-02 22:12:25 | [diff] [blame] | 119 | #endif // defined(OS_CHROMEOS) |
| 120 | |
[email protected] | 55f59335 | 2011-12-24 05:42:46 | [diff] [blame] | 121 | namespace ash { |
[email protected] | 87b0d82e | 2011-10-07 21:02:59 | [diff] [blame] | 122 | |
| 123 | namespace { |
[email protected] | 671a2ae | 2011-10-13 21:53:23 | [diff] [blame] | 124 | |
[email protected] | 615922f | 2012-02-07 02:41:15 | [diff] [blame] | 125 | using aura::Window; |
[email protected] | 3f02dc5 | 2011-10-21 19:36:45 | [diff] [blame] | 126 | using views::Widget; |
| 127 | |
[email protected] | 10b2261 | 2012-03-22 17:07:55 | [diff] [blame] | 128 | // This dummy class is used for shell unit tests. We dont have chrome delegate |
| 129 | // in these tests. |
[email protected] | 5c54324 | 2012-03-24 16:25:42 | [diff] [blame] | 130 | class DummyUserWallpaperDelegate : public UserWallpaperDelegate { |
[email protected] | 10b2261 | 2012-03-22 17:07:55 | [diff] [blame] | 131 | public: |
| 132 | DummyUserWallpaperDelegate() {} |
| 133 | |
| 134 | virtual ~DummyUserWallpaperDelegate() {} |
| 135 | |
[email protected] | d217769 | 2012-11-29 16:19:04 | [diff] [blame] | 136 | virtual int GetAnimationType() OVERRIDE { |
| 137 | return views::corewm::WINDOW_VISIBILITY_ANIMATION_TYPE_FADE; |
[email protected] | 815d0c38 | 2012-07-21 08:13:44 | [diff] [blame] | 138 | } |
| 139 | |
[email protected] | bca9a7e | 2012-11-10 06:25:49 | [diff] [blame] | 140 | virtual bool ShouldShowInitialAnimation() OVERRIDE { |
| 141 | return false; |
| 142 | } |
| 143 | |
[email protected] | c10baf7 | 2012-11-01 18:24:32 | [diff] [blame] | 144 | virtual void UpdateWallpaper() OVERRIDE { |
| 145 | } |
| 146 | |
[email protected] | 0c4f87d | 2012-06-12 02:00:35 | [diff] [blame] | 147 | virtual void InitializeWallpaper() OVERRIDE { |
[email protected] | d5003473 | 2012-06-04 19:11:04 | [diff] [blame] | 148 | ash::Shell::GetInstance()->desktop_background_controller()-> |
| 149 | CreateEmptyWallpaper(); |
[email protected] | 10b2261 | 2012-03-22 17:07:55 | [diff] [blame] | 150 | } |
| 151 | |
[email protected] | 5c54324 | 2012-03-24 16:25:42 | [diff] [blame] | 152 | virtual void OpenSetWallpaperPage() OVERRIDE { |
| 153 | } |
| 154 | |
[email protected] | 0cfc18e | 2012-04-11 18:17:47 | [diff] [blame] | 155 | virtual bool CanOpenSetWallpaperPage() OVERRIDE { |
| 156 | return false; |
| 157 | } |
| 158 | |
[email protected] | 07a2fa6 | 2012-06-26 10:39:38 | [diff] [blame] | 159 | virtual void OnWallpaperAnimationFinished() OVERRIDE { |
| 160 | } |
| 161 | |
[email protected] | 8b04a165 | 2012-08-04 02:59:49 | [diff] [blame] | 162 | virtual void OnWallpaperBootAnimationFinished() OVERRIDE { |
| 163 | } |
| 164 | |
[email protected] | 10b2261 | 2012-03-22 17:07:55 | [diff] [blame] | 165 | private: |
[email protected] | 0039db9 | 2012-05-09 04:11:45 | [diff] [blame] | 166 | DISALLOW_COPY_AND_ASSIGN(DummyUserWallpaperDelegate); |
[email protected] | 10b2261 | 2012-03-22 17:07:55 | [diff] [blame] | 167 | }; |
| 168 | |
[email protected] | b5756e2 | 2012-11-30 01:32:02 | [diff] [blame] | 169 | // A Corewm VisibilityController subclass that calls the Ash animation routine |
| 170 | // so we can pick up our extended animations. See ash/wm/window_animations.h. |
| 171 | class AshVisibilityController : public views::corewm::VisibilityController { |
| 172 | public: |
| 173 | AshVisibilityController() {} |
| 174 | virtual ~AshVisibilityController() {} |
| 175 | |
| 176 | private: |
| 177 | // Overridden from views::corewm::VisibilityController: |
| 178 | virtual bool CallAnimateOnChildWindowVisibilityChanged( |
| 179 | aura::Window* window, |
| 180 | bool visible) OVERRIDE { |
| 181 | return AnimateOnChildWindowVisibilityChanged(window, visible); |
| 182 | } |
| 183 | |
| 184 | DISALLOW_COPY_AND_ASSIGN(AshVisibilityController); |
| 185 | }; |
| 186 | |
[email protected] | 87b0d82e | 2011-10-07 21:02:59 | [diff] [blame] | 187 | } // namespace |
| 188 | |
[email protected] | cac10fc6 | 2011-10-07 23:22:56 | [diff] [blame] | 189 | // static |
| 190 | Shell* Shell::instance_ = NULL; |
[email protected] | 2b4cd30 | 2012-02-24 20:21:13 | [diff] [blame] | 191 | // static |
[email protected] | 9488d4d | 2012-02-29 18:32:37 | [diff] [blame] | 192 | bool Shell::initially_hide_cursor_ = false; |
[email protected] | 2b4cd30 | 2012-02-24 20:21:13 | [diff] [blame] | 193 | |
| 194 | //////////////////////////////////////////////////////////////////////////////// |
[email protected] | cac10fc6 | 2011-10-07 23:22:56 | [diff] [blame] | 195 | // Shell, public: |
| 196 | |
[email protected] | 3266c2b9 | 2011-11-14 00:06:08 | [diff] [blame] | 197 | Shell::Shell(ShellDelegate* delegate) |
[email protected] | d90b839 | 2012-06-13 09:34:56 | [diff] [blame] | 198 | : screen_(new ScreenAsh), |
[email protected] | be65be36 | 2012-06-15 07:38:23 | [diff] [blame] | 199 | active_root_window_(NULL), |
[email protected] | 9c66adc | 2012-01-05 02:10:16 | [diff] [blame] | 200 | delegate_(delegate), |
[email protected] | 39718b5 | 2012-12-03 17:24:56 | [diff] [blame] | 201 | activation_client_(NULL), |
[email protected] | 70b3e7d5 | 2012-06-02 22:12:25 | [diff] [blame] | 202 | #if defined(OS_CHROMEOS) |
[email protected] | cf1c70e | 2012-08-30 01:13:02 | [diff] [blame] | 203 | output_configurator_(new chromeos::OutputConfigurator()), |
[email protected] | 70b3e7d5 | 2012-06-02 22:12:25 | [diff] [blame] | 204 | #endif // defined(OS_CHROMEOS) |
[email protected] | c0ff034 | 2013-02-27 00:41:29 | [diff] [blame] | 205 | native_cursor_manager_(new AshNativeCursorManager), |
| 206 | cursor_manager_(scoped_ptr<views::corewm::NativeCursorManager>( |
| 207 | native_cursor_manager_)), |
[email protected] | 852a55d | 2012-10-17 13:30:30 | [diff] [blame] | 208 | browser_context_(NULL), |
| 209 | simulate_modal_window_open_for_testing_(false) { |
[email protected] | 02dbd1a | 2012-11-08 22:50:13 | [diff] [blame] | 210 | DCHECK(delegate_.get()); |
[email protected] | 6bdf795 | 2012-11-14 10:10:58 | [diff] [blame] | 211 | display_manager_.reset(new internal::DisplayManager); |
[email protected] | b0a8faa | 2012-10-19 03:22:22 | [diff] [blame] | 212 | ANNOTATE_LEAKING_OBJECT_PTR(screen_); // see crbug.com/156466 |
[email protected] | b0a8faa | 2012-10-19 03:22:22 | [diff] [blame] | 213 | gfx::Screen::SetScreenInstance(gfx::SCREEN_TYPE_ALTERNATE, screen_); |
[email protected] | 5fdb45b | 2012-10-23 20:26:28 | [diff] [blame] | 214 | if (!gfx::Screen::GetScreenByType(gfx::SCREEN_TYPE_NATIVE)) |
| 215 | gfx::Screen::SetScreenInstance(gfx::SCREEN_TYPE_NATIVE, screen_); |
[email protected] | 70b3e7d5 | 2012-06-02 22:12:25 | [diff] [blame] | 216 | #if defined(OS_CHROMEOS) |
[email protected] | 7158db1 | 2012-10-15 22:19:31 | [diff] [blame] | 217 | content::GpuFeatureType blacklisted_features = |
| 218 | content::GpuDataManager::GetInstance()->GetBlacklistedFeatures(); |
| 219 | bool is_panel_fitting_disabled = |
| 220 | (blacklisted_features & content::GPU_FEATURE_TYPE_PANEL_FITTING) || |
| 221 | CommandLine::ForCurrentProcess()->HasSwitch( |
[email protected] | 963dd66 | 2013-01-31 06:48:35 | [diff] [blame] | 222 | ::switches::kDisablePanelFitting); |
[email protected] | 44d444c | 2013-01-30 01:47:44 | [diff] [blame] | 223 | |
| 224 | output_configurator_->Init( |
| 225 | !is_panel_fitting_disabled, |
| 226 | delegate_->IsFirstRunAfterBoot() ? kChromeOsBootColor : 0); |
[email protected] | 7158db1 | 2012-10-15 22:19:31 | [diff] [blame] | 227 | |
[email protected] | 4168ad7 | 2012-08-30 16:57:21 | [diff] [blame] | 228 | base::MessagePumpAuraX11::Current()->AddDispatcherForRootWindow( |
| 229 | output_configurator()); |
[email protected] | 70b3e7d5 | 2012-06-02 22:12:25 | [diff] [blame] | 230 | #endif // defined(OS_CHROMEOS) |
[email protected] | 049cf34b | 2012-12-07 17:15:48 | [diff] [blame] | 231 | AddPreTargetHandler(this); |
[email protected] | 87b0d82e | 2011-10-07 21:02:59 | [diff] [blame] | 232 | } |
| 233 | |
| 234 | Shell::~Shell() { |
[email protected] | e7293fa | 2012-05-17 04:42:33 | [diff] [blame] | 235 | views::FocusManagerFactory::Install(NULL); |
[email protected] | cb3b8b2 | 2012-06-27 23:26:37 | [diff] [blame] | 236 | |
| 237 | // Remove the focus from any window. This will prevent overhead and side |
| 238 | // effects (e.g. crashes) from changing focus during shutdown. |
| 239 | // See bug crbug.com/134502. |
| 240 | if (active_root_window_) |
[email protected] | 550543e | 2013-01-11 22:43:44 | [diff] [blame] | 241 | aura::client::GetFocusClient(active_root_window_)->FocusWindow(NULL); |
[email protected] | cb3b8b2 | 2012-06-27 23:26:37 | [diff] [blame] | 242 | |
[email protected] | 9861f175 | 2012-06-01 07:16:14 | [diff] [blame] | 243 | // Please keep in same order as in Init() because it's easy to miss one. |
[email protected] | 304594c | 2012-11-13 16:35:27 | [diff] [blame] | 244 | RemovePreTargetHandler(user_activity_detector_.get()); |
| 245 | RemovePreTargetHandler(event_rewriter_filter_.get()); |
| 246 | RemovePreTargetHandler(overlay_filter_.get()); |
| 247 | RemovePreTargetHandler(input_method_filter_.get()); |
| 248 | RemovePreTargetHandler(window_modality_controller_.get()); |
[email protected] | 78d9630 | 2012-06-22 00:58:07 | [diff] [blame] | 249 | if (mouse_cursor_filter_.get()) |
[email protected] | 304594c | 2012-11-13 16:35:27 | [diff] [blame] | 250 | RemovePreTargetHandler(mouse_cursor_filter_.get()); |
[email protected] | f9f017c | 2012-11-12 19:05:17 | [diff] [blame] | 251 | RemovePreTargetHandler(system_gesture_filter_.get()); |
[email protected] | 6e9f6aa | 2012-02-09 04:16:20 | [diff] [blame] | 252 | #if !defined(OS_MACOSX) |
[email protected] | f9f017c | 2012-11-12 19:05:17 | [diff] [blame] | 253 | RemovePreTargetHandler(accelerator_filter_.get()); |
[email protected] | 6e9f6aa | 2012-02-09 04:16:20 | [diff] [blame] | 254 | #endif |
[email protected] | 7307474 | 2012-05-17 01:44:41 | [diff] [blame] | 255 | if (touch_observer_hud_.get()) |
[email protected] | f9f017c | 2012-11-12 19:05:17 | [diff] [blame] | 256 | RemovePreTargetHandler(touch_observer_hud_.get()); |
[email protected] | 745816be | 2011-11-22 05:08:30 | [diff] [blame] | 257 | |
[email protected] | 931f4f4 | 2012-02-10 23:49:42 | [diff] [blame] | 258 | // TooltipController is deleted with the Shell so removing its references. |
[email protected] | 304594c | 2012-11-13 16:35:27 | [diff] [blame] | 259 | RemovePreTargetHandler(tooltip_controller_.get()); |
[email protected] | ef589af | 2011-12-03 01:07:15 | [diff] [blame] | 260 | |
[email protected] | f5f3c75 | 2012-06-07 05:16:02 | [diff] [blame] | 261 | // AppList needs to be released before shelf layout manager, which is |
| 262 | // destroyed with launcher container in the loop below. However, app list |
| 263 | // container is now on top of launcher container and released after it. |
| 264 | // TODO(xiyuan): Move it back when app list container is no longer needed. |
| 265 | app_list_controller_.reset(); |
| 266 | |
[email protected] | 51ed599 | 2012-11-07 10:14:39 | [diff] [blame] | 267 | // Destroy SystemTrayDelegate before destroying the status area(s). |
| 268 | system_tray_delegate_.reset(); |
| 269 | |
[email protected] | be65be36 | 2012-06-15 07:38:23 | [diff] [blame] | 270 | // Destroy all child windows including widgets. |
[email protected] | 2e236a5 | 2012-06-27 22:21:47 | [diff] [blame] | 271 | display_controller_->CloseChildWindows(); |
[email protected] | ef589af | 2011-12-03 01:07:15 | [diff] [blame] | 272 | |
[email protected] | 45590a86 | 2012-12-11 01:55:31 | [diff] [blame] | 273 | // Destroy SystemTrayNotifier after destroying SystemTray as TrayItems |
| 274 | // needs to remove observers from it. |
| 275 | system_tray_notifier_.reset(); |
| 276 | |
[email protected] | 40c4cbb | 2012-01-10 23:26:07 | [diff] [blame] | 277 | // These need a valid Shell instance to clean up properly, so explicitly |
| 278 | // delete them before invalidating the instance. |
[email protected] | b913a3a | 2012-12-11 13:07:19 | [diff] [blame] | 279 | // Alphabetical. TODO(oshima): sort. |
[email protected] | 084b6bb | 2011-11-17 05:18:16 | [diff] [blame] | 280 | drag_drop_controller_.reset(); |
[email protected] | c1c67017 | 2012-04-26 04:20:26 | [diff] [blame] | 281 | magnification_controller_.reset(); |
[email protected] | 77f7c13 | 2012-11-15 06:52:54 | [diff] [blame] | 282 | partial_magnification_controller_.reset(); |
[email protected] | e4a181cc | 2012-03-17 02:20:57 | [diff] [blame] | 283 | resize_shadow_controller_.reset(); |
[email protected] | 58482fa | 2012-03-02 14:57:39 | [diff] [blame] | 284 | shadow_controller_.reset(); |
[email protected] | fd162f7 | 2012-04-14 03:24:53 | [diff] [blame] | 285 | tooltip_controller_.reset(); |
[email protected] | e67291f1 | 2012-10-10 05:52:38 | [diff] [blame] | 286 | event_client_.reset(); |
[email protected] | aa47650 | 2012-05-01 18:03:19 | [diff] [blame] | 287 | window_cycle_controller_.reset(); |
[email protected] | 60a978b7 | 2012-06-08 00:29:18 | [diff] [blame] | 288 | capture_controller_.reset(); |
[email protected] | 60a978b7 | 2012-06-08 00:29:18 | [diff] [blame] | 289 | nested_dispatcher_controller_.reset(); |
[email protected] | 60a978b7 | 2012-06-08 00:29:18 | [diff] [blame] | 290 | user_action_client_.reset(); |
[email protected] | 60a978b7 | 2012-06-08 00:29:18 | [diff] [blame] | 291 | visibility_controller_.reset(); |
[email protected] | b913a3a | 2012-12-11 13:07:19 | [diff] [blame] | 292 | launcher_delegate_.reset(); |
| 293 | launcher_model_.reset(); |
[email protected] | 084b6bb | 2011-11-17 05:18:16 | [diff] [blame] | 294 | |
[email protected] | 83482fbf | 2012-11-21 14:02:09 | [diff] [blame] | 295 | power_button_controller_.reset(); |
| 296 | session_state_controller_.reset(); |
| 297 | |
[email protected] | 28b5556 | 2013-02-20 11:37:34 | [diff] [blame] | 298 | // This also deletes all RootWindows. Note that we invoke Shutdown() on |
| 299 | // DisplayController before resetting |display_controller_|, since destruction |
| 300 | // of its owned RootWindowControllers relies on the value. |
| 301 | display_controller_->Shutdown(); |
[email protected] | 2e236a5 | 2012-06-27 22:21:47 | [diff] [blame] | 302 | display_controller_.reset(); |
[email protected] | 8d625fb | 2012-07-18 16:40:06 | [diff] [blame] | 303 | screen_position_controller_.reset(); |
[email protected] | d90b839 | 2012-06-13 09:34:56 | [diff] [blame] | 304 | |
[email protected] | 764864e | 2012-06-11 19:16:16 | [diff] [blame] | 305 | // Delete the activation controller after other controllers and launcher |
| 306 | // because they might have registered ActivationChangeObserver. |
[email protected] | 764864e | 2012-06-11 19:16:16 | [diff] [blame] | 307 | activation_controller_.reset(); |
| 308 | |
[email protected] | 70b3e7d5 | 2012-06-02 22:12:25 | [diff] [blame] | 309 | #if defined(OS_CHROMEOS) |
[email protected] | 32c3e98e5 | 2013-01-30 19:20:09 | [diff] [blame] | 310 | if (display_change_observer_.get()) |
| 311 | output_configurator_->RemoveObserver(display_change_observer_.get()); |
| 312 | if (output_configurator_animation_.get()) |
| 313 | output_configurator_->RemoveObserver(output_configurator_animation_.get()); |
[email protected] | 18b21b2e | 2013-03-01 20:56:23 | [diff] [blame] | 314 | if (display_error_observer_.get()) |
| 315 | output_configurator_->RemoveObserver(display_error_observer_.get()); |
[email protected] | 4168ad7 | 2012-08-30 16:57:21 | [diff] [blame] | 316 | base::MessagePumpAuraX11::Current()->RemoveDispatcherForRootWindow( |
| 317 | output_configurator()); |
[email protected] | 70b3e7d5 | 2012-06-02 22:12:25 | [diff] [blame] | 318 | #endif // defined(OS_CHROMEOS) |
[email protected] | 18b21b2e | 2013-03-01 20:56:23 | [diff] [blame] | 319 | |
| 320 | DCHECK(instance_ == this); |
| 321 | instance_ = NULL; |
[email protected] | 87b0d82e | 2011-10-07 21:02:59 | [diff] [blame] | 322 | } |
| 323 | |
[email protected] | cac10fc6 | 2011-10-07 23:22:56 | [diff] [blame] | 324 | // static |
[email protected] | 3266c2b9 | 2011-11-14 00:06:08 | [diff] [blame] | 325 | Shell* Shell::CreateInstance(ShellDelegate* delegate) { |
| 326 | CHECK(!instance_); |
| 327 | instance_ = new Shell(delegate); |
| 328 | instance_->Init(); |
| 329 | return instance_; |
| 330 | } |
| 331 | |
| 332 | // static |
[email protected] | cac10fc6 | 2011-10-07 23:22:56 | [diff] [blame] | 333 | Shell* Shell::GetInstance() { |
[email protected] | 3266c2b9 | 2011-11-14 00:06:08 | [diff] [blame] | 334 | DCHECK(instance_); |
[email protected] | cac10fc6 | 2011-10-07 23:22:56 | [diff] [blame] | 335 | return instance_; |
| 336 | } |
| 337 | |
[email protected] | 6377a00 | 2011-11-10 20:26:47 | [diff] [blame] | 338 | // static |
[email protected] | b3b7bcd | 2012-03-06 19:35:45 | [diff] [blame] | 339 | bool Shell::HasInstance() { |
| 340 | return !!instance_; |
| 341 | } |
| 342 | |
| 343 | // static |
[email protected] | ef589af | 2011-12-03 01:07:15 | [diff] [blame] | 344 | void Shell::DeleteInstance() { |
[email protected] | 6377a00 | 2011-11-10 20:26:47 | [diff] [blame] | 345 | delete instance_; |
| 346 | instance_ = NULL; |
| 347 | } |
| 348 | |
[email protected] | e73bd780 | 2012-02-17 20:10:34 | [diff] [blame] | 349 | // static |
[email protected] | d90b839 | 2012-06-13 09:34:56 | [diff] [blame] | 350 | internal::RootWindowController* Shell::GetPrimaryRootWindowController() { |
[email protected] | 7ae52500 | 2012-07-26 23:55:10 | [diff] [blame] | 351 | return GetRootWindowController(GetPrimaryRootWindow()); |
[email protected] | be65be36 | 2012-06-15 07:38:23 | [diff] [blame] | 352 | } |
| 353 | |
| 354 | // static |
| 355 | Shell::RootWindowControllerList Shell::GetAllRootWindowControllers() { |
[email protected] | 2e236a5 | 2012-06-27 22:21:47 | [diff] [blame] | 356 | return Shell::GetInstance()->display_controller()-> |
[email protected] | be65be36 | 2012-06-15 07:38:23 | [diff] [blame] | 357 | GetAllRootWindowControllers(); |
[email protected] | d90b839 | 2012-06-13 09:34:56 | [diff] [blame] | 358 | } |
| 359 | |
| 360 | // static |
[email protected] | 42713f7 | 2012-05-25 00:41:50 | [diff] [blame] | 361 | aura::RootWindow* Shell::GetPrimaryRootWindow() { |
[email protected] | 2e236a5 | 2012-06-27 22:21:47 | [diff] [blame] | 362 | return GetInstance()->display_controller()->GetPrimaryRootWindow(); |
[email protected] | e73bd780 | 2012-02-17 20:10:34 | [diff] [blame] | 363 | } |
| 364 | |
[email protected] | 7b0f750 | 2012-06-11 00:12:39 | [diff] [blame] | 365 | // static |
[email protected] | a857dbe | 2012-05-30 22:10:14 | [diff] [blame] | 366 | aura::RootWindow* Shell::GetActiveRootWindow() { |
| 367 | return GetInstance()->active_root_window_; |
| 368 | } |
| 369 | |
[email protected] | 7b0f750 | 2012-06-11 00:12:39 | [diff] [blame] | 370 | // static |
[email protected] | ffabb1e | 2012-10-12 19:51:17 | [diff] [blame] | 371 | gfx::Screen* Shell::GetScreen() { |
[email protected] | 5fdb45b | 2012-10-23 20:26:28 | [diff] [blame] | 372 | return gfx::Screen::GetScreenByType(gfx::SCREEN_TYPE_ALTERNATE); |
[email protected] | ffabb1e | 2012-10-12 19:51:17 | [diff] [blame] | 373 | } |
| 374 | |
| 375 | // static |
[email protected] | be65be36 | 2012-06-15 07:38:23 | [diff] [blame] | 376 | Shell::RootWindowList Shell::GetAllRootWindows() { |
[email protected] | 2e236a5 | 2012-06-27 22:21:47 | [diff] [blame] | 377 | return Shell::GetInstance()->display_controller()-> |
[email protected] | be65be36 | 2012-06-15 07:38:23 | [diff] [blame] | 378 | GetAllRootWindows(); |
| 379 | } |
| 380 | |
| 381 | // static |
[email protected] | 7b0f750 | 2012-06-11 00:12:39 | [diff] [blame] | 382 | aura::Window* Shell::GetContainer(aura::RootWindow* root_window, |
| 383 | int container_id) { |
| 384 | return root_window->GetChildById(container_id); |
| 385 | } |
| 386 | |
| 387 | // static |
[email protected] | e67291f1 | 2012-10-10 05:52:38 | [diff] [blame] | 388 | const aura::Window* Shell::GetContainer(const aura::RootWindow* root_window, |
| 389 | int container_id) { |
| 390 | return root_window->GetChildById(container_id); |
| 391 | } |
| 392 | |
| 393 | // static |
[email protected] | 429433f | 2012-12-28 20:14:46 | [diff] [blame] | 394 | std::vector<aura::Window*> Shell::GetContainersFromAllRootWindows( |
| 395 | int container_id, |
| 396 | aura::RootWindow* priority_root) { |
[email protected] | 7b0f750 | 2012-06-11 00:12:39 | [diff] [blame] | 397 | std::vector<aura::Window*> containers; |
[email protected] | 001272f | 2012-11-02 20:05:23 | [diff] [blame] | 398 | RootWindowList root_windows = GetAllRootWindows(); |
| 399 | for (RootWindowList::const_iterator it = root_windows.begin(); |
| 400 | it != root_windows.end(); ++it) { |
| 401 | aura::Window* container = (*it)->GetChildById(container_id); |
[email protected] | 429433f | 2012-12-28 20:14:46 | [diff] [blame] | 402 | if (container) { |
| 403 | if (priority_root && priority_root->Contains(container)) |
| 404 | containers.insert(containers.begin(), container); |
| 405 | else |
| 406 | containers.push_back(container); |
| 407 | } |
[email protected] | 001272f | 2012-11-02 20:05:23 | [diff] [blame] | 408 | } |
[email protected] | 7b0f750 | 2012-06-11 00:12:39 | [diff] [blame] | 409 | return containers; |
| 410 | } |
| 411 | |
[email protected] | e74aaf0a | 2012-10-12 18:42:28 | [diff] [blame] | 412 | // static |
| 413 | bool Shell::IsLauncherPerDisplayEnabled() { |
| 414 | CommandLine* command_line = CommandLine::ForCurrentProcess(); |
[email protected] | 8039e06c | 2013-01-17 23:34:50 | [diff] [blame] | 415 | return !command_line->HasSwitch(switches::kAshDisableLauncherPerDisplay); |
[email protected] | e74aaf0a | 2012-10-12 18:42:28 | [diff] [blame] | 416 | } |
| 417 | |
[email protected] | 87b0d82e | 2011-10-07 21:02:59 | [diff] [blame] | 418 | void Shell::Init() { |
[email protected] | 6bdf795 | 2012-11-14 10:10:58 | [diff] [blame] | 419 | #if defined(OS_CHROMEOS) |
| 420 | if (base::chromeos::IsRunningOnChromeOS()) { |
| 421 | display_change_observer_.reset(new internal::DisplayChangeObserverX11); |
[email protected] | 32c3e98e5 | 2013-01-30 19:20:09 | [diff] [blame] | 422 | // Register |display_change_observer_| first so that the rest of |
| 423 | // observer gets invoked after the root windows are configured. |
| 424 | output_configurator_->AddObserver(display_change_observer_.get()); |
| 425 | output_configurator_animation_.reset( |
[email protected] | 18b21b2e | 2013-03-01 20:56:23 | [diff] [blame] | 426 | new internal::OutputConfiguratorAnimation()); |
| 427 | display_error_observer_.reset(new internal::DisplayErrorObserver()); |
[email protected] | 32c3e98e5 | 2013-01-30 19:20:09 | [diff] [blame] | 428 | output_configurator_->AddObserver(output_configurator_animation_.get()); |
[email protected] | 18b21b2e | 2013-03-01 20:56:23 | [diff] [blame] | 429 | output_configurator_->AddObserver(display_error_observer_.get()); |
[email protected] | 32c3e98e5 | 2013-01-30 19:20:09 | [diff] [blame] | 430 | display_change_observer_->OnDisplayModeChanged(); |
[email protected] | 6bdf795 | 2012-11-14 10:10:58 | [diff] [blame] | 431 | } |
| 432 | #endif |
| 433 | |
[email protected] | c9301e3 | 2012-05-23 08:34:58 | [diff] [blame] | 434 | // Install the custom factory first so that views::FocusManagers for Tray, |
| 435 | // Launcher, and WallPaper could be created by the factory. |
| 436 | views::FocusManagerFactory::Install(new AshFocusManagerFactory); |
| 437 | |
[email protected] | 4a59e4e | 2012-11-12 21:15:40 | [diff] [blame] | 438 | env_filter_.reset(new views::corewm::CompoundEventFilter); |
[email protected] | 304594c | 2012-11-13 16:35:27 | [diff] [blame] | 439 | AddPreTargetHandler(env_filter_.get()); |
[email protected] | 1aad332 | 2012-06-06 06:37:09 | [diff] [blame] | 440 | |
[email protected] | 05ab8e1 | 2013-01-31 21:21:33 | [diff] [blame] | 441 | // Env creates the compositor. Historically it seems to have been implicitly |
| 442 | // initialized first by the ActivationController, but now that FocusController |
| 443 | // no longer does this we need to do it explicitly. |
| 444 | aura::Env::GetInstance(); |
[email protected] | 052305f | 2012-12-05 18:53:04 | [diff] [blame] | 445 | if (views::corewm::UseFocusController()) { |
[email protected] | 39718b5 | 2012-12-03 17:24:56 | [diff] [blame] | 446 | views::corewm::FocusController* focus_controller = |
| 447 | new views::corewm::FocusController(new wm::AshFocusRules); |
| 448 | focus_client_.reset(focus_controller); |
| 449 | activation_client_ = focus_controller; |
[email protected] | 1ae36165 | 2012-12-12 22:39:51 | [diff] [blame] | 450 | activation_client_->AddObserver(this); |
[email protected] | 39718b5 | 2012-12-03 17:24:56 | [diff] [blame] | 451 | } else { |
| 452 | focus_client_.reset(new aura::FocusManager); |
| 453 | activation_controller_.reset( |
| 454 | new internal::ActivationController( |
| 455 | focus_client_.get(), |
| 456 | new internal::AshActivationController)); |
| 457 | activation_client_ = activation_controller_.get(); |
| 458 | AddPreTargetHandler(activation_controller_.get()); |
| 459 | } |
[email protected] | be65be36 | 2012-06-15 07:38:23 | [diff] [blame] | 460 | |
[email protected] | e74aaf0a | 2012-10-12 18:42:28 | [diff] [blame] | 461 | focus_cycler_.reset(new internal::FocusCycler()); |
| 462 | |
[email protected] | 8d625fb | 2012-07-18 16:40:06 | [diff] [blame] | 463 | screen_position_controller_.reset(new internal::ScreenPositionController); |
[email protected] | fca90ea | 2012-12-14 04:13:30 | [diff] [blame] | 464 | root_window_host_factory_.reset(delegate_->CreateRootWindowHostFactory()); |
[email protected] | edbfb8d | 2012-09-03 08:33:43 | [diff] [blame] | 465 | display_controller_.reset(new DisplayController); |
[email protected] | 2e236a5 | 2012-06-27 22:21:47 | [diff] [blame] | 466 | display_controller_->InitPrimaryDisplay(); |
| 467 | aura::RootWindow* root_window = display_controller_->GetPrimaryRootWindow(); |
[email protected] | be65be36 | 2012-06-15 07:38:23 | [diff] [blame] | 468 | active_root_window_ = root_window; |
[email protected] | a857dbe | 2012-05-30 22:10:14 | [diff] [blame] | 469 | |
[email protected] | 151ffdff | 2012-09-11 20:18:35 | [diff] [blame] | 470 | cursor_manager_.SetDeviceScaleFactor( |
| 471 | root_window->AsRootWindowHostDelegate()->GetDeviceScaleFactor()); |
| 472 | |
[email protected] | 58482fa | 2012-03-02 14:57:39 | [diff] [blame] | 473 | #if !defined(OS_MACOSX) |
| 474 | nested_dispatcher_controller_.reset(new NestedDispatcherController); |
| 475 | accelerator_controller_.reset(new AcceleratorController); |
| 476 | #endif |
[email protected] | 58482fa | 2012-03-02 14:57:39 | [diff] [blame] | 477 | |
[email protected] | c16b942 | 2012-06-06 21:51:11 | [diff] [blame] | 478 | // The order in which event filters are added is significant. |
[email protected] | c16b942 | 2012-06-06 21:51:11 | [diff] [blame] | 479 | user_activity_detector_.reset(new UserActivityDetector); |
[email protected] | 304594c | 2012-11-13 16:35:27 | [diff] [blame] | 480 | AddPreTargetHandler(user_activity_detector_.get()); |
[email protected] | c16b942 | 2012-06-06 21:51:11 | [diff] [blame] | 481 | |
[email protected] | b9d224c | 2012-07-13 01:09:03 | [diff] [blame] | 482 | event_rewriter_filter_.reset(new internal::EventRewriterEventFilter); |
[email protected] | 304594c | 2012-11-13 16:35:27 | [diff] [blame] | 483 | AddPreTargetHandler(event_rewriter_filter_.get()); |
[email protected] | 0b0b074 | 2012-02-16 13:23:45 | [diff] [blame] | 484 | |
[email protected] | 9ae32df | 2012-07-26 03:25:18 | [diff] [blame] | 485 | overlay_filter_.reset(new internal::OverlayEventFilter); |
[email protected] | 304594c | 2012-11-13 16:35:27 | [diff] [blame] | 486 | AddPreTargetHandler(overlay_filter_.get()); |
[email protected] | 9ae32df | 2012-07-26 03:25:18 | [diff] [blame] | 487 | AddShellObserver(overlay_filter_.get()); |
[email protected] | 0b0b074 | 2012-02-16 13:23:45 | [diff] [blame] | 488 | |
[email protected] | 15a1b4e | 2012-12-06 23:03:10 | [diff] [blame] | 489 | input_method_filter_.reset(new views::corewm::InputMethodEventFilter( |
| 490 | root_window->GetAcceleratedWidget())); |
[email protected] | 304594c | 2012-11-13 16:35:27 | [diff] [blame] | 491 | AddPreTargetHandler(input_method_filter_.get()); |
[email protected] | c16b942 | 2012-06-06 21:51:11 | [diff] [blame] | 492 | |
[email protected] | 21472b1 | 2012-02-17 00:30:05 | [diff] [blame] | 493 | #if !defined(OS_MACOSX) |
| 494 | accelerator_filter_.reset(new internal::AcceleratorFilter); |
[email protected] | f9f017c | 2012-11-12 19:05:17 | [diff] [blame] | 495 | AddPreTargetHandler(accelerator_filter_.get()); |
[email protected] | 21472b1 | 2012-02-17 00:30:05 | [diff] [blame] | 496 | #endif |
[email protected] | fcbbf08 | 2012-01-20 06:07:15 | [diff] [blame] | 497 | |
[email protected] | 682990f | 2013-01-10 06:49:11 | [diff] [blame] | 498 | event_transformation_handler_.reset(new internal::EventTransformationHandler); |
| 499 | AddPreTargetHandler(event_transformation_handler_.get()); |
| 500 | |
[email protected] | 435b212e | 2012-04-05 19:43:37 | [diff] [blame] | 501 | system_gesture_filter_.reset(new internal::SystemGestureEventFilter); |
[email protected] | f9f017c | 2012-11-12 19:05:17 | [diff] [blame] | 502 | AddPreTargetHandler(system_gesture_filter_.get()); |
[email protected] | 435b212e | 2012-04-05 19:43:37 | [diff] [blame] | 503 | |
[email protected] | 60a978b7 | 2012-06-08 00:29:18 | [diff] [blame] | 504 | capture_controller_.reset(new internal::CaptureController); |
[email protected] | 87b0d82e | 2011-10-07 21:02:59 | [diff] [blame] | 505 | |
[email protected] | 871e9cc | 2012-06-17 22:41:55 | [diff] [blame] | 506 | internal::RootWindowController* root_window_controller = |
| 507 | new internal::RootWindowController(root_window); |
| 508 | root_window_controller->CreateContainers(); |
[email protected] | 697f04c | 2012-10-03 01:15:10 | [diff] [blame] | 509 | root_window_controller->CreateSystemBackground( |
[email protected] | 02dbd1a | 2012-11-08 22:50:13 | [diff] [blame] | 510 | delegate_->IsFirstRunAfterBoot()); |
[email protected] | 871e9cc | 2012-06-17 22:41:55 | [diff] [blame] | 511 | |
[email protected] | 7307474 | 2012-05-17 01:44:41 | [diff] [blame] | 512 | CommandLine* command_line = CommandLine::ForCurrentProcess(); |
| 513 | |
[email protected] | c11aa8f1 | 2012-12-18 18:43:14 | [diff] [blame] | 514 | if (command_line->HasSwitch(ash::switches::kAshDisableNewLockAnimations)) |
[email protected] | 7ac6c5d | 2012-12-18 15:44:56 | [diff] [blame] | 515 | session_state_controller_.reset(new SessionStateControllerImpl); |
[email protected] | c11aa8f1 | 2012-12-18 18:43:14 | [diff] [blame] | 516 | else |
| 517 | session_state_controller_.reset(new SessionStateControllerImpl2); |
[email protected] | 83482fbf | 2012-11-21 14:02:09 | [diff] [blame] | 518 | power_button_controller_.reset(new PowerButtonController( |
| 519 | session_state_controller_.get())); |
| 520 | AddShellObserver(session_state_controller_.get()); |
| 521 | |
[email protected] | 7307474 | 2012-05-17 01:44:41 | [diff] [blame] | 522 | if (command_line->HasSwitch(switches::kAshTouchHud)) { |
| 523 | touch_observer_hud_.reset(new internal::TouchObserverHUD); |
[email protected] | f9f017c | 2012-11-12 19:05:17 | [diff] [blame] | 524 | AddPreTargetHandler(touch_observer_hud_.get()); |
[email protected] | 7307474 | 2012-05-17 01:44:41 | [diff] [blame] | 525 | } |
[email protected] | d90b839 | 2012-06-13 09:34:56 | [diff] [blame] | 526 | |
[email protected] | 8b7ba87b | 2012-09-01 00:40:40 | [diff] [blame] | 527 | mouse_cursor_filter_.reset(new internal::MouseCursorEventFilter()); |
[email protected] | 304594c | 2012-11-13 16:35:27 | [diff] [blame] | 528 | AddPreTargetHandler(mouse_cursor_filter_.get()); |
[email protected] | 0518d0d | 2012-08-26 11:59:04 | [diff] [blame] | 529 | |
[email protected] | d90b839 | 2012-06-13 09:34:56 | [diff] [blame] | 530 | // Create Controllers that may need root window. |
| 531 | // TODO(oshima): Move as many controllers before creating |
| 532 | // RootWindowController as possible. |
[email protected] | b5756e2 | 2012-11-30 01:32:02 | [diff] [blame] | 533 | visibility_controller_.reset(new AshVisibilityController); |
[email protected] | d90b839 | 2012-06-13 09:34:56 | [diff] [blame] | 534 | drag_drop_controller_.reset(new internal::DragDropController); |
[email protected] | 02dbd1a | 2012-11-08 22:50:13 | [diff] [blame] | 535 | user_action_client_.reset(delegate_->CreateUserActionClient()); |
[email protected] | 0c2dc01 | 2012-12-02 00:00:23 | [diff] [blame] | 536 | window_modality_controller_.reset( |
| 537 | new views::corewm::WindowModalityController); |
[email protected] | 304594c | 2012-11-13 16:35:27 | [diff] [blame] | 538 | AddPreTargetHandler(window_modality_controller_.get()); |
[email protected] | 488b4204 | 2011-11-15 00:20:18 | [diff] [blame] | 539 | |
[email protected] | 9613eacf | 2012-06-22 02:18:05 | [diff] [blame] | 540 | magnification_controller_.reset( |
[email protected] | 77f7c13 | 2012-11-15 06:52:54 | [diff] [blame] | 541 | MagnificationController::CreateInstance()); |
| 542 | |
| 543 | partial_magnification_controller_.reset( |
| 544 | new PartialMagnificationController()); |
[email protected] | 9613eacf | 2012-06-22 02:18:05 | [diff] [blame] | 545 | |
[email protected] | d90b839 | 2012-06-13 09:34:56 | [diff] [blame] | 546 | high_contrast_controller_.reset(new HighContrastController); |
| 547 | video_detector_.reset(new VideoDetector); |
[email protected] | 39718b5 | 2012-12-03 17:24:56 | [diff] [blame] | 548 | window_cycle_controller_.reset(new WindowCycleController(activation_client_)); |
[email protected] | b0079a9 | 2012-01-25 20:13:38 | [diff] [blame] | 549 | |
[email protected] | a1b7a82 | 2013-02-23 19:08:04 | [diff] [blame] | 550 | tooltip_controller_.reset(new views::corewm::TooltipController( |
| 551 | gfx::SCREEN_TYPE_ALTERNATE)); |
[email protected] | 304594c | 2012-11-13 16:35:27 | [diff] [blame] | 552 | AddPreTargetHandler(tooltip_controller_.get()); |
[email protected] | 54a37cdc | 2012-07-25 19:16:01 | [diff] [blame] | 553 | |
[email protected] | e67291f1 | 2012-10-10 05:52:38 | [diff] [blame] | 554 | event_client_.reset(new internal::EventClientImpl); |
| 555 | |
[email protected] | be65be36 | 2012-06-15 07:38:23 | [diff] [blame] | 556 | InitRootWindowController(root_window_controller); |
[email protected] | 262f8bd | 2012-03-23 19:30:27 | [diff] [blame] | 557 | |
[email protected] | 36f56653 | 2012-09-19 04:07:24 | [diff] [blame] | 558 | // This controller needs to be set before SetupManagedWindowMode. |
| 559 | desktop_background_controller_.reset(new DesktopBackgroundController()); |
[email protected] | 02dbd1a | 2012-11-08 22:50:13 | [diff] [blame] | 560 | user_wallpaper_delegate_.reset(delegate_->CreateUserWallpaperDelegate()); |
[email protected] | 36f56653 | 2012-09-19 04:07:24 | [diff] [blame] | 561 | if (!user_wallpaper_delegate_.get()) |
| 562 | user_wallpaper_delegate_.reset(new DummyUserWallpaperDelegate()); |
| 563 | |
[email protected] | f4c92b38 | 2012-08-28 00:59:59 | [diff] [blame] | 564 | // StatusAreaWidget uses Shell's CapsLockDelegate. |
[email protected] | 02dbd1a | 2012-11-08 22:50:13 | [diff] [blame] | 565 | caps_lock_delegate_.reset(delegate_->CreateCapsLockDelegate()); |
[email protected] | f4c92b38 | 2012-08-28 00:59:59 | [diff] [blame] | 566 | |
[email protected] | a1b7a82 | 2013-02-23 19:08:04 | [diff] [blame] | 567 | if (!command_line->HasSwitch(views::corewm::switches::kNoDropShadows)) { |
[email protected] | e4a181cc | 2012-03-17 02:20:57 | [diff] [blame] | 568 | resize_shadow_controller_.reset(new internal::ResizeShadowController()); |
[email protected] | 86f2b5e | 2012-11-14 20:37:00 | [diff] [blame] | 569 | shadow_controller_.reset( |
[email protected] | 7dd11db | 2013-02-27 01:29:13 | [diff] [blame] | 570 | new views::corewm::ShadowController(activation_client_)); |
[email protected] | e4a181cc | 2012-03-17 02:20:57 | [diff] [blame] | 571 | } |
[email protected] | a54e65b | 2011-11-21 22:03:34 | [diff] [blame] | 572 | |
[email protected] | 83b2b84c | 2012-11-14 01:11:00 | [diff] [blame] | 573 | // Create system_tray_notifier_ before the delegate. |
| 574 | system_tray_notifier_.reset(new ash::SystemTrayNotifier()); |
| 575 | |
[email protected] | 51ed599 | 2012-11-07 10:14:39 | [diff] [blame] | 576 | // Initialize system_tray_delegate_ before initializing StatusAreaWidget. |
[email protected] | 02dbd1a | 2012-11-08 22:50:13 | [diff] [blame] | 577 | system_tray_delegate_.reset(delegate()->CreateSystemTrayDelegate()); |
[email protected] | 51ed599 | 2012-11-07 10:14:39 | [diff] [blame] | 578 | if (!system_tray_delegate_.get()) |
| 579 | system_tray_delegate_.reset(SystemTrayDelegate::CreateDummyDelegate()); |
| 580 | |
| 581 | // Creates StatusAreaWidget. |
[email protected] | e74aaf0a | 2012-10-12 18:42:28 | [diff] [blame] | 582 | root_window_controller->InitForPrimaryDisplay(); |
[email protected] | 3d29912a | 2012-02-07 07:41:51 | [diff] [blame] | 583 | |
[email protected] | 51ed599 | 2012-11-07 10:14:39 | [diff] [blame] | 584 | // Initialize system_tray_delegate_ after StatusAreaWidget is created. |
| 585 | system_tray_delegate_->Initialize(); |
| 586 | |
[email protected] | 16059276d | 2012-10-22 18:59:50 | [diff] [blame] | 587 | display_controller_->InitSecondaryDisplays(); |
| 588 | |
[email protected] | d90b839 | 2012-06-13 09:34:56 | [diff] [blame] | 589 | // Force Layout |
[email protected] | be65be36 | 2012-06-15 07:38:23 | [diff] [blame] | 590 | root_window_controller->root_window_layout()->OnWindowResized(); |
[email protected] | 084b6bb | 2011-11-17 05:18:16 | [diff] [blame] | 591 | |
[email protected] | 60b5b86 | 2012-04-27 18:56:34 | [diff] [blame] | 592 | // It needs to be created after OnWindowResized has been called, otherwise the |
[email protected] | 5f2391ea | 2012-09-12 23:46:49 | [diff] [blame] | 593 | // widget will not paint when restoring after a browser crash. Also it needs |
| 594 | // to be created after InitSecondaryDisplays() to initialize the wallpapers in |
| 595 | // the correct size. |
[email protected] | 0c4f87d | 2012-06-12 02:00:35 | [diff] [blame] | 596 | user_wallpaper_delegate_->InitializeWallpaper(); |
[email protected] | 60b5b86 | 2012-04-27 18:56:34 | [diff] [blame] | 597 | |
[email protected] | d90b839 | 2012-06-13 09:34:56 | [diff] [blame] | 598 | if (initially_hide_cursor_) |
[email protected] | 4e72174 | 2013-02-04 21:39:30 | [diff] [blame] | 599 | cursor_manager_.HideCursor(); |
[email protected] | 86e38e4 | 2012-11-20 17:53:26 | [diff] [blame] | 600 | cursor_manager_.SetCursor(ui::kCursorPointer); |
[email protected] | 0ad9b76 | 2012-09-28 04:22:09 | [diff] [blame] | 601 | |
[email protected] | 4e72174 | 2013-02-04 21:39:30 | [diff] [blame] | 602 | if (!cursor_manager_.IsCursorVisible()) { |
| 603 | // Cursor might have been hidden by something other than chrome. |
| 604 | // Let the first mouse event show the cursor. |
| 605 | env_filter_->set_cursor_hidden_by_filter(true); |
| 606 | } |
[email protected] | 87b0d82e | 2011-10-07 21:02:59 | [diff] [blame] | 607 | } |
| 608 | |
[email protected] | 431552c | 2012-10-23 00:38:33 | [diff] [blame] | 609 | void Shell::ShowContextMenu(const gfx::Point& location_in_screen) { |
[email protected] | f60c623 | 2012-08-24 18:55:03 | [diff] [blame] | 610 | // No context menus if user have not logged in. |
[email protected] | 02dbd1a | 2012-11-08 22:50:13 | [diff] [blame] | 611 | if (!delegate_->IsUserLoggedIn()) |
[email protected] | f60c623 | 2012-08-24 18:55:03 | [diff] [blame] | 612 | return; |
| 613 | // No context menus when screen is locked. |
| 614 | if (IsScreenLocked()) |
| 615 | return; |
[email protected] | 431552c | 2012-10-23 00:38:33 | [diff] [blame] | 616 | |
[email protected] | 88d7112 | 2012-10-18 07:11:01 | [diff] [blame] | 617 | aura::RootWindow* root = |
[email protected] | 431552c | 2012-10-23 00:38:33 | [diff] [blame] | 618 | wm::GetRootWindowMatching(gfx::Rect(location_in_screen, gfx::Size())); |
[email protected] | 43dcd35 | 2012-12-18 02:28:46 | [diff] [blame] | 619 | // TODO(oshima): The root and root window controller shouldn't be |
| 620 | // NULL even for the out-of-bounds |location_in_screen| (It should |
| 621 | // return the primary root). Investigate why/how this is |
| 622 | // happening. crbug.com/165214. |
| 623 | internal::RootWindowController* rwc = GetRootWindowController(root); |
[email protected] | bd4814b | 2012-12-27 01:16:00 | [diff] [blame] | 624 | CHECK(rwc) << "root=" << root |
| 625 | << ", location:" << location_in_screen.ToString(); |
[email protected] | 43dcd35 | 2012-12-18 02:28:46 | [diff] [blame] | 626 | if (rwc) |
| 627 | rwc->ShowContextMenu(location_in_screen); |
[email protected] | 46ca363 | 2011-11-03 03:33:42 | [diff] [blame] | 628 | } |
| 629 | |
[email protected] | b913a3a | 2012-12-11 13:07:19 | [diff] [blame] | 630 | void Shell::ToggleAppList(aura::Window* window) { |
| 631 | // If the context window is not given, show it on the active root window. |
| 632 | if (!window) |
| 633 | window = GetActiveRootWindow(); |
[email protected] | 0039db9 | 2012-05-09 04:11:45 | [diff] [blame] | 634 | if (!app_list_controller_.get()) |
| 635 | app_list_controller_.reset(new internal::AppListController); |
[email protected] | b913a3a | 2012-12-11 13:07:19 | [diff] [blame] | 636 | app_list_controller_->SetVisible(!app_list_controller_->IsVisible(), window); |
[email protected] | ae4987d | 2011-11-21 22:52:44 | [diff] [blame] | 637 | } |
| 638 | |
[email protected] | 7510d108 | 2012-03-30 21:58:34 | [diff] [blame] | 639 | bool Shell::GetAppListTargetVisibility() const { |
[email protected] | 0039db9 | 2012-05-09 04:11:45 | [diff] [blame] | 640 | return app_list_controller_.get() && |
| 641 | app_list_controller_->GetTargetVisibility(); |
[email protected] | 7510d108 | 2012-03-30 21:58:34 | [diff] [blame] | 642 | } |
| 643 | |
[email protected] | 1e51a9d | 2012-04-09 23:31:11 | [diff] [blame] | 644 | aura::Window* Shell::GetAppListWindow() { |
[email protected] | 0039db9 | 2012-05-09 04:11:45 | [diff] [blame] | 645 | return app_list_controller_.get() ? app_list_controller_->GetWindow() : NULL; |
[email protected] | 1e51a9d | 2012-04-09 23:31:11 | [diff] [blame] | 646 | } |
| 647 | |
[email protected] | 9154587 | 2012-11-21 13:58:27 | [diff] [blame] | 648 | bool Shell::CanLockScreen() { |
| 649 | return delegate_->CanLockScreen(); |
| 650 | } |
| 651 | |
[email protected] | f7eb89c | 2011-12-13 09:48:54 | [diff] [blame] | 652 | bool Shell::IsScreenLocked() const { |
[email protected] | 02dbd1a | 2012-11-08 22:50:13 | [diff] [blame] | 653 | return delegate_->IsScreenLocked(); |
[email protected] | f7eb89c | 2011-12-13 09:48:54 | [diff] [blame] | 654 | } |
| 655 | |
[email protected] | dc0973937 | 2012-11-15 20:17:39 | [diff] [blame] | 656 | bool Shell::IsSystemModalWindowOpen() const { |
[email protected] | 852a55d | 2012-10-17 13:30:30 | [diff] [blame] | 657 | if (simulate_modal_window_open_for_testing_) |
| 658 | return true; |
[email protected] | 429433f | 2012-12-28 20:14:46 | [diff] [blame] | 659 | const std::vector<aura::Window*> containers = GetContainersFromAllRootWindows( |
| 660 | internal::kShellWindowId_SystemModalContainer, NULL); |
[email protected] | 001272f | 2012-11-02 20:05:23 | [diff] [blame] | 661 | for (std::vector<aura::Window*>::const_iterator cit = containers.begin(); |
| 662 | cit != containers.end(); ++cit) { |
| 663 | for (aura::Window::Windows::const_iterator wit = (*cit)->children().begin(); |
| 664 | wit != (*cit)->children().end(); ++wit) { |
| 665 | if ((*wit)->GetProperty(aura::client::kModalKey) == |
| 666 | ui::MODAL_TYPE_SYSTEM && (*wit)->TargetVisibility()) { |
| 667 | return true; |
| 668 | } |
| 669 | } |
| 670 | } |
| 671 | return false; |
[email protected] | 40c4cbb | 2012-01-10 23:26:07 | [diff] [blame] | 672 | } |
| 673 | |
[email protected] | 57b8bb35 | 2012-01-11 05:11:46 | [diff] [blame] | 674 | views::NonClientFrameView* Shell::CreateDefaultNonClientFrameView( |
| 675 | views::Widget* widget) { |
[email protected] | fef157d1 | 2013-02-04 20:43:23 | [diff] [blame] | 676 | if (views::DialogDelegate::UseNewStyle()) |
| 677 | return views::DialogDelegate::CreateNewStyleFrameView(widget); |
[email protected] | c73d133 | 2012-03-08 17:11:04 | [diff] [blame] | 678 | // Use translucent-style window frames for dialogs. |
[email protected] | 95c6cc4 | 2012-03-08 20:53:15 | [diff] [blame] | 679 | CustomFrameViewAsh* frame_view = new CustomFrameViewAsh; |
[email protected] | c73d133 | 2012-03-08 17:11:04 | [diff] [blame] | 680 | frame_view->Init(widget); |
| 681 | return frame_view; |
[email protected] | 57b8bb35 | 2012-01-11 05:11:46 | [diff] [blame] | 682 | } |
| 683 | |
[email protected] | 3d29912a | 2012-02-07 07:41:51 | [diff] [blame] | 684 | void Shell::RotateFocus(Direction direction) { |
| 685 | focus_cycler_->RotateFocus( |
| 686 | direction == FORWARD ? internal::FocusCycler::FORWARD : |
| 687 | internal::FocusCycler::BACKWARD); |
| 688 | } |
| 689 | |
[email protected] | 2e236a5 | 2012-06-27 22:21:47 | [diff] [blame] | 690 | void Shell::SetDisplayWorkAreaInsets(Window* contains, |
[email protected] | 8a45c97 | 2012-03-14 18:22:44 | [diff] [blame] | 691 | const gfx::Insets& insets) { |
[email protected] | 6bdf795 | 2012-11-14 10:10:58 | [diff] [blame] | 692 | if (!display_manager_->UpdateWorkAreaOfDisplayNearestWindow(contains, insets)) |
[email protected] | 1a2145b | 2012-03-13 21:09:17 | [diff] [blame] | 693 | return; |
[email protected] | 1a2145b | 2012-03-13 21:09:17 | [diff] [blame] | 694 | FOR_EACH_OBSERVER(ShellObserver, observers_, |
[email protected] | 2e236a5 | 2012-06-27 22:21:47 | [diff] [blame] | 695 | OnDisplayWorkAreaInsetsChanged()); |
[email protected] | 1a2145b | 2012-03-13 21:09:17 | [diff] [blame] | 696 | } |
| 697 | |
[email protected] | 82d3954ae | 2012-04-20 09:02:22 | [diff] [blame] | 698 | void Shell::OnLoginStateChanged(user::LoginStatus status) { |
| 699 | FOR_EACH_OBSERVER(ShellObserver, observers_, OnLoginStateChanged(status)); |
[email protected] | 16059276d | 2012-10-22 18:59:50 | [diff] [blame] | 700 | RootWindowControllerList controllers = GetAllRootWindowControllers(); |
| 701 | for (RootWindowControllerList::iterator iter = controllers.begin(); |
| 702 | iter != controllers.end(); ++iter) |
| 703 | (*iter)->OnLoginStateChanged(status); |
[email protected] | 82d3954ae | 2012-04-20 09:02:22 | [diff] [blame] | 704 | } |
| 705 | |
[email protected] | 88d7112 | 2012-10-18 07:11:01 | [diff] [blame] | 706 | void Shell::UpdateAfterLoginStatusChange(user::LoginStatus status) { |
[email protected] | 16059276d | 2012-10-22 18:59:50 | [diff] [blame] | 707 | RootWindowControllerList controllers = GetAllRootWindowControllers(); |
| 708 | for (RootWindowControllerList::iterator iter = controllers.begin(); |
| 709 | iter != controllers.end(); ++iter) |
| 710 | (*iter)->UpdateAfterLoginStatusChange(status); |
[email protected] | 88d7112 | 2012-10-18 07:11:01 | [diff] [blame] | 711 | } |
| 712 | |
[email protected] | 82d3954ae | 2012-04-20 09:02:22 | [diff] [blame] | 713 | void Shell::OnAppTerminating() { |
| 714 | FOR_EACH_OBSERVER(ShellObserver, observers_, OnAppTerminating()); |
| 715 | } |
| 716 | |
| 717 | void Shell::OnLockStateChanged(bool locked) { |
| 718 | FOR_EACH_OBSERVER(ShellObserver, observers_, OnLockStateChanged(locked)); |
| 719 | } |
| 720 | |
[email protected] | d9456cb | 2012-03-21 16:41:04 | [diff] [blame] | 721 | void Shell::CreateLauncher() { |
[email protected] | a0afeb1 | 2012-12-10 22:57:09 | [diff] [blame] | 722 | if (IsLauncherPerDisplayEnabled()) { |
| 723 | RootWindowControllerList controllers = GetAllRootWindowControllers(); |
| 724 | for (RootWindowControllerList::iterator iter = controllers.begin(); |
| 725 | iter != controllers.end(); ++iter) |
[email protected] | 478c6c3 | 2013-03-09 02:50:58 | [diff] [blame] | 726 | (*iter)->shelf()->CreateLauncher(); |
[email protected] | a0afeb1 | 2012-12-10 22:57:09 | [diff] [blame] | 727 | } else { |
[email protected] | 478c6c3 | 2013-03-09 02:50:58 | [diff] [blame] | 728 | GetPrimaryRootWindowController()->shelf()->CreateLauncher(); |
[email protected] | a0afeb1 | 2012-12-10 22:57:09 | [diff] [blame] | 729 | } |
[email protected] | d9456cb | 2012-03-21 16:41:04 | [diff] [blame] | 730 | } |
| 731 | |
[email protected] | 7e1df2f6 | 2012-07-19 19:17:18 | [diff] [blame] | 732 | void Shell::ShowLauncher() { |
[email protected] | bde8ae9 | 2012-12-15 17:08:18 | [diff] [blame] | 733 | if (IsLauncherPerDisplayEnabled()) { |
| 734 | RootWindowControllerList controllers = GetAllRootWindowControllers(); |
| 735 | for (RootWindowControllerList::iterator iter = controllers.begin(); |
| 736 | iter != controllers.end(); ++iter) |
| 737 | (*iter)->ShowLauncher(); |
| 738 | } else { |
| 739 | GetPrimaryRootWindowController()->ShowLauncher(); |
| 740 | } |
[email protected] | 7e1df2f6 | 2012-07-19 19:17:18 | [diff] [blame] | 741 | } |
| 742 | |
[email protected] | 1a2145b | 2012-03-13 21:09:17 | [diff] [blame] | 743 | void Shell::AddShellObserver(ShellObserver* observer) { |
| 744 | observers_.AddObserver(observer); |
| 745 | } |
| 746 | |
| 747 | void Shell::RemoveShellObserver(ShellObserver* observer) { |
| 748 | observers_.RemoveObserver(observer); |
| 749 | } |
| 750 | |
[email protected] | c758fbf | 2012-03-25 22:53:59 | [diff] [blame] | 751 | void Shell::UpdateShelfVisibility() { |
[email protected] | 431552c | 2012-10-23 00:38:33 | [diff] [blame] | 752 | RootWindowControllerList controllers = GetAllRootWindowControllers(); |
| 753 | for (RootWindowControllerList::iterator iter = controllers.begin(); |
| 754 | iter != controllers.end(); ++iter) |
| 755 | if ((*iter)->shelf()) |
| 756 | (*iter)->UpdateShelfVisibility(); |
[email protected] | c758fbf | 2012-03-25 22:53:59 | [diff] [blame] | 757 | } |
| 758 | |
[email protected] | 431552c | 2012-10-23 00:38:33 | [diff] [blame] | 759 | void Shell::SetShelfAutoHideBehavior(ShelfAutoHideBehavior behavior, |
| 760 | aura::RootWindow* root_window) { |
[email protected] | 478c6c3 | 2013-03-09 02:50:58 | [diff] [blame] | 761 | ash::internal::ShelfLayoutManager::ForLauncher(root_window)-> |
| 762 | SetAutoHideBehavior(behavior); |
[email protected] | c758fbf | 2012-03-25 22:53:59 | [diff] [blame] | 763 | } |
| 764 | |
[email protected] | 431552c | 2012-10-23 00:38:33 | [diff] [blame] | 765 | ShelfAutoHideBehavior Shell::GetShelfAutoHideBehavior( |
| 766 | aura::RootWindow* root_window) const { |
[email protected] | 478c6c3 | 2013-03-09 02:50:58 | [diff] [blame] | 767 | return ash::internal::ShelfLayoutManager::ForLauncher(root_window)-> |
| 768 | auto_hide_behavior(); |
[email protected] | c758fbf | 2012-03-25 22:53:59 | [diff] [blame] | 769 | } |
| 770 | |
[email protected] | 431552c | 2012-10-23 00:38:33 | [diff] [blame] | 771 | void Shell::SetShelfAlignment(ShelfAlignment alignment, |
| 772 | aura::RootWindow* root_window) { |
[email protected] | 478c6c3 | 2013-03-09 02:50:58 | [diff] [blame] | 773 | if (ash::internal::ShelfLayoutManager::ForLauncher(root_window)-> |
| 774 | SetAlignment(alignment)) { |
[email protected] | f89f751 | 2012-12-17 19:21:18 | [diff] [blame] | 775 | FOR_EACH_OBSERVER( |
| 776 | ShellObserver, observers_, OnShelfAlignmentChanged(root_window)); |
| 777 | } |
[email protected] | 5544450 | 2012-05-10 15:43:53 | [diff] [blame] | 778 | } |
| 779 | |
[email protected] | 431552c | 2012-10-23 00:38:33 | [diff] [blame] | 780 | ShelfAlignment Shell::GetShelfAlignment(aura::RootWindow* root_window) { |
[email protected] | 478c6c3 | 2013-03-09 02:50:58 | [diff] [blame] | 781 | return GetRootWindowController(root_window)-> |
| 782 | GetShelfLayoutManager()->GetAlignment(); |
[email protected] | 5544450 | 2012-05-10 15:43:53 | [diff] [blame] | 783 | } |
| 784 | |
[email protected] | d90b839 | 2012-06-13 09:34:56 | [diff] [blame] | 785 | void Shell::SetDimming(bool should_dim) { |
[email protected] | be65be36 | 2012-06-15 07:38:23 | [diff] [blame] | 786 | RootWindowControllerList controllers = GetAllRootWindowControllers(); |
| 787 | for (RootWindowControllerList::iterator iter = controllers.begin(); |
| 788 | iter != controllers.end(); ++iter) |
| 789 | (*iter)->screen_dimmer()->SetDimming(should_dim); |
[email protected] | d90b839 | 2012-06-13 09:34:56 | [diff] [blame] | 790 | } |
| 791 | |
[email protected] | 090c4f1 | 2012-10-29 18:56:42 | [diff] [blame] | 792 | void Shell::CreateModalBackground(aura::Window* window) { |
[email protected] | c0ce80e | 2012-10-05 23:28:27 | [diff] [blame] | 793 | if (!modality_filter_.get()) { |
| 794 | modality_filter_.reset(new internal::SystemModalContainerEventFilter(this)); |
[email protected] | 304594c | 2012-11-13 16:35:27 | [diff] [blame] | 795 | AddPreTargetHandler(modality_filter_.get()); |
[email protected] | c0ce80e | 2012-10-05 23:28:27 | [diff] [blame] | 796 | } |
| 797 | RootWindowControllerList controllers = GetAllRootWindowControllers(); |
| 798 | for (RootWindowControllerList::iterator iter = controllers.begin(); |
| 799 | iter != controllers.end(); ++iter) |
[email protected] | 090c4f1 | 2012-10-29 18:56:42 | [diff] [blame] | 800 | (*iter)->GetSystemModalLayoutManager(window)->CreateModalBackground(); |
[email protected] | c0ce80e | 2012-10-05 23:28:27 | [diff] [blame] | 801 | } |
| 802 | |
| 803 | void Shell::OnModalWindowRemoved(aura::Window* removed) { |
| 804 | RootWindowControllerList controllers = GetAllRootWindowControllers(); |
| 805 | bool activated = false; |
| 806 | for (RootWindowControllerList::iterator iter = controllers.begin(); |
| 807 | iter != controllers.end() && !activated; ++iter) { |
[email protected] | 8674b31 | 2012-10-12 19:02:44 | [diff] [blame] | 808 | activated = (*iter)->GetSystemModalLayoutManager(removed)-> |
| 809 | ActivateNextModalWindow(); |
[email protected] | c0ce80e | 2012-10-05 23:28:27 | [diff] [blame] | 810 | } |
| 811 | if (!activated) { |
[email protected] | 304594c | 2012-11-13 16:35:27 | [diff] [blame] | 812 | RemovePreTargetHandler(modality_filter_.get()); |
[email protected] | c0ce80e | 2012-10-05 23:28:27 | [diff] [blame] | 813 | modality_filter_.reset(); |
| 814 | for (RootWindowControllerList::iterator iter = controllers.begin(); |
| 815 | iter != controllers.end(); ++iter) |
[email protected] | 8674b31 | 2012-10-12 19:02:44 | [diff] [blame] | 816 | (*iter)->GetSystemModalLayoutManager(removed)->DestroyModalBackground(); |
[email protected] | c0ce80e | 2012-10-05 23:28:27 | [diff] [blame] | 817 | } |
| 818 | } |
| 819 | |
[email protected] | 88d7112 | 2012-10-18 07:11:01 | [diff] [blame] | 820 | WebNotificationTray* Shell::GetWebNotificationTray() { |
[email protected] | 478c6c3 | 2013-03-09 02:50:58 | [diff] [blame] | 821 | return GetPrimaryRootWindowController()->shelf()-> |
| 822 | status_area_widget()->web_notification_tray(); |
[email protected] | e74aaf0a | 2012-10-12 18:42:28 | [diff] [blame] | 823 | } |
| 824 | |
[email protected] | a0afeb1 | 2012-12-10 22:57:09 | [diff] [blame] | 825 | bool Shell::HasPrimaryStatusArea() { |
[email protected] | 478c6c3 | 2013-03-09 02:50:58 | [diff] [blame] | 826 | ShelfWidget* shelf = GetPrimaryRootWindowController()->shelf(); |
| 827 | return shelf && shelf->status_area_widget(); |
[email protected] | 31f19e3 | 2012-10-30 22:31:23 | [diff] [blame] | 828 | } |
| 829 | |
[email protected] | a0afeb1 | 2012-12-10 22:57:09 | [diff] [blame] | 830 | SystemTray* Shell::GetPrimarySystemTray() { |
| 831 | return GetPrimaryRootWindowController()->GetSystemTray(); |
[email protected] | aa54218b | 2012-06-12 16:51:42 | [diff] [blame] | 832 | } |
| 833 | |
[email protected] | b913a3a | 2012-12-11 13:07:19 | [diff] [blame] | 834 | LauncherDelegate* Shell::GetLauncherDelegate() { |
| 835 | if (!launcher_delegate_.get()) { |
| 836 | launcher_model_.reset(new LauncherModel); |
| 837 | launcher_delegate_.reset( |
| 838 | delegate_->CreateLauncherDelegate(launcher_model_.get())); |
| 839 | } |
| 840 | return launcher_delegate_.get(); |
| 841 | } |
| 842 | |
[email protected] | 2e236a5 | 2012-06-27 22:21:47 | [diff] [blame] | 843 | void Shell::InitRootWindowForSecondaryDisplay(aura::RootWindow* root) { |
[email protected] | 8cfb672 | 2012-11-28 03:28:46 | [diff] [blame] | 844 | aura::client::SetFocusClient(root, focus_client_.get()); |
[email protected] | cf1c70e | 2012-08-30 01:13:02 | [diff] [blame] | 845 | internal::RootWindowController* controller = |
| 846 | new internal::RootWindowController(root); |
| 847 | controller->CreateContainers(); |
[email protected] | bca9a7e | 2012-11-10 06:25:49 | [diff] [blame] | 848 | // Pass false for the |is_first_run_after_boot| parameter so we'll show a |
| 849 | // black background on this display instead of trying to mimic the boot splash |
| 850 | // screen. |
| 851 | controller->CreateSystemBackground(false); |
[email protected] | cf1c70e | 2012-08-30 01:13:02 | [diff] [blame] | 852 | InitRootWindowController(controller); |
[email protected] | 16059276d | 2012-10-22 18:59:50 | [diff] [blame] | 853 | if (IsLauncherPerDisplayEnabled()) |
| 854 | controller->InitForPrimaryDisplay(); |
[email protected] | cf1c70e | 2012-08-30 01:13:02 | [diff] [blame] | 855 | controller->root_window_layout()->OnWindowResized(); |
| 856 | desktop_background_controller_->OnRootWindowAdded(root); |
[email protected] | 6b37addd | 2012-09-28 03:08:09 | [diff] [blame] | 857 | high_contrast_controller_->OnRootWindowAdded(root); |
[email protected] | cf1c70e | 2012-08-30 01:13:02 | [diff] [blame] | 858 | root->ShowRootWindow(); |
| 859 | // Activate new root for testing. |
| 860 | active_root_window_ = root; |
[email protected] | a857dbe | 2012-05-30 22:10:14 | [diff] [blame] | 861 | } |
| 862 | |
[email protected] | f946670 | 2012-09-17 16:35:27 | [diff] [blame] | 863 | void Shell::DoInitialWorkspaceAnimation() { |
| 864 | return GetPrimaryRootWindowController()->workspace_controller()-> |
| 865 | DoInitialAnimation(); |
| 866 | } |
| 867 | |
[email protected] | be65be36 | 2012-06-15 07:38:23 | [diff] [blame] | 868 | void Shell::InitRootWindowController( |
| 869 | internal::RootWindowController* controller) { |
| 870 | aura::RootWindow* root_window = controller->root_window(); |
[email protected] | 39718b5 | 2012-12-03 17:24:56 | [diff] [blame] | 871 | DCHECK(activation_client_); |
[email protected] | d90b839 | 2012-06-13 09:34:56 | [diff] [blame] | 872 | DCHECK(visibility_controller_.get()); |
| 873 | DCHECK(drag_drop_controller_.get()); |
| 874 | DCHECK(capture_controller_.get()); |
[email protected] | 8fef743 | 2012-08-06 15:34:25 | [diff] [blame] | 875 | DCHECK(window_cycle_controller_.get()); |
[email protected] | d90b839 | 2012-06-13 09:34:56 | [diff] [blame] | 876 | |
[email protected] | 8cfb672 | 2012-11-28 03:28:46 | [diff] [blame] | 877 | aura::client::SetFocusClient(root_window, focus_client_.get()); |
[email protected] | d90b839 | 2012-06-13 09:34:56 | [diff] [blame] | 878 | input_method_filter_->SetInputMethodPropertyInRootWindow(root_window); |
[email protected] | 39718b5 | 2012-12-03 17:24:56 | [diff] [blame] | 879 | aura::client::SetActivationClient(root_window, activation_client_); |
[email protected] | 052305f | 2012-12-05 18:53:04 | [diff] [blame] | 880 | if (views::corewm::UseFocusController()) { |
[email protected] | 39718b5 | 2012-12-03 17:24:56 | [diff] [blame] | 881 | views::corewm::FocusController* controller = |
| 882 | static_cast<views::corewm::FocusController*>(activation_client_); |
| 883 | root_window->AddPreTargetHandler(controller); |
| 884 | } |
[email protected] | d90b839 | 2012-06-13 09:34:56 | [diff] [blame] | 885 | aura::client::SetVisibilityClient(root_window, visibility_controller_.get()); |
| 886 | aura::client::SetDragDropClient(root_window, drag_drop_controller_.get()); |
[email protected] | d90b839 | 2012-06-13 09:34:56 | [diff] [blame] | 887 | aura::client::SetCaptureClient(root_window, capture_controller_.get()); |
[email protected] | 8d625fb | 2012-07-18 16:40:06 | [diff] [blame] | 888 | aura::client::SetScreenPositionClient(root_window, |
| 889 | screen_position_controller_.get()); |
[email protected] | 4b8003c | 2012-07-26 00:54:19 | [diff] [blame] | 890 | aura::client::SetCursorClient(root_window, &cursor_manager_); |
[email protected] | 54a37cdc | 2012-07-25 19:16:01 | [diff] [blame] | 891 | aura::client::SetTooltipClient(root_window, tooltip_controller_.get()); |
[email protected] | e67291f1 | 2012-10-10 05:52:38 | [diff] [blame] | 892 | aura::client::SetEventClient(root_window, event_client_.get()); |
[email protected] | d90b839 | 2012-06-13 09:34:56 | [diff] [blame] | 893 | |
| 894 | if (nested_dispatcher_controller_.get()) { |
| 895 | aura::client::SetDispatcherClient(root_window, |
| 896 | nested_dispatcher_controller_.get()); |
| 897 | } |
| 898 | if (user_action_client_.get()) |
| 899 | aura::client::SetUserActionClient(root_window, user_action_client_.get()); |
| 900 | |
| 901 | root_window->SetCursor(ui::kCursorPointer); |
[email protected] | be65be36 | 2012-06-15 07:38:23 | [diff] [blame] | 902 | controller->InitLayoutManagers(); |
[email protected] | f059c694 | 2012-07-21 14:27:57 | [diff] [blame] | 903 | |
| 904 | // TODO(oshima): Move the instance to RootWindowController when |
| 905 | // the extended desktop is enabled by default. |
| 906 | internal::AlwaysOnTopController* always_on_top_controller = |
| 907 | new internal::AlwaysOnTopController; |
[email protected] | c96b981 | 2012-10-17 16:04:04 | [diff] [blame] | 908 | always_on_top_controller->SetAlwaysOnTopContainer( |
[email protected] | f059c694 | 2012-07-21 14:27:57 | [diff] [blame] | 909 | root_window->GetChildById(internal::kShellWindowId_AlwaysOnTopContainer)); |
| 910 | root_window->SetProperty(internal::kAlwaysOnTopControllerKey, |
| 911 | always_on_top_controller); |
[email protected] | 8674b31 | 2012-10-12 19:02:44 | [diff] [blame] | 912 | if (GetPrimaryRootWindowController()->GetSystemModalLayoutManager(NULL)-> |
[email protected] | c0ce80e | 2012-10-05 23:28:27 | [diff] [blame] | 913 | has_modal_background()) { |
[email protected] | 8674b31 | 2012-10-12 19:02:44 | [diff] [blame] | 914 | controller->GetSystemModalLayoutManager(NULL)->CreateModalBackground(); |
[email protected] | c0ce80e | 2012-10-05 23:28:27 | [diff] [blame] | 915 | } |
[email protected] | 8fef743 | 2012-08-06 15:34:25 | [diff] [blame] | 916 | |
| 917 | window_cycle_controller_->OnRootWindowAdded(root_window); |
[email protected] | d90b839 | 2012-06-13 09:34:56 | [diff] [blame] | 918 | } |
| 919 | |
[email protected] | 46ca363 | 2011-11-03 03:33:42 | [diff] [blame] | 920 | //////////////////////////////////////////////////////////////////////////////// |
| 921 | // Shell, private: |
| 922 | |
[email protected] | c0ce80e | 2012-10-05 23:28:27 | [diff] [blame] | 923 | bool Shell::CanWindowReceiveEvents(aura::Window* window) { |
| 924 | RootWindowControllerList controllers = GetAllRootWindowControllers(); |
| 925 | for (RootWindowControllerList::iterator iter = controllers.begin(); |
| 926 | iter != controllers.end(); ++iter) { |
[email protected] | 8674b31 | 2012-10-12 19:02:44 | [diff] [blame] | 927 | if ((*iter)->GetSystemModalLayoutManager(window)-> |
[email protected] | c0ce80e | 2012-10-05 23:28:27 | [diff] [blame] | 928 | CanWindowReceiveEvents(window)) { |
| 929 | return true; |
| 930 | } |
| 931 | } |
| 932 | return false; |
| 933 | } |
| 934 | |
[email protected] | 049cf34b | 2012-12-07 17:15:48 | [diff] [blame] | 935 | //////////////////////////////////////////////////////////////////////////////// |
| 936 | // Shell, ui::EventTarget overrides: |
| 937 | |
[email protected] | 869f635 | 2012-12-06 20:47:17 | [diff] [blame] | 938 | bool Shell::CanAcceptEvent(const ui::Event& event) { |
[email protected] | 5097e69 | 2012-10-30 22:08:41 | [diff] [blame] | 939 | return true; |
| 940 | } |
| 941 | |
| 942 | ui::EventTarget* Shell::GetParentTarget() { |
| 943 | return NULL; |
| 944 | } |
| 945 | |
[email protected] | 049cf34b | 2012-12-07 17:15:48 | [diff] [blame] | 946 | void Shell::OnEvent(ui::Event* event) { |
[email protected] | 1ae36165 | 2012-12-12 22:39:51 | [diff] [blame] | 947 | } |
| 948 | |
| 949 | //////////////////////////////////////////////////////////////////////////////// |
| 950 | // Shell, aura::client::ActivationChangeObserver implementation: |
| 951 | |
| 952 | void Shell::OnWindowActivated(aura::Window* gained_active, |
| 953 | aura::Window* lost_active) { |
[email protected] | d219a19 | 2012-12-14 00:08:18 | [diff] [blame] | 954 | if (gained_active) |
| 955 | active_root_window_ = gained_active->GetRootWindow(); |
[email protected] | 049cf34b | 2012-12-07 17:15:48 | [diff] [blame] | 956 | } |
| 957 | |
[email protected] | 55f59335 | 2011-12-24 05:42:46 | [diff] [blame] | 958 | } // namespace ash |