Bug 1477967 - Fix the popup menu sizes and redrawing on Wayland/hidpi monitor, r=stransky
authorJan Horak <jhorak@redhat.com>
Tue, 24 Jul 2018 12:51:34 +0200
changeset 427975 10e5948ad22bed6996fedae750c7ef358bf73f2d
parent 427974 5b6028970a75e87e57c59c4af895637b3b47f39c
child 427976 acf0257a7eb426af3e75a38fcdc80062e4c667fe
push id34322
push userrgurzau@mozilla.com
push dateTue, 24 Jul 2018 15:47:07 +0000
treeherdermozilla-central@db9d47b49936 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersstransky
bugs1477967
milestone63.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 1477967 - Fix the popup menu sizes and redrawing on Wayland/hidpi monitor, r=stransky This patch fixes redrawing of the popup element by removing the scale factor from the invalid regions because the wl_surface_damage multiplies it with the scale factor too. Also we set scaling factor of the wl_surface right after we create it to avoid flickering when the compositor switches from unscaled to scaled surface. MozReview-Commit-ID: 1eGoFu87wtF
widget/gtk/WindowSurfaceWayland.cpp
widget/gtk/mozcontainer.cpp
--- a/widget/gtk/WindowSurfaceWayland.cpp
+++ b/widget/gtk/WindowSurfaceWayland.cpp
@@ -788,19 +788,23 @@ WindowSurfaceWayland::Commit(const Layou
     CommitImageSurface(aInvalidRegion);
   }
 
   if (mFullScreenDamage) {
     LayoutDeviceIntRect rect = mWindow->GetBounds();
     wl_surface_damage(waylandSurface, 0, 0, rect.width, rect.height);
     mFullScreenDamage = false;
   } else {
+    gint scaleFactor = mWindow->GdkScaleFactor();
     for (auto iter = aInvalidRegion.RectIter(); !iter.Done(); iter.Next()) {
       const mozilla::LayoutDeviceIntRect &r = iter.Get();
-      wl_surface_damage(waylandSurface, r.x, r.y, r.width, r.height);
+      // We need to remove the scale factor because the wl_surface_damage
+      // also multiplies by current  scale factor.
+      wl_surface_damage(waylandSurface, r.x/scaleFactor, r.y/scaleFactor,
+                        r.width/scaleFactor, r.height/scaleFactor);
     }
   }
 
   // Frame callback is always connected to actual wl_surface. When the surface
   // is unmapped/deleted the frame callback is never called. Unfortunatelly
   // we don't know if the frame callback is not going to be called.
   // But our mozcontainer code deletes wl_surface when the GdkWindow is hidden
   // creates a new one when is visible.
--- a/widget/gtk/mozcontainer.cpp
+++ b/widget/gtk/mozcontainer.cpp
@@ -600,16 +600,25 @@ struct wl_surface*
 moz_container_get_wl_surface(MozContainer *container)
 {
     if (!container->subsurface || !container->surface) {
         GdkWindow* window = gtk_widget_get_window(GTK_WIDGET(container));
         if (!gdk_window_is_visible(window))
             return nullptr;
 
         moz_container_map_surface(container);
+        // Set the scale factor for the buffer right after we create it.
+        if (container->surface) {
+            static auto sGdkWindowGetScaleFactorPtr = (gint (*)(GdkWindow*))
+            dlsym(RTLD_DEFAULT, "gdk_window_get_scale_factor");
+            if (sGdkWindowGetScaleFactorPtr && window) {
+              gint scaleFactor = (*sGdkWindowGetScaleFactorPtr)(window);
+              wl_surface_set_buffer_scale(container->surface, scaleFactor);
+            }
+        }
     }
 
     return container->surface;
 }
 
 struct wl_egl_window *
 moz_container_get_wl_egl_window(MozContainer *container)
 {