OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "ash/shell.h" | 5 #include "ash/shell.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <string> | 8 #include <string> |
9 #include <utility> | 9 #include <utility> |
10 | 10 |
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
147 #include "ui/base/ui_base_switches.h" | 147 #include "ui/base/ui_base_switches.h" |
148 #include "ui/base/user_activity/user_activity_detector.h" | 148 #include "ui/base/user_activity/user_activity_detector.h" |
149 #include "ui/chromeos/user_activity_power_manager_notifier.h" | 149 #include "ui/chromeos/user_activity_power_manager_notifier.h" |
150 #include "ui/compositor/layer.h" | 150 #include "ui/compositor/layer.h" |
151 #include "ui/compositor/layer_animator.h" | 151 #include "ui/compositor/layer_animator.h" |
152 #include "ui/display/display.h" | 152 #include "ui/display/display.h" |
153 #include "ui/display/manager/chromeos/display_change_observer.h" | 153 #include "ui/display/manager/chromeos/display_change_observer.h" |
154 #include "ui/display/manager/chromeos/display_configurator.h" | 154 #include "ui/display/manager/chromeos/display_configurator.h" |
155 #include "ui/display/manager/display_manager.h" | 155 #include "ui/display/manager/display_manager.h" |
156 #include "ui/display/screen.h" | 156 #include "ui/display/screen.h" |
157 #include "ui/display/types/native_display_delegate.h" | |
158 #include "ui/events/event_target_iterator.h" | 157 #include "ui/events/event_target_iterator.h" |
159 #include "ui/gfx/geometry/insets.h" | 158 #include "ui/gfx/geometry/insets.h" |
160 #include "ui/gfx/image/image_skia.h" | 159 #include "ui/gfx/image/image_skia.h" |
161 #include "ui/keyboard/keyboard_controller.h" | 160 #include "ui/keyboard/keyboard_controller.h" |
162 #include "ui/keyboard/keyboard_switches.h" | 161 #include "ui/keyboard/keyboard_switches.h" |
163 #include "ui/keyboard/keyboard_util.h" | 162 #include "ui/keyboard/keyboard_util.h" |
164 #include "ui/views/corewm/tooltip_aura.h" | 163 #include "ui/views/corewm/tooltip_aura.h" |
165 #include "ui/views/corewm/tooltip_controller.h" | 164 #include "ui/views/corewm/tooltip_controller.h" |
166 #include "ui/views/focus/focus_manager_factory.h" | 165 #include "ui/views/focus/focus_manager_factory.h" |
167 #include "ui/views/widget/native_widget_aura.h" | 166 #include "ui/views/widget/native_widget_aura.h" |
168 #include "ui/views/widget/widget.h" | 167 #include "ui/views/widget/widget.h" |
169 #include "ui/wm/core/accelerator_filter.h" | 168 #include "ui/wm/core/accelerator_filter.h" |
170 #include "ui/wm/core/compound_event_filter.h" | 169 #include "ui/wm/core/compound_event_filter.h" |
171 #include "ui/wm/core/focus_controller.h" | 170 #include "ui/wm/core/focus_controller.h" |
172 #include "ui/wm/core/shadow_controller.h" | 171 #include "ui/wm/core/shadow_controller.h" |
173 #include "ui/wm/core/visibility_controller.h" | 172 #include "ui/wm/core/visibility_controller.h" |
174 #include "ui/wm/core/window_modality_controller.h" | 173 #include "ui/wm/core/window_modality_controller.h" |
175 | 174 |
| 175 #if defined(USE_X11) |
| 176 #include "ui/display/manager/chromeos/x11/native_display_delegate_x11.h" |
| 177 #include "ui/gfx/x/x11_types.h" // nogncheck |
| 178 #endif |
| 179 |
| 180 #if defined(USE_OZONE) |
| 181 #include "ui/display/types/native_display_delegate.h" |
| 182 #include "ui/ozone/public/ozone_platform.h" |
| 183 #endif |
| 184 |
176 namespace ash { | 185 namespace ash { |
177 | 186 |
178 namespace { | 187 namespace { |
179 | 188 |
180 using aura::Window; | 189 using aura::Window; |
181 using views::Widget; | 190 using views::Widget; |
182 | 191 |
183 // A Corewm VisibilityController subclass that calls the Ash animation routine | 192 // A Corewm VisibilityController subclass that calls the Ash animation routine |
184 // so we can pick up our extended animations. See ash/wm/window_animations.h. | 193 // so we can pick up our extended animations. See ash/wm/window_animations.h. |
185 class AshVisibilityController : public ::wm::VisibilityController { | 194 class AshVisibilityController : public ::wm::VisibilityController { |
(...skipping 377 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
563 app_list_(base::MakeUnique<app_list::AppList>()), | 572 app_list_(base::MakeUnique<app_list::AppList>()), |
564 link_handler_model_factory_(nullptr), | 573 link_handler_model_factory_(nullptr), |
565 tray_bluetooth_helper_(base::MakeUnique<TrayBluetoothHelper>()), | 574 tray_bluetooth_helper_(base::MakeUnique<TrayBluetoothHelper>()), |
566 display_configurator_(new display::DisplayConfigurator()), | 575 display_configurator_(new display::DisplayConfigurator()), |
567 native_cursor_manager_(nullptr), | 576 native_cursor_manager_(nullptr), |
568 simulate_modal_window_open_for_testing_(false), | 577 simulate_modal_window_open_for_testing_(false), |
569 is_touch_hud_projection_enabled_(false) { | 578 is_touch_hud_projection_enabled_(false) { |
570 // TODO(sky): better refactor cash/mash dependencies. Perhaps put all cash | 579 // TODO(sky): better refactor cash/mash dependencies. Perhaps put all cash |
571 // state on ShellPortClassic. http://crbug.com/671246. | 580 // state on ShellPortClassic. http://crbug.com/671246. |
572 | 581 |
573 gpu_support_.reset(shell_delegate_->CreateGPUSupport()); | |
574 | |
575 // Don't use Shell::GetAshConfig() as |instance_| has not yet been set. | 582 // Don't use Shell::GetAshConfig() as |instance_| has not yet been set. |
576 if (shell_port_->GetAshConfig() != Config::MASH) { | 583 if (shell_port_->GetAshConfig() != Config::MASH) { |
| 584 gpu_support_.reset(shell_delegate_->CreateGPUSupport()); |
577 display_manager_.reset(ScreenAsh::CreateDisplayManager()); | 585 display_manager_.reset(ScreenAsh::CreateDisplayManager()); |
578 window_tree_host_manager_.reset(new WindowTreeHostManager); | 586 window_tree_host_manager_.reset(new WindowTreeHostManager); |
579 user_metrics_recorder_.reset(new UserMetricsRecorder); | 587 user_metrics_recorder_.reset(new UserMetricsRecorder); |
580 } | 588 } |
581 | 589 |
582 PowerStatus::Initialize(); | 590 PowerStatus::Initialize(); |
583 | 591 |
584 session_controller_->AddObserver(this); | 592 session_controller_->AddObserver(this); |
585 } | 593 } |
586 | 594 |
(...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
831 window_positioner_ = base::MakeUnique<WindowPositioner>(); | 839 window_positioner_ = base::MakeUnique<WindowPositioner>(); |
832 | 840 |
833 if (config == Config::CLASSIC) { | 841 if (config == Config::CLASSIC) { |
834 // TODO: needs to work in mus. http://crbug.com/705592. | 842 // TODO: needs to work in mus. http://crbug.com/705592. |
835 native_cursor_manager_ = new AshNativeCursorManager; | 843 native_cursor_manager_ = new AshNativeCursorManager; |
836 cursor_manager_.reset( | 844 cursor_manager_.reset( |
837 new CursorManager(base::WrapUnique(native_cursor_manager_))); | 845 new CursorManager(base::WrapUnique(native_cursor_manager_))); |
838 } | 846 } |
839 | 847 |
840 shell_delegate_->PreInit(); | 848 shell_delegate_->PreInit(); |
841 // TODO(sky): remove MASH from here. | 849 bool display_initialized = true; |
842 bool display_initialized = | 850 if (config == Config::CLASSIC) { |
843 (config == Config::MASH || display_manager_->InitFromCommandLine()); | 851 // TODO: decide if this needs to be made to work in Config::MUS. |
844 if (config == Config::MUS && !display_initialized) { | 852 // http://crbug.com/705595. |
845 // Run display configuration off device in mus mode. | 853 display_initialized = display_manager_->InitFromCommandLine(); |
846 display_manager_->set_configure_displays(true); | 854 |
847 display_configurator_->set_configure_display(true); | |
848 } | |
849 if (config != Config::MASH) { | |
850 // TODO(sky): should work in mash too. | |
851 display_configuration_controller_.reset(new DisplayConfigurationController( | 855 display_configuration_controller_.reset(new DisplayConfigurationController( |
852 display_manager_.get(), window_tree_host_manager_.get())); | 856 display_manager_.get(), window_tree_host_manager_.get())); |
853 display_configurator_->Init(shell_port_->CreateNativeDisplayDelegate(), | 857 |
854 !gpu_support_->IsPanelFittingDisabled()); | 858 #if defined(USE_OZONE) |
| 859 display_configurator_->Init( |
| 860 ui::OzonePlatform::GetInstance()->CreateNativeDisplayDelegate(), |
| 861 !gpu_support_->IsPanelFittingDisabled()); |
| 862 #elif defined(USE_X11) |
| 863 display_configurator_->Init( |
| 864 base::MakeUnique<display::NativeDisplayDelegateX11>(), |
| 865 !gpu_support_->IsPanelFittingDisabled()); |
| 866 #endif |
855 } | 867 } |
856 | 868 |
857 // The DBusThreadManager must outlive this Shell. See the DCHECK in ~Shell. | 869 // The DBusThreadManager must outlive this Shell. See the DCHECK in ~Shell. |
858 chromeos::DBusThreadManager* dbus_thread_manager = | 870 chromeos::DBusThreadManager* dbus_thread_manager = |
859 chromeos::DBusThreadManager::Get(); | 871 chromeos::DBusThreadManager::Get(); |
860 projecting_observer_.reset( | 872 projecting_observer_.reset( |
861 new ProjectingObserver(dbus_thread_manager->GetPowerManagerClient())); | 873 new ProjectingObserver(dbus_thread_manager->GetPowerManagerClient())); |
862 display_configurator_->AddObserver(projecting_observer_.get()); | 874 display_configurator_->AddObserver(projecting_observer_.get()); |
863 AddShellObserver(projecting_observer_.get()); | 875 AddShellObserver(projecting_observer_.get()); |
864 | 876 |
865 // TODO(sky): once simplified display management is enabled for mash | 877 if (!display_initialized && chromeos::IsRunningAsSystemCompositor()) { |
866 // config == Config::MUS should be config != Config::CLASSIC. | |
867 if (!display_initialized && | |
868 (config == Config::MUS || chromeos::IsRunningAsSystemCompositor())) { | |
869 display_change_observer_ = base::MakeUnique<display::DisplayChangeObserver>( | 878 display_change_observer_ = base::MakeUnique<display::DisplayChangeObserver>( |
870 display_configurator_.get(), display_manager_.get()); | 879 display_configurator_.get(), display_manager_.get()); |
871 | 880 |
872 shutdown_observer_ = | 881 shutdown_observer_ = |
873 base::MakeUnique<ShutdownObserver>(display_configurator_.get()); | 882 base::MakeUnique<ShutdownObserver>(display_configurator_.get()); |
874 | 883 |
875 // Register |display_change_observer_| first so that the rest of | 884 // Register |display_change_observer_| first so that the rest of |
876 // observer gets invoked after the root windows are configured. | 885 // observer gets invoked after the root windows are configured. |
877 display_configurator_->AddObserver(display_change_observer_.get()); | 886 display_configurator_->AddObserver(display_change_observer_.get()); |
878 display_error_observer_.reset(new DisplayErrorObserver()); | 887 display_error_observer_.reset(new DisplayErrorObserver()); |
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1041 SetSystemTrayDelegate( | 1050 SetSystemTrayDelegate( |
1042 base::WrapUnique(shell_delegate_->CreateSystemTrayDelegate())); | 1051 base::WrapUnique(shell_delegate_->CreateSystemTrayDelegate())); |
1043 | 1052 |
1044 // May trigger initialization of the Bluetooth adapter. | 1053 // May trigger initialization of the Bluetooth adapter. |
1045 tray_bluetooth_helper_->Initialize(); | 1054 tray_bluetooth_helper_->Initialize(); |
1046 | 1055 |
1047 // Create AshTouchTransformController before | 1056 // Create AshTouchTransformController before |
1048 // WindowTreeHostManager::InitDisplays() | 1057 // WindowTreeHostManager::InitDisplays() |
1049 // since AshTouchTransformController listens on | 1058 // since AshTouchTransformController listens on |
1050 // WindowTreeHostManager::Observer::OnDisplaysInitialized(). | 1059 // WindowTreeHostManager::Observer::OnDisplaysInitialized(). |
1051 // TODO(sky): needs to to work for mus too. | 1060 if (config != Config::MASH) { |
1052 if (config == Config::CLASSIC) { | |
1053 touch_transformer_controller_.reset(new AshTouchTransformController( | 1061 touch_transformer_controller_.reset(new AshTouchTransformController( |
1054 display_configurator_.get(), display_manager_.get())); | 1062 display_configurator_.get(), display_manager_.get())); |
1055 } | 1063 } |
1056 | 1064 |
1057 keyboard_ui_ = shell_port_->CreateKeyboardUI(); | 1065 keyboard_ui_ = shell_port_->CreateKeyboardUI(); |
1058 | 1066 |
1059 shell_port_->InitHosts(init_params); | 1067 shell_port_->InitHosts(init_params); |
1060 | 1068 |
1061 // Needs to be created after InitDisplays() since it may cause the virtual | 1069 // Needs to be created after InitDisplays() since it may cause the virtual |
1062 // keyboard to be deployed. | 1070 // keyboard to be deployed. |
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1242 void Shell::OnPrefServiceInitialized( | 1250 void Shell::OnPrefServiceInitialized( |
1243 std::unique_ptr<::PrefService> pref_service) { | 1251 std::unique_ptr<::PrefService> pref_service) { |
1244 if (!instance_) | 1252 if (!instance_) |
1245 return; | 1253 return; |
1246 // |pref_service_| is null if can't connect to Chrome (as happens when | 1254 // |pref_service_| is null if can't connect to Chrome (as happens when |
1247 // running mash outside of chrome --mash and chrome isn't built). | 1255 // running mash outside of chrome --mash and chrome isn't built). |
1248 pref_service_ = std::move(pref_service); | 1256 pref_service_ = std::move(pref_service); |
1249 } | 1257 } |
1250 | 1258 |
1251 } // namespace ash | 1259 } // namespace ash |
OLD | NEW |