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.
This commit is contained in:
Carlos Garnacho 2022-01-26 15:49:29 +01:00
parent 2f8eac2c0a
commit 2b41e72196
2 changed files with 9 additions and 17 deletions

View File

@ -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

View File

@ -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);
}
}
/**