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

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

Issue 2904993003: chromeos: changes how DisplayManagerObservers are notified (Closed)
Patch Set: cleanup Created 3 years, 7 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/bridge/shell_port_mash.h ('k') | ash/mus/display_synchronizer.h » ('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"
11 #include "ash/aura/key_event_watcher_aura.h" 11 #include "ash/aura/key_event_watcher_aura.h"
12 #include "ash/aura/pointer_watcher_adapter.h" 12 #include "ash/aura/pointer_watcher_adapter.h"
13 #include "ash/display/window_tree_host_manager.h" 13 #include "ash/display/window_tree_host_manager.h"
14 #include "ash/host/ash_window_tree_host_init_params.h" 14 #include "ash/host/ash_window_tree_host_init_params.h"
15 #include "ash/key_event_watcher.h" 15 #include "ash/key_event_watcher.h"
16 #include "ash/laser/laser_pointer_controller.h" 16 #include "ash/laser/laser_pointer_controller.h"
17 #include "ash/magnifier/partial_magnification_controller.h" 17 #include "ash/magnifier/partial_magnification_controller.h"
18 #include "ash/mus/accelerators/accelerator_controller_delegate_mus.h" 18 #include "ash/mus/accelerators/accelerator_controller_delegate_mus.h"
19 #include "ash/mus/accelerators/accelerator_controller_registrar.h" 19 #include "ash/mus/accelerators/accelerator_controller_registrar.h"
20 #include "ash/mus/ash_window_tree_host_mus.h" 20 #include "ash/mus/ash_window_tree_host_mus.h"
21 #include "ash/mus/bridge/immersive_handler_factory_mus.h" 21 #include "ash/mus/bridge/immersive_handler_factory_mus.h"
22 #include "ash/mus/bridge/workspace_event_handler_mus.h" 22 #include "ash/mus/bridge/workspace_event_handler_mus.h"
23 #include "ash/mus/display_synchronizer.h"
23 #include "ash/mus/drag_window_resizer.h" 24 #include "ash/mus/drag_window_resizer.h"
24 #include "ash/mus/keyboard_ui_mus.h" 25 #include "ash/mus/keyboard_ui_mus.h"
25 #include "ash/mus/screen_mus.h" 26 #include "ash/mus/screen_mus.h"
26 #include "ash/mus/touch_transform_setter_mus.h" 27 #include "ash/mus/touch_transform_setter_mus.h"
27 #include "ash/mus/window_manager.h" 28 #include "ash/mus/window_manager.h"
28 #include "ash/public/cpp/config.h" 29 #include "ash/public/cpp/config.h"
29 #include "ash/public/cpp/shell_window_ids.h" 30 #include "ash/public/cpp/shell_window_ids.h"
30 #include "ash/root_window_controller.h" 31 #include "ash/root_window_controller.h"
31 #include "ash/root_window_settings.h" 32 #include "ash/root_window_settings.h"
32 #include "ash/session/session_state_delegate.h" 33 #include "ash/session/session_state_delegate.h"
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
154 return root_window_controller; 155 return root_window_controller;
155 } 156 }
156 return nullptr; 157 return nullptr;
157 } 158 }
158 159
159 aura::WindowTreeClient* ShellPortMash::window_tree_client() { 160 aura::WindowTreeClient* ShellPortMash::window_tree_client() {
160 return window_manager_->window_tree_client(); 161 return window_manager_->window_tree_client();
161 } 162 }
162 163
163 void ShellPortMash::Shutdown() { 164 void ShellPortMash::Shutdown() {
165 display_synchronizer_.reset();
166
164 if (added_display_observer_) 167 if (added_display_observer_)
165 Shell::Get()->window_tree_host_manager()->RemoveObserver(this); 168 Shell::Get()->window_tree_host_manager()->RemoveObserver(this);
166 169
167 if (mus_state_) 170 if (mus_state_)
168 mus_state_->pointer_watcher_adapter.reset(); 171 mus_state_->pointer_watcher_adapter.reset();
169 172
170 ShellPort::Shutdown(); 173 ShellPort::Shutdown();
171 174
172 // TODO(sky): Config::MASH should use WindowTreeHostManager too. 175 // TODO(sky): Config::MASH should use WindowTreeHostManager too.
173 if (GetAshConfig() == Config::MUS) 176 if (GetAshConfig() == Config::MUS)
(...skipping 344 matching lines...) Expand 10 before | Expand all | Expand 10 after
518 // In Config::MUS PointerWatcherAdapter must be created when this function is 521 // In Config::MUS PointerWatcherAdapter must be created when this function is
519 // called (it is order dependent), that is not the case with Config::MASH. 522 // called (it is order dependent), that is not the case with Config::MASH.
520 if (GetAshConfig() == Config::MUS) { 523 if (GetAshConfig() == Config::MUS) {
521 mus_state_->pointer_watcher_adapter = 524 mus_state_->pointer_watcher_adapter =
522 base::MakeUnique<PointerWatcherAdapter>(); 525 base::MakeUnique<PointerWatcherAdapter>();
523 } 526 }
524 } 527 }
525 528
526 std::unique_ptr<AshWindowTreeHost> ShellPortMash::CreateAshWindowTreeHost( 529 std::unique_ptr<AshWindowTreeHost> ShellPortMash::CreateAshWindowTreeHost(
527 const AshWindowTreeHostInitParams& init_params) { 530 const AshWindowTreeHostInitParams& init_params) {
528 // TODO(sky): make this work for mash too. 531 if (!Shell::ShouldEnableSimplifiedDisplayManagement())
529 if (GetAshConfig() != Config::MUS)
530 return nullptr; 532 return nullptr;
531 533
532 std::unique_ptr<aura::DisplayInitParams> display_params = 534 std::unique_ptr<aura::DisplayInitParams> display_params =
533 base::MakeUnique<aura::DisplayInitParams>(); 535 base::MakeUnique<aura::DisplayInitParams>();
534 display_params->viewport_metrics.bounds_in_pixels = 536 display_params->viewport_metrics.bounds_in_pixels =
535 init_params.initial_bounds; 537 init_params.initial_bounds;
536 display_params->viewport_metrics.device_scale_factor = 538 display_params->viewport_metrics.device_scale_factor =
537 init_params.device_scale_factor; 539 init_params.device_scale_factor;
538 display_params->viewport_metrics.ui_scale_factor = 540 display_params->viewport_metrics.ui_scale_factor =
539 init_params.ui_scale_factor; 541 init_params.ui_scale_factor;
540 display::Display mirrored_display = 542 display::Display mirrored_display =
541 Shell::Get()->display_manager()->GetMirroringDisplayById( 543 Shell::Get()->display_manager()->GetMirroringDisplayById(
542 init_params.display_id); 544 init_params.display_id);
543 if (mirrored_display.is_valid()) { 545 if (mirrored_display.is_valid()) {
544 display_params->display = 546 display_params->display =
545 base::MakeUnique<display::Display>(mirrored_display); 547 base::MakeUnique<display::Display>(mirrored_display);
546 } 548 }
547 // TODO: wire update is_primary_display correctly.
548 display_params->is_primary_display = true; 549 display_params->is_primary_display = true;
549 aura::WindowTreeHostMusInitParams aura_init_params = 550 aura::WindowTreeHostMusInitParams aura_init_params =
550 window_manager_->window_manager_client()->CreateInitParamsForNewDisplay(); 551 window_manager_->window_manager_client()->CreateInitParamsForNewDisplay();
551 aura_init_params.display_id = init_params.display_id; 552 aura_init_params.display_id = init_params.display_id;
552 aura_init_params.display_init_params = std::move(display_params); 553 aura_init_params.display_init_params = std::move(display_params);
553 aura_init_params.use_classic_ime = !Shell::ShouldUseIMEService(); 554 aura_init_params.use_classic_ime = !Shell::ShouldUseIMEService();
554 return base::MakeUnique<AshWindowTreeHostMus>(std::move(aura_init_params)); 555 return base::MakeUnique<AshWindowTreeHostMus>(std::move(aura_init_params));
555 } 556 }
556 557
557 void ShellPortMash::OnCreatedRootWindowContainers( 558 void ShellPortMash::OnCreatedRootWindowContainers(
(...skipping 11 matching lines...) Expand all
569 if (GetAshConfig() == Config::MASH) 570 if (GetAshConfig() == Config::MASH)
570 return; 571 return;
571 572
572 DCHECK_EQ(Config::MUS, GetAshConfig()); 573 DCHECK_EQ(Config::MUS, GetAshConfig());
573 Shell::Get()->window_tree_host_manager()->Start(); 574 Shell::Get()->window_tree_host_manager()->Start();
574 AshWindowTreeHostInitParams ash_init_params; 575 AshWindowTreeHostInitParams ash_init_params;
575 Shell::Get()->window_tree_host_manager()->CreatePrimaryHost(ash_init_params); 576 Shell::Get()->window_tree_host_manager()->CreatePrimaryHost(ash_init_params);
576 } 577 }
577 578
578 void ShellPortMash::InitHosts(const ShellInitParams& init_params) { 579 void ShellPortMash::InitHosts(const ShellInitParams& init_params) {
579 if (GetAshConfig() == Config::MUS) { 580 if (Shell::ShouldEnableSimplifiedDisplayManagement()) {
580 Shell::Get()->window_tree_host_manager()->InitHosts(); 581 Shell::Get()->window_tree_host_manager()->InitHosts();
582 display_synchronizer_ = base::MakeUnique<DisplaySynchronizer>(
583 window_manager_->window_manager_client());
581 } else { 584 } else {
582 window_manager_->CreatePrimaryRootWindowController( 585 window_manager_->CreatePrimaryRootWindowController(
583 base::WrapUnique(init_params.primary_window_tree_host)); 586 base::WrapUnique(init_params.primary_window_tree_host));
584 } 587 }
585 } 588 }
586 589
587 std::unique_ptr<display::NativeDisplayDelegate> 590 std::unique_ptr<display::NativeDisplayDelegate>
588 ShellPortMash::CreateNativeDisplayDelegate() { 591 ShellPortMash::CreateNativeDisplayDelegate() {
589 #if defined(USE_OZONE) 592 #if defined(USE_OZONE)
590 display::mojom::NativeDisplayDelegatePtr native_display_delegate; 593 display::mojom::NativeDisplayDelegatePtr native_display_delegate;
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
635 observer.OnDisplayConfigurationChanging(); 638 observer.OnDisplayConfigurationChanging();
636 } 639 }
637 640
638 void ShellPortMash::OnDisplayConfigurationChanged() { 641 void ShellPortMash::OnDisplayConfigurationChanged() {
639 for (auto& observer : display_observers_) 642 for (auto& observer : display_observers_)
640 observer.OnDisplayConfigurationChanged(); 643 observer.OnDisplayConfigurationChanged();
641 } 644 }
642 645
643 } // namespace mus 646 } // namespace mus
644 } // namespace ash 647 } // namespace ash
OLDNEW
« no previous file with comments | « ash/mus/bridge/shell_port_mash.h ('k') | ash/mus/display_synchronizer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698