Chromium Code Reviews| Index: ui/display/win/screen_win.cc |
| diff --git a/ui/display/win/screen_win.cc b/ui/display/win/screen_win.cc |
| index b518fd4d3daa4c91ee1ef2e113574069869a7832..47911905022d894583cb42b2088a8d7375f6fe18 100644 |
| --- a/ui/display/win/screen_win.cc |
| +++ b/ui/display/win/screen_win.cc |
| @@ -295,6 +295,22 @@ gfx::Size ScreenWin::DIPToScreenSize(HWND hwnd, const gfx::Size& dip_size) { |
| return ScaleToCeiledSize(dip_size, scale_factor); |
| } |
| +// static |
| +int ScreenWin::GetSystemMetricsForHwnd(HWND hwnd, int metric) { |
| + // GetSystemMetrics returns screen values based off of the primary monitor's |
| + // DPI. This will further scale based off of the DPI for |hwnd|. |
| + if (!g_screen_win_instance) |
|
oshima
2016/06/30 19:06:12
is this for unit test case?
robliao
2016/06/30 19:20:24
Yup. This is for the unit tests.
|
| + return ::GetSystemMetrics(metric); |
| + |
| + Display primary_display(g_screen_win_instance->GetPrimaryDisplay()); |
| + int system_metrics_result = g_screen_win_instance->GetSystemMetrics(metric); |
| + |
| + float scale_factor = hwnd |
| + ? GetScaleFactorForHWND(hwnd) / primary_display.device_scale_factor() |
|
oshima
2016/06/30 19:06:12
calling this "scale factor" is confusing. Can you
robliao
2016/06/30 19:20:24
I went with metrics_relative_scale_factor. How's t
|
| + : 1.0f; |
| + return static_cast<int>(std::round(system_metrics_result * scale_factor)); |
| +} |
| + |
| HWND ScreenWin::GetHWNDFromNativeView(gfx::NativeView window) const { |
| NOTREACHED(); |
| return nullptr; |
| @@ -419,6 +435,10 @@ HWND ScreenWin::GetRootWindow(HWND hwnd) const { |
| return ::GetAncestor(hwnd, GA_ROOT); |
| } |
| +int ScreenWin::GetSystemMetrics(int metric) const { |
| + return ::GetSystemMetrics(metric); |
| +} |
| + |
| void ScreenWin::OnWndProc(HWND hwnd, |
| UINT message, |
| WPARAM wparam, |