From e6b70f1a2bc5c0640c6078dd005400d699c70155 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonas=20=C3=85dahl?= Date: Thu, 28 Jan 2021 14:40:49 +0100 Subject: [PATCH] seat-impl: Dispatch source also when there are already queued events Libinput will queue a few initial events when a seat is assigned to the udev backend; a result of it probing udev adding detected devices. For us to see these events, we need to dispatch libinput before going idle, as nothing will show up on the libinput file descriptor until something else (e.g. keyboard event or mouse movement) wakes us up. Do this by adding a prepare() function to the libinput GSource, that checks whether there are any events in the queue already, and return TRUE if so is the case, causing us to dispatch before going fully idle. Part-of: --- src/backends/native/meta-seat-impl.c | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/src/backends/native/meta-seat-impl.c b/src/backends/native/meta-seat-impl.c index b483956fc..da87b086b 100644 --- a/src/backends/native/meta-seat-impl.c +++ b/src/backends/native/meta-seat-impl.c @@ -943,6 +943,25 @@ meta_seat_impl_notify_touch_event_in_impl (MetaSeatImpl *seat_impl, /* * MetaEventSource for reading input devices */ + +static gboolean +meta_event_prepare (GSource *g_source, + int *timeout_ms) +{ + MetaEventSource *source = (MetaEventSource *) g_source; + MetaSeatImpl *seat_impl = source->seat_impl; + + *timeout_ms = -1; + + switch (libinput_next_event_type (seat_impl->libinput)) + { + case LIBINPUT_EVENT_NONE: + return FALSE; + default: + return TRUE; + } +} + static gboolean meta_event_check (GSource *source) { @@ -1429,7 +1448,7 @@ meta_event_dispatch (GSource *g_source, } static GSourceFuncs event_funcs = { - NULL, + meta_event_prepare, meta_event_check, meta_event_dispatch, NULL