diff --git a/gfx/drivers_context/wayland_ctx.c b/gfx/drivers_context/wayland_ctx.c index de599e60ec..8457d22aa1 100644 --- a/gfx/drivers_context/wayland_ctx.c +++ b/gfx/drivers_context/wayland_ctx.c @@ -251,32 +251,6 @@ static void gfx_ctx_wl_destroy_resources(gfx_ctx_wayland_data_t *wl) } -void flush_wayland_fd(void *data) -{ - struct pollfd fd = {0}; - input_ctx_wayland_data_t *wl = (input_ctx_wayland_data_t*)data; - - wl_display_dispatch_pending(wl->dpy); - wl_display_flush(wl->dpy); - - fd.fd = wl->fd; - fd.events = POLLIN | POLLOUT | POLLERR | POLLHUP; - - if (poll(&fd, 1, 0) > 0) - { - if (fd.revents & (POLLERR | POLLHUP)) - { - close(wl->fd); - frontend_driver_set_signal_handler_state(1); - } - - if (fd.revents & POLLIN) - wl_display_dispatch(wl->dpy); - if (fd.revents & POLLOUT) - wl_display_flush(wl->dpy); - } -} - static void gfx_ctx_wl_check_window(void *data, bool *quit, bool *resize, unsigned *width, unsigned *height) { diff --git a/input/common/wayland_common.c b/input/common/wayland_common.c index fbdb6cc5e4..6dae1522fe 100644 --- a/input/common/wayland_common.c +++ b/input/common/wayland_common.c @@ -666,3 +666,29 @@ const struct wl_pointer_listener pointer_listener = { pointer_handle_button, pointer_handle_axis, }; + +void flush_wayland_fd(void *data) +{ + struct pollfd fd = {0}; + input_ctx_wayland_data_t *wl = (input_ctx_wayland_data_t*)data; + + wl_display_dispatch_pending(wl->dpy); + wl_display_flush(wl->dpy); + + fd.fd = wl->fd; + fd.events = POLLIN | POLLOUT | POLLERR | POLLHUP; + + if (poll(&fd, 1, 0) > 0) + { + if (fd.revents & (POLLERR | POLLHUP)) + { + close(wl->fd); + frontend_driver_set_signal_handler_state(1); + } + + if (fd.revents & POLLIN) + wl_display_dispatch(wl->dpy); + if (fd.revents & POLLOUT) + wl_display_flush(wl->dpy); + } +}