mirror of
https://gitlab.freedesktop.org/wlroots/wlroots.git
synced 2025-11-23 06:59:44 -05:00
Merge pull request #519 from emersion/xwayland-primary-selection
Implement xwayland primary selection sync
This commit is contained in:
commit
e809250171
7 changed files with 527 additions and 307 deletions
|
|
@ -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) {
|
||||
struct wlr_data_source *source =
|
||||
wl_resource_get_user_data(resource);
|
||||
char **p;
|
||||
|
||||
wl_signal_emit(&source->events.destroy, source);
|
||||
|
||||
wl_array_for_each(p, &source->mime_types) {
|
||||
free(*p);
|
||||
}
|
||||
|
||||
wl_array_release(&source->mime_types);
|
||||
|
||||
wlr_data_source_finish(source);
|
||||
free(source);
|
||||
}
|
||||
|
||||
|
|
@ -927,6 +918,25 @@ static struct wl_data_source_interface data_source_impl = {
|
|||
.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,
|
||||
struct wl_resource *resource, uint32_t id) {
|
||||
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);
|
||||
return;
|
||||
}
|
||||
wlr_data_source_init(source);
|
||||
|
||||
source->resource =
|
||||
wl_resource_create(client, &wl_data_source_interface,
|
||||
wl_resource_get_version(resource), id);
|
||||
source->resource = wl_resource_create(client, &wl_data_source_interface,
|
||||
wl_resource_get_version(resource), id);
|
||||
if (source->resource == NULL) {
|
||||
free(source);
|
||||
wl_resource_post_no_memory(resource);
|
||||
return;
|
||||
}
|
||||
wl_resource_set_implementation(source->resource, &data_source_impl,
|
||||
source, data_source_resource_destroy);
|
||||
|
||||
source->accept = client_data_source_accept;
|
||||
source->send = client_data_source_send;
|
||||
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
|
||||
|
|
|
|||
|
|
@ -144,15 +144,7 @@ static const struct gtk_primary_selection_source_interface source_impl = {
|
|||
static void source_resource_handle_destroy(struct wl_resource *resource) {
|
||||
struct wlr_primary_selection_source *source =
|
||||
wl_resource_get_user_data(resource);
|
||||
|
||||
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);
|
||||
|
||||
wlr_primary_selection_source_finish(source);
|
||||
free(source);
|
||||
}
|
||||
|
||||
|
|
@ -262,6 +254,27 @@ static void device_resource_handle_destroy(struct wl_resource *resource) {
|
|||
}
|
||||
|
||||
|
||||
void wlr_primary_selection_source_init(
|
||||
struct wlr_primary_selection_source *source) {
|
||||
wl_array_init(&source->mime_types);
|
||||
wl_signal_init(&source->events.destroy);
|
||||
}
|
||||
|
||||
void wlr_primary_selection_source_finish(
|
||||
struct wlr_primary_selection_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 device_manager_handle_create_source(struct wl_client *client,
|
||||
struct wl_resource *manager_resource, uint32_t id) {
|
||||
struct wlr_primary_selection_source *source =
|
||||
|
|
@ -270,6 +283,7 @@ static void device_manager_handle_create_source(struct wl_client *client,
|
|||
wl_client_post_no_memory(client);
|
||||
return;
|
||||
}
|
||||
wlr_primary_selection_source_init(source);
|
||||
|
||||
int version = wl_resource_get_version(manager_resource);
|
||||
source->resource = wl_resource_create(client,
|
||||
|
|
@ -284,9 +298,6 @@ static void device_manager_handle_create_source(struct wl_client *client,
|
|||
|
||||
source->send = client_source_send;
|
||||
source->cancel = client_source_cancel;
|
||||
|
||||
wl_array_init(&source->mime_types);
|
||||
wl_signal_init(&source->events.destroy);
|
||||
}
|
||||
|
||||
void device_manager_handle_get_device(struct wl_client *client,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue