static void unbind_resource(struct wl_resource *resource)
{
- wl_list_remove(&resource->link);
+ wl_list_remove(wl_resource_get_link(resource));
free(resource);
}
resource = pointer->focus_resource;
if (resource) {
- display = wl_client_get_display(resource->client);
+ display = wl_client_get_display(wl_resource_get_client(resource));
serial = wl_display_next_serial(display);
wl_pointer_send_button(resource, serial, time, button, state_w);
}
uint32_t serial;
if (touch->focus_resource && touch->focus) {
- display = wl_client_get_display(touch->focus_resource->client);
+ display = wl_client_get_display(wl_resource_get_client(touch->focus_resource));
serial = wl_display_next_serial(display);
wl_touch_send_down(touch->focus_resource, serial, time,
touch->focus->resource,
uint32_t serial;
if (touch->focus_resource) {
- display = wl_client_get_display(touch->focus_resource->client);
+ display = wl_client_get_display(wl_resource_get_client(touch->focus_resource));
serial = wl_display_next_serial(display);
wl_touch_send_up(touch->focus_resource, serial, time, touch_id);
}
resource = keyboard->focus_resource;
if (resource) {
- display = wl_client_get_display(resource->client);
+ display = wl_client_get_display(wl_resource_get_client(resource));
serial = wl_display_next_serial(display);
wl_keyboard_send_key(resource, serial, time, key, state);
}
static struct wl_resource *
find_resource_for_surface(struct wl_list *list, struct weston_surface *surface)
{
- struct wl_resource *r;
-
if (!surface)
return NULL;
- wl_list_for_each(r, list, link) {
- if (r->client == wl_resource_get_client(surface->resource))
- return r;
- }
-
- return NULL;
+ if (!surface->resource)
+ return NULL;
+
+ return wl_resource_find_for_client(list, wl_resource_get_client(surface->resource));
}
static void
static void
seat_send_updated_caps(struct weston_seat *seat)
{
- struct wl_resource *r;
+ struct wl_list *link;
enum wl_seat_capability caps = 0;
if (seat->pointer)
if (seat->touch)
caps |= WL_SEAT_CAPABILITY_TOUCH;
- wl_list_for_each(r, &seat->base_resource_list, link)
- wl_seat_send_capabilities(r, caps);
+ for (link = seat->base_resource_list.next;
+ link != &seat->base_resource_list; link = link->next) {
+ wl_seat_send_capabilities(wl_resource_from_link(link), caps);
+ }
}
WL_EXPORT void
resource = pointer->focus_resource;
if (resource && pointer->focus != surface) {
- display = wl_client_get_display(resource->client);
+ display = wl_client_get_display(wl_resource_get_client(resource));
serial = wl_display_next_serial(display);
wl_pointer_send_leave(resource, serial,
pointer->focus->resource);
if (resource &&
(pointer->focus != surface ||
pointer->focus_resource != resource)) {
- display = wl_client_get_display(resource->client);
+ display = wl_client_get_display(wl_resource_get_client(resource));
serial = wl_display_next_serial(display);
if (kbd) {
kr = find_resource_for_surface(&kbd->resource_list,
}
wl_pointer_send_enter(resource, serial, surface->resource,
sx, sy);
- wl_signal_add(&resource->destroy_signal,
- &pointer->focus_listener);
+ wl_resource_add_destroy_listener(resource,
+ &pointer->focus_listener);
pointer->focus_serial = serial;
}
if (keyboard->focus_resource && keyboard->focus != surface) {
resource = keyboard->focus_resource;
- display = wl_client_get_display(resource->client);
+ display = wl_client_get_display(wl_resource_get_client(resource));
serial = wl_display_next_serial(display);
wl_keyboard_send_leave(resource, serial,
keyboard->focus->resource);
if (resource &&
(keyboard->focus != surface ||
keyboard->focus_resource != resource)) {
- display = wl_client_get_display(resource->client);
+ display = wl_client_get_display(wl_resource_get_client(resource));
serial = wl_display_next_serial(display);
wl_keyboard_send_modifiers(resource, serial,
keyboard->modifiers.mods_depressed,
keyboard->modifiers.group);
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;
}
seat->touch->focus = surface;
seat->touch->focus_resource = resource;
- wl_signal_add(&resource->destroy_signal,
- &seat->touch->focus_listener);
+ wl_resource_add_destroy_listener(resource,
+ &seat->touch->focus_listener);
}
}
uint32_t serial, struct wl_resource *surface_resource,
int32_t x, int32_t y)
{
- struct weston_pointer *pointer = resource->data;
+ struct weston_pointer *pointer = wl_resource_get_user_data(resource);
struct weston_surface *surface = NULL;
if (surface_resource)
seat_get_pointer(struct wl_client *client, struct wl_resource *resource,
uint32_t id)
{
- struct weston_seat *seat = resource->data;
+ struct weston_seat *seat = wl_resource_get_user_data(resource);
struct wl_resource *cr;
if (!seat->pointer)
cr = wl_client_add_object(client, &wl_pointer_interface,
&pointer_interface, id, seat->pointer);
- 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 &&
wl_resource_get_client(seat->pointer->focus->resource) == client) {
seat_get_keyboard(struct wl_client *client, struct wl_resource *resource,
uint32_t id)
{
- struct weston_seat *seat = resource->data;
+ struct weston_seat *seat = wl_resource_get_user_data(resource);
struct wl_resource *cr;
if (!seat->keyboard)
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,
seat->xkb_info.keymap_fd,
seat_get_touch(struct wl_client *client, struct wl_resource *resource,
uint32_t id)
{
- struct weston_seat *seat = resource->data;
+ struct weston_seat *seat = wl_resource_get_user_data(resource);
struct wl_resource *cr;
if (!seat->touch)
return;
cr = wl_client_add_object(client, &wl_touch_interface, NULL, id, seat);
- wl_list_insert(&seat->touch->resource_list, &cr->link);
- cr->destroy = unbind_resource;
+ wl_list_insert(&seat->touch->resource_list, wl_resource_get_link(cr));
+ wl_resource_set_destructor(cr, unbind_resource);
}
static const struct wl_seat_interface seat_interface = {
resource = wl_client_add_object(client, &wl_seat_interface,
&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);
if (seat->pointer)
caps |= WL_SEAT_CAPABILITY_POINTER;