Add libinput_next_event_type()
authorPeter Hutterer <peter.hutterer@who-t.net>
Fri, 13 Dec 2013 07:58:50 +0000 (17:58 +1000)
committerPeter Hutterer <peter.hutterer@who-t.net>
Fri, 10 Jan 2014 01:23:57 +0000 (11:23 +1000)
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 <peter.hutterer@who-t.net>
src/libinput.c
src/libinput.h

index 713593e4e9fde95b8832a3762cddef687e46bd7d..a9e458f26286cb2f336df925219607c686bb09d0 100644 (file)
@@ -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)
 {
index 586d0f487c38a4c9bd758795e1e9b002b321f4d8..22642fbd500b2846ca9386a5a81e4ba8f982d113 100644 (file)
@@ -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
  *