mirror of
https://gitlab.freedesktop.org/libinput/libinput.git
synced 2025-12-25 02:20:05 +01:00
test: use poll instead of a busy wait
Drop the busy loop we had waiting for an event to appear and just call poll on the libinput fd. This actually makes the tests more correct, if we now time out where we didn't before it means we're not setting the timers correctly. Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net> Reviewed-by: Hans de Goede <hdegoede@redhat.com>
This commit is contained in:
parent
97f447d670
commit
676be4b944
1 changed files with 6 additions and 1 deletions
|
|
@ -1560,6 +1560,7 @@ litest_wait_for_event_of_type(struct libinput *li, ...)
|
|||
enum libinput_event_type types[32] = {LIBINPUT_EVENT_NONE};
|
||||
size_t ntypes = 0;
|
||||
enum libinput_event_type type;
|
||||
struct pollfd fds;
|
||||
|
||||
va_start(args, li);
|
||||
type = va_arg(args, int);
|
||||
|
|
@ -1571,12 +1572,16 @@ litest_wait_for_event_of_type(struct libinput *li, ...)
|
|||
}
|
||||
va_end(args);
|
||||
|
||||
fds.fd = libinput_get_fd(li);
|
||||
fds.events = POLLIN;
|
||||
fds.revents = 0;
|
||||
|
||||
while (1) {
|
||||
size_t i;
|
||||
struct libinput_event *event;
|
||||
|
||||
while ((type = libinput_next_event_type(li)) == LIBINPUT_EVENT_NONE) {
|
||||
msleep(10);
|
||||
poll(&fds, 1, -1);
|
||||
libinput_dispatch(li);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue