Bug 1264196 - Use the DPI from the parent window, if any, for consistency between popups and their owners when straddling a monitor boundary. r=emk
authorJonathan Kew <jkew@mozilla.com>
Wed, 13 Apr 2016 14:40:46 +0100
changeset 330900 3bcaa74cc73a490cc7f2c309b72009dd229a41dc
parent 330899 041577d97132aea17fe52583feccc157dac3f84e
child 330901 685e89b31d6b9814d95c3678b7bf8ecafee245a0
push id6048
push userkmoir@mozilla.com
push dateMon, 06 Jun 2016 19:02:08 +0000
treeherdermozilla-beta@46d72a56c57d [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersemk
bugs1264196
milestone48.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1264196 - Use the DPI from the parent window, if any, for consistency between popups and their owners when straddling a monitor boundary. r=emk
widget/windows/WinUtils.h
--- a/widget/windows/WinUtils.h
+++ b/widget/windows/WinUtils.h
@@ -140,17 +140,20 @@ public:
 
   static bool IsPerMonitorDPIAware();
   /**
    * Functions to convert between logical pixels as used by most Windows APIs
    * and physical (device) pixels.
    */
   static double LogToPhysFactor(HMONITOR aMonitor);
   static double LogToPhysFactor(HWND aWnd) {
-    return LogToPhysFactor(::MonitorFromWindow(aWnd, MONITOR_DEFAULTTOPRIMARY));
+    // if there's an ancestor window, we want to share its DPI setting
+    HWND ancestor = ::GetAncestor(aWnd, GA_ROOTOWNER);
+    return LogToPhysFactor(::MonitorFromWindow(ancestor ? ancestor : aWnd,
+                                               MONITOR_DEFAULTTOPRIMARY));
   }
   static double LogToPhysFactor(HDC aDC) {
     return LogToPhysFactor(::WindowFromDC(aDC));
   }
   static int32_t LogToPhys(HMONITOR aMonitor, double aValue);
   static HMONITOR GetPrimaryMonitor();
   static HMONITOR MonitorFromRect(const gfx::Rect& rect);