if (client->id_count-- < 64)
wl_display_post_range(display, client);
+ wl_list_init(&resource->destroy_listener_list);
+
wl_hash_table_insert(client->display->objects,
resource->object.id, resource);
wl_list_insert(client->resource_list.prev, &resource->link);
}
WL_EXPORT void
-wl_resource_destroy(struct wl_resource *resource, struct wl_client *client)
+wl_resource_destroy(struct wl_resource *resource,
+ struct wl_client *client, uint32_t time)
{
struct wl_display *display = client->display;
+ struct wl_listener *l, *next;
+
+ wl_list_for_each_safe(l, next,
+ &resource->destroy_listener_list, link)
+ l->func(l, resource, time);
wl_list_remove(&resource->link);
if (resource->object.id > 0)
printf("disconnect from client %p\n", client);
wl_list_for_each_safe(resource, tmp, &client->resource_list, link)
- wl_resource_destroy(resource, client);
+ wl_resource_destroy(resource, client, 0);
wl_event_source_remove(client->source);
wl_connection_destroy(client->connection);
static void
lose_pointer_focus(struct wl_listener *listener,
- struct wl_surface *surface, uint32_t time)
+ struct wl_resource *resource, uint32_t time)
{
struct wl_input_device *device =
container_of(listener, struct wl_input_device,
static void
lose_keyboard_focus(struct wl_listener *listener,
- struct wl_surface *surface, uint32_t time)
+ struct wl_resource *resource, uint32_t time)
{
struct wl_input_device *device =
container_of(listener, struct wl_input_device,
&device->object,
WL_INPUT_DEVICE_POINTER_FOCUS,
time, surface, x, y, sx, sy);
- wl_list_insert(surface->destroy_listener_list.prev,
+ wl_list_insert(surface->resource.destroy_listener_list.prev,
&device->pointer_focus_listener.link);
}
&device->object,
WL_INPUT_DEVICE_KEYBOARD_FOCUS,
time, surface, &device->keys);
- wl_list_insert(surface->destroy_listener_list.prev,
+ wl_list_insert(surface->resource.destroy_listener_list.prev,
&device->keyboard_focus_listener.link);
}
static void
lose_grab_surface(struct wl_listener *listener,
- struct wl_surface *surface, uint32_t time)
+ struct wl_resource *resource, uint32_t time)
{
struct wl_input_device *device =
container_of(listener,
device->grab_y = device->y;
device->grab_listener.func = lose_grab_surface;
- wl_list_insert(focus->destroy_listener_list.prev,
+ wl_list_insert(focus->resource.destroy_listener_list.prev,
&device->grab_listener.link);
grab->input_device = device;
listener->client = client;
listener->key = key;
listener->surface = surface;
+ wl_list_init(&listener->resource.destroy_listener_list);
wl_list_insert(client->resource_list.prev, &listener->resource.link);
wl_list_insert(display->frame_list.prev, &listener->link);
}
continue;
wl_client_post_event(listener->client, &display->object,
WL_DISPLAY_KEY, listener->key, time);
- wl_resource_destroy(&listener->resource, listener->client);
+ wl_resource_destroy(&listener->resource, listener->client, 0);
}
}
void (*destroy)(struct wl_resource *resource,
struct wl_client *client);
struct wl_list link;
+ struct wl_list destroy_listener_list;
};
struct wl_buffer {
struct wl_listener {
struct wl_list link;
void (*func)(struct wl_listener *listener,
- struct wl_surface *surface, uint32_t time);
+ struct wl_resource *resource, uint32_t time);
};
struct wl_surface {
struct wl_resource resource;
struct wl_client *client;
- struct wl_list destroy_listener_list;
};
struct wl_grab;
wl_client_get_display(struct wl_client *client);
void
-wl_resource_destroy(struct wl_resource *resource, struct wl_client *client);
+wl_resource_destroy(struct wl_resource *resource,
+ struct wl_client *client, uint32_t time);
void
wl_input_device_init(struct wl_input_device *device,