Bug 1514501 - Fix screen selection and scaling for fullscreen. r=jmathies, a=RyanVM
authorAdam Gashlin <agashlin@mozilla.com>
Wed, 09 Jan 2019 16:35:40 +0000
changeset 509424 694ef5b65db8c5e3570e6e1a9bee47608b4d3ba9
parent 509423 9a0b078546bd21aabdc056dfb6a08e8594565d88
child 509425 60be2a80ee0e8c213d16a192780a9f70ac6f5d5a
push id1905
push userffxbld-merge
push dateMon, 21 Jan 2019 12:33:13 +0000
treeherdermozilla-release@c2fca1944d8c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjmathies, RyanVM
bugs1514501
milestone65.0
Bug 1514501 - Fix screen selection and scaling for fullscreen. r=jmathies, a=RyanVM I needed to scale the layout device pixels coming from Windows before passing them to ScreenForRect(). Also, I'm using GetRect() directly instead of GetRectDisplayPix() * scale now, to avoid an unnecessary double scale & round which was making fullscreen windows off by one pixel in many cases. Differential Revision: https://phabricator.services.mozilla.com/D15604
widget/windows/nsWindow.cpp
--- a/widget/windows/nsWindow.cpp
+++ b/widget/windows/nsWindow.cpp
@@ -6499,29 +6499,32 @@ void nsWindow::OnWindowPosChanging(LPWIN
   // Force fullscreen. This works around a bug in Windows 10 1809 where
   // using fullscreen when a window is "snapped" causes a spurious resize
   // smaller than the full screen, see bug 1482920.
   if (mSizeMode == nsSizeMode_Fullscreen && !(info->flags & SWP_NOMOVE) &&
       !(info->flags & SWP_NOSIZE)) {
     nsCOMPtr<nsIScreenManager> screenmgr =
         do_GetService(sScreenManagerContractID);
     if (screenmgr) {
+      LayoutDeviceIntRect bounds(info->x, info->y, info->cx, info->cy);
+      DesktopIntRect deskBounds =
+          RoundedToInt(bounds / GetDesktopToDeviceScale());
       nsCOMPtr<nsIScreen> screen;
-      screenmgr->ScreenForRect(info->x, info->y, info->cx, info->cy,
+      screenmgr->ScreenForRect(deskBounds.X(), deskBounds.Y(),
+                               deskBounds.Width(), deskBounds.Height(),
                                getter_AddRefs(screen));
 
       if (screen) {
         int32_t x, y, width, height;
-        screen->GetRectDisplayPix(&x, &y, &width, &height);
-        double scale = GetDesktopToDeviceScale().scale;
-
-        info->x = NSToIntRound(x * scale);
-        info->y = NSToIntRound(y * scale);
-        info->cx = NSToIntRound(width * scale);
-        info->cy = NSToIntRound(height * scale);
+        screen->GetRect(&x, &y, &width, &height);
+
+        info->x = x;
+        info->y = y;
+        info->cx = width;
+        info->cy = height;
       }
     }
   }
 
   // enforce local z-order rules
   if (!(info->flags & SWP_NOZORDER)) {
     HWND hwndAfter = info->hwndInsertAfter;