summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHarish Krupo <harishkrupo@gmail.com>2019-04-19 22:06:37 +0530
committerSimon Ser <contact@emersion.fr>2019-06-19 07:44:51 +0000
commit2e5ad9252e0ba20c5c547552788fb6ac585c2a84 (patch)
tree0b98d8e8afb00818ccadc9aaf8ce458abd6bb5bf
parent48e1c4278442ef2d59696d996f921cc23b13d539 (diff)
downloadweston-2e5ad9252e0ba20c5c547552788fb6ac585c2a84.tar.gz
data-device: send INVALID_FINISH when operation != dnd
The documentation of wl_data_offer::finish states that it should be used to signify that a drag and drop operation is completed. So send WL_DATA_OFFER_ERROR_INVALID_FINISH when the client calls the finish request but the operation isn't dnd. Signed-off-by: Harish Krupo <harishkrupo@gmail.com> (cherry picked from commit 737ac0d4b3f7b40c345b61ff62dea0550217f063)
-rw-r--r--libweston/compositor.h1
-rw-r--r--libweston/data-device.c9
2 files changed, 10 insertions, 0 deletions
diff --git a/libweston/compositor.h b/libweston/compositor.h
index a5223c28..3af1443a 100644
--- a/libweston/compositor.h
+++ b/libweston/compositor.h
@@ -427,6 +427,7 @@ struct weston_data_source {
struct weston_seat *seat;
bool accepted;
bool actions_set;
+ bool set_selection;
uint32_t dnd_actions;
enum wl_data_device_manager_dnd_action current_dnd_action;
enum wl_data_device_manager_dnd_action compositor_action;
diff --git a/libweston/data-device.c b/libweston/data-device.c
index e3dbee3e..5d0426f2 100644
--- a/libweston/data-device.c
+++ b/libweston/data-device.c
@@ -220,6 +220,13 @@ data_offer_finish(struct wl_client *client, struct wl_resource *resource)
if (!offer->source || offer->source->offer != offer)
return;
+ if (offer->source->set_selection) {
+ wl_resource_post_error(offer->resource,
+ WL_DATA_OFFER_ERROR_INVALID_FINISH,
+ "finish only valid for drag n drop");
+ return;
+ }
+
/* Disallow finish while we have a grab driving drag-and-drop, or
* if the negotiation is not at the right stage
*/
@@ -1145,6 +1152,7 @@ weston_seat_set_selection(struct weston_seat *seat,
seat->selection_data_source = source;
seat->selection_serial = serial;
+ source->set_selection = true;
if (keyboard)
focus = keyboard->focus;
@@ -1267,6 +1275,7 @@ create_data_source(struct wl_client *client,
source->dnd_actions = 0;
source->current_dnd_action = WL_DATA_DEVICE_MANAGER_DND_ACTION_NONE;
source->compositor_action = WL_DATA_DEVICE_MANAGER_DND_ACTION_NONE;
+ source->set_selection = false;
wl_array_init(&source->mime_types);