From 84f278eca1a8f1b7b8371d48d4a494d32c15f3bb Mon Sep 17 00:00:00 2001 From: emersion Date: Sun, 9 Dec 2018 13:07:42 +0100 Subject: data-device: remove data_source_send_offer --- include/types/wlr_data_device.h | 8 ++++---- types/data_device/wlr_data_device.c | 4 ++-- types/data_device/wlr_data_offer.c | 18 ++++++++++++++++-- types/data_device/wlr_data_source.c | 19 ------------------- types/data_device/wlr_drag.c | 2 +- 5 files changed, 23 insertions(+), 28 deletions(-) diff --git a/include/types/wlr_data_device.h b/include/types/wlr_data_device.h index 376c5f09..d2bdcc38 100644 --- a/include/types/wlr_data_device.h +++ b/include/types/wlr_data_device.h @@ -16,8 +16,8 @@ struct wlr_client_data_source { extern const struct wlr_surface_role drag_icon_surface_role; -struct wlr_data_offer *data_offer_create(struct wl_client *client, - struct wlr_data_source *source, uint32_t version); +struct wlr_data_offer *data_offer_create(struct wl_resource *device_resource, + struct wlr_data_source *source); void data_offer_update_action(struct wlr_data_offer *offer); void data_offer_destroy(struct wlr_data_offer *offer); @@ -26,10 +26,10 @@ struct wlr_client_data_source *client_data_source_create( struct wl_list *resource_list); struct wlr_client_data_source *client_data_source_from_resource( struct wl_resource *resource); -struct wlr_data_offer *data_source_send_offer(struct wlr_data_source *source, - struct wl_resource *device_resource); void data_source_notify_finish(struct wlr_data_source *source); +struct wlr_seat_client *seat_client_from_data_device_resource( + struct wl_resource *resource); bool seat_client_start_drag(struct wlr_seat_client *client, struct wlr_data_source *source, struct wlr_surface *icon_surface, struct wlr_surface *origin, uint32_t serial); diff --git a/types/data_device/wlr_data_device.c b/types/data_device/wlr_data_device.c index f2bcb806..63f3b9c1 100644 --- a/types/data_device/wlr_data_device.c +++ b/types/data_device/wlr_data_device.c @@ -14,7 +14,7 @@ static const struct wl_data_device_interface data_device_impl; -static struct wlr_seat_client *seat_client_from_data_device_resource( +struct wlr_seat_client *seat_client_from_data_device_resource( struct wl_resource *resource) { assert(wl_resource_instance_of(resource, &wl_data_device_interface, &data_device_impl)); @@ -103,7 +103,7 @@ void wlr_seat_client_send_selection(struct wlr_seat_client *seat_client) { wl_resource_for_each(device_resource, &seat_client->data_devices) { if (source != NULL) { struct wlr_data_offer *offer = - data_source_send_offer(source, device_resource); + data_offer_create(device_resource, source); if (offer == NULL) { wl_client_post_no_memory(seat_client->client); return; diff --git a/types/data_device/wlr_data_offer.c b/types/data_device/wlr_data_offer.c index b8cec091..07ce18c4 100644 --- a/types/data_device/wlr_data_offer.c +++ b/types/data_device/wlr_data_offer.c @@ -198,14 +198,21 @@ static void data_offer_handle_source_destroy(struct wl_listener *listener, data_offer_destroy(offer); } -struct wlr_data_offer *data_offer_create(struct wl_client *client, - struct wlr_data_source *source, uint32_t version) { +struct wlr_data_offer *data_offer_create(struct wl_resource *device_resource, + struct wlr_data_source *source) { + struct wlr_seat_client *seat_client = + seat_client_from_data_device_resource(device_resource); + assert(seat_client != NULL); + assert(source != NULL); // a NULL source means no selection + struct wlr_data_offer *offer = calloc(1, sizeof(struct wlr_data_offer)); if (offer == NULL) { return NULL; } offer->source = source; + struct wl_client *client = wl_resource_get_client(device_resource); + uint32_t version = wl_resource_get_version(device_resource); offer->resource = wl_resource_create(client, &wl_data_offer_interface, version, 0); if (offer->resource == NULL) { @@ -218,5 +225,12 @@ struct wlr_data_offer *data_offer_create(struct wl_client *client, offer->source_destroy.notify = data_offer_handle_source_destroy; wl_signal_add(&source->events.destroy, &offer->source_destroy); + wl_data_device_send_data_offer(device_resource, offer->resource); + + char **p; + wl_array_for_each(p, &source->mime_types) { + wl_data_offer_send_offer(offer->resource, *p); + } + return offer; } diff --git a/types/data_device/wlr_data_source.c b/types/data_device/wlr_data_source.c index a2878aed..d4265132 100644 --- a/types/data_device/wlr_data_source.c +++ b/types/data_device/wlr_data_source.c @@ -11,25 +11,6 @@ #include "types/wlr_data_device.h" #include "util/signal.h" -struct wlr_data_offer *data_source_send_offer(struct wlr_data_source *source, - struct wl_resource *device_resource) { - struct wl_client *client = wl_resource_get_client(device_resource); - uint32_t version = wl_resource_get_version(device_resource); - struct wlr_data_offer *offer = data_offer_create(client, source, version); - if (offer == NULL) { - return NULL; - } - - wl_data_device_send_data_offer(device_resource, offer->resource); - - char **p; - wl_array_for_each(p, &source->mime_types) { - wl_data_offer_send_offer(offer->resource, *p); - } - - return offer; -} - void wlr_data_source_init(struct wlr_data_source *source, const struct wlr_data_source_impl *impl) { assert(impl->send); diff --git a/types/data_device/wlr_drag.c b/types/data_device/wlr_drag.c index 8b4048c8..ba5e384c 100644 --- a/types/data_device/wlr_drag.c +++ b/types/data_device/wlr_drag.c @@ -62,7 +62,7 @@ static void drag_set_focus(struct wlr_drag *drag, struct wl_resource *device_resource; wl_resource_for_each(device_resource, &focus_client->data_devices) { struct wlr_data_offer *offer = - data_source_send_offer(drag->source, device_resource); + data_offer_create(device_resource, drag->source); if (offer == NULL) { wl_resource_post_no_memory(device_resource); return; -- cgit v1.2.3