Move flush_wayland_fd to input/common/wayland_common.c

This commit is contained in:
twinaphex 2020-07-14 16:17:43 +02:00
parent 4009919eca
commit b7c2cbc6b2
2 changed files with 26 additions and 26 deletions

View File

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

View File

@ -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);
}
}