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
display_handle_global (struct wl_display *display,
registry_handle_global (void *data,
struct wl_registry *registry,
uint32_t id,
const char *interface,
uint32_t version,
void *data)
uint32_t version)
{
ClutterBackendWayland *backend_wayland = data;
if (strcmp (interface, "wl_compositor") == 0)
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)
{
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)
{
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)
{
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)
{
/* FIXME: Support multiple outputs */
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,
&wayland_output_listener,
backend_wayland);
}
}
static const struct wl_registry_listener wayland_registry_listener = {
registry_handle_global,
};
static gboolean
clutter_backend_wayland_post_parse (ClutterBackend *backend,
GError **error)
@ -179,6 +183,9 @@ clutter_backend_wayland_post_parse (ClutterBackend *backend,
return FALSE;
}
backend_wayland->wayland_registry =
wl_display_get_registry (backend_wayland->wayland_display);
backend_wayland->wayland_source =
_clutter_event_source_wayland_new (backend_wayland->wayland_display);
g_source_attach (backend_wayland->wayland_source, NULL);
@ -200,8 +207,8 @@ clutter_backend_wayland_post_parse (ClutterBackend *backend,
_clutter_device_manager_wayland_new (backend);
/* Set up listener so we'll catch all events. */
wl_display_add_global_listener (backend_wayland->wayland_display,
display_handle_global,
wl_registry_add_listener (backend_wayland->wayland_registry,
&wayland_registry_listener,
backend_wayland);
/* Wait until we have been notified about the compositor and shell objects */

View File

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

View File

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

View File

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

View File

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