[gtk/wip/carlosg/flush-uncompressed-motion] gdk: Ensure GdkFrameClock::flush-events with uncompressed motion




commit 5ea961ed93ddcdc6fe3c5bedecb8469f08484024
Author: Carlos Garnacho <carlosg gnome org>
Date:   Mon Oct 3 16:39:08 2022 +0200

    gdk: Ensure GdkFrameClock::flush-events with uncompressed motion
    
    Sometimes, there may be motion events left in the queue, because at the
    time of handlign these motion events the GDK_FRAME_CLOCK_PHASE_FLUSH_EVENTS
    phase is not requested.
    
    Ensure that, when finding motion events on a window that does not disable
    motion compression, the events are anyways flushed, so they can be processed
    early by the window/widget event handlers.
    
    Closes: https://gitlab.gnome.org/GNOME/gtk/-/issues/4946

 gdk/gdkevents.c | 16 +++++++++++-----
 1 file changed, 11 insertions(+), 5 deletions(-)
---
diff --git a/gdk/gdkevents.c b/gdk/gdkevents.c
index 12af9ccb96..087178ee75 100644
--- a/gdk/gdkevents.c
+++ b/gdk/gdkevents.c
@@ -258,6 +258,7 @@ _gdk_event_queue_handle_motion_compression (GdkDisplay *display)
   GList *pending_motions = NULL;
   GdkWindow *pending_motion_window = NULL;
   GdkDevice *pending_motion_device = NULL;
+  gboolean uncompressed_motion = FALSE;
 
   /* If the last N events in the event queue are motion notify
    * events for the same window, drop all but the last */
@@ -282,10 +283,14 @@ _gdk_event_queue_handle_motion_compression (GdkDisplay *display)
           pending_motion_device != event->event.motion.device)
         break;
 
+      pending_motion_window = event->event.motion.window;
+
       if (!event->event.motion.window->event_compression)
-        break;
+        {
+          uncompressed_motion = TRUE;
+          break;
+        }
 
-      pending_motion_window = event->event.motion.window;
       pending_motion_device = event->event.motion.device;
       pending_motions = tmp_list;
 
@@ -301,9 +306,10 @@ _gdk_event_queue_handle_motion_compression (GdkDisplay *display)
       pending_motions = next;
     }
 
-  if (pending_motions &&
-      pending_motions == display->queued_events &&
-      pending_motions == display->queued_tail)
+  if (uncompressed_motion ||
+      (pending_motions &&
+       pending_motions == display->queued_events &&
+       pending_motions == display->queued_tail))
     {
       GdkFrameClock *clock = gdk_window_get_frame_clock (pending_motion_window);
       if (clock) /* might be NULL if window was destroyed */


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