From 4ec24b2037a0161fe4a9240a7fc3225d3d1cbca3 Mon Sep 17 00:00:00 2001 From: Peter Hutterer Date: Wed, 22 Jan 2014 11:20:50 +1000 Subject: [PATCH] test: Add a common helper function to drain all current events Signed-off-by: Peter Hutterer --- test/litest.c | 12 ++++++++++++ test/litest.h | 1 + 2 files changed, 13 insertions(+) diff --git a/test/litest.c b/test/litest.c index 1f063c02..79d19a27 100644 --- a/test/litest.c +++ b/test/litest.c @@ -461,3 +461,15 @@ int litest_scale(const struct litest_device *d, unsigned int axis, int val) max = d->interface->max[axis]; return (max - min) * val/100.0 + min; } + +void +litest_drain_events(struct libinput *li) +{ + struct libinput_event *event; + + libinput_dispatch(li); + while ((event = libinput_get_event(li))) { + libinput_event_destroy(event); + libinput_dispatch(li); + } +} diff --git a/test/litest.h b/test/litest.h index bace4b77..7de2d393 100644 --- a/test/litest.h +++ b/test/litest.h @@ -90,5 +90,6 @@ void litest_touch_move_to(struct litest_device *d, void litest_button_click(struct litest_device *d, unsigned int button, bool is_press); +void litest_drain_events(struct libinput *li); #endif /* LITEST_H */