From 506105432db22e0a98813d966ce91462db03b9d0 Mon Sep 17 00:00:00 2001 From: "Wonsik, Jung" Date: Mon, 10 Apr 2017 13:53:23 +0900 Subject: [PATCH] [Wayland] Modify wayland event polling Modify wayland event polling in wayaland backend. This patch is made by referring the below. https://wayland.freedesktop.org/docs/html/apb.html#Client-classwl__display Change-Id: Ia070b96e285b595b223752386099484b753b0d9f --- src/video/wayland/SDL_waylandevents.c | 21 ++++++++++++++++++--- src/video/wayland/SDL_waylandsym.h | 3 +++ 2 files changed, 21 insertions(+), 3 deletions(-) diff --git a/src/video/wayland/SDL_waylandevents.c b/src/video/wayland/SDL_waylandevents.c index e1eaa58..4ca9483 100644 --- a/src/video/wayland/SDL_waylandevents.c +++ b/src/video/wayland/SDL_waylandevents.c @@ -71,15 +71,30 @@ Wayland_PumpEvents(_THIS) { SDL_VideoData *d = _this->driverdata; struct pollfd pfd[1]; + int ret = 0; pfd[0].fd = WAYLAND_wl_display_get_fd(d->display); pfd[0].events = POLLIN; - poll(pfd, 1, 0); - if (pfd[0].revents & POLLIN) + while (WAYLAND_wl_display_prepare_read(d->display) != 0) { + WAYLAND_wl_display_dispatch_pending(d->display); + } + WAYLAND_wl_display_flush(d->display); + + ret = poll(pfd, 1, 0); + if (ret < 0) { + WAYLAND_wl_display_cancel_read(d->display); + } + else { + WAYLAND_wl_display_read_events(d->display); + } + + if (pfd[0].revents & POLLIN) { WAYLAND_wl_display_dispatch(d->display); - else + } + else { WAYLAND_wl_display_dispatch_pending(d->display); + } } static void diff --git a/src/video/wayland/SDL_waylandsym.h b/src/video/wayland/SDL_waylandsym.h index 6b66aff..5b355b5 100644 --- a/src/video/wayland/SDL_waylandsym.h +++ b/src/video/wayland/SDL_waylandsym.h @@ -50,6 +50,9 @@ SDL_WAYLAND_SYM(void, wl_list_remove, (struct wl_list *)) SDL_WAYLAND_SYM(int, wl_list_length, (const struct wl_list *)) SDL_WAYLAND_SYM(int, wl_list_empty, (const struct wl_list *)) SDL_WAYLAND_SYM(void, wl_list_insert_list, (struct wl_list *, struct wl_list *)) +SDL_WAYLAND_SYM(int, wl_display_prepare_read, (struct wl_display *)) +SDL_WAYLAND_SYM(int, wl_display_cancel_read, (struct wl_display *)) +SDL_WAYLAND_SYM(int, wl_display_read_events, (struct wl_display *)) /* These functions are available in Wayland >= 1.4 */ SDL_WAYLAND_MODULE(WAYLAND_CLIENT_1_4) -- 2.7.4