aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/wlr/types/wlr_data_device.h1
-rw-r--r--types/wlr_data_device.c36
2 files changed, 30 insertions, 7 deletions
diff --git a/include/wlr/types/wlr_data_device.h b/include/wlr/types/wlr_data_device.h
index d5be311f..3074a6e3 100644
--- a/include/wlr/types/wlr_data_device.h
+++ b/include/wlr/types/wlr_data_device.h
@@ -30,6 +30,7 @@ struct wlr_data_source {
enum wl_data_device_manager_dnd_action current_dnd_action;
uint32_t dnd_actions;
uint32_t compositor_action;
+ bool actions_set;
struct {
struct wl_signal destroy;
diff --git a/types/wlr_data_device.c b/types/wlr_data_device.c
index 5760cfc3..2dae555e 100644
--- a/types/wlr_data_device.c
+++ b/types/wlr_data_device.c
@@ -65,24 +65,20 @@ static void data_offer_destroy(struct wl_client *client,
}
static void data_source_notify_finish(struct wlr_data_source *source) {
- // TODO
- /*
if (!source->actions_set) {
return;
}
- if (source->offer->in_ask &&
- wl_resource_get_version(source->resource) >=
+ if (source->offer->in_ask && wl_resource_get_version(source->resource) >=
WL_DATA_SOURCE_ACTION_SINCE_VERSION) {
wl_data_source_send_action(source->resource,
- source->current_dnd_action);
+ source->current_dnd_action);
}
if (wl_resource_get_version(source->resource) >=
WL_DATA_SOURCE_DND_FINISHED_SINCE_VERSION) {
wl_data_source_send_dnd_finished(source->resource);
}
- */
source->offer = NULL;
}
@@ -403,7 +399,33 @@ static void data_source_destroy(struct wl_client *client,
static void data_source_set_actions(struct wl_client *client,
struct wl_resource *resource, uint32_t dnd_actions) {
- wlr_log(L_DEBUG, "TODO: data source set actions");
+ struct wlr_data_source *source =
+ wl_resource_get_user_data(resource);
+
+ if (source->actions_set) {
+ wl_resource_post_error(source->resource,
+ WL_DATA_SOURCE_ERROR_INVALID_ACTION_MASK,
+ "cannot set actions more than once");
+ return;
+ }
+
+ if (dnd_actions & ~ALL_ACTIONS) {
+ wl_resource_post_error(source->resource,
+ WL_DATA_SOURCE_ERROR_INVALID_ACTION_MASK,
+ "invalid action mask %x", dnd_actions);
+ return;
+ }
+
+ if (source->seat) {
+ wl_resource_post_error(source->resource,
+ WL_DATA_SOURCE_ERROR_INVALID_ACTION_MASK,
+ "invalid action change after "
+ "wl_data_device.start_drag");
+ return;
+ }
+
+ source->dnd_actions = dnd_actions;
+ source->actions_set = true;
}
static void data_source_offer(struct wl_client *client,