[mutter/wip/wayland-display: 16/62] squash: Prepare for wl_resource becoming opaque (2)
- From: Giovanni Campagna <gcampagna src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [mutter/wip/wayland-display: 16/62] squash: Prepare for wl_resource becoming opaque (2)
- Date: Thu, 8 Aug 2013 08:29:27 +0000 (UTC)
commit a28c2d850720197977e970a86a8a4026ef3d538e
Author: Neil Roberts <neil linux intel com>
Date: Mon Jul 8 18:17:45 2013 +0100
squash: Prepare for wl_resource becoming opaque (2)
wl_client_add_resource is deprecated an wl_resource will soon become
opaque.
This should be squashed into the commit:
“wayland: Add basic input support”
Based on this clayland commit:
https://github.com/clutter-project/clayland/commit/b8e5fe1c9920a9104
src/wayland/meta-wayland-data-device.c | 116 +++++++++++++++-----------------
src/wayland/meta-wayland-keyboard.c | 29 +++++----
src/wayland/meta-wayland-pointer.c | 36 +++++-----
src/wayland/meta-wayland-private.h | 4 +-
src/wayland/meta-wayland-seat.c | 35 +++++-----
5 files changed, 109 insertions(+), 111 deletions(-)
---
diff --git a/src/wayland/meta-wayland-data-device.c b/src/wayland/meta-wayland-data-device.c
index f488880..62b9265 100644
--- a/src/wayland/meta-wayland-data-device.c
+++ b/src/wayland/meta-wayland-data-device.c
@@ -38,7 +38,7 @@ data_offer_accept (struct wl_client *client,
guint32 serial,
const char *mime_type)
{
- MetaWaylandDataOffer *offer = resource->data;
+ MetaWaylandDataOffer *offer = wl_resource_get_user_data (resource);
/* FIXME: Check that client is currently focused by the input
* device that is currently dragging this data source. Should
@@ -52,7 +52,7 @@ static void
data_offer_receive (struct wl_client *client, struct wl_resource *resource,
const char *mime_type, int32_t fd)
{
- MetaWaylandDataOffer *offer = resource->data;
+ MetaWaylandDataOffer *offer = wl_resource_get_user_data (resource);
if (offer->source)
offer->source->send (offer->source, mime_type, fd);
@@ -75,7 +75,7 @@ static const struct wl_data_offer_interface data_offer_interface = {
static void
destroy_data_offer (struct wl_resource *resource)
{
- MetaWaylandDataOffer *offer = resource->data;
+ MetaWaylandDataOffer *offer = wl_resource_get_user_data (resource);
if (offer->source)
wl_list_remove (&offer->source_destroy_listener.link);
@@ -103,30 +103,31 @@ meta_wayland_data_source_send_offer (MetaWaylandDataSource *source,
if (offer == NULL)
return NULL;
- wl_resource_init (&offer->resource, &wl_data_offer_interface,
- &data_offer_interface, 0, offer);
- offer->resource.destroy = destroy_data_offer;
-
offer->source = source;
offer->source_destroy_listener.notify = destroy_offer_data_source;
- wl_signal_add (&source->resource.destroy_signal,
- &offer->source_destroy_listener);
- wl_client_add_resource (target->client, &offer->resource);
+ offer->resource = wl_client_add_object (wl_resource_get_client (target),
+ &wl_data_offer_interface,
+ &data_offer_interface,
+ 0,
+ offer);
+ wl_resource_set_destructor (offer->resource, destroy_data_offer);
+ wl_resource_add_destroy_listener (source->resource,
+ &offer->source_destroy_listener);
- wl_data_device_send_data_offer (target, &offer->resource);
+ wl_data_device_send_data_offer (target, offer->resource);
wl_array_for_each (p, &source->mime_types)
- wl_data_offer_send_offer (&offer->resource, *p);
+ wl_data_offer_send_offer (offer->resource, *p);
- return &offer->resource;
+ return offer->resource;
}
static void
data_source_offer (struct wl_client *client,
struct wl_resource *resource, const char *type)
{
- MetaWaylandDataSource *source = resource->data;
+ MetaWaylandDataSource *source = wl_resource_get_user_data (resource);
char **p;
p = wl_array_add (&source->mime_types, sizeof *p);
@@ -147,20 +148,6 @@ static struct wl_data_source_interface data_source_interface = {
data_source_destroy
};
-static struct wl_resource *
-find_resource (struct wl_list *list, struct wl_client *client)
-{
- struct wl_resource *r;
-
- wl_list_for_each (r, list, link)
- {
- if (r->client == client)
- return r;
- }
-
- return NULL;
-}
-
static void
destroy_drag_focus (struct wl_listener *listener, void *data)
{
@@ -192,27 +179,28 @@ drag_grab_focus (MetaWaylandPointerGrab *grab,
return;
if (!seat->drag_data_source &&
- surface->resource.client != seat->drag_client)
+ wl_resource_get_client (surface->resource) != seat->drag_client)
return;
- resource = find_resource (&seat->drag_resource_list,
- surface->resource.client);
+ resource =
+ wl_resource_find_for_client (&seat->drag_resource_list,
+ wl_resource_get_client (surface->resource));
if (!resource)
return;
- display = wl_client_get_display (resource->client);
+ display = wl_client_get_display (wl_resource_get_client (resource));
serial = wl_display_next_serial (display);
if (seat->drag_data_source)
offer = meta_wayland_data_source_send_offer (seat->drag_data_source,
resource);
- wl_data_device_send_enter (resource, serial, &surface->resource,
+ wl_data_device_send_enter (resource, serial, surface->resource,
x, y, offer);
seat->drag_focus = surface;
seat->drag_focus_listener.notify = destroy_drag_focus;
- wl_signal_add (&resource->destroy_signal, &seat->drag_focus_listener);
+ wl_resource_add_destroy_listener (resource, &seat->drag_focus_listener);
seat->drag_focus_resource = resource;
grab->focus = surface;
}
@@ -298,7 +286,7 @@ data_device_start_drag (struct wl_client *client,
struct wl_resource *origin_resource,
struct wl_resource *icon_resource, guint32 serial)
{
- MetaWaylandSeat *seat = resource->data;
+ MetaWaylandSeat *seat = wl_resource_get_user_data (resource);
/* FIXME: Check that client has implicit grab on the origin
* surface that matches the given time. */
@@ -312,18 +300,18 @@ data_device_start_drag (struct wl_client *client,
if (source_resource)
{
- seat->drag_data_source = source_resource->data;
+ seat->drag_data_source = wl_resource_get_user_data (source_resource);
seat->drag_data_source_listener.notify = destroy_data_device_source;
- wl_signal_add (&source_resource->destroy_signal,
- &seat->drag_data_source_listener);
+ wl_resource_add_destroy_listener (source_resource,
+ &seat->drag_data_source_listener);
}
if (icon_resource)
{
- seat->drag_surface = icon_resource->data;
+ seat->drag_surface = wl_resource_get_user_data (icon_resource);
seat->drag_icon_listener.notify = destroy_data_device_icon;
- wl_signal_add (&icon_resource->destroy_signal,
- &seat->drag_icon_listener);
+ wl_resource_add_destroy_listener (icon_resource,
+ &seat->drag_icon_listener);
wl_signal_emit (&seat->drag_icon_signal, icon_resource);
}
@@ -347,7 +335,9 @@ destroy_selection_data_source (struct wl_listener *listener, void *data)
if (focus)
{
- data_device = find_resource (&seat->drag_resource_list, focus->client);
+ data_device =
+ wl_resource_find_for_client (&seat->drag_resource_list,
+ wl_resource_get_client (focus));
if (data_device)
wl_data_device_send_selection (data_device, NULL);
}
@@ -381,7 +371,9 @@ meta_wayland_seat_set_selection (MetaWaylandSeat *seat,
if (focus)
{
- data_device = find_resource (&seat->drag_resource_list, focus->client);
+ data_device =
+ wl_resource_find_for_client (&seat->drag_resource_list,
+ wl_resource_get_client (focus));
if (data_device && source)
{
offer =
@@ -401,8 +393,8 @@ meta_wayland_seat_set_selection (MetaWaylandSeat *seat,
{
seat->selection_data_source_listener.notify =
destroy_selection_data_source;
- wl_signal_add (&source->resource.destroy_signal,
- &seat->selection_data_source_listener);
+ wl_resource_add_destroy_listener (source->resource,
+ &seat->selection_data_source_listener);
}
}
@@ -416,8 +408,8 @@ data_device_set_selection (struct wl_client *client,
return;
/* FIXME: Store serial and check against incoming serial here. */
- meta_wayland_seat_set_selection (resource->data,
- source_resource->data,
+ meta_wayland_seat_set_selection (wl_resource_get_user_data (resource),
+ wl_resource_get_user_data (source_resource),
serial);
}
@@ -435,29 +427,27 @@ destroy_data_source (struct wl_resource *resource)
wl_array_for_each (p, &source->mime_types) free (*p);
wl_array_release (&source->mime_types);
-
- source->resource.object.id = 0;
}
static void
client_source_accept (MetaWaylandDataSource *source,
guint32 time, const char *mime_type)
{
- wl_data_source_send_target (&source->resource, mime_type);
+ wl_data_source_send_target (source->resource, mime_type);
}
static void
client_source_send (MetaWaylandDataSource *source,
const char *mime_type, int32_t fd)
{
- wl_data_source_send_send (&source->resource, mime_type, fd);
+ wl_data_source_send_send (source->resource, mime_type, fd);
close (fd);
}
static void
client_source_cancel (MetaWaylandDataSource *source)
{
- wl_data_source_send_cancelled (&source->resource);
+ wl_data_source_send_cancelled (source->resource);
}
static void
@@ -473,23 +463,24 @@ create_data_source (struct wl_client *client,
return;
}
- wl_resource_init (&source->resource, &wl_data_source_interface,
- &data_source_interface, id, source);
- source->resource.destroy = destroy_data_source;
+ 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->accept = client_source_accept;
source->send = client_source_send;
source->cancel = client_source_cancel;
wl_array_init (&source->mime_types);
- wl_client_add_resource (client, &source->resource);
}
static void
unbind_data_device (struct wl_resource *resource)
{
- wl_list_remove (&resource->link);
- free (resource);
+ wl_list_remove (wl_resource_get_link (resource));
}
static void
@@ -497,14 +488,14 @@ get_data_device (struct wl_client *client,
struct wl_resource *manager_resource,
guint32 id, struct wl_resource *seat_resource)
{
- MetaWaylandSeat *seat = seat_resource->data;
+ 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);
- wl_list_insert (&seat->drag_resource_list, &resource->link);
- resource->destroy = 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 = {
@@ -530,7 +521,8 @@ meta_wayland_data_device_set_keyboard_focus (MetaWaylandSeat *seat)
if (!focus)
return;
- data_device = find_resource (&seat->drag_resource_list, focus->client);
+ data_device = wl_resource_find_for_client (&seat->drag_resource_list,
+ wl_resource_get_client (focus));
if (!data_device)
return;
diff --git a/src/wayland/meta-wayland-keyboard.c b/src/wayland/meta-wayland-keyboard.c
index 13d23bc..19144a1 100644
--- a/src/wayland/meta-wayland-keyboard.c
+++ b/src/wayland/meta-wayland-keyboard.c
@@ -253,7 +253,8 @@ default_grab_key (MetaWaylandKeyboardGrab *grab,
resource = keyboard->focus_resource;
if (resource)
{
- struct wl_display *display = wl_client_get_display (resource->client);
+ struct wl_client *client = wl_resource_get_client (resource);
+ struct wl_display *display = wl_client_get_display (client);
serial = wl_display_next_serial (display);
wl_keyboard_send_key (resource, serial, time, key, state);
}
@@ -262,18 +263,17 @@ default_grab_key (MetaWaylandKeyboardGrab *grab,
static struct wl_resource *
find_resource_for_surface (struct wl_list *list, MetaWaylandSurface *surface)
{
- struct wl_resource *r;
+ struct wl_client *client;
if (!surface)
return NULL;
- wl_list_for_each (r, list, link)
- {
- if (r->client == surface->resource.client)
- return r;
- }
+ if (!surface->resource)
+ return NULL;
+
+ client = wl_resource_get_client (surface->resource);
- return NULL;
+ return wl_resource_find_for_client (list, client);
}
static void
@@ -483,11 +483,13 @@ meta_wayland_keyboard_set_focus (MetaWaylandKeyboard *keyboard,
if (keyboard->focus_resource && keyboard->focus != surface)
{
struct wl_display *display;
+ struct wl_client *client;
resource = keyboard->focus_resource;
- display = wl_client_get_display (resource->client);
+ client = wl_resource_get_client (resource);
+ display = wl_client_get_display (client);
serial = wl_display_next_serial (display);
- wl_keyboard_send_leave (resource, serial, &keyboard->focus->resource);
+ wl_keyboard_send_leave (resource, serial, keyboard->focus->resource);
wl_list_remove (&keyboard->focus_listener.link);
}
@@ -495,18 +497,19 @@ meta_wayland_keyboard_set_focus (MetaWaylandKeyboard *keyboard,
if (resource &&
(keyboard->focus != surface || keyboard->focus_resource != resource))
{
+ struct wl_client *client = wl_resource_get_client (resource);
struct wl_display *display;
- display = wl_client_get_display (resource->client);
+ display = wl_client_get_display (client);
serial = wl_display_next_serial (display);
wl_keyboard_send_modifiers (resource, serial,
keyboard->modifiers.mods_depressed,
keyboard->modifiers.mods_latched,
keyboard->modifiers.mods_locked,
keyboard->modifiers.group);
- wl_keyboard_send_enter (resource, serial, &surface->resource,
+ wl_keyboard_send_enter (resource, serial, surface->resource,
&keyboard->keys);
- wl_signal_add (&resource->destroy_signal, &keyboard->focus_listener);
+ wl_resource_add_destroy_listener (resource, &keyboard->focus_listener);
keyboard->focus_serial = serial;
}
diff --git a/src/wayland/meta-wayland-pointer.c b/src/wayland/meta-wayland-pointer.c
index c7c2ab9..2254bc3 100644
--- a/src/wayland/meta-wayland-pointer.c
+++ b/src/wayland/meta-wayland-pointer.c
@@ -99,7 +99,8 @@ default_grab_button (MetaWaylandPointerGrab *grab,
resource = pointer->focus_resource;
if (resource)
{
- struct wl_display *display = wl_client_get_display (resource->client);
+ struct wl_client *client = wl_resource_get_client (resource);
+ struct wl_display *display = wl_client_get_display (client);
serial = wl_display_next_serial (display);
wl_pointer_send_button (resource, serial, time, button, state_w);
}
@@ -142,24 +143,23 @@ meta_wayland_pointer_release (MetaWaylandPointer *pointer)
static struct wl_resource *
find_resource_for_surface (struct wl_list *list, MetaWaylandSurface *surface)
{
- struct wl_resource *r;
+ struct wl_client *client;
if (!surface)
return NULL;
- wl_list_for_each (r, list, link)
- {
- if (r->client == surface->resource.client)
- return r;
- }
+ if (!surface->resource)
+ return NULL;
+
+ client = wl_resource_get_client (surface->resource);
- return NULL;
+ return wl_resource_find_for_client (list, client);
}
void
meta_wayland_pointer_set_focus (MetaWaylandPointer *pointer,
- MetaWaylandSurface *surface,
- wl_fixed_t sx, wl_fixed_t sy)
+ MetaWaylandSurface *surface,
+ wl_fixed_t sx, wl_fixed_t sy)
{
MetaWaylandSeat *seat = meta_wayland_pointer_get_seat (pointer);
MetaWaylandKeyboard *kbd = &seat->keyboard;
@@ -169,9 +169,10 @@ meta_wayland_pointer_set_focus (MetaWaylandPointer *pointer,
resource = pointer->focus_resource;
if (resource && pointer->focus != surface)
{
- struct wl_display *display = wl_client_get_display (resource->client);
+ struct wl_client *client = wl_resource_get_client (resource);
+ struct wl_display *display = wl_client_get_display (client);
serial = wl_display_next_serial (display);
- wl_pointer_send_leave (resource, serial, &pointer->focus->resource);
+ wl_pointer_send_leave (resource, serial, pointer->focus->resource);
wl_list_remove (&pointer->focus_listener.link);
}
@@ -179,7 +180,8 @@ meta_wayland_pointer_set_focus (MetaWaylandPointer *pointer,
if (resource &&
(pointer->focus != surface || pointer->focus_resource != resource))
{
- struct wl_display *display = wl_client_get_display (resource->client);
+ struct wl_client *client = wl_resource_get_client (resource);
+ struct wl_display *display = wl_client_get_display (client);
serial = wl_display_next_serial (display);
if (kbd)
{
@@ -194,8 +196,8 @@ meta_wayland_pointer_set_focus (MetaWaylandPointer *pointer,
kbd->modifiers.group);
}
}
- wl_pointer_send_enter (resource, serial, &surface->resource, sx, sy);
- wl_signal_add (&resource->destroy_signal, &pointer->focus_listener);
+ wl_pointer_send_enter (resource, serial, surface->resource, sx, sy);
+ wl_resource_add_destroy_listener (resource, &pointer->focus_listener);
pointer->focus_serial = serial;
}
@@ -252,7 +254,7 @@ meta_wayland_pointer_set_current (MetaWaylandPointer *pointer,
if (!surface)
return;
- wl_signal_add (&surface->resource.destroy_signal,
- &pointer->current_listener);
+ wl_resource_add_destroy_listener (surface->resource,
+ &pointer->current_listener);
pointer->current_listener.notify = current_surface_destroy;
}
diff --git a/src/wayland/meta-wayland-private.h b/src/wayland/meta-wayland-private.h
index b6b04fc..c33f7f9 100644
--- a/src/wayland/meta-wayland-private.h
+++ b/src/wayland/meta-wayland-private.h
@@ -292,14 +292,14 @@ struct _MetaWaylandKeyboard
struct _MetaWaylandDataOffer
{
- struct wl_resource resource;
+ struct wl_resource *resource;
MetaWaylandDataSource *source;
struct wl_listener source_destroy_listener;
};
struct _MetaWaylandDataSource
{
- struct wl_resource resource;
+ struct wl_resource *resource;
struct wl_array mime_types;
void (*accept) (MetaWaylandDataSource * source,
diff --git a/src/wayland/meta-wayland-seat.c b/src/wayland/meta-wayland-seat.c
index e39e971..9fb285a 100644
--- a/src/wayland/meta-wayland-seat.c
+++ b/src/wayland/meta-wayland-seat.c
@@ -42,8 +42,7 @@
static void
unbind_resource (struct wl_resource *resource)
{
- wl_list_remove (&resource->link);
- free (resource);
+ wl_list_remove (wl_resource_get_link (resource));
}
static void
@@ -115,14 +114,16 @@ pointer_set_cursor (struct wl_client *client,
struct wl_resource *surface_resource,
int32_t x, int32_t y)
{
- MetaWaylandSeat *seat = resource->data;
+ MetaWaylandSeat *seat = wl_resource_get_user_data (resource);
MetaWaylandSurface *surface;
- surface = surface_resource ? surface_resource->data : NULL;
+ surface = (surface_resource ?
+ wl_resource_get_user_data (surface_resource) :
+ NULL);
if (seat->pointer.focus == NULL)
return;
- if (seat->pointer.focus->resource.client != client)
+ if (wl_resource_get_client (seat->pointer.focus->resource) != client)
return;
if (seat->pointer.focus_serial - serial > G_MAXUINT32 / 2)
return;
@@ -137,8 +138,8 @@ pointer_set_cursor (struct wl_client *client,
if (!surface)
return;
- wl_signal_add (&surface->resource.destroy_signal,
- &seat->sprite_destroy_listener);
+ wl_resource_add_destroy_listener (surface->resource,
+ &seat->sprite_destroy_listener);
seat->sprite = surface;
@@ -158,16 +159,16 @@ seat_get_pointer (struct wl_client *client,
struct wl_resource *resource,
uint32_t id)
{
- MetaWaylandSeat *seat = resource->data;
+ 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);
- wl_list_insert (&seat->pointer.resource_list, &cr->link);
- cr->destroy = 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 &&
- seat->pointer.focus->resource.client == client)
+ wl_resource_get_client (seat->pointer.focus->resource) == client)
{
MetaWaylandSurface *surface;
wl_fixed_t sx, sy;
@@ -188,12 +189,12 @@ seat_get_keyboard (struct wl_client *client,
struct wl_resource *resource,
uint32_t id)
{
- MetaWaylandSeat *seat = resource->data;
+ MetaWaylandSeat *seat = wl_resource_get_user_data (resource);
struct wl_resource *cr;
cr = wl_client_add_object (client, &wl_keyboard_interface, NULL, id, seat);
- wl_list_insert (&seat->keyboard.resource_list, &cr->link);
- cr->destroy = 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,
@@ -201,7 +202,7 @@ seat_get_keyboard (struct wl_client *client,
seat->keyboard.xkb_info.keymap_size);
if (seat->keyboard.focus &&
- seat->keyboard.focus->resource.client == client)
+ wl_resource_get_client (seat->keyboard.focus->resource) == client)
{
meta_wayland_keyboard_set_focus (&seat->keyboard,
seat->keyboard.focus);
@@ -239,8 +240,8 @@ bind_seat (struct wl_client *client,
&seat_interface,
id,
data);
- wl_list_insert (&seat->base_resource_list, &resource->link);
- resource->destroy = 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 |
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]