[gtk/wip/carlosg/for-master: 8/8] gdk/surface: Trigger motion check for next frame after thaw




commit e6c66be3f967fd7077e592cad44340286fe844e1
Author: Carlos Garnacho <carlosg gnome org>
Date:   Sat Dec 12 01:36:16 2020 +0100

    gdk/surface: Trigger motion check for next frame after thaw
    
    This is a more reliable calling point than ::resume-events, and a
    good one to schedule things so they happen on a frame clock in no
    special phase (Thus still fixing the original issue at 80d4a08e30)
    
    Fixes: https://gitlab.gnome.org/GNOME/gtk/-/issues/3461

 gdk/gdksurface.c | 41 +++++++++++++++++++++--------------------
 1 file changed, 21 insertions(+), 20 deletions(-)
---
diff --git a/gdk/gdksurface.c b/gdk/gdksurface.c
index b6f739c5c0..52f911bcfe 100644
--- a/gdk/gdksurface.c
+++ b/gdk/gdksurface.c
@@ -1555,6 +1555,20 @@ gdk_surface_freeze_updates (GdkSurface *surface)
     _gdk_frame_clock_uninhibit_freeze (surface->frame_clock);
 }
 
+static gboolean
+request_motion_cb (void *data)
+{
+  GdkSurface *surface = GDK_SURFACE (data);
+  GdkFrameClock *clock = gdk_surface_get_frame_clock (surface);
+
+  if (clock)
+    gdk_frame_clock_request_phase (clock, GDK_FRAME_CLOCK_PHASE_FLUSH_EVENTS);
+  surface->request_motion_id = 0;
+
+  return G_SOURCE_REMOVE;
+}
+
+
 /*
  * gdk_surface_thaw_updates:
  * @surface: a #GdkSurface
@@ -1578,6 +1592,13 @@ gdk_surface_thaw_updates (GdkSurface *surface)
 
       if (surface->pending_phases)
         gdk_frame_clock_request_phase (frame_clock, surface->pending_phases);
+
+      if (surface->request_motion)
+        {
+          surface->request_motion_id =
+            g_idle_add_full (GDK_PRIORITY_REDRAW + 20,
+                             request_motion_cb, surface, NULL);
+        }
     }
 }
 
@@ -2410,19 +2431,6 @@ gdk_surface_flush_events (GdkFrameClock *clock,
   surface->frame_clock_events_paused = TRUE;
 }
 
-static gboolean
-request_motion_cb (void *data)
-{
-  GdkSurface *surface = GDK_SURFACE (data);
-  GdkFrameClock *clock = gdk_surface_get_frame_clock (surface);
-
-  if (clock)
-    gdk_frame_clock_request_phase (clock, GDK_FRAME_CLOCK_PHASE_FLUSH_EVENTS);
-  surface->request_motion_id = 0;
-
-  return G_SOURCE_REMOVE;
-}
-
 static void
 gdk_surface_resume_events (GdkFrameClock *clock,
                            void          *data)
@@ -2434,13 +2442,6 @@ gdk_surface_resume_events (GdkFrameClock *clock,
       _gdk_display_unpause_events (surface->display);
       surface->frame_clock_events_paused = FALSE;
     }
-
-  if (surface->request_motion)
-    {
-      surface->request_motion_id =
-        g_idle_add_full (GDK_PRIORITY_REDRAW + 1,
-                         request_motion_cb, surface, NULL);
-    }
 }
 
 static void


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]