From 2b41e72196ee648ae71f8c8af393d8d8942ea0d4 Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Wed, 26 Jan 2022 15:49:29 +0100 Subject: [PATCH 1/3] gdk: Always request "flush events" frame clock phase on events This change is done for 2 reasons: - The logic to request this phase when compressing scroll events is slightly broken. If there are multiple scroll events that are coalesced into one, the surface frame clock will not get this request. The worst case is having >= 2 scroll events on every frame, as the compressed event will be left in the queue, and be further compressed on future events. - Even scroll events aside, this phase is requested in oddly specific places that are not enough to cover all events, others do rely on unrelated GdkFrameClock activity that happens to flush the events as well. Unify this phase request so it explicitly happens on the arrival of any event. This ensures that events (compressed or not) will be handled promptly after arrival. --- gdk/gdkevents.c | 16 ---------------- gdk/gdksurface.c | 10 +++++++++- 2 files changed, 9 insertions(+), 17 deletions(-) diff --git a/gdk/gdkevents.c b/gdk/gdkevents.c index 1f4a920720..454e69ed64 100644 --- a/gdk/gdkevents.c +++ b/gdk/gdkevents.c @@ -719,14 +719,6 @@ gdk_event_queue_handle_scroll_compression (GdkDisplay *display) gdk_event_unref (old_event); } - - if (g_queue_get_length (&display->queued_events) == 1 && - g_queue_peek_head_link (&display->queued_events) == scrolls) - { - GdkFrameClock *clock = gdk_surface_get_frame_clock (surface); - if (clock) /* might be NULL if surface was destroyed */ - gdk_frame_clock_request_phase (clock, GDK_FRAME_CLOCK_PHASE_FLUSH_EVENTS); - } } static void @@ -832,14 +824,6 @@ _gdk_event_queue_handle_motion_compression (GdkDisplay *display) g_queue_delete_link (&display->queued_events, pending_motions); pending_motions = next; } - - if (g_queue_get_length (&display->queued_events) == 1 && - g_queue_peek_head_link (&display->queued_events) == pending_motions) - { - GdkFrameClock *clock = gdk_surface_get_frame_clock (pending_motion_surface); - if (clock) /* might be NULL if surface was destroyed */ - gdk_frame_clock_request_phase (clock, GDK_FRAME_CLOCK_PHASE_FLUSH_EVENTS); - } } void diff --git a/gdk/gdksurface.c b/gdk/gdksurface.c index 1f176b9b87..ddfa767a99 100644 --- a/gdk/gdksurface.c +++ b/gdk/gdksurface.c @@ -2244,7 +2244,7 @@ _gdk_windowing_got_event (GdkDisplay *display, GdkEvent *event, gulong serial) { - GdkSurface *event_surface; + GdkSurface *event_surface = NULL; gboolean unlink_event = FALSE; GdkDeviceGrabInfo *button_release_grab; GdkPointerSurfaceInfo *pointer_info = NULL; @@ -2336,6 +2336,14 @@ _gdk_windowing_got_event (GdkDisplay *display, */ _gdk_event_queue_handle_motion_compression (display); gdk_event_queue_handle_scroll_compression (display); + + if (event_surface) + { + GdkFrameClock *clock = gdk_surface_get_frame_clock (event_surface); + + if (clock) /* might be NULL if surface was destroyed */ + gdk_frame_clock_request_phase (clock, GDK_FRAME_CLOCK_PHASE_FLUSH_EVENTS); + } } /** From 8e86e6325b4138a8ef0bb4ab8ef77627e6da3e03 Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Wed, 26 Jan 2022 15:59:36 +0100 Subject: [PATCH 2/3] gtk/main: Do not use touchpad event sequence for pointer focus lookup Despite touchpad gestures having a sequence, these must use the logical pointer focus. Avoid using the sequence for GtkPointerFocus lookups with those events, in order to ensure those events make it all the way to the intended target. This is fallout from adding GdkEventSequence information to touchpad gestures. --- gtk/gtkmain.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/gtk/gtkmain.c b/gtk/gtkmain.c index c96bfb3c81..bfab35ad61 100644 --- a/gtk/gtkmain.c +++ b/gtk/gtkmain.c @@ -1352,6 +1352,14 @@ handle_pointing_event (GdkEvent *event) */ device = gdk_seat_get_pointer (gdk_event_get_seat (event)); } + else if (type == GDK_TOUCHPAD_PINCH || + type == GDK_TOUCHPAD_SWIPE) + { + /* Another bit of a kludge, touchpad gesture sequences do not + * reflect on the pointer focus lookup. + */ + sequence = NULL; + } switch ((guint) type) { From 6fd36457130b89d030f684785987c6e5e0531a33 Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Wed, 26 Jan 2022 16:02:00 +0100 Subject: [PATCH 3/3] gtk/gesture: Fix point info lookup on touchpad events Since the addition of GdkEventSequence in touchpad events, these are now stored in the gesture using that sequence. This bit of touchpad gesture handling was however missing to be updated, still looking up the special NULL sequence. Use the last sequence here, which will be the one coming from touchpad gesture events. --- gtk/gtkgesture.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gtk/gtkgesture.c b/gtk/gtkgesture.c index 3897ba0549..33b2fb9326 100644 --- a/gtk/gtkgesture.c +++ b/gtk/gtkgesture.c @@ -242,7 +242,7 @@ _gtk_gesture_get_n_touchpad_points (GtkGesture *gesture, if (!priv->touchpad) return 0; - data = g_hash_table_lookup (priv->points, NULL); + data = g_hash_table_lookup (priv->points, priv->last_sequence); if (!data) return 0;