static void move_resources_for_client(struct wl_list *destination, struct wl_list *source, struct wl_client *client) { struct wl_resource *resource, *tmp; wl_resource_for_each_safe(resource, tmp, source) { if (wl_resource_get_client(resource) == client) { wl_list_remove(wl_resource_get_link(resource)); wl_list_insert(destination, wl_resource_get_link(resource)); } } }
void wlb_keyboard_create_resource(struct wlb_keyboard *keyboard, struct wl_client *client, uint32_t id) { struct wl_resource *resource; int null_fd; resource = wl_resource_create(client, &wl_keyboard_interface, 1, id); if (!resource) { wl_client_post_no_memory(client); return; } wl_resource_set_implementation(resource, &keyboard_interface, NULL, unlink_resource); wl_list_insert(&keyboard->resource_list, wl_resource_get_link(resource)); if (keyboard->keymap.data) { wl_keyboard_send_keymap(resource, keyboard->keymap.format, keyboard->keymap.fd, keyboard->keymap.size); } else { null_fd = open("/dev/null", O_RDONLY); wl_keyboard_send_keymap(resource, WL_KEYBOARD_KEYMAP_FORMAT_NO_KEYMAP, null_fd, 0); close(null_fd); } }
static void seat_get_keyboard (struct wl_client *client, struct wl_resource *resource, uint32_t id) { ClaylandSeat *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, wl_resource_get_link (cr)); wl_resource_set_destructor (cr, unbind_resource); wl_keyboard_send_keymap (cr, WL_KEYBOARD_KEYMAP_FORMAT_XKB_V1, seat->keyboard.xkb_info.keymap_fd, seat->keyboard.xkb_info.keymap_size); if (seat->keyboard.focus && wl_resource_get_client (seat->keyboard.focus->resource) == client) { clayland_keyboard_set_focus (&seat->keyboard, seat->keyboard.focus); clayland_data_device_set_keyboard_focus (seat); } }
static void seat_get_pointer (struct wl_client *client, struct wl_resource *resource, uint32_t id) { ClaylandSeat *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, 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) { ClaylandSurface *surface; wl_fixed_t sx, sy; surface = (ClaylandSurface *) seat->pointer.focus; transform_stage_point_fixed (surface, seat->pointer.x, seat->pointer.y, &sx, &sy); clayland_pointer_set_focus (&seat->pointer, seat->pointer.focus, sx, sy); } }
static void get_data_device (struct wl_client *client, struct wl_resource *manager_resource, guint32 id, struct wl_resource *seat_resource) { MetaWaylandSeat *seat = wl_resource_get_user_data (seat_resource); struct wl_resource *cr; cr = wl_resource_create (client, &wl_data_device_interface, wl_resource_get_version (manager_resource), id); wl_resource_set_implementation (cr, &data_device_interface, &seat->data_device, unbind_resource); wl_list_insert (&seat->data_device.resource_list, wl_resource_get_link (cr)); }
static void get_data_device(struct wl_client *client, struct wl_resource *manager_resource, uint32_t id, struct wl_resource *seat_resource) { struct weston_seat *seat = wl_resource_get_user_data(seat_resource); struct wl_resource *resource; resource = wl_resource_create(client, &wl_data_device_interface, 1, id); if (resource == NULL) { wl_resource_post_no_memory(manager_resource); return; } wl_list_insert(&seat->drag_resource_list, wl_resource_get_link(resource)); wl_resource_set_implementation(resource, &data_device_interface, seat, unbind_data_device); }
static void bind_tag(struct wl_client * client, void * data, uint32_t version, uint32_t id) { struct tag * tag = data; struct wl_resource * resource; if (version >= 1) version = 1; resource = wl_resource_create(client, &velox_tag_interface, version, id); if (!resource) { wl_client_post_no_memory(client); return; } wl_resource_set_destructor(resource, &remove_resource); wl_list_insert(&tag->resources, wl_resource_get_link(resource)); velox_tag_send_name(resource, tag->name); tag_send_screen(tag, client, resource, NULL); }
static void bind_seat (struct wl_client *client, void *data, guint32 version, guint32 id) { ClaylandSeat *seat = data; struct wl_resource *resource; resource = wl_client_add_object (client, &wl_seat_interface, &seat_interface, id, data); 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); }
static void unbind_resource (struct wl_resource *resource) { wl_list_remove (wl_resource_get_link (resource)); }