From b5e57c914b943ca32a8ae51078c75eddbbea2bff Mon Sep 17 00:00:00 2001 From: Andreas Oberritter Date: Tue, 16 Apr 2013 20:22:15 +0100 Subject: [PATCH] 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 Reviewed-by: Robert Bragg (cherry picked from commit 323fe1887487f19c3e26aa6b7644de31d8d0a532) --- cogl/winsys/cogl-winsys-egl-wayland.c | 44 +++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) diff --git a/cogl/winsys/cogl-winsys-egl-wayland.c b/cogl/winsys/cogl-winsys-egl-wayland.c index feeb529d0..eaf97af77 100644 --- a/cogl/winsys/cogl-winsys-egl-wayland.c +++ b/cogl/winsys/cogl-winsys-egl-wayland.c @@ -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; }