mirror of
https://gitlab.freedesktop.org/libinput/libei.git
synced 2026-05-01 03:27:59 +02:00
eis: implement eis_peek_event() and eis_next_event_type()
Motivation for peek is the same as for libei - the upcoming test suite needs to check a few things before actually dequeuing the event. Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
This commit is contained in:
parent
5631abfc77
commit
9ee00ada3a
2 changed files with 48 additions and 0 deletions
19
src/libeis.c
19
src/libeis.c
|
|
@ -315,3 +315,22 @@ eis_get_event(struct eis *eis)
|
|||
|
||||
return e;
|
||||
}
|
||||
|
||||
_public_ struct eis_event *
|
||||
eis_peek_event(struct eis *eis)
|
||||
{
|
||||
if (list_empty(&eis->event_queue))
|
||||
return NULL;
|
||||
|
||||
struct eis_event *e = list_first_entry(&eis->event_queue, e, link);
|
||||
return eis_event_ref(e);
|
||||
}
|
||||
|
||||
_public_ enum eis_event_type
|
||||
eis_next_event_type(struct eis *eis)
|
||||
{
|
||||
if (list_empty(&eis->event_queue))
|
||||
return EIS_EVENT_NONE;
|
||||
struct eis_event *e = list_first_entry(&eis->event_queue, e, link);
|
||||
return e->type;
|
||||
}
|
||||
|
|
|
|||
29
src/libeis.h
29
src/libeis.h
|
|
@ -149,9 +149,38 @@ eis_get_fd(struct eis *eis);
|
|||
void
|
||||
eis_dispatch(struct eis *eis);
|
||||
|
||||
/**
|
||||
* Returns the next event in the internal event queue (or NULL) and removes
|
||||
* it from the queue.
|
||||
*
|
||||
* The returned event is refcounted, use eis_event_unref() to drop the
|
||||
* reference.
|
||||
*
|
||||
* You must not call this function while holding a reference to an event
|
||||
* returned by eis_peek_event().
|
||||
*/
|
||||
struct eis_event *
|
||||
eis_get_event(struct eis *eis);
|
||||
|
||||
/**
|
||||
* Returns the next event in the internal event queue (or NULL) without
|
||||
* removing that event from the queue, i.e. the next call to eis_get_event()
|
||||
* will return that same event.
|
||||
*
|
||||
* This call is useful for checking whether there is an event and/or what
|
||||
* type of event it is.
|
||||
*
|
||||
* Repeated calls to eis_peek_event() return the same event.
|
||||
*
|
||||
* The returned event is refcounted, use eis_event_unref() to drop the
|
||||
* reference.
|
||||
*
|
||||
* A caller must not call eis_get_event() while holding a ref to an event
|
||||
* returned by eis_peek_event().
|
||||
*/
|
||||
struct eis_event *
|
||||
eis_peek_event(struct eis *eis);
|
||||
|
||||
struct eis_event *
|
||||
eis_event_unref(struct eis_event *event);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue