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

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

Issue 2361283002: Add GetDisplayWithDisplayId to display::Screen. (Closed)
Patch Set: ref, test, etc 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
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 370 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 std::vector<display::Display> ScreenWin::GetAllDisplays() const {
388 return ScreenWinDisplaysToDisplays(screen_win_displays_); 388 return ScreenWinDisplaysToDisplays(screen_win_displays_);
389 } 389 }
390 390
391 bool ScreenWin::GetDisplayWithDisplayId(int64_t display_id,
392 display::Display* display) const {
393 for (const display::Display& display_in_list :
394 ScreenWinDisplaysToDisplays(screen_win_displays_)) {
sadrul 2016/09/30 03:17:14 This too is creating a new list that we don't need
riajiang 2016/10/05 14:54:11 Done.
395 if (display_in_list.id() == display_id) {
396 *display = display_in_list;
397 return true;
398 }
399 }
400 return false;
401 }
402
391 display::Display ScreenWin::GetDisplayNearestWindow( 403 display::Display ScreenWin::GetDisplayNearestWindow(
392 gfx::NativeView window) const { 404 gfx::NativeView window) const {
393 HWND window_hwnd = GetHWNDFromNativeView(window); 405 HWND window_hwnd = GetHWNDFromNativeView(window);
394 if (!window_hwnd) { 406 if (!window_hwnd) {
395 // When |window| isn't rooted to a display, we should just return the 407 // 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 408 // default display so we get some correct display information like the
397 // scaling factor. 409 // scaling factor.
398 return GetPrimaryDisplay(); 410 return GetPrimaryDisplay();
399 } 411 }
400 ScreenWinDisplay screen_win_display = 412 ScreenWinDisplay screen_win_display =
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after
588 if (std::find(unique_scale_factors.begin(), unique_scale_factors.end(), 600 if (std::find(unique_scale_factors.begin(), unique_scale_factors.end(),
589 reported_scale) == unique_scale_factors.end()) { 601 reported_scale) == unique_scale_factors.end()) {
590 unique_scale_factors.push_back(reported_scale); 602 unique_scale_factors.push_back(reported_scale);
591 UMA_HISTOGRAM_SPARSE_SLOWLY("UI.DeviceScale", reported_scale); 603 UMA_HISTOGRAM_SPARSE_SLOWLY("UI.DeviceScale", reported_scale);
592 } 604 }
593 } 605 }
594 } 606 }
595 607
596 } // namespace win 608 } // namespace win
597 } // namespace display 609 } // namespace display
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698