From 34c5535b23768cec5991f0f9f694e58b60dd7e5f Mon Sep 17 00:00:00 2001 From: Las Date: Mon, 2 Oct 2017 21:37:29 +0200 Subject: [PATCH 1/4] Make wl_data_device_manager version 3 --- src/compositor/seat/data.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/compositor/seat/data.c b/src/compositor/seat/data.c index e8694491..54850b49 100644 --- a/src/compositor/seat/data.c +++ b/src/compositor/seat/data.c @@ -171,7 +171,7 @@ static void wl_data_device_manager_bind(struct wl_client *client, void *data, uint32_t version, uint32_t id) { struct wl_resource *resource; - if (!(resource = wl_resource_create_checked(client, &wl_data_device_manager_interface, version, 2, id))) + if (!(resource = wl_resource_create_checked(client, &wl_data_device_manager_interface, version, 3, id))) return; wl_resource_set_implementation(resource, &wl_data_device_manager_implementation, data, NULL); @@ -232,7 +232,7 @@ wlc_data_device_manager(struct wlc_data_device_manager *manager, struct wlc_seat memset(manager, 0, sizeof(struct wlc_data_device_manager)); manager->seat = seat; - if (!(manager->wl.manager = wl_global_create(wlc_display(), &wl_data_device_manager_interface, 2, manager, wl_data_device_manager_bind))) + if (!(manager->wl.manager = wl_global_create(wlc_display(), &wl_data_device_manager_interface, 3, manager, wl_data_device_manager_bind))) goto manager_interface_fail; if (!wlc_source(&manager->sources, "data-source", wlc_data_source, wlc_data_source_release, 32, sizeof(struct wlc_data_source)) || From 1b2f43f070f353c718a2ffc473c9b3943472cc06 Mon Sep 17 00:00:00 2001 From: Las Date: Sat, 14 Oct 2017 00:08:44 +0200 Subject: [PATCH 2/4] Add support for wl_data_offer.finish --- src/compositor/seat/data.c | 35 ++++++++++++++++++++++++------- src/resources/types/data-source.h | 1 + 2 files changed, 29 insertions(+), 7 deletions(-) diff --git a/src/compositor/seat/data.c b/src/compositor/seat/data.c index 54850b49..1281fddf 100644 --- a/src/compositor/seat/data.c +++ b/src/compositor/seat/data.c @@ -37,10 +37,23 @@ wl_cb_data_offer_receive(struct wl_client *client, struct wl_resource *resource, source->impl->send(source, type, fd); } +static void +wl_cb_data_offer_finish(struct wl_client *client, struct wl_resource *resource) +{ + (void)client; + + struct wlc_data_source *source; + if (!(source = (struct wlc_data_source*)wl_resource_get_user_data(resource))) + return; + + source->impl->dnd_finished(source); +} + static struct wl_data_offer_interface wl_data_offer_implementation = { - .accept = wl_cb_data_offer_accept, - .receive = wl_cb_data_offer_receive, - .destroy = wlc_cb_resource_destructor + .accept = wl_cb_data_offer_accept, + .receive = wl_cb_data_offer_receive, + .finish = wl_cb_data_offer_finish, + .destroy = wlc_cb_resource_destructor, }; static void @@ -65,16 +78,24 @@ data_source_client_cancel(struct wlc_data_source *data_source) wl_data_source_send_cancelled(res); } +static void +data_source_client_dnd_finished(struct wlc_data_source *data_source) +{ + struct wl_resource *res = convert_to_wl_resource(data_source, "data-source"); + wl_data_source_send_dnd_finished(res); +} + static struct wlc_data_source_impl data_source_client_impl = { - .accept = data_source_client_accept, - .send = data_source_client_send, - .cancel = data_source_client_cancel, + .accept = data_source_client_accept, + .send = data_source_client_send, + .cancel = data_source_client_cancel, + .dnd_finished = data_source_client_dnd_finished, }; static void wl_cb_data_source_offer(struct wl_client *client, struct wl_resource *resource, const char *type) { - (void)client, (void)resource, (void)type; + (void)client; struct wlc_data_source *source; if (!(source = convert_from_wl_resource(resource, "data-source"))) diff --git a/src/resources/types/data-source.h b/src/resources/types/data-source.h index 7a23ad82..1e1e5ca6 100644 --- a/src/resources/types/data-source.h +++ b/src/resources/types/data-source.h @@ -9,6 +9,7 @@ struct wlc_data_source_impl { void (*send)(struct wlc_data_source *data_source, const char *type, int fd); void (*accept)(struct wlc_data_source *data_source, const char *type); void (*cancel)(struct wlc_data_source *data_source); + void (*dnd_finished)(struct wlc_data_source *data_source); }; struct wlc_data_source { From efdc5a341f4c6397947f36cc200885dd563efee1 Mon Sep 17 00:00:00 2001 From: Las Date: Sat, 14 Oct 2017 00:22:52 +0200 Subject: [PATCH 3/4] Add support for wl_data_(offer|source).set_actions --- src/compositor/seat/data.c | 31 +++++++++++++++++++++++++++++-- src/resources/types/data-source.h | 3 +++ 2 files changed, 32 insertions(+), 2 deletions(-) diff --git a/src/compositor/seat/data.c b/src/compositor/seat/data.c index 1281fddf..fd04790b 100644 --- a/src/compositor/seat/data.c +++ b/src/compositor/seat/data.c @@ -37,6 +37,19 @@ wl_cb_data_offer_receive(struct wl_client *client, struct wl_resource *resource, source->impl->send(source, type, fd); } +static void +wl_cb_data_offer_set_actions(struct wl_client *client, struct wl_resource *resource, uint32_t dnd_actions, uint32_t preferred_action) +{ + (void)client; + + struct wlc_data_source *source; + if (!(source = (struct wlc_data_source*)wl_resource_get_user_data(resource))) + return; + + source->dst_dnd_actions = dnd_actions; + source->prf_dnd_action = preferred_action; +} + static void wl_cb_data_offer_finish(struct wl_client *client, struct wl_resource *resource) { @@ -52,6 +65,7 @@ wl_cb_data_offer_finish(struct wl_client *client, struct wl_resource *resource) static struct wl_data_offer_interface wl_data_offer_implementation = { .accept = wl_cb_data_offer_accept, .receive = wl_cb_data_offer_receive, + .set_actions = wl_cb_data_offer_set_actions, .finish = wl_cb_data_offer_finish, .destroy = wlc_cb_resource_destructor, }; @@ -118,9 +132,22 @@ wl_cb_data_source_destroy(struct wl_client *client, struct wl_resource *resource wlc_cb_resource_destructor(client, resource); } +static void +wl_cb_data_source_set_actions(struct wl_client *client, struct wl_resource *resource, uint32_t dnd_actions) +{ + (void)client; + + struct wlc_data_source *source; + if (!(source = convert_from_wl_resource(resource, "data-source"))) + return; + + source->src_dnd_actions = dnd_actions; +} + static struct wl_data_source_interface wl_data_source_implementation = { - .offer = wl_cb_data_source_offer, - .destroy = wl_cb_data_source_destroy + .offer = wl_cb_data_source_offer, + .destroy = wl_cb_data_source_destroy, + .set_actions = wl_cb_data_source_set_actions }; static void diff --git a/src/resources/types/data-source.h b/src/resources/types/data-source.h index 1e1e5ca6..7fd9ca55 100644 --- a/src/resources/types/data-source.h +++ b/src/resources/types/data-source.h @@ -14,6 +14,9 @@ struct wlc_data_source_impl { struct wlc_data_source { struct chck_iter_pool types; + uint32_t prf_dnd_action; // preferred + uint32_t dst_dnd_actions; + uint32_t src_dnd_actions; const struct wlc_data_source_impl *impl; }; From e7e3e9c9e0d633b4e91b0bdbf6a8f8971b898a5e Mon Sep 17 00:00:00 2001 From: Las Date: Sat, 14 Oct 2017 10:19:21 +0200 Subject: [PATCH 4/4] Increment version to 3 for data_(offer|source|device) too --- src/compositor/seat/data.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/compositor/seat/data.c b/src/compositor/seat/data.c index fd04790b..9bf41d87 100644 --- a/src/compositor/seat/data.c +++ b/src/compositor/seat/data.c @@ -158,7 +158,7 @@ wl_cb_manager_create_data_source(struct wl_client *client, struct wl_resource *r return; wlc_resource r; - if (!(r = wlc_resource_create(&manager->sources, client, &wl_data_source_interface, wl_resource_get_version(resource), 2, id))) + if (!(r = wlc_resource_create(&manager->sources, client, &wl_data_source_interface, wl_resource_get_version(resource), 3, id))) return; struct wlc_data_source *source = convert_from_wlc_resource(r, "data-source"); @@ -204,7 +204,7 @@ wl_cb_manager_get_data_device(struct wl_client *client, struct wl_resource *reso return; wlc_resource r; - if (!(r = wlc_resource_create(&seat->manager.devices, client, &wl_data_device_interface, wl_resource_get_version(resource), 2, id))) + if (!(r = wlc_resource_create(&seat->manager.devices, client, &wl_data_device_interface, wl_resource_get_version(resource), 3, id))) return; wlc_resource_implement(r, &wl_data_device_implementation, &seat->manager); @@ -237,7 +237,7 @@ wlc_data_device_manager_offer(struct wlc_data_device_manager *manager, struct wl struct wlc_data_source *source = manager->source; wlc_resource offer = 0; - if (source && !(offer = wlc_resource_create(&manager->offers, client, &wl_data_offer_interface, wl_resource_get_version(resource), 2, 0))) + if (source && !(offer = wlc_resource_create(&manager->offers, client, &wl_data_offer_interface, wl_resource_get_version(resource), 3, 0))) return; if (offer) {