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

Unified Diff: ui/display/win/screen_win.cc

Issue 2110313002: Add ScreenWin::GetSystemMetricsForHwnd (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Self Review Fix Created 4 years, 6 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ui/display/win/screen_win.h ('k') | ui/display/win/screen_win_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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,
« no previous file with comments | « ui/display/win/screen_win.h ('k') | ui/display/win/screen_win_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698