Bug 1289143 - Apply the appropriate scaling to window edges when processing WM_NCCALCSIZE for a window on a secondary screen with non-system DPI. r=emk a=ritu
authorJonathan Kew <jkew@mozilla.com>
Tue, 06 Sep 2016 17:53:50 +0100
changeset 350143 7a8b1ac451d942a5faa6f3a9dfa0c3c55eeed155
parent 350142 8f259d3c70b9192923644f3317eb670ab06e3c13
child 350144 495649a434dac4419107f2603fd123031efc7145
push id1230
push userjlund@mozilla.com
push dateMon, 31 Oct 2016 18:13:35 +0000
treeherdermozilla-release@5e06e3766db2 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersemk, ritu
bugs1289143
milestone50.0a2
Bug 1289143 - Apply the appropriate scaling to window edges when processing WM_NCCALCSIZE for a window on a secondary screen with non-system DPI. r=emk a=ritu
widget/windows/nsWindow.cpp
--- a/widget/windows/nsWindow.cpp
+++ b/widget/windows/nsWindow.cpp
@@ -4924,20 +4924,27 @@ nsWindow::ProcessMessage(UINT msg, WPARA
         // be used to specify portions of the source and destination window
         // rectangles that are valid and should be preserved.  We opt not to
         // implement an elaborate client-area preservation technique, and
         // simply return 0, which means "preserve the entire old client area
         // and align it with the upper-left corner of our new client area".
         RECT *clientRect = wParam
                          ? &(reinterpret_cast<NCCALCSIZE_PARAMS*>(lParam))->rgrc[0]
                          : (reinterpret_cast<RECT*>(lParam));
-        clientRect->top      += (mCaptionHeight - mNonClientOffset.top);
-        clientRect->left     += (mHorResizeMargin - mNonClientOffset.left);
-        clientRect->right    -= (mHorResizeMargin - mNonClientOffset.right);
-        clientRect->bottom   -= (mVertResizeMargin - mNonClientOffset.bottom);
+        double scale = WinUtils::IsPerMonitorDPIAware()
+          ? WinUtils::LogToPhysFactor(mWnd) / WinUtils::SystemScaleFactor()
+          : 1.0;
+        clientRect->top +=
+          NSToIntRound((mCaptionHeight - mNonClientOffset.top) * scale);
+        clientRect->left +=
+          NSToIntRound((mHorResizeMargin - mNonClientOffset.left) * scale);
+        clientRect->right -=
+          NSToIntRound((mHorResizeMargin - mNonClientOffset.right) * scale);
+        clientRect->bottom -=
+          NSToIntRound((mVertResizeMargin - mNonClientOffset.bottom) * scale);
 
         result = true;
         *aRetValue = 0;
       }
       break;
     }
 
     case WM_NCHITTEST: