mirror of
https://github.com/brl/mutter.git
synced 2025-01-11 04:02:36 +00:00
wayland: implement poll_get_info and poll_dispatch
Call wl_display_dispatch on POLLIN. This follows the implementation in weston/clients/window.c and improves integration of input events, at least. Signed-off-by: Andreas Oberritter <obi@saftware.de> Reviewed-by: Robert Bragg <robert@linux.intel.com> (cherry picked from commit 323fe1887487f19c3e26aa6b7644de31d8d0a532)
This commit is contained in:
parent
8d6d1a4daa
commit
b5e57c914b
@ -50,6 +50,7 @@ typedef struct _CoglRendererWayland
|
||||
struct wl_compositor *wayland_compositor;
|
||||
struct wl_shell *wayland_shell;
|
||||
struct wl_registry *wayland_registry;
|
||||
CoglPollFD poll_fd;
|
||||
} CoglRendererWayland;
|
||||
|
||||
typedef struct _CoglDisplayWayland
|
||||
@ -175,6 +176,10 @@ _cogl_winsys_renderer_connect (CoglRenderer *renderer,
|
||||
if (!_cogl_winsys_egl_renderer_connect_common (renderer, error))
|
||||
goto error;
|
||||
|
||||
wayland_renderer->poll_fd.fd =
|
||||
wl_display_get_fd(wayland_renderer->wayland_display);
|
||||
wayland_renderer->poll_fd.events = COGL_POLL_FD_EVENT_IN;
|
||||
|
||||
return TRUE;
|
||||
|
||||
error:
|
||||
@ -566,6 +571,42 @@ cogl_wayland_onscreen_resize (CoglOnscreen *onscreen,
|
||||
_cogl_framebuffer_winsys_update_size (fb, width, height);
|
||||
}
|
||||
|
||||
static void
|
||||
_cogl_winsys_poll_get_info (CoglContext *context,
|
||||
CoglPollFD **poll_fds,
|
||||
int *n_poll_fds,
|
||||
int64_t *timeout)
|
||||
{
|
||||
CoglDisplay *display = context->display;
|
||||
CoglRenderer *renderer = display->renderer;
|
||||
CoglRendererEGL *egl_renderer = renderer->winsys;
|
||||
CoglRendererWayland *wayland_renderer = egl_renderer->platform;
|
||||
|
||||
*poll_fds = &wayland_renderer->poll_fd;
|
||||
*n_poll_fds = 1;
|
||||
*timeout = -1;
|
||||
}
|
||||
|
||||
static void
|
||||
_cogl_winsys_poll_dispatch (CoglContext *context,
|
||||
const CoglPollFD *poll_fds,
|
||||
int n_poll_fds)
|
||||
{
|
||||
CoglDisplay *display = context->display;
|
||||
CoglRenderer *renderer = display->renderer;
|
||||
CoglRendererEGL *egl_renderer = renderer->winsys;
|
||||
CoglRendererWayland *wayland_renderer = egl_renderer->platform;
|
||||
int i;
|
||||
|
||||
for (i = 0; i < n_poll_fds; i++)
|
||||
if (poll_fds[i].fd == wayland_renderer->poll_fd.fd)
|
||||
{
|
||||
if (poll_fds[i].revents & COGL_POLL_FD_EVENT_IN)
|
||||
wl_display_dispatch (wayland_renderer->wayland_display);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static const CoglWinsysEGLVtable
|
||||
_cogl_winsys_egl_vtable =
|
||||
{
|
||||
@ -600,6 +641,9 @@ _cogl_winsys_egl_wayland_get_vtable (void)
|
||||
|
||||
vtable.onscreen_swap_buffers = _cogl_winsys_onscreen_swap_buffers;
|
||||
|
||||
vtable.poll_get_info = _cogl_winsys_poll_get_info;
|
||||
vtable.poll_dispatch = _cogl_winsys_poll_dispatch;
|
||||
|
||||
vtable_inited = TRUE;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user