OLD | NEW |
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 Loading... |
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 (display::Display display_in_list : GetAllDisplays()) { |
| 394 if (display_in_list.id() == display_id) { |
| 395 *display = display_in_list; |
| 396 return true; |
| 397 } |
| 398 } |
| 399 return false; |
| 400 } |
| 401 |
391 display::Display ScreenWin::GetDisplayNearestWindow( | 402 display::Display ScreenWin::GetDisplayNearestWindow( |
392 gfx::NativeView window) const { | 403 gfx::NativeView window) const { |
393 HWND window_hwnd = GetHWNDFromNativeView(window); | 404 HWND window_hwnd = GetHWNDFromNativeView(window); |
394 if (!window_hwnd) { | 405 if (!window_hwnd) { |
395 // When |window| isn't rooted to a display, we should just return the | 406 // 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 | 407 // default display so we get some correct display information like the |
397 // scaling factor. | 408 // scaling factor. |
398 return GetPrimaryDisplay(); | 409 return GetPrimaryDisplay(); |
399 } | 410 } |
400 ScreenWinDisplay screen_win_display = | 411 ScreenWinDisplay screen_win_display = |
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
588 if (std::find(unique_scale_factors.begin(), unique_scale_factors.end(), | 599 if (std::find(unique_scale_factors.begin(), unique_scale_factors.end(), |
589 reported_scale) == unique_scale_factors.end()) { | 600 reported_scale) == unique_scale_factors.end()) { |
590 unique_scale_factors.push_back(reported_scale); | 601 unique_scale_factors.push_back(reported_scale); |
591 UMA_HISTOGRAM_SPARSE_SLOWLY("UI.DeviceScale", reported_scale); | 602 UMA_HISTOGRAM_SPARSE_SLOWLY("UI.DeviceScale", reported_scale); |
592 } | 603 } |
593 } | 604 } |
594 } | 605 } |
595 | 606 |
596 } // namespace win | 607 } // namespace win |
597 } // namespace display | 608 } // namespace display |
OLD | NEW |