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

Side by Side Diff: ui/display/win/screen_win.cc

Issue 2489873002: Change GetAllDisplays() in all screens to return a const vector&. (Closed)
Patch Set: roll back to rebase as dummy_screen_android is reverted Created 4 years, 1 month 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 | « ui/display/win/screen_win.h ('k') | ui/views/mus/window_manager_connection.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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "ui/display/win/screen_win.h" 5 #include "ui/display/win/screen_win.h"
6 6
7 #include <windows.h> 7 #include <windows.h>
8 #include <shellscalingapi.h> 8 #include <shellscalingapi.h>
9 9
10 #include <algorithm> 10 #include <algorithm>
(...skipping 366 matching lines...) Expand 10 before | Expand all | Expand 10 after
377 377
378 gfx::NativeWindow ScreenWin::GetWindowAtScreenPoint(const gfx::Point& point) { 378 gfx::NativeWindow ScreenWin::GetWindowAtScreenPoint(const gfx::Point& point) {
379 gfx::Point point_in_pixels = DIPToScreenPoint(point); 379 gfx::Point point_in_pixels = DIPToScreenPoint(point);
380 return GetNativeWindowFromHWND(WindowFromPoint(point_in_pixels.ToPOINT())); 380 return GetNativeWindowFromHWND(WindowFromPoint(point_in_pixels.ToPOINT()));
381 } 381 }
382 382
383 int ScreenWin::GetNumDisplays() const { 383 int ScreenWin::GetNumDisplays() const {
384 return static_cast<int>(screen_win_displays_.size()); 384 return static_cast<int>(screen_win_displays_.size());
385 } 385 }
386 386
387 std::vector<display::Display> ScreenWin::GetAllDisplays() const { 387 const std::vector<display::Display>& ScreenWin::GetAllDisplays() const {
388 return ScreenWinDisplaysToDisplays(screen_win_displays_); 388 return displays_;
389 } 389 }
390 390
391 display::Display ScreenWin::GetDisplayNearestWindow( 391 display::Display ScreenWin::GetDisplayNearestWindow(
392 gfx::NativeView window) const { 392 gfx::NativeView window) const {
393 HWND window_hwnd = GetHWNDFromNativeView(window); 393 HWND window_hwnd = GetHWNDFromNativeView(window);
394 if (!window_hwnd) { 394 if (!window_hwnd) {
395 // When |window| isn't rooted to a display, we should just return the 395 // When |window| isn't rooted to a display, we should just return the
396 // default display so we get some correct display information like the 396 // default display so we get some correct display information like the
397 // scaling factor. 397 // scaling factor.
398 return GetPrimaryDisplay(); 398 return GetPrimaryDisplay();
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
436 436
437 gfx::Rect ScreenWin::DIPToScreenRectInWindow(gfx::NativeView view, 437 gfx::Rect ScreenWin::DIPToScreenRectInWindow(gfx::NativeView view,
438 const gfx::Rect& dip_rect) const { 438 const gfx::Rect& dip_rect) const {
439 HWND hwnd = view ? GetHWNDFromNativeView(view) : nullptr; 439 HWND hwnd = view ? GetHWNDFromNativeView(view) : nullptr;
440 return DIPToScreenRect(hwnd, dip_rect); 440 return DIPToScreenRect(hwnd, dip_rect);
441 } 441 }
442 442
443 void ScreenWin::UpdateFromDisplayInfos( 443 void ScreenWin::UpdateFromDisplayInfos(
444 const std::vector<DisplayInfo>& display_infos) { 444 const std::vector<DisplayInfo>& display_infos) {
445 screen_win_displays_ = DisplayInfosToScreenWinDisplays(display_infos); 445 screen_win_displays_ = DisplayInfosToScreenWinDisplays(display_infos);
446 displays_ = ScreenWinDisplaysToDisplays(screen_win_displays_);
446 } 447 }
447 448
448 void ScreenWin::Initialize() { 449 void ScreenWin::Initialize() {
449 singleton_hwnd_observer_.reset( 450 singleton_hwnd_observer_.reset(
450 new gfx::SingletonHwndObserver( 451 new gfx::SingletonHwndObserver(
451 base::Bind(&ScreenWin::OnWndProc, base::Unretained(this)))); 452 base::Bind(&ScreenWin::OnWndProc, base::Unretained(this))));
452 UpdateFromDisplayInfos(GetDisplayInfosFromSystem()); 453 UpdateFromDisplayInfos(GetDisplayInfosFromSystem());
453 RecordDisplayScaleFactors(); 454 RecordDisplayScaleFactors();
454 } 455 }
455 456
(...skipping 24 matching lines...) Expand all
480 return ::GetSystemMetrics(metric); 481 return ::GetSystemMetrics(metric);
481 } 482 }
482 483
483 void ScreenWin::OnWndProc(HWND hwnd, 484 void ScreenWin::OnWndProc(HWND hwnd,
484 UINT message, 485 UINT message,
485 WPARAM wparam, 486 WPARAM wparam,
486 LPARAM lparam) { 487 LPARAM lparam) {
487 if (message != WM_DISPLAYCHANGE) 488 if (message != WM_DISPLAYCHANGE)
488 return; 489 return;
489 490
490 std::vector<display::Display> old_displays = GetAllDisplays(); 491 std::vector<display::Display> old_displays = std::move(displays_);
491 UpdateFromDisplayInfos(GetDisplayInfosFromSystem()); 492 UpdateFromDisplayInfos(GetDisplayInfosFromSystem());
492 change_notifier_.NotifyDisplaysChanged(old_displays, GetAllDisplays()); 493 change_notifier_.NotifyDisplaysChanged(old_displays, displays_);
493 } 494 }
494 495
495 ScreenWinDisplay ScreenWin::GetScreenWinDisplayNearestHWND(HWND hwnd) 496 ScreenWinDisplay ScreenWin::GetScreenWinDisplayNearestHWND(HWND hwnd)
496 const { 497 const {
497 return GetScreenWinDisplay(MonitorInfoFromWindow(hwnd, 498 return GetScreenWinDisplay(MonitorInfoFromWindow(hwnd,
498 MONITOR_DEFAULTTONEAREST)); 499 MONITOR_DEFAULTTONEAREST));
499 } 500 }
500 501
501 ScreenWinDisplay ScreenWin::GetScreenWinDisplayNearestScreenRect( 502 ScreenWinDisplay ScreenWin::GetScreenWinDisplayNearestScreenRect(
502 const gfx::Rect& screen_rect) const { 503 const gfx::Rect& screen_rect) const {
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
588 if (std::find(unique_scale_factors.begin(), unique_scale_factors.end(), 589 if (std::find(unique_scale_factors.begin(), unique_scale_factors.end(),
589 reported_scale) == unique_scale_factors.end()) { 590 reported_scale) == unique_scale_factors.end()) {
590 unique_scale_factors.push_back(reported_scale); 591 unique_scale_factors.push_back(reported_scale);
591 UMA_HISTOGRAM_SPARSE_SLOWLY("UI.DeviceScale", reported_scale); 592 UMA_HISTOGRAM_SPARSE_SLOWLY("UI.DeviceScale", reported_scale);
592 } 593 }
593 } 594 }
594 } 595 }
595 596
596 } // namespace win 597 } // namespace win
597 } // namespace display 598 } // namespace display
OLDNEW
« no previous file with comments | « ui/display/win/screen_win.h ('k') | ui/views/mus/window_manager_connection.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698