|
|
@ -856,16 +856,7 @@ void data_device_manager_get_data_device(struct wl_client *client,
|
|
|
|
static void data_source_resource_destroy(struct wl_resource *resource) {
|
|
|
|
static void data_source_resource_destroy(struct wl_resource *resource) {
|
|
|
|
struct wlr_data_source *source =
|
|
|
|
struct wlr_data_source *source =
|
|
|
|
wl_resource_get_user_data(resource);
|
|
|
|
wl_resource_get_user_data(resource);
|
|
|
|
char **p;
|
|
|
|
wlr_data_source_finish(source);
|
|
|
|
|
|
|
|
|
|
|
|
wl_signal_emit(&source->events.destroy, source);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
wl_array_for_each(p, &source->mime_types) {
|
|
|
|
|
|
|
|
free(*p);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
wl_array_release(&source->mime_types);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
free(source);
|
|
|
|
free(source);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -927,6 +918,25 @@ static struct wl_data_source_interface data_source_impl = {
|
|
|
|
.set_actions = data_source_set_actions,
|
|
|
|
.set_actions = data_source_set_actions,
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void wlr_data_source_init(struct wlr_data_source *source) {
|
|
|
|
|
|
|
|
wl_array_init(&source->mime_types);
|
|
|
|
|
|
|
|
wl_signal_init(&source->events.destroy);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void wlr_data_source_finish(struct wlr_data_source *source) {
|
|
|
|
|
|
|
|
if (source == NULL) {
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
wl_signal_emit(&source->events.destroy, source);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
char **p;
|
|
|
|
|
|
|
|
wl_array_for_each(p, &source->mime_types) {
|
|
|
|
|
|
|
|
free(*p);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
wl_array_release(&source->mime_types);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void data_device_manager_create_data_source(struct wl_client *client,
|
|
|
|
static void data_device_manager_create_data_source(struct wl_client *client,
|
|
|
|
struct wl_resource *resource, uint32_t id) {
|
|
|
|
struct wl_resource *resource, uint32_t id) {
|
|
|
|
struct wlr_data_source *source = calloc(1, sizeof(struct wlr_data_source));
|
|
|
|
struct wlr_data_source *source = calloc(1, sizeof(struct wlr_data_source));
|
|
|
@ -934,25 +944,21 @@ static void data_device_manager_create_data_source(struct wl_client *client,
|
|
|
|
wl_resource_post_no_memory(resource);
|
|
|
|
wl_resource_post_no_memory(resource);
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
wlr_data_source_init(source);
|
|
|
|
|
|
|
|
|
|
|
|
source->resource =
|
|
|
|
source->resource = wl_resource_create(client, &wl_data_source_interface,
|
|
|
|
wl_resource_create(client, &wl_data_source_interface,
|
|
|
|
|
|
|
|
wl_resource_get_version(resource), id);
|
|
|
|
wl_resource_get_version(resource), id);
|
|
|
|
if (source->resource == NULL) {
|
|
|
|
if (source->resource == NULL) {
|
|
|
|
free(source);
|
|
|
|
free(source);
|
|
|
|
wl_resource_post_no_memory(resource);
|
|
|
|
wl_resource_post_no_memory(resource);
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
wl_resource_set_implementation(source->resource, &data_source_impl,
|
|
|
|
|
|
|
|
source, data_source_resource_destroy);
|
|
|
|
|
|
|
|
|
|
|
|
source->accept = client_data_source_accept;
|
|
|
|
source->accept = client_data_source_accept;
|
|
|
|
source->send = client_data_source_send;
|
|
|
|
source->send = client_data_source_send;
|
|
|
|
source->cancel = client_data_source_cancel;
|
|
|
|
source->cancel = client_data_source_cancel;
|
|
|
|
|
|
|
|
|
|
|
|
wl_array_init(&source->mime_types);
|
|
|
|
|
|
|
|
wl_signal_init(&source->events.destroy);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
wl_resource_set_implementation(source->resource, &data_source_impl,
|
|
|
|
|
|
|
|
source, data_source_resource_destroy);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static const struct wl_data_device_manager_interface
|
|
|
|
static const struct wl_data_device_manager_interface
|
|
|
|