Bug 1573813 - use parent window scale factor for the popup/tooltips; r=stransky
☠☠ backed out by 3b09fca43df9 ☠ ☠
authorJan Horak <jhorak@redhat.com>
Tue, 27 Aug 2019 13:03:50 +0000
changeset 490374 9b5ceca1eedf6bbaddee2a67bf027db5c7b90404
parent 490373 9aa911cc3fcf58e031540b5161f3f4032ce9567a
child 490375 c933104a7470cd417801700110c6b7aa22a7080f
push id93818
push userbtara@mozilla.com
push dateWed, 28 Aug 2019 12:04:46 +0000
treeherderautoland@9b5ceca1eedf [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersstransky
bugs1573813
milestone70.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 1573813 - use parent window scale factor for the popup/tooltips; r=stransky For popup windows with parent we need to get scale factor of the parent window. Because when the windows are hidden they're not receiving updates about changing scaling factor. So when moving from normal dpi to the hidpi monitor the newly opened popup windows will have the same scale Differential Revision: https://phabricator.services.mozilla.com/D41947
widget/gtk/nsWindow.cpp
--- a/widget/gtk/nsWindow.cpp
+++ b/widget/gtk/nsWindow.cpp
@@ -6572,21 +6572,32 @@ void nsWindow::SetDrawsInTitlebar(bool a
       UpdateTitlebarTransparencyBitmap();
     } else {
       ClearTransparencyBitmap();
     }
   }
 }
 
 gint nsWindow::GdkScaleFactor() {
+  // For popup windows with parent window we need to get scale factor of the
+  // parent window. Otherwise the scale factor of the popup is not updated
+  // during it's hidden.
+  GdkWindow* scaledGdkWindow = mGdkWindow;
+  if (mToplevelParentWindow) {
+    scaledGdkWindow = gtk_widget_get_window(GTK_WIDGET(mToplevelParentWindow));
+    // Fallback for windows which parent has been unrealized.
+    if (!scaledGdkWindow) {
+      scaledGdkWindow = mGdkWindow;
+    }
+  }
   // Available as of GTK 3.10+
   static auto sGdkWindowGetScaleFactorPtr =
       (gint(*)(GdkWindow*))dlsym(RTLD_DEFAULT, "gdk_window_get_scale_factor");
-  if (sGdkWindowGetScaleFactorPtr && mGdkWindow)
-    return (*sGdkWindowGetScaleFactorPtr)(mGdkWindow);
+  if (sGdkWindowGetScaleFactorPtr && scaledGdkWindow)
+    return (*sGdkWindowGetScaleFactorPtr)(scaledGdkWindow);
   return ScreenHelperGTK::GetGTKMonitorScaleFactor();
 }
 
 gint nsWindow::DevicePixelsToGdkCoordRoundUp(int pixels) {
   gint scale = GdkScaleFactor();
   return (pixels + scale - 1) / scale;
 }