wayland: fix deprecation warnings

Replace the deprecated APIs with the modern variants (which
also give us full control on the versioning).
Also, note that we only support version 2 of wl_seat. Version
3 is for multiple pointer/keyboards for a client, but
we don't implement that yet. If a client requests version 3
of wl_seat or make a version 3 request, it will get a protocol error.

https://bugzilla.gnome.org/show_bug.cgi?id=707851
This commit is contained in:
Giovanni Campagna 2013-09-10 13:03:37 +02:00
parent 72b6699efb
commit 95a9655412
2 changed files with 31 additions and 33 deletions

View File

@ -109,12 +109,11 @@ meta_wayland_data_source_send_offer (MetaWaylandDataSource *source,
offer->source = source;
offer->source_destroy_listener.notify = destroy_offer_data_source;
offer->resource = wl_client_add_object (wl_resource_get_client (target),
offer->resource = wl_resource_create (wl_resource_get_client (target),
&wl_data_offer_interface,
&data_offer_interface,
0,
offer);
wl_resource_set_destructor (offer->resource, destroy_data_offer);
MIN (1, wl_resource_get_version (target)), 0);
wl_resource_set_implementation (offer->resource, &data_offer_interface,
offer, destroy_data_offer);
wl_resource_add_destroy_listener (source->resource,
&offer->source_destroy_listener);
@ -466,12 +465,10 @@ create_data_source (struct wl_client *client,
return;
}
source->resource = wl_client_add_object (client,
&wl_data_source_interface,
&data_source_interface,
id,
source);
wl_resource_set_destructor (source->resource, destroy_data_source);
source->resource = wl_resource_create (client, &wl_data_source_interface,
MIN (1, wl_resource_get_version (resource)), id);
wl_resource_set_implementation (source->resource, &data_source_interface,
source, destroy_data_source);
source->accept = client_source_accept;
source->send = client_source_send;
@ -494,11 +491,10 @@ get_data_device (struct wl_client *client,
MetaWaylandSeat *seat = wl_resource_get_user_data (seat_resource);
struct wl_resource *resource;
resource = wl_client_add_object (client, &wl_data_device_interface,
&data_device_interface, id, seat);
resource = wl_resource_create (client, &wl_data_device_interface,
MIN (1, wl_resource_get_version (manager_resource)), id);
wl_resource_set_implementation (resource, &data_device_interface, seat, unbind_data_device);
wl_list_insert (&seat->drag_resource_list, wl_resource_get_link (resource));
wl_resource_set_destructor (resource, unbind_data_device);
}
static const struct wl_data_device_manager_interface manager_interface = {
@ -510,8 +506,10 @@ static void
bind_manager (struct wl_client *client,
void *data, guint32 version, guint32 id)
{
wl_client_add_object (client, &wl_data_device_manager_interface,
&manager_interface, id, NULL);
struct wl_resource *resource;
resource = wl_resource_create (client, &wl_data_device_manager_interface, MIN (version, 1), id);
wl_resource_set_implementation (resource, &manager_interface, NULL, NULL);
}
void
@ -540,8 +538,8 @@ meta_wayland_data_device_set_keyboard_focus (MetaWaylandSeat *seat)
int
meta_wayland_data_device_manager_init (struct wl_display *display)
{
if (wl_display_add_global (display,
&wl_data_device_manager_interface,
if (wl_global_create (display,
&wl_data_device_manager_interface, 1,
NULL, bind_manager) == NULL)
return -1;

View File

@ -175,10 +175,10 @@ seat_get_pointer (struct wl_client *client,
MetaWaylandSeat *seat = wl_resource_get_user_data (resource);
struct wl_resource *cr;
cr = wl_client_add_object (client, &wl_pointer_interface,
&pointer_interface, id, seat);
cr = wl_resource_create (client, &wl_pointer_interface,
MIN (wl_resource_get_version (resource), 2), id);
wl_resource_set_implementation (cr, &pointer_interface, seat, unbind_resource);
wl_list_insert (&seat->pointer.resource_list, wl_resource_get_link (cr));
wl_resource_set_destructor (cr, unbind_resource);
if (seat->pointer.focus &&
wl_resource_get_client (seat->pointer.focus->resource) == client)
@ -205,9 +205,10 @@ seat_get_keyboard (struct wl_client *client,
MetaWaylandSeat *seat = wl_resource_get_user_data (resource);
struct wl_resource *cr;
cr = wl_client_add_object (client, &wl_keyboard_interface, NULL, id, seat);
cr = wl_resource_create (client, &wl_keyboard_interface,
MIN (wl_resource_get_version (resource), 2), id);
wl_resource_set_implementation (cr, NULL, seat, unbind_resource);
wl_list_insert (&seat->keyboard.resource_list, wl_resource_get_link (cr));
wl_resource_set_destructor (cr, unbind_resource);
wl_keyboard_send_keymap (cr,
WL_KEYBOARD_KEYMAP_FORMAT_XKB_V1,
@ -248,17 +249,16 @@ bind_seat (struct wl_client *client,
MetaWaylandSeat *seat = data;
struct wl_resource *resource;
resource = wl_client_add_object (client,
&wl_seat_interface,
&seat_interface,
id,
data);
resource = wl_resource_create (client, &wl_seat_interface, MIN (version, 2), id);
wl_resource_set_implementation (resource, &seat_interface, seat, unbind_resource);
wl_list_insert (&seat->base_resource_list, wl_resource_get_link (resource));
wl_resource_set_destructor (resource, unbind_resource);
wl_seat_send_capabilities (resource,
WL_SEAT_CAPABILITY_POINTER |
WL_SEAT_CAPABILITY_KEYBOARD);
if (version >= 2)
wl_seat_send_name (resource, "seat0");
}
static void
@ -297,7 +297,7 @@ meta_wayland_seat_new (struct wl_display *display,
seat->hotspot_x = 16;
seat->hotspot_y = 16;
wl_display_add_global (display, &wl_seat_interface, seat, bind_seat);
wl_global_create (display, &wl_seat_interface, 2, seat, bind_seat);
return seat;
}