{
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
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)