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

Side by Side Diff: ash/mus/bridge/shell_port_mash.cc

Issue 2906873003: chromeos: turn on simplified display management for mash (Closed)
Patch Set: bug refs Created 3 years, 6 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
« no previous file with comments | « ash/mus/BUILD.gn ('k') | ash/mus/screen_mus_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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/mus/bridge/shell_port_mash.h" 5 #include "ash/mus/bridge/shell_port_mash.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "ash/accelerators/accelerator_controller.h" 9 #include "ash/accelerators/accelerator_controller.h"
10 #include "ash/accelerators/accelerator_controller_delegate_aura.h" 10 #include "ash/accelerators/accelerator_controller_delegate_aura.h"
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
129 display_synchronizer_.reset(); 129 display_synchronizer_.reset();
130 130
131 if (added_display_observer_) 131 if (added_display_observer_)
132 Shell::Get()->window_tree_host_manager()->RemoveObserver(this); 132 Shell::Get()->window_tree_host_manager()->RemoveObserver(this);
133 133
134 if (mus_state_) 134 if (mus_state_)
135 mus_state_->pointer_watcher_adapter.reset(); 135 mus_state_->pointer_watcher_adapter.reset();
136 136
137 ShellPort::Shutdown(); 137 ShellPort::Shutdown();
138 138
139 // TODO(sky): Config::MASH should use WindowTreeHostManager too. 139 if (Shell::ShouldEnableSimplifiedDisplayManagement())
140 if (GetAshConfig() == Config::MUS)
141 Shell::Get()->window_tree_host_manager()->Shutdown(); 140 Shell::Get()->window_tree_host_manager()->Shutdown();
142 else 141 else
143 window_manager_->DeleteAllRootWindowControllers(); 142 window_manager_->DeleteAllRootWindowControllers();
144 } 143 }
145 144
146 Config ShellPortMash::GetAshConfig() const { 145 Config ShellPortMash::GetAshConfig() const {
147 return window_manager_->config(); 146 return window_manager_->config();
148 } 147 }
149 148
150 aura::Window* ShellPortMash::GetPrimaryRootWindow() { 149 aura::Window* ShellPortMash::GetPrimaryRootWindow() {
151 if (GetAshConfig() == Config::MUS) 150 if (Shell::ShouldEnableSimplifiedDisplayManagement())
152 return Shell::Get()->window_tree_host_manager()->GetPrimaryRootWindow(); 151 return Shell::Get()->window_tree_host_manager()->GetPrimaryRootWindow();
153 // NOTE: This is called before the RootWindowController has been created, so 152 // NOTE: This is called before the RootWindowController has been created, so
154 // it can't call through to RootWindowController to get all windows. 153 // it can't call through to RootWindowController to get all windows.
155 return primary_root_window_; 154 return primary_root_window_;
156 } 155 }
157 156
158 aura::Window* ShellPortMash::GetRootWindowForDisplayId(int64_t display_id) { 157 aura::Window* ShellPortMash::GetRootWindowForDisplayId(int64_t display_id) {
159 if (GetAshConfig() == Config::MUS) { 158 if (Shell::ShouldEnableSimplifiedDisplayManagement()) {
160 return Shell::Get()->window_tree_host_manager()->GetRootWindowForDisplayId( 159 return Shell::Get()->window_tree_host_manager()->GetRootWindowForDisplayId(
161 display_id); 160 display_id);
162 } 161 }
163 RootWindowController* root_window_controller = 162 RootWindowController* root_window_controller =
164 GetRootWindowControllerWithDisplayId(display_id); 163 GetRootWindowControllerWithDisplayId(display_id);
165 return root_window_controller ? root_window_controller->GetRootWindow() 164 return root_window_controller ? root_window_controller->GetRootWindow()
166 : nullptr; 165 : nullptr;
167 } 166 }
168 167
169 const display::ManagedDisplayInfo& ShellPortMash::GetDisplayInfo( 168 const display::ManagedDisplayInfo& ShellPortMash::GetDisplayInfo(
170 int64_t display_id) const { 169 int64_t display_id) const {
171 // TODO(sky): mash should use this too http://crbug.com/718860. 170 if (Shell::ShouldEnableSimplifiedDisplayManagement())
172 if (GetAshConfig() == Config::MUS)
173 return Shell::Get()->display_manager()->GetDisplayInfo(display_id); 171 return Shell::Get()->display_manager()->GetDisplayInfo(display_id);
174 172
175 // TODO(mash): implement http://crbug.com/622480. 173 // TODO(mash): implement http://crbug.com/622480.
176 NOTIMPLEMENTED(); 174 NOTIMPLEMENTED();
177 static display::ManagedDisplayInfo fake_info; 175 static display::ManagedDisplayInfo fake_info;
178 return fake_info; 176 return fake_info;
179 } 177 }
180 178
181 bool ShellPortMash::IsActiveDisplayId(int64_t display_id) const { 179 bool ShellPortMash::IsActiveDisplayId(int64_t display_id) const {
182 // TODO(sky): mash should use this too http://crbug.com/718860. 180 if (Shell::ShouldEnableSimplifiedDisplayManagement())
183 if (GetAshConfig() == Config::MUS)
184 return Shell::Get()->display_manager()->IsActiveDisplayId(display_id); 181 return Shell::Get()->display_manager()->IsActiveDisplayId(display_id);
185 182
186 // TODO(mash): implement http://crbug.com/622480. 183 // TODO(mash): implement http://crbug.com/622480.
187 NOTIMPLEMENTED(); 184 NOTIMPLEMENTED();
188 return true; 185 return true;
189 } 186 }
190 187
191 display::Display ShellPortMash::GetFirstDisplay() const { 188 display::Display ShellPortMash::GetFirstDisplay() const {
192 // TODO(sky): mash should use this too http://crbug.com/718860. 189 if (Shell::ShouldEnableSimplifiedDisplayManagement()) {
193 if (GetAshConfig() == Config::MUS) {
194 return Shell::Get() 190 return Shell::Get()
195 ->display_manager() 191 ->display_manager()
196 ->software_mirroring_display_list()[0]; 192 ->software_mirroring_display_list()[0];
197 } 193 }
198 194
199 // TODO(mash): implement http://crbug.com/622480. 195 // TODO(mash): implement http://crbug.com/622480.
200 NOTIMPLEMENTED(); 196 NOTIMPLEMENTED();
201 return display::Screen::GetScreen()->GetPrimaryDisplay(); 197 return display::Screen::GetScreen()->GetPrimaryDisplay();
202 } 198 }
203 199
204 bool ShellPortMash::IsInUnifiedMode() const { 200 bool ShellPortMash::IsInUnifiedMode() const {
205 // TODO(sky): mash should use this too http://crbug.com/718860. 201 if (Shell::ShouldEnableSimplifiedDisplayManagement())
206 if (GetAshConfig() == Config::MUS)
207 return Shell::Get()->display_manager()->IsInUnifiedMode(); 202 return Shell::Get()->display_manager()->IsInUnifiedMode();
208 203
209 // TODO(mash): implement http://crbug.com/622480. 204 // TODO(mash): implement http://crbug.com/622480.
210 NOTIMPLEMENTED(); 205 NOTIMPLEMENTED();
211 return false; 206 return false;
212 } 207 }
213 208
214 bool ShellPortMash::IsInUnifiedModeIgnoreMirroring() const { 209 bool ShellPortMash::IsInUnifiedModeIgnoreMirroring() const {
215 // TODO(sky): mash should use this too http://crbug.com/718860. 210 if (Shell::ShouldEnableSimplifiedDisplayManagement()) {
216 if (GetAshConfig() == Config::MUS) {
217 return Shell::Get() 211 return Shell::Get()
218 ->display_manager() 212 ->display_manager()
219 ->current_default_multi_display_mode() == 213 ->current_default_multi_display_mode() ==
220 display::DisplayManager::UNIFIED; 214 display::DisplayManager::UNIFIED;
221 } 215 }
222 216
223 // TODO(mash): implement http://crbug.com/622480. 217 // TODO(mash): implement http://crbug.com/622480.
224 NOTIMPLEMENTED(); 218 NOTIMPLEMENTED();
225 return false; 219 return false;
226 } 220 }
227 221
228 void ShellPortMash::SetDisplayWorkAreaInsets(aura::Window* window, 222 void ShellPortMash::SetDisplayWorkAreaInsets(aura::Window* window,
229 const gfx::Insets& insets) { 223 const gfx::Insets& insets) {
230 if (GetAshConfig() == Config::MUS) { 224 if (Shell::ShouldEnableSimplifiedDisplayManagement()) {
231 Shell::Get() 225 Shell::Get()
232 ->window_tree_host_manager() 226 ->window_tree_host_manager()
233 ->UpdateWorkAreaOfDisplayNearestWindow(window, insets); 227 ->UpdateWorkAreaOfDisplayNearestWindow(window, insets);
234 return; 228 return;
235 } 229 }
236 window_manager_->screen()->SetWorkAreaInsets(window, insets); 230 window_manager_->screen()->SetWorkAreaInsets(window, insets);
237 } 231 }
238 232
239 std::unique_ptr<display::TouchTransformSetter> 233 std::unique_ptr<display::TouchTransformSetter>
240 ShellPortMash::CreateTouchTransformDelegate() { 234 ShellPortMash::CreateTouchTransformDelegate() {
(...skipping 23 matching lines...) Expand all
264 std::move(cursor)); 258 std::move(cursor));
265 } 259 }
266 260
267 bool ShellPortMash::IsMouseEventsEnabled() { 261 bool ShellPortMash::IsMouseEventsEnabled() {
268 // TODO: http://crbug.com/637853 262 // TODO: http://crbug.com/637853
269 NOTIMPLEMENTED(); 263 NOTIMPLEMENTED();
270 return true; 264 return true;
271 } 265 }
272 266
273 std::vector<aura::Window*> ShellPortMash::GetAllRootWindows() { 267 std::vector<aura::Window*> ShellPortMash::GetAllRootWindows() {
274 if (GetAshConfig() == Config::MUS) 268 if (Shell::ShouldEnableSimplifiedDisplayManagement())
275 return Shell::Get()->window_tree_host_manager()->GetAllRootWindows(); 269 return Shell::Get()->window_tree_host_manager()->GetAllRootWindows();
276 270
277 aura::Window::Windows root_windows; 271 aura::Window::Windows root_windows;
278 for (RootWindowController* root_window_controller : 272 for (RootWindowController* root_window_controller :
279 RootWindowController::root_window_controllers()) { 273 RootWindowController::root_window_controllers()) {
280 root_windows.push_back(root_window_controller->GetRootWindow()); 274 root_windows.push_back(root_window_controller->GetRootWindow());
281 } 275 }
282 return root_windows; 276 return root_windows;
283 } 277 }
284 278
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
336 return base::MakeUnique<wm::MaximizeModeEventHandlerAura>(); 330 return base::MakeUnique<wm::MaximizeModeEventHandlerAura>();
337 331
338 // TODO: need support for window manager to get events before client: 332 // TODO: need support for window manager to get events before client:
339 // http://crbug.com/624157. 333 // http://crbug.com/624157.
340 NOTIMPLEMENTED(); 334 NOTIMPLEMENTED();
341 return nullptr; 335 return nullptr;
342 } 336 }
343 337
344 std::unique_ptr<ScopedDisableInternalMouseAndKeyboard> 338 std::unique_ptr<ScopedDisableInternalMouseAndKeyboard>
345 ShellPortMash::CreateScopedDisableInternalMouseAndKeyboard() { 339 ShellPortMash::CreateScopedDisableInternalMouseAndKeyboard() {
346 if (GetAshConfig() == Config::MUS) { 340 if (Shell::ShouldEnableSimplifiedDisplayManagement()) {
347 #if defined(USE_OZONE) 341 #if defined(USE_OZONE)
348 return base::MakeUnique<ScopedDisableInternalMouseAndKeyboardOzone>(); 342 return base::MakeUnique<ScopedDisableInternalMouseAndKeyboardOzone>();
349 #else 343 #else
350 // TODO: remove this conditional. Bots build this config, but it is never 344 // TODO: remove this conditional. Bots build this config, but it is never
351 // actually used. http://crbug.com/671355. 345 // actually used. http://crbug.com/671355.
352 NOTREACHED(); 346 NOTREACHED();
353 return nullptr; 347 return nullptr;
354 #endif 348 #endif
355 } 349 }
356 350
(...skipping 25 matching lines...) Expand all
382 std::unique_ptr<KeyEventWatcher> ShellPortMash::CreateKeyEventWatcher() { 376 std::unique_ptr<KeyEventWatcher> ShellPortMash::CreateKeyEventWatcher() {
383 if (GetAshConfig() == Config::MUS) 377 if (GetAshConfig() == Config::MUS)
384 return base::MakeUnique<KeyEventWatcherAura>(); 378 return base::MakeUnique<KeyEventWatcherAura>();
385 379
386 // TODO: needs implementation for mus, http://crbug.com/649600. 380 // TODO: needs implementation for mus, http://crbug.com/649600.
387 NOTIMPLEMENTED(); 381 NOTIMPLEMENTED();
388 return std::unique_ptr<KeyEventWatcher>(); 382 return std::unique_ptr<KeyEventWatcher>();
389 } 383 }
390 384
391 void ShellPortMash::AddDisplayObserver(WmDisplayObserver* observer) { 385 void ShellPortMash::AddDisplayObserver(WmDisplayObserver* observer) {
392 // TODO(sky): mash should use the same code as mus/classic and 386 // TODO(sky): WmDisplayObserver should be removed; http://crbug.com/718860.
393 // WmDisplayObserver should be removed; http://crbug.com/718860. 387 if (!Shell::ShouldEnableSimplifiedDisplayManagement()) {
394 if (GetAshConfig() == Config::MASH) {
395 NOTIMPLEMENTED(); 388 NOTIMPLEMENTED();
396 return; 389 return;
397 } 390 }
398 if (!added_display_observer_) { 391 if (!added_display_observer_) {
399 added_display_observer_ = true; 392 added_display_observer_ = true;
400 Shell::Get()->window_tree_host_manager()->AddObserver(this); 393 Shell::Get()->window_tree_host_manager()->AddObserver(this);
401 } 394 }
402 display_observers_.AddObserver(observer); 395 display_observers_.AddObserver(observer);
403 } 396 }
404 397
405 void ShellPortMash::RemoveDisplayObserver(WmDisplayObserver* observer) { 398 void ShellPortMash::RemoveDisplayObserver(WmDisplayObserver* observer) {
406 // TODO(sky): mash should use the same code as mus/classic and 399 // TODO(sky): WmDisplayObserver should be removed; http://crbug.com/718860.
407 // WmDisplayObserver should be removed; http://crbug.com/718860. 400 if (!Shell::ShouldEnableSimplifiedDisplayManagement()) {
408 if (GetAshConfig() == Config::MASH) {
409 NOTIMPLEMENTED(); 401 NOTIMPLEMENTED();
410 return; 402 return;
411 } 403 }
412 display_observers_.RemoveObserver(observer); 404 display_observers_.RemoveObserver(observer);
413 } 405 }
414 406
415 void ShellPortMash::AddPointerWatcher(views::PointerWatcher* watcher, 407 void ShellPortMash::AddPointerWatcher(views::PointerWatcher* watcher,
416 views::PointerWatcherEventTypes events) { 408 views::PointerWatcherEventTypes events) {
417 if (GetAshConfig() == Config::MUS) { 409 if (GetAshConfig() == Config::MUS) {
418 mus_state_->pointer_watcher_adapter->AddPointerWatcher(watcher, events); 410 mus_state_->pointer_watcher_adapter->AddPointerWatcher(watcher, events);
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
513 // TODO: To avoid lots of IPC AddActivationParent() should take an array. 505 // TODO: To avoid lots of IPC AddActivationParent() should take an array.
514 // http://crbug.com/682048. 506 // http://crbug.com/682048.
515 aura::Window* root_window = root_window_controller->GetRootWindow(); 507 aura::Window* root_window = root_window_controller->GetRootWindow();
516 for (size_t i = 0; i < kNumActivatableShellWindowIds; ++i) { 508 for (size_t i = 0; i < kNumActivatableShellWindowIds; ++i) {
517 window_manager_->window_manager_client()->AddActivationParent( 509 window_manager_->window_manager_client()->AddActivationParent(
518 root_window->GetChildById(kActivatableShellWindowIds[i])); 510 root_window->GetChildById(kActivatableShellWindowIds[i]));
519 } 511 }
520 } 512 }
521 513
522 void ShellPortMash::CreatePrimaryHost() { 514 void ShellPortMash::CreatePrimaryHost() {
523 if (GetAshConfig() == Config::MASH) 515 if (!Shell::ShouldEnableSimplifiedDisplayManagement())
524 return; 516 return;
525 517
526 DCHECK_EQ(Config::MUS, GetAshConfig());
527 Shell::Get()->window_tree_host_manager()->Start(); 518 Shell::Get()->window_tree_host_manager()->Start();
528 AshWindowTreeHostInitParams ash_init_params; 519 AshWindowTreeHostInitParams ash_init_params;
529 Shell::Get()->window_tree_host_manager()->CreatePrimaryHost(ash_init_params); 520 Shell::Get()->window_tree_host_manager()->CreatePrimaryHost(ash_init_params);
530 } 521 }
531 522
532 void ShellPortMash::InitHosts(const ShellInitParams& init_params) { 523 void ShellPortMash::InitHosts(const ShellInitParams& init_params) {
533 if (Shell::ShouldEnableSimplifiedDisplayManagement()) { 524 if (Shell::ShouldEnableSimplifiedDisplayManagement()) {
534 Shell::Get()->window_tree_host_manager()->InitHosts(); 525 Shell::Get()->window_tree_host_manager()->InitHosts();
535 display_synchronizer_ = base::MakeUnique<DisplaySynchronizer>( 526 display_synchronizer_ = base::MakeUnique<DisplaySynchronizer>(
536 window_manager_->window_manager_client()); 527 window_manager_->window_manager_client());
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
591 observer.OnDisplayConfigurationChanging(); 582 observer.OnDisplayConfigurationChanging();
592 } 583 }
593 584
594 void ShellPortMash::OnDisplayConfigurationChanged() { 585 void ShellPortMash::OnDisplayConfigurationChanged() {
595 for (auto& observer : display_observers_) 586 for (auto& observer : display_observers_)
596 observer.OnDisplayConfigurationChanged(); 587 observer.OnDisplayConfigurationChanged();
597 } 588 }
598 589
599 } // namespace mus 590 } // namespace mus
600 } // namespace ash 591 } // namespace ash
OLDNEW
« no previous file with comments | « ash/mus/BUILD.gn ('k') | ash/mus/screen_mus_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698