summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarlos Garnacho <carlosg@gnome.org>2022-01-26 15:49:29 +0100
committerCarlos Garnacho <carlosg@gnome.org>2022-01-26 15:49:29 +0100
commit2b41e72196ee648ae71f8c8af393d8d8942ea0d4 (patch)
tree3d7abd6bd3ba57cc23f35cbab567045d18d3cb56
parent2f8eac2c0acca181926749b787748813ca600914 (diff)
downloadgtk+-2b41e72196ee648ae71f8c8af393d8d8942ea0d4.tar.gz
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.
-rw-r--r--gdk/gdkevents.c16
-rw-r--r--gdk/gdksurface.c10
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);
+ }
}
/**