Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(182)

Side by Side Diff: ash/shell.cc

Issue 2840043003: chromeos: Makes mushrome use simplified display management (Closed)
Patch Set: make virtual terminal work Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
145 #include "ui/base/ui_base_switches.h" 145 #include "ui/base/ui_base_switches.h"
146 #include "ui/base/user_activity/user_activity_detector.h" 146 #include "ui/base/user_activity/user_activity_detector.h"
147 #include "ui/chromeos/user_activity_power_manager_notifier.h" 147 #include "ui/chromeos/user_activity_power_manager_notifier.h"
148 #include "ui/compositor/layer.h" 148 #include "ui/compositor/layer.h"
149 #include "ui/compositor/layer_animator.h" 149 #include "ui/compositor/layer_animator.h"
150 #include "ui/display/display.h" 150 #include "ui/display/display.h"
151 #include "ui/display/manager/chromeos/display_change_observer.h" 151 #include "ui/display/manager/chromeos/display_change_observer.h"
152 #include "ui/display/manager/chromeos/display_configurator.h" 152 #include "ui/display/manager/chromeos/display_configurator.h"
153 #include "ui/display/manager/display_manager.h" 153 #include "ui/display/manager/display_manager.h"
154 #include "ui/display/screen.h" 154 #include "ui/display/screen.h"
155 #include "ui/display/types/native_display_delegate.h"
155 #include "ui/events/event_target_iterator.h" 156 #include "ui/events/event_target_iterator.h"
156 #include "ui/gfx/geometry/insets.h" 157 #include "ui/gfx/geometry/insets.h"
157 #include "ui/gfx/image/image_skia.h" 158 #include "ui/gfx/image/image_skia.h"
158 #include "ui/keyboard/keyboard_controller.h" 159 #include "ui/keyboard/keyboard_controller.h"
159 #include "ui/keyboard/keyboard_switches.h" 160 #include "ui/keyboard/keyboard_switches.h"
160 #include "ui/keyboard/keyboard_util.h" 161 #include "ui/keyboard/keyboard_util.h"
161 #include "ui/views/corewm/tooltip_aura.h" 162 #include "ui/views/corewm/tooltip_aura.h"
162 #include "ui/views/corewm/tooltip_controller.h" 163 #include "ui/views/corewm/tooltip_controller.h"
163 #include "ui/views/focus/focus_manager_factory.h" 164 #include "ui/views/focus/focus_manager_factory.h"
164 #include "ui/views/widget/native_widget_aura.h" 165 #include "ui/views/widget/native_widget_aura.h"
165 #include "ui/views/widget/widget.h" 166 #include "ui/views/widget/widget.h"
166 #include "ui/wm/core/accelerator_filter.h" 167 #include "ui/wm/core/accelerator_filter.h"
167 #include "ui/wm/core/compound_event_filter.h" 168 #include "ui/wm/core/compound_event_filter.h"
168 #include "ui/wm/core/focus_controller.h" 169 #include "ui/wm/core/focus_controller.h"
169 #include "ui/wm/core/shadow_controller.h" 170 #include "ui/wm/core/shadow_controller.h"
170 #include "ui/wm/core/visibility_controller.h" 171 #include "ui/wm/core/visibility_controller.h"
171 #include "ui/wm/core/window_modality_controller.h" 172 #include "ui/wm/core/window_modality_controller.h"
172 173
173 #if defined(USE_X11)
174 #include "ui/display/manager/chromeos/x11/native_display_delegate_x11.h"
175 #include "ui/gfx/x/x11_types.h" // nogncheck
176 #endif
177
178 #if defined(USE_OZONE)
179 #include "ui/display/types/native_display_delegate.h"
180 #include "ui/ozone/public/ozone_platform.h"
181 #endif
182
183 namespace ash { 174 namespace ash {
184 175
185 namespace { 176 namespace {
186 177
187 using aura::Window; 178 using aura::Window;
188 using views::Widget; 179 using views::Widget;
189 180
190 // A Corewm VisibilityController subclass that calls the Ash animation routine 181 // A Corewm VisibilityController subclass that calls the Ash animation routine
191 // so we can pick up our extended animations. See ash/wm/window_animations.h. 182 // so we can pick up our extended animations. See ash/wm/window_animations.h.
192 class AshVisibilityController : public ::wm::VisibilityController { 183 class AshVisibilityController : public ::wm::VisibilityController {
(...skipping 370 matching lines...) Expand 10 before | Expand all | Expand 10 after
563 app_list_(base::MakeUnique<app_list::AppList>()), 554 app_list_(base::MakeUnique<app_list::AppList>()),
564 link_handler_model_factory_(nullptr), 555 link_handler_model_factory_(nullptr),
565 tray_bluetooth_helper_(base::MakeUnique<TrayBluetoothHelper>()), 556 tray_bluetooth_helper_(base::MakeUnique<TrayBluetoothHelper>()),
566 display_configurator_(new display::DisplayConfigurator()), 557 display_configurator_(new display::DisplayConfigurator()),
567 native_cursor_manager_(nullptr), 558 native_cursor_manager_(nullptr),
568 simulate_modal_window_open_for_testing_(false), 559 simulate_modal_window_open_for_testing_(false),
569 is_touch_hud_projection_enabled_(false) { 560 is_touch_hud_projection_enabled_(false) {
570 // TODO(sky): better refactor cash/mash dependencies. Perhaps put all cash 561 // TODO(sky): better refactor cash/mash dependencies. Perhaps put all cash
571 // state on ShellPortClassic. http://crbug.com/671246. 562 // state on ShellPortClassic. http://crbug.com/671246.
572 563
564 gpu_support_.reset(shell_delegate_->CreateGPUSupport());
565
573 // Don't use Shell::GetAshConfig() as |instance_| has not yet been set. 566 // Don't use Shell::GetAshConfig() as |instance_| has not yet been set.
574 if (shell_port_->GetAshConfig() != Config::MASH) { 567 if (shell_port_->GetAshConfig() != Config::MASH) {
575 gpu_support_.reset(shell_delegate_->CreateGPUSupport());
576 display_manager_.reset(ScreenAsh::CreateDisplayManager()); 568 display_manager_.reset(ScreenAsh::CreateDisplayManager());
577 window_tree_host_manager_.reset(new WindowTreeHostManager); 569 window_tree_host_manager_.reset(new WindowTreeHostManager);
578 user_metrics_recorder_.reset(new UserMetricsRecorder); 570 user_metrics_recorder_.reset(new UserMetricsRecorder);
579 } 571 }
580 572
581 PowerStatus::Initialize(); 573 PowerStatus::Initialize();
582 574
583 session_controller_->AddObserver(this); 575 session_controller_->AddObserver(this);
584 } 576 }
585 577
(...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after
825 window_positioner_ = base::MakeUnique<WindowPositioner>(); 817 window_positioner_ = base::MakeUnique<WindowPositioner>();
826 818
827 if (config == Config::CLASSIC) { 819 if (config == Config::CLASSIC) {
828 // TODO: needs to work in mus. http://crbug.com/705592. 820 // TODO: needs to work in mus. http://crbug.com/705592.
829 native_cursor_manager_ = new AshNativeCursorManager; 821 native_cursor_manager_ = new AshNativeCursorManager;
830 cursor_manager_.reset( 822 cursor_manager_.reset(
831 new CursorManager(base::WrapUnique(native_cursor_manager_))); 823 new CursorManager(base::WrapUnique(native_cursor_manager_)));
832 } 824 }
833 825
834 shell_delegate_->PreInit(); 826 shell_delegate_->PreInit();
835 bool display_initialized = true; 827 // TODO(sky): remove MASH from here.
836 if (config == Config::CLASSIC) { 828 bool display_initialized =
837 // TODO: decide if this needs to be made to work in Config::MUS. 829 (config == Config::MASH || display_manager_->InitFromCommandLine());
kylechar 2017/04/26 16:41:44 display_manager_->InitFromCommandLine() is what ma
sky 2017/04/26 19:36:41 I motivated the reason for this over IM.
838 // http://crbug.com/705595. 830 if (config == Config::MUS && !display_initialized) {
839 display_initialized = display_manager_->InitFromCommandLine(); 831 // Run display configuration off device in mus mode.
840 832 display_manager_->set_configure_displays(true);
833 display_configurator_->set_configure_display(true);
834 }
835 if (config != Config::MASH) {
836 // TODO(sky): should work in mash too.
841 display_configuration_controller_.reset(new DisplayConfigurationController( 837 display_configuration_controller_.reset(new DisplayConfigurationController(
842 display_manager_.get(), window_tree_host_manager_.get())); 838 display_manager_.get(), window_tree_host_manager_.get()));
843 839 display_configurator_->Init(shell_port_->CreateNativeDisplayDelegate(),
844 #if defined(USE_OZONE) 840 !gpu_support_->IsPanelFittingDisabled());
845 display_configurator_->Init(
846 ui::OzonePlatform::GetInstance()->CreateNativeDisplayDelegate(),
847 !gpu_support_->IsPanelFittingDisabled());
848 #elif defined(USE_X11)
849 display_configurator_->Init(
850 base::MakeUnique<display::NativeDisplayDelegateX11>(),
851 !gpu_support_->IsPanelFittingDisabled());
852 #endif
853 } 841 }
854 842
855 // The DBusThreadManager must outlive this Shell. See the DCHECK in ~Shell. 843 // The DBusThreadManager must outlive this Shell. See the DCHECK in ~Shell.
856 chromeos::DBusThreadManager* dbus_thread_manager = 844 chromeos::DBusThreadManager* dbus_thread_manager =
857 chromeos::DBusThreadManager::Get(); 845 chromeos::DBusThreadManager::Get();
858 projecting_observer_.reset( 846 projecting_observer_.reset(
859 new ProjectingObserver(dbus_thread_manager->GetPowerManagerClient())); 847 new ProjectingObserver(dbus_thread_manager->GetPowerManagerClient()));
860 display_configurator_->AddObserver(projecting_observer_.get()); 848 display_configurator_->AddObserver(projecting_observer_.get());
861 AddShellObserver(projecting_observer_.get()); 849 AddShellObserver(projecting_observer_.get());
862 850
863 if (!display_initialized && chromeos::IsRunningAsSystemCompositor()) { 851 // TODO(sky): once simplified display management is enabled for mash
852 // config == Config::MUS should be config != Config::CLASSIC.
853 if (!display_initialized &&
854 (config == Config::MUS || chromeos::IsRunningAsSystemCompositor())) {
864 display_change_observer_ = base::MakeUnique<display::DisplayChangeObserver>( 855 display_change_observer_ = base::MakeUnique<display::DisplayChangeObserver>(
865 display_configurator_.get(), display_manager_.get()); 856 display_configurator_.get(), display_manager_.get());
866 857
867 shutdown_observer_ = 858 shutdown_observer_ =
868 base::MakeUnique<ShutdownObserver>(display_configurator_.get()); 859 base::MakeUnique<ShutdownObserver>(display_configurator_.get());
869 860
870 // Register |display_change_observer_| first so that the rest of 861 // Register |display_change_observer_| first so that the rest of
871 // observer gets invoked after the root windows are configured. 862 // observer gets invoked after the root windows are configured.
872 display_configurator_->AddObserver(display_change_observer_.get()); 863 display_configurator_->AddObserver(display_change_observer_.get());
873 display_error_observer_.reset(new DisplayErrorObserver()); 864 display_error_observer_.reset(new DisplayErrorObserver());
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after
1032 SetSystemTrayDelegate( 1023 SetSystemTrayDelegate(
1033 base::WrapUnique(shell_delegate_->CreateSystemTrayDelegate())); 1024 base::WrapUnique(shell_delegate_->CreateSystemTrayDelegate()));
1034 1025
1035 // May trigger initialization of the Bluetooth adapter. 1026 // May trigger initialization of the Bluetooth adapter.
1036 tray_bluetooth_helper_->Initialize(); 1027 tray_bluetooth_helper_->Initialize();
1037 1028
1038 // Create AshTouchTransformController before 1029 // Create AshTouchTransformController before
1039 // WindowTreeHostManager::InitDisplays() 1030 // WindowTreeHostManager::InitDisplays()
1040 // since AshTouchTransformController listens on 1031 // since AshTouchTransformController listens on
1041 // WindowTreeHostManager::Observer::OnDisplaysInitialized(). 1032 // WindowTreeHostManager::Observer::OnDisplaysInitialized().
1042 if (config != Config::MASH) { 1033 // TODO(sky): needs to to work for mus too.
1034 if (config == Config::CLASSIC) {
1043 touch_transformer_controller_.reset(new AshTouchTransformController( 1035 touch_transformer_controller_.reset(new AshTouchTransformController(
1044 display_configurator_.get(), display_manager_.get())); 1036 display_configurator_.get(), display_manager_.get()));
1045 } 1037 }
1046 1038
1047 keyboard_ui_ = shell_port_->CreateKeyboardUI(); 1039 keyboard_ui_ = shell_port_->CreateKeyboardUI();
1048 1040
1049 shell_port_->InitHosts(init_params); 1041 shell_port_->InitHosts(init_params);
1050 1042
1051 // Needs to be created after InitDisplays() since it may cause the virtual 1043 // Needs to be created after InitDisplays() since it may cause the virtual
1052 // keyboard to be deployed. 1044 // keyboard to be deployed.
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after
1232 void Shell::OnPrefServiceInitialized( 1224 void Shell::OnPrefServiceInitialized(
1233 std::unique_ptr<::PrefService> pref_service) { 1225 std::unique_ptr<::PrefService> pref_service) {
1234 if (!instance_) 1226 if (!instance_)
1235 return; 1227 return;
1236 // |pref_service_| is null if can't connect to Chrome (as happens when 1228 // |pref_service_| is null if can't connect to Chrome (as happens when
1237 // running mash outside of chrome --mash and chrome isn't built). 1229 // running mash outside of chrome --mash and chrome isn't built).
1238 pref_service_ = std::move(pref_service); 1230 pref_service_ = std::move(pref_service);
1239 } 1231 }
1240 1232
1241 } // namespace ash 1233 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698