OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "services/ui/ws/display.h" | 5 #include "services/ui/ws/display.h" |
6 | 6 |
7 #include <set> | 7 #include <set> |
8 #include <utility> | 8 #include <utility> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
92 display_ptr->is_primary = platform_display_->IsPrimaryDisplay(); | 92 display_ptr->is_primary = platform_display_->IsPrimaryDisplay(); |
93 | 93 |
94 // TODO(sky): make this real. | 94 // TODO(sky): make this real. |
95 display_ptr->frame_decoration_values = mojom::FrameDecorationValues::New(); | 95 display_ptr->frame_decoration_values = mojom::FrameDecorationValues::New(); |
96 return display_ptr; | 96 return display_ptr; |
97 } | 97 } |
98 | 98 |
99 display::Display Display::ToDisplay() const { | 99 display::Display Display::ToDisplay() const { |
100 display::Display display(GetId()); | 100 display::Display display(GetId()); |
101 | 101 |
102 display.set_bounds(platform_display_->GetBounds()); | 102 const display::ViewportMetrics& metrics = |
103 // TODO(sky): window manager needs an API to set the work area. | 103 platform_display_->GetViewportMetrics(); |
104 display.set_work_area(display.bounds()); | 104 |
105 display.set_device_scale_factor(platform_display_->GetDeviceScaleFactor()); | 105 display.set_bounds(metrics.bounds); |
106 display.set_rotation(platform_display_->GetRotation()); | 106 display.set_work_area(metrics.work_area); |
| 107 display.set_device_scale_factor(metrics.device_scale_factor); |
| 108 display.set_rotation(metrics.rotation); |
107 display.set_touch_support( | 109 display.set_touch_support( |
108 display::Display::TouchSupport::TOUCH_SUPPORT_UNKNOWN); | 110 display::Display::TouchSupport::TOUCH_SUPPORT_UNKNOWN); |
109 | 111 |
110 return display; | 112 return display; |
111 } | 113 } |
112 | 114 |
113 void Display::SchedulePaint(const ServerWindow* window, | 115 void Display::SchedulePaint(const ServerWindow* window, |
114 const gfx::Rect& bounds) { | 116 const gfx::Rect& bounds) { |
115 DCHECK(root_->Contains(window)); | 117 DCHECK(root_->Contains(window)); |
116 platform_display_->SchedulePaint(window, bounds); | 118 platform_display_->SchedulePaint(window, bounds); |
117 } | 119 } |
118 | 120 |
119 display::Display::Rotation Display::GetRotation() const { | |
120 return platform_display_->GetRotation(); | |
121 } | |
122 | |
123 gfx::Size Display::GetSize() const { | 121 gfx::Size Display::GetSize() const { |
124 return platform_display_->GetBounds().size(); | 122 return platform_display_->GetBounds().size(); |
125 } | 123 } |
126 | 124 |
127 ServerWindow* Display::GetRootWithId(const WindowId& id) { | 125 ServerWindow* Display::GetRootWithId(const WindowId& id) { |
128 if (id == root_->id()) | 126 if (id == root_->id()) |
129 return root_.get(); | 127 return root_.get(); |
130 for (auto& pair : window_manager_display_root_map_) { | 128 for (auto& pair : window_manager_display_root_map_) { |
131 if (pair.second->root()->id() == id) | 129 if (pair.second->root()->id() == id) |
132 return pair.second->root(); | 130 return pair.second->root(); |
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
302 window_server_->user_id_tracker()->active_id()) | 300 window_server_->user_id_tracker()->active_id()) |
303 ->OnUserActivity(); | 301 ->OnUserActivity(); |
304 } | 302 } |
305 | 303 |
306 void Display::OnNativeCaptureLost() { | 304 void Display::OnNativeCaptureLost() { |
307 WindowManagerDisplayRoot* display_root = GetActiveWindowManagerDisplayRoot(); | 305 WindowManagerDisplayRoot* display_root = GetActiveWindowManagerDisplayRoot(); |
308 if (display_root) | 306 if (display_root) |
309 display_root->window_manager_state()->SetCapture(nullptr, kInvalidClientId); | 307 display_root->window_manager_state()->SetCapture(nullptr, kInvalidClientId); |
310 } | 308 } |
311 | 309 |
312 void Display::OnViewportMetricsChanged(const ViewportMetrics& old_metrics, | 310 void Display::OnViewportMetricsChanged( |
313 const ViewportMetrics& new_metrics) { | 311 const display::ViewportMetrics& new_metrics) { |
314 if (!root_) | 312 if (!root_ || root_->bounds().size() == new_metrics.bounds.size()) |
315 return; | 313 return; |
316 | 314 |
317 gfx::Rect new_bounds(new_metrics.bounds.size()); | 315 gfx::Rect new_bounds(new_metrics.bounds.size()); |
318 root_->SetBounds(new_bounds); | 316 root_->SetBounds(new_bounds); |
319 for (auto& pair : window_manager_display_root_map_) | 317 for (auto& pair : window_manager_display_root_map_) |
320 pair.second->root()->SetBounds(new_bounds); | 318 pair.second->root()->SetBounds(new_bounds); |
321 | |
322 display_manager()->OnDisplayUpdate(this); | |
323 } | 319 } |
324 | 320 |
325 bool Display::CanHaveActiveChildren(ServerWindow* window) const { | 321 bool Display::CanHaveActiveChildren(ServerWindow* window) const { |
326 return window && activation_parents_.Contains(window); | 322 return window && activation_parents_.Contains(window); |
327 } | 323 } |
328 | 324 |
329 void Display::OnActivationChanged(ServerWindow* old_active_window, | 325 void Display::OnActivationChanged(ServerWindow* old_active_window, |
330 ServerWindow* new_active_window) { | 326 ServerWindow* new_active_window) { |
331 // Don't do anything here. We assume the window manager handles restacking. If | 327 // Don't do anything here. We assume the window manager handles restacking. If |
332 // we did attempt to restack than we would have to ensure clients see the | 328 // we did attempt to restack than we would have to ensure clients see the |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
400 } | 396 } |
401 | 397 |
402 void Display::OnWindowManagerWindowTreeFactoryReady( | 398 void Display::OnWindowManagerWindowTreeFactoryReady( |
403 WindowManagerWindowTreeFactory* factory) { | 399 WindowManagerWindowTreeFactory* factory) { |
404 if (!binding_) | 400 if (!binding_) |
405 CreateWindowManagerDisplayRootFromFactory(factory); | 401 CreateWindowManagerDisplayRootFromFactory(factory); |
406 } | 402 } |
407 | 403 |
408 } // namespace ws | 404 } // namespace ws |
409 } // namespace ui | 405 } // namespace ui |
OLD | NEW |