Bug 1240749 - Fixes for DPI support in Gtk widget interface: remove incorrect Get[Avail]RectDisplayPix overrides, as desktop pixels == device pixels for the Gtk widget backend, and implement nsScreenGtk::GetDefaultCSSScaleFactor, required by nsGlobalWindow since per-monitor DPI patches in bug 890156. r=karlt
☠☠ backed out by 41a76dfcce45 ☠ ☠
authorJonathan Kew <jkew@mozilla.com>
Fri, 26 Feb 2016 22:34:11 +0000
changeset 286063 bc33885d20340641e06cc40031618dd30ccd6567
parent 286062 8ad96eb28e4fb4903c326987e07cf2fded0e67b6
child 286064 41a76dfcce45e8216516b390752dfe3365b0c777
push id30039
push usercbook@mozilla.com
push dateTue, 01 Mar 2016 11:02:11 +0000
treeherdermozilla-central@5cafa6f3019b [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerskarlt
bugs1240749, 890156
milestone47.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 1240749 - Fixes for DPI support in Gtk widget interface: remove incorrect Get[Avail]RectDisplayPix overrides, as desktop pixels == device pixels for the Gtk widget backend, and implement nsScreenGtk::GetDefaultCSSScaleFactor, required by nsGlobalWindow since per-monitor DPI patches in bug 890156. r=karlt
widget/gtk/nsScreenGtk.cpp
widget/gtk/nsScreenGtk.h
widget/gtk/nsScreenManagerGtk.cpp
widget/gtk/nsScreenManagerGtk.h
--- a/widget/gtk/nsScreenGtk.cpp
+++ b/widget/gtk/nsScreenGtk.cpp
@@ -86,66 +86,39 @@ nsScreenGtk :: GetDPIScale()
 {
   double dpiScale = nsIWidget::DefaultScaleOverride();
   if (dpiScale <= 0.0) {
     dpiScale = GetGtkMonitorScaleFactor() * gfxPlatformGtk::GetDPIScale();
   }
   return dpiScale;
 }
 
-NS_IMETHODIMP
-nsScreenGtk :: GetRectDisplayPix(int32_t *outLeft,  int32_t *outTop, int32_t *outWidth, int32_t *outHeight)
-{
-  int32_t left, top, width, height;
-
-  GetRect(&left, &top, &width, &height);
-
-  double scaleFactor = 1.0 / GetDPIScale();
-  *outLeft = NSToIntRound(left * scaleFactor);
-  *outTop = NSToIntRound(top * scaleFactor);
-  *outWidth = NSToIntRound(width * scaleFactor);
-  *outHeight = NSToIntRound(height * scaleFactor);
-
-  return NS_OK;
-}
-
-NS_IMETHODIMP
-nsScreenGtk :: GetAvailRectDisplayPix(int32_t *outLeft,  int32_t *outTop,  int32_t *outWidth, int32_t *outHeight)
-{
-  int32_t left, top, width, height;
-
-  GetAvailRect(&left, &top, &width, &height);
-
-  double scaleFactor = 1.0 / GetDPIScale();
-  *outLeft = NSToIntRound(left * scaleFactor);
-  *outTop = NSToIntRound(top * scaleFactor);
-  *outWidth = NSToIntRound(width * scaleFactor);
-  *outHeight = NSToIntRound(height * scaleFactor);
-
-  return NS_OK;
-}
-
 NS_IMETHODIMP 
 nsScreenGtk :: GetPixelDepth(int32_t *aPixelDepth)
 {
   GdkVisual * visual = gdk_screen_get_system_visual(gdk_screen_get_default());
   *aPixelDepth = gdk_visual_get_depth(visual);
 
   return NS_OK;
 
 } // GetPixelDepth
 
-
 NS_IMETHODIMP 
 nsScreenGtk :: GetColorDepth(int32_t *aColorDepth)
 {
   return GetPixelDepth ( aColorDepth );
 
 } // GetColorDepth
 
+NS_IMETHODIMP
+nsScreenGtk::GetDefaultCSSScaleFactor(double* aScaleFactor)
+{
+  *aScaleFactor = GetDPIScale();
+  return NS_OK;
+}
 
 void
 nsScreenGtk :: Init (GdkWindow *aRootWindow)
 {
   gint scale = nsScreenGtk::GetGtkMonitorScaleFactor();
   gint width = gdk_screen_width()*scale;
   gint height = gdk_screen_height()*scale;
 
--- a/widget/gtk/nsScreenGtk.h
+++ b/widget/gtk/nsScreenGtk.h
@@ -28,20 +28,19 @@ class nsScreenGtk : public nsBaseScreen
 {
 public:
   nsScreenGtk();
   ~nsScreenGtk();
 
   NS_IMETHOD GetId(uint32_t* aId);
   NS_IMETHOD GetRect(int32_t* aLeft, int32_t* aTop, int32_t* aWidth, int32_t* aHeight);
   NS_IMETHOD GetAvailRect(int32_t* aLeft, int32_t* aTop, int32_t* aWidth, int32_t* aHeight);
-  NS_IMETHOD GetRectDisplayPix(int32_t *outLeft, int32_t *outTop, int32_t *outWidth, int32_t *outHeight);
-  NS_IMETHOD GetAvailRectDisplayPix(int32_t *outLeft, int32_t *outTop, int32_t *outWidth, int32_t *outHeight);
   NS_IMETHOD GetPixelDepth(int32_t* aPixelDepth);
   NS_IMETHOD GetColorDepth(int32_t* aColorDepth);
+  NS_IMETHOD GetDefaultCSSScaleFactor(double* aScaleFactor) override;
 
   void Init(GdkWindow *aRootWindow);
 #ifdef MOZ_X11
   void Init(XineramaScreenInfo *aScreenInfo);
 #endif /* MOZ_X11 */
 
   static gint    GetGtkMonitorScaleFactor();
   static double  GetDPIScale();
--- a/widget/gtk/nsScreenManagerGtk.cpp
+++ b/widget/gtk/nsScreenManagerGtk.cpp
@@ -232,40 +232,22 @@ nsScreenManagerGtk :: ScreenForId ( uint
 
 
 //
 // ScreenForRect 
 //
 // Returns the screen that contains the rectangle. If the rect overlaps
 // multiple screens, it picks the screen with the greatest area of intersection.
 //
-// The coordinates are in CSS pixels (not app units) and in screen coordinates.
+// The coordinates are in desktop pixels.
 //
 NS_IMETHODIMP
-nsScreenManagerGtk :: ScreenForRect( int32_t aX, int32_t aY,
-                                     int32_t aWidth, int32_t aHeight,
-                                     nsIScreen **aOutScreen )
-{
-  uint32_t scale = nsScreenGtk::GetDPIScale();
-  return ScreenForRectPix(aX*scale, aY*scale, aWidth*scale, aHeight*scale,
-                          aOutScreen);
-}
-
-//
-// ScreenForRectPix
-//
-// Returns the screen that contains the rectangle. If the rect overlaps
-// multiple screens, it picks the screen with the greatest area of intersection.
-//
-// The coordinates are in device (X11) pixels.
-//
-nsresult
-nsScreenManagerGtk :: ScreenForRectPix( int32_t aX, int32_t aY,
-                                        int32_t aWidth, int32_t aHeight,
-                                        nsIScreen **aOutScreen )
+nsScreenManagerGtk::ScreenForRect(int32_t aX, int32_t aY,
+                                  int32_t aWidth, int32_t aHeight,
+                                  nsIScreen **aOutScreen)
 {
   nsresult rv;
   rv = EnsureInit();
   if (NS_FAILED(rv)) {
     NS_ERROR("nsScreenManagerGtk::EnsureInit() failed from ScreenForRect");
     return rv;
   }
 
@@ -369,15 +351,15 @@ nsScreenManagerGtk :: ScreenForNativeWid
 
 #if (MOZ_WIDGET_GTK == 2)
     gdk_window_get_geometry(GDK_WINDOW(aWidget), &x, &y, &width, &height,
                             &depth);
 #else
     gdk_window_get_geometry(GDK_WINDOW(aWidget), &x, &y, &width, &height);
 #endif
     gdk_window_get_origin(GDK_WINDOW(aWidget), &x, &y);
-    rv = ScreenForRectPix(x, y, width, height, outScreen);
+    rv = ScreenForRect(x, y, width, height, outScreen);
   } else {
     rv = GetPrimaryScreen(outScreen);
   }
 
   return rv;
 }
--- a/widget/gtk/nsScreenManagerGtk.h
+++ b/widget/gtk/nsScreenManagerGtk.h
@@ -32,19 +32,16 @@ public:
   
   // For internal use, or reinitialization from change notification.
   nsresult Init();
 
 private:
   virtual ~nsScreenManagerGtk();
 
   nsresult EnsureInit();
-  nsresult ScreenForRectPix(int32_t aX, int32_t aY,
-                            int32_t aWidth, int32_t aHeight,
-                            nsIScreen **aOutScreen);
 
   // Cached screen array.  Its length is the number of screens we have.
   nsCOMArray<nsIScreen> mCachedScreenArray;
 
   PRLibrary *mXineramalib;
 
   GdkWindow *mRootWindow;
 #ifdef MOZ_X11