gdk/wayland: freeze popups when hidden
authorChristian Hergert <chergert@redhat.com>
Thu, 24 Mar 2022 00:00:21 +0000 (17:00 -0700)
committerMatthias Clasen <mclasen@redhat.com>
Wed, 11 May 2022 20:32:17 +0000 (16:32 -0400)
Previously, there was an issue with glitching after showing/hiding a
popover that was not also destroyed. This was due to the popover having
an update_freeze_count of zero after hiding the surface.

That resulted in it's toplevel continuously dropping frames such as during
high-frame-rate scrolling in textviews. This problem is much more visible
on high-frame-rate displays such as 120hz/144hz.

With this commit, we freeze the frame clock of the popup until it is
mapped again.

gdk/wayland/gdksurface-wayland.c

index 09328bdb890f247ee33d3d5f300e0723580dc62f..0b3315075ec233d51c9aa6b05d10591eebea5493 100644 (file)
@@ -113,6 +113,7 @@ struct _GdkWaylandSurface
 
   PopupState popup_state;
 
+  unsigned int popup_thaw_upon_show : 1;
   unsigned int initial_configure_received : 1;
   unsigned int has_uncommitted_ack_configure : 1;
   unsigned int mapped : 1;
@@ -2984,6 +2985,9 @@ gdk_wayland_surface_hide_surface (GdkSurface *surface)
 
       if (GDK_IS_POPUP (surface))
         {
+          impl->popup_thaw_upon_show = TRUE;
+          gdk_surface_freeze_updates (surface);
+
           switch (impl->popup_state)
             {
             case POPUP_STATE_WAITING_FOR_REPOSITIONED:
@@ -3223,6 +3227,12 @@ show_popup (GdkSurface     *surface,
   if (!impl->display_server.wl_surface)
     gdk_wayland_surface_create_surface (surface);
 
+  if (impl->popup_thaw_upon_show)
+    {
+      impl->popup_thaw_upon_show = FALSE;
+      gdk_surface_thaw_updates (surface);
+    }
+
   gdk_wayland_surface_map_popup (surface, width, height, layout);
 }