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

Side by Side Diff: services/ui/ws/display.cc

Issue 2356913002: Pass device scale factor from display to ws. (Closed)
Patch Set: Fix more tests. Created 4 years, 3 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 | « services/ui/ws/display.h ('k') | services/ui/ws/display_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
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 267 matching lines...) Expand 10 before | Expand all | Expand 10 after
278 display_root->window_manager_state_ = window_manager_state; 278 display_root->window_manager_state_ = window_manager_state;
279 const bool is_active = 279 const bool is_active =
280 factory->user_id() == window_server_->user_id_tracker()->active_id(); 280 factory->user_id() == window_server_->user_id_tracker()->active_id();
281 display_root->root()->SetVisible(is_active); 281 display_root->root()->SetVisible(is_active);
282 window_manager_state->window_tree()->AddRootForWindowManager( 282 window_manager_state->window_tree()->AddRootForWindowManager(
283 display_root->root()); 283 display_root->root());
284 window_manager_state->AddWindowManagerDisplayRoot( 284 window_manager_state->AddWindowManagerDisplayRoot(
285 std::move(display_root_ptr)); 285 std::move(display_root_ptr));
286 } 286 }
287 287
288 void Display::CreateRootWindow(const gfx::Size& size) {
289 DCHECK(!root_);
290
291 root_.reset(window_server_->CreateServerWindow(
292 display_manager()->GetAndAdvanceNextRootId(),
293 ServerWindow::Properties()));
294 root_->SetBounds(gfx::Rect(size));
295 root_->SetVisible(true);
296 focus_controller_.reset(new FocusController(this, root_.get()));
297 focus_controller_->AddObserver(this);
298 InitWindowManagerDisplayRootsIfNecessary();
299 }
300
288 ServerWindow* Display::GetRootWindow() { 301 ServerWindow* Display::GetRootWindow() {
289 return root_.get(); 302 return root_.get();
290 } 303 }
291 304
292 bool Display::IsInHighContrastMode() { 305 bool Display::IsInHighContrastMode() {
293 return window_server_->IsActiveUserInHighContrastMode(); 306 return window_server_->IsActiveUserInHighContrastMode();
294 } 307 }
295 308
296 void Display::OnEvent(const ui::Event& event) { 309 void Display::OnEvent(const ui::Event& event) {
297 WindowManagerDisplayRoot* display_root = GetActiveWindowManagerDisplayRoot(); 310 WindowManagerDisplayRoot* display_root = GetActiveWindowManagerDisplayRoot();
298 if (display_root) 311 if (display_root)
299 display_root->window_manager_state()->ProcessEvent(event); 312 display_root->window_manager_state()->ProcessEvent(event);
300 window_server_ 313 window_server_
301 ->GetUserActivityMonitorForUser( 314 ->GetUserActivityMonitorForUser(
302 window_server_->user_id_tracker()->active_id()) 315 window_server_->user_id_tracker()->active_id())
303 ->OnUserActivity(); 316 ->OnUserActivity();
304 } 317 }
305 318
306 void Display::OnNativeCaptureLost() { 319 void Display::OnNativeCaptureLost() {
307 WindowManagerDisplayRoot* display_root = GetActiveWindowManagerDisplayRoot(); 320 WindowManagerDisplayRoot* display_root = GetActiveWindowManagerDisplayRoot();
308 if (display_root) 321 if (display_root)
309 display_root->window_manager_state()->SetCapture(nullptr, kInvalidClientId); 322 display_root->window_manager_state()->SetCapture(nullptr, kInvalidClientId);
310 } 323 }
311 324
312 void Display::OnViewportMetricsChanged(const ViewportMetrics& old_metrics, 325 void Display::OnViewportMetricsChanged(const ViewportMetrics& old_metrics,
313 const ViewportMetrics& new_metrics) { 326 const ViewportMetrics& new_metrics) {
327 if (!root_)
328 return;
329
314 gfx::Rect new_bounds(new_metrics.bounds.size()); 330 gfx::Rect new_bounds(new_metrics.bounds.size());
315 if (!root_) { 331 root_->SetBounds(new_bounds);
316 root_.reset(window_server_->CreateServerWindow( 332 for (auto& pair : window_manager_display_root_map_)
317 display_manager()->GetAndAdvanceNextRootId(), 333 pair.second->root()->SetBounds(new_bounds);
318 ServerWindow::Properties())); 334
319 root_->SetBounds(new_bounds); 335 display_manager()->OnDisplayUpdate(this);
320 root_->SetVisible(true);
321 focus_controller_.reset(new FocusController(this, root_.get()));
322 focus_controller_->AddObserver(this);
323 InitWindowManagerDisplayRootsIfNecessary();
324 } else {
325 root_->SetBounds(new_bounds);
326 for (auto& pair : window_manager_display_root_map_)
327 pair.second->root()->SetBounds(new_bounds);
328 }
329 if (init_called_)
330 display_manager()->OnDisplayUpdate(this);
331 } 336 }
332 337
333 void Display::OnCompositorFrameDrawn() { 338 void Display::OnCompositorFrameDrawn() {
334 std::set<ServerWindow*> windows; 339 std::set<ServerWindow*> windows;
335 windows.swap(windows_needing_frame_destruction_); 340 windows.swap(windows_needing_frame_destruction_);
336 for (ServerWindow* window : windows) { 341 for (ServerWindow* window : windows) {
337 window->RemoveObserver(this); 342 window->RemoveObserver(this);
338 window->DestroySurfacesScheduledForDestruction(); 343 window->DestroySurfacesScheduledForDestruction();
339 } 344 }
340 } 345 }
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
425 } 430 }
426 431
427 void Display::OnWindowManagerWindowTreeFactoryReady( 432 void Display::OnWindowManagerWindowTreeFactoryReady(
428 WindowManagerWindowTreeFactory* factory) { 433 WindowManagerWindowTreeFactory* factory) {
429 if (!binding_) 434 if (!binding_)
430 CreateWindowManagerDisplayRootFromFactory(factory); 435 CreateWindowManagerDisplayRootFromFactory(factory);
431 } 436 }
432 437
433 } // namespace ws 438 } // namespace ws
434 } // namespace ui 439 } // namespace ui
OLDNEW
« no previous file with comments | « services/ui/ws/display.h ('k') | services/ui/ws/display_manager.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698