wayland: Port to new protocol

This commit is contained in:
Rob Bradford 2012-10-12 18:54:25 +01:00
parent 4316592c2f
commit cbab0a62ad
5 changed files with 26 additions and 27 deletions

View File

@ -126,17 +126,17 @@ static const struct wl_output_listener wayland_output_listener = {
static void static void
display_handle_global (struct wl_display *display, registry_handle_global (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)
{ {
ClutterBackendWayland *backend_wayland = data; ClutterBackendWayland *backend_wayland = data;
if (strcmp (interface, "wl_compositor") == 0) if (strcmp (interface, "wl_compositor") == 0)
backend_wayland->wayland_compositor = backend_wayland->wayland_compositor =
wl_display_bind (display, id, &wl_compositor_interface); wl_registry_bind (registry, id, &wl_compositor_interface, 1);
else if (strcmp (interface, "wl_seat") == 0) else if (strcmp (interface, "wl_seat") == 0)
{ {
ClutterDeviceManager *device_manager = backend_wayland->device_manager; ClutterDeviceManager *device_manager = backend_wayland->device_manager;
@ -145,24 +145,28 @@ display_handle_global (struct wl_display *display,
else if (strcmp (interface, "wl_shell") == 0) else if (strcmp (interface, "wl_shell") == 0)
{ {
backend_wayland->wayland_shell = backend_wayland->wayland_shell =
wl_display_bind (display, id, &wl_shell_interface); wl_registry_bind (registry, id, &wl_shell_interface, 1);
} }
else if (strcmp (interface, "wl_shm") == 0) else if (strcmp (interface, "wl_shm") == 0)
{ {
backend_wayland->wayland_shm = backend_wayland->wayland_shm =
wl_display_bind (display, id, &wl_shm_interface); wl_registry_bind (registry, id, &wl_shm_interface, 1);
} }
else if (strcmp (interface, "wl_output") == 0) else if (strcmp (interface, "wl_output") == 0)
{ {
/* FIXME: Support multiple outputs */ /* FIXME: Support multiple outputs */
backend_wayland->wayland_output = backend_wayland->wayland_output =
wl_display_bind (display, id, &wl_output_interface); wl_registry_bind (registry, id, &wl_output_interface, 1);
wl_output_add_listener (backend_wayland->wayland_output, wl_output_add_listener (backend_wayland->wayland_output,
&wayland_output_listener, &wayland_output_listener,
backend_wayland); backend_wayland);
} }
} }
static const struct wl_registry_listener wayland_registry_listener = {
registry_handle_global,
};
static gboolean static gboolean
clutter_backend_wayland_post_parse (ClutterBackend *backend, clutter_backend_wayland_post_parse (ClutterBackend *backend,
GError **error) GError **error)
@ -179,6 +183,9 @@ clutter_backend_wayland_post_parse (ClutterBackend *backend,
return FALSE; return FALSE;
} }
backend_wayland->wayland_registry =
wl_display_get_registry (backend_wayland->wayland_display);
backend_wayland->wayland_source = backend_wayland->wayland_source =
_clutter_event_source_wayland_new (backend_wayland->wayland_display); _clutter_event_source_wayland_new (backend_wayland->wayland_display);
g_source_attach (backend_wayland->wayland_source, NULL); g_source_attach (backend_wayland->wayland_source, NULL);
@ -200,9 +207,9 @@ clutter_backend_wayland_post_parse (ClutterBackend *backend,
_clutter_device_manager_wayland_new (backend); _clutter_device_manager_wayland_new (backend);
/* Set up listener so we'll catch all events. */ /* Set up listener so we'll catch all events. */
wl_display_add_global_listener (backend_wayland->wayland_display, wl_registry_add_listener (backend_wayland->wayland_registry,
display_handle_global, &wayland_registry_listener,
backend_wayland); backend_wayland);
/* Wait until we have been notified about the compositor and shell objects */ /* Wait until we have been notified about the compositor and shell objects */
while (!(backend_wayland->wayland_compositor && while (!(backend_wayland->wayland_compositor &&

View File

@ -56,6 +56,7 @@ struct _ClutterBackendWayland
ClutterDeviceManager *device_manager; ClutterDeviceManager *device_manager;
struct wl_display *wayland_display; struct wl_display *wayland_display;
struct wl_registry *wayland_registry;
struct wl_compositor *wayland_compositor; struct wl_compositor *wayland_compositor;
struct wl_shell *wayland_shell; struct wl_shell *wayland_shell;
struct wl_shm *wayland_shm; struct wl_shm *wayland_shm;

View File

@ -162,8 +162,8 @@ _clutter_device_manager_wayland_add_input_group (ClutterDeviceManager *manager,
NULL); NULL);
device->input_device = device->input_device =
wl_display_bind (backend_wayland->wayland_display, id, wl_registry_bind (backend_wayland->wayland_registry, id,
&wl_seat_interface); &wl_seat_interface, 1);
wl_seat_add_listener (device->input_device, wl_seat_add_listener (device->input_device,
&_clutter_seat_wayland_listener, &_clutter_seat_wayland_listener,
device); device);

View File

@ -42,7 +42,6 @@ typedef struct _ClutterEventSourceWayland
{ {
GSource source; GSource source;
GPollFD pfd; GPollFD pfd;
uint32_t mask;
struct wl_display *display; struct wl_display *display;
} ClutterEventSourceWayland; } ClutterEventSourceWayland;
@ -95,7 +94,7 @@ clutter_event_source_wayland_dispatch (GSource *base,
if (source->pfd.revents) if (source->pfd.revents)
{ {
wl_display_iterate (source->display, WL_DISPLAY_READABLE); wl_display_dispatch (source->display);
source->pfd.revents = 0; source->pfd.revents = 0;
} }
@ -120,15 +119,6 @@ static GSourceFuncs clutter_event_source_wayland_funcs = {
NULL NULL
}; };
static int
clutter_event_source_wayland_update (uint32_t mask, void *data)
{
ClutterEventSourceWayland *source = data;
source->mask = mask;
return 0;
}
GSource * GSource *
_clutter_event_source_wayland_new (struct wl_display *display) _clutter_event_source_wayland_new (struct wl_display *display)
@ -140,8 +130,7 @@ _clutter_event_source_wayland_new (struct wl_display *display)
sizeof (ClutterEventSourceWayland)); sizeof (ClutterEventSourceWayland));
source->display = display; source->display = display;
source->pfd.fd = source->pfd.fd =
wl_display_get_fd (display, wl_display_get_fd (display);
clutter_event_source_wayland_update, source);
source->pfd.events = G_IO_IN | G_IO_ERR; source->pfd.events = G_IO_IN | G_IO_ERR;
g_source_add_poll (&source->source, &source->pfd); g_source_add_poll (&source->source, &source->pfd);

View File

@ -365,6 +365,8 @@ clutter_wayland_handle_pointer_enter (void *data,
0, 0,
32, /* XXX: FFS */ 32, /* XXX: FFS */
32); 32);
wl_surface_commit (backend_wayland->cursor_surface);
} }
static void static void