From 8eac85e3fb20298acffa6750e620b5a83dec8940 Mon Sep 17 00:00:00 2001 From: Peter Hutterer Date: Fri, 13 Dec 2013 17:58:50 +1000 Subject: [PATCH] Add libinput_next_event_type() Returns the event type of the next event pending in the queue. For systems that have the device init state separate from the actual event procesing (read: xorg drivers) we need to be able to peek at the next event type to check for the end of any initialization events (seat/device added) and the beginning of actual device input events. Signed-off-by: Peter Hutterer --- src/libinput.c | 12 ++++++++++++ src/libinput.h | 14 ++++++++++++++ 2 files changed, 26 insertions(+) diff --git a/src/libinput.c b/src/libinput.c index 713593e4..a9e458f2 100644 --- a/src/libinput.c +++ b/src/libinput.c @@ -910,6 +910,18 @@ libinput_get_event(struct libinput *libinput) return event; } +LIBINPUT_EXPORT enum libinput_event_type +libinput_next_event_type(struct libinput *libinput) +{ + struct libinput_event *event; + + if (libinput->events_count == 0) + return LIBINPUT_EVENT_NONE; + + event = libinput->events[libinput->events_out]; + return event->type; +} + LIBINPUT_EXPORT void * libinput_get_user_data(struct libinput *libinput) { diff --git a/src/libinput.h b/src/libinput.h index 586d0f48..22642fbd 100644 --- a/src/libinput.h +++ b/src/libinput.h @@ -488,6 +488,20 @@ libinput_dispatch(struct libinput *libinput); struct libinput_event * libinput_get_event(struct libinput *libinput); +/** + * @ingroup base + * + * Return the type of the next event in the internal queue. This function + * does not pop the event off the queue and the next call to + * libinput_get_event() returns that event. + * + * @param libinput A previously initialized libinput context + * @return The event type of the next available event or LIBINPUT_EVENT_NONE + * if no event is availble. + */ +enum libinput_event_type +libinput_next_event_type(struct libinput *libinput); + /** * @ingroup base *