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

Side by Side Diff: ash/mus/display_synchronizer.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/display_synchronizer.h ('k') | ash/mus/window_manager.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2017 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "ash/mus/display_synchronizer.h"
6
7 #include "ash/shell.h"
8 #include "ui/aura/mus/window_manager_delegate.h"
9 #include "ui/display/manager/display_manager.h"
10 #include "ui/display/manager/managed_display_info.h"
11
12 namespace ash {
13
14 DisplaySynchronizer::DisplaySynchronizer(
15 aura::WindowManagerClient* window_manager_client)
16 : window_manager_client_(window_manager_client) {
17 Shell::Get()->window_tree_host_manager()->AddObserver(this);
18 SendDisplayConfigurationToServer();
19 }
20
21 DisplaySynchronizer::~DisplaySynchronizer() {
22 Shell::Get()->window_tree_host_manager()->RemoveObserver(this);
23 }
24
25 void DisplaySynchronizer::SendDisplayConfigurationToServer() {
26 display::DisplayManager* display_manager = Shell::Get()->display_manager();
27 const size_t display_count = display_manager->GetNumDisplays();
28 if (display_count == 0)
29 return;
30
31 std::vector<display::Display> displays;
32 std::vector<ui::mojom::WmViewportMetricsPtr> metrics;
33 for (size_t i = 0; i < display_count; ++i) {
34 displays.push_back(display_manager->GetDisplayAt(i));
35 ui::mojom::WmViewportMetricsPtr viewport_metrics =
36 ui::mojom::WmViewportMetrics::New();
37 const display::ManagedDisplayInfo& display_info =
38 display_manager->GetDisplayInfo(displays.back().id());
39 viewport_metrics->bounds_in_pixels = display_info.bounds_in_native();
40 viewport_metrics->device_scale_factor = display_info.device_scale_factor();
41 viewport_metrics->ui_scale_factor = display_info.configured_ui_scale();
42 metrics.push_back(std::move(viewport_metrics));
43 }
44 window_manager_client_->SetDisplayConfiguration(
45 displays, std::move(metrics),
46 WindowTreeHostManager::GetPrimaryDisplayId());
47 }
48
49 void DisplaySynchronizer::OnDisplaysInitialized() {
50 SendDisplayConfigurationToServer();
51 }
52
53 void DisplaySynchronizer::OnDisplayConfigurationChanged() {
54 SendDisplayConfigurationToServer();
55 }
56
57 } // namespace ash
OLDNEW
« no previous file with comments | « ash/mus/display_synchronizer.h ('k') | ash/mus/window_manager.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698