[Cogl] [PATCH] stash: wayland 0.85 hacks
Robert Bragg
robert at sixbynine.org
Tue Apr 23 16:17:51 PDT 2013
Err, oops, git send-email fail! sorry for the spam :-/
On Wed, Apr 24, 2013 at 12:17 AM, Robert Bragg <robert at sixbynine.org> wrote:
> From: Robert Bragg <robert at linux.intel.com>
>
> ---
> cogl/winsys/cogl-winsys-egl-wayland.c | 45 ++++++++++++++++++++++++++++++++++-
> configure.ac | 2 +-
> 2 files changed, 45 insertions(+), 2 deletions(-)
>
> diff --git a/cogl/winsys/cogl-winsys-egl-wayland.c b/cogl/winsys/cogl-winsys-egl-wayland.c
> index eaf97af..67cdc1b 100644
> --- a/cogl/winsys/cogl-winsys-egl-wayland.c
> +++ b/cogl/winsys/cogl-winsys-egl-wayland.c
> @@ -49,7 +49,9 @@ typedef struct _CoglRendererWayland
> struct wl_display *wayland_display;
> struct wl_compositor *wayland_compositor;
> struct wl_shell *wayland_shell;
> +#if WAYLAND_VERSION_MAJOR >= 1
> struct wl_registry *wayland_registry;
> +#endif
> CoglPollFD poll_fd;
> } CoglRendererWayland;
>
> @@ -75,6 +77,7 @@ typedef struct _CoglOnscreenWayland
> CoglBool has_pending;
> } CoglOnscreenWayland;
>
> +#if WAYLAND_VERSION_MAJOR >= 1
> static void
> registry_handle_global_cb (void *data,
> struct wl_registry *registry,
> @@ -93,6 +96,29 @@ registry_handle_global_cb (void *data,
> wl_registry_bind (registry, id, &wl_shell_interface, 1);
> }
>
> +#else /* 0.85 */
> +
> +/* XXX: We are maintaining Wayland 0.85 protocol support until Mutter
> + * has been ported to the 1.x protocol... */
> +static void
> +display_handle_global_cb (struct wl_display *display,
> + uint32_t id,
> + const char *interface,
> + uint32_t version,
> + void *data)
> +{
> + CoglRendererEGL *egl_renderer = (CoglRendererEGL *)data;
> + CoglRendererWayland *wayland_renderer = egl_renderer->platform;
> +
> + if (strcmp (interface, "wl_compositor") == 0)
> + wayland_renderer->wayland_compositor =
> + wl_display_bind (display, id, &wl_compositor_interface);
> + else if (strcmp(interface, "wl_shell") == 0)
> + wayland_renderer->wayland_shell =
> + wl_display_bind (display, id, &wl_shell_interface);
> +}
> +#endif
> +
> static void
> _cogl_winsys_renderer_disconnect (CoglRenderer *renderer)
> {
> @@ -104,9 +130,11 @@ _cogl_winsys_renderer_disconnect (CoglRenderer *renderer)
> g_slice_free (CoglRendererEGL, egl_renderer);
> }
>
> +#if WAYLAND_VERSION_MAJOR >= 1
> static const struct wl_registry_listener registry_listener = {
> registry_handle_global_cb,
> };
> +#endif
>
> static CoglBool
> _cogl_winsys_renderer_connect (CoglRenderer *renderer,
> @@ -152,12 +180,21 @@ _cogl_winsys_renderer_connect (CoglRenderer *renderer,
> goto error;
> }
>
> +#if WAYLAND_VERSION_MAJOR >= 1
> wayland_renderer->wayland_registry =
> wl_display_get_registry (wayland_renderer->wayland_display);
>
> wl_registry_add_listener (wayland_renderer->wayland_registry,
> ®istry_listener,
> egl_renderer);
> +#else
> +
> + /* XXX: We are maintaining Wayland 0.85 protocol support until
> + * Mutter has been ported to the 1.x protocol... */
> + wl_display_add_global_listener (wayland_renderer->wayland_display,
> + display_handle_global_cb,
> + egl_renderer);
> +#endif
> }
>
> /*
> @@ -176,9 +213,11 @@ _cogl_winsys_renderer_connect (CoglRenderer *renderer,
> if (!_cogl_winsys_egl_renderer_connect_common (renderer, error))
> goto error;
>
> +#if WAYLAND_VERSION_MAJOR >= 1
> wayland_renderer->poll_fd.fd =
> - wl_display_get_fd(wayland_renderer->wayland_display);
> + wl_display_get_fd (wayland_renderer->wayland_display);
> wayland_renderer->poll_fd.events = COGL_POLL_FD_EVENT_IN;
> +#endif
>
> return TRUE;
>
> @@ -571,6 +610,7 @@ cogl_wayland_onscreen_resize (CoglOnscreen *onscreen,
> _cogl_framebuffer_winsys_update_size (fb, width, height);
> }
>
> +#if WAYLAND_VERSION_MAJOR >= 1
> static void
> _cogl_winsys_poll_get_info (CoglContext *context,
> CoglPollFD **poll_fds,
> @@ -606,6 +646,7 @@ _cogl_winsys_poll_dispatch (CoglContext *context,
> break;
> }
> }
> +#endif
>
> static const CoglWinsysEGLVtable
> _cogl_winsys_egl_vtable =
> @@ -641,8 +682,10 @@ _cogl_winsys_egl_wayland_get_vtable (void)
>
> vtable.onscreen_swap_buffers = _cogl_winsys_onscreen_swap_buffers;
>
> +#if WAYLAND_VERSION_MAJOR >= 1
> vtable.poll_get_info = _cogl_winsys_poll_get_info;
> vtable.poll_dispatch = _cogl_winsys_poll_dispatch;
> +#endif
>
> vtable_inited = TRUE;
> }
> diff --git a/configure.ac b/configure.ac
> index 3e9742b..96d6fc1 100644
> --- a/configure.ac
> +++ b/configure.ac
> @@ -92,7 +92,7 @@ m4_define([xfixes_req_version], [3])
> m4_define([xcomposite_req_version], [0.4])
> m4_define([xrandr_req_version], [1.2])
> m4_define([cairo_req_version], [1.10])
> -m4_define([wayland_req_version], [1.0.0])
> +m4_define([wayland_req_version], [0.85.0])
>
> dnl These variables get copied into the generated README
> AC_SUBST([GLIB_REQ_VERSION], [glib_req_version])
> --
> 1.8.2.1
>
More information about the Cogl
mailing list