aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoremersion <contact@emersion.fr>2019-02-18 11:37:45 +0100
committeremersion <contact@emersion.fr>2019-02-20 18:42:34 +0100
commit7d367a9e216431d4c80a1f7c57e246df02de3886 (patch)
tree30ccffe09e95c7aa4593a15478473f37bd2c2ab8
parentae2aeb65cc8cf16944b02d1f8ed6ea6fc15de6ec (diff)
data-offer: send WL_DATA_OFFER_ERROR_INVALID_FINISH
-rw-r--r--types/data_device/wlr_data_offer.c21
1 files changed, 21 insertions, 0 deletions
diff --git a/types/data_device/wlr_data_offer.c b/types/data_device/wlr_data_offer.c
index 0b0332b1..26b894ea 100644
--- a/types/data_device/wlr_data_offer.c
+++ b/types/data_device/wlr_data_offer.c
@@ -135,6 +135,27 @@ static void data_offer_handle_finish(struct wl_client *client,
return;
}
+ // TODO: also fail while we have a drag-and-drop grab
+ if (offer->type != WLR_DATA_OFFER_DRAG) {
+ wl_resource_post_error(offer->resource,
+ WL_DATA_OFFER_ERROR_INVALID_FINISH, "Offer is not drag-and-drop");
+ return;
+ }
+ if (!offer->source->accepted) {
+ wl_resource_post_error(offer->resource,
+ WL_DATA_OFFER_ERROR_INVALID_FINISH, "Premature finish request");
+ return;
+ }
+ enum wl_data_device_manager_dnd_action action =
+ offer->source->current_dnd_action;
+ if (action == WL_DATA_DEVICE_MANAGER_DND_ACTION_NONE ||
+ action == WL_DATA_DEVICE_MANAGER_DND_ACTION_ASK) {
+ wl_resource_post_error(offer->resource,
+ WL_DATA_OFFER_ERROR_INVALID_FINISH,
+ "Offer finished with an invalid action");
+ return;
+ }
+
data_offer_dnd_finish(offer);
data_offer_destroy(offer);
}