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