wayland: Port to new Wayland protocol

Reviewed-by: Neil Roberts <neil@linux.intel.com>

(cherry picked from commit db50c3015c589375029a4c26c58db8295bb17bca)
This commit is contained in:
Rob Bradford 2012-10-12 18:50:33 +01:00 committed by Neil Roberts
parent ad05cb37c6
commit 0e33654efb

View File

@ -48,6 +48,7 @@ typedef struct _CoglRendererWayland
struct wl_display *wayland_display; struct wl_display *wayland_display;
struct wl_compositor *wayland_compositor; struct wl_compositor *wayland_compositor;
struct wl_shell *wayland_shell; struct wl_shell *wayland_shell;
struct wl_registry *wayland_registry;
} CoglRendererWayland; } CoglRendererWayland;
typedef struct _CoglDisplayWayland typedef struct _CoglDisplayWayland
@ -73,21 +74,21 @@ typedef struct _CoglOnscreenWayland
} CoglOnscreenWayland; } CoglOnscreenWayland;
static void static void
display_handle_global_cb (struct wl_display *display, registry_handle_global_cb (void *data,
uint32_t id, struct wl_registry *registry,
const char *interface, uint32_t id,
uint32_t version, const char *interface,
void *data) uint32_t version)
{ {
CoglRendererEGL *egl_renderer = (CoglRendererEGL *)data; CoglRendererEGL *egl_renderer = (CoglRendererEGL *)data;
CoglRendererWayland *wayland_renderer = egl_renderer->platform; CoglRendererWayland *wayland_renderer = egl_renderer->platform;
if (strcmp (interface, "wl_compositor") == 0) if (strcmp (interface, "wl_compositor") == 0)
wayland_renderer->wayland_compositor = wayland_renderer->wayland_compositor =
wl_display_bind (display, id, &wl_compositor_interface); wl_registry_bind (registry, id, &wl_compositor_interface, 1);
else if (strcmp(interface, "wl_shell") == 0) else if (strcmp(interface, "wl_shell") == 0)
wayland_renderer->wayland_shell = wayland_renderer->wayland_shell =
wl_display_bind (display, id, &wl_shell_interface); wl_registry_bind (registry, id, &wl_shell_interface, 1);
} }
static void static void
@ -101,6 +102,10 @@ _cogl_winsys_renderer_disconnect (CoglRenderer *renderer)
g_slice_free (CoglRendererEGL, egl_renderer); g_slice_free (CoglRendererEGL, egl_renderer);
} }
static const struct wl_registry_listener registry_listener = {
registry_handle_global_cb,
};
static CoglBool static CoglBool
_cogl_winsys_renderer_connect (CoglRenderer *renderer, _cogl_winsys_renderer_connect (CoglRenderer *renderer,
GError **error) GError **error)
@ -145,9 +150,12 @@ _cogl_winsys_renderer_connect (CoglRenderer *renderer,
goto error; goto error;
} }
wl_display_add_global_listener (wayland_renderer->wayland_display, wayland_renderer->wayland_registry =
display_handle_global_cb, wl_display_get_registry (wayland_renderer->wayland_display);
egl_renderer);
wl_registry_add_listener (wayland_renderer->wayland_registry,
&registry_listener,
egl_renderer);
} }
/* /*