aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/types/wlr_data_device.h2
-rw-r--r--include/wlr/types/wlr_data_device.h6
-rw-r--r--types/data_device/wlr_data_device.c4
-rw-r--r--types/data_device/wlr_data_offer.c12
-rw-r--r--types/data_device/wlr_data_source.c2
-rw-r--r--types/data_device/wlr_drag.c4
6 files changed, 23 insertions, 7 deletions
diff --git a/include/types/wlr_data_device.h b/include/types/wlr_data_device.h
index 0f58cc29..28073880 100644
--- a/include/types/wlr_data_device.h
+++ b/include/types/wlr_data_device.h
@@ -17,7 +17,7 @@ struct wlr_client_data_source {
extern const struct wlr_surface_role drag_icon_surface_role;
struct wlr_data_offer *data_offer_create(struct wl_resource *device_resource,
- struct wlr_data_source *source);
+ struct wlr_data_source *source, enum wlr_data_offer_type type);
void data_offer_update_action(struct wlr_data_offer *offer);
void data_offer_destroy(struct wlr_data_offer *offer);
diff --git a/include/wlr/types/wlr_data_device.h b/include/wlr/types/wlr_data_device.h
index 5bf52599..e82dfa60 100644
--- a/include/wlr/types/wlr_data_device.h
+++ b/include/wlr/types/wlr_data_device.h
@@ -35,9 +35,15 @@ struct wlr_data_device_manager {
void *data;
};
+enum wlr_data_offer_type {
+ WLR_DATA_OFFER_SELECTION,
+ WLR_DATA_OFFER_DRAG,
+};
+
struct wlr_data_offer {
struct wl_resource *resource;
struct wlr_data_source *source;
+ enum wlr_data_offer_type type;
uint32_t actions;
enum wl_data_device_manager_dnd_action preferred_action;
diff --git a/types/data_device/wlr_data_device.c b/types/data_device/wlr_data_device.c
index e4e56d4a..ad5bed36 100644
--- a/types/data_device/wlr_data_device.c
+++ b/types/data_device/wlr_data_device.c
@@ -107,8 +107,8 @@ static void device_resource_send_selection(struct wl_resource *device_resource)
struct wlr_data_source *source = seat_client->seat->selection_source;
if (source != NULL) {
- struct wlr_data_offer *offer =
- data_offer_create(device_resource, source);
+ struct wlr_data_offer *offer = data_offer_create(device_resource,
+ source, WLR_DATA_OFFER_SELECTION);
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 07ce18c4..b610e4ac 100644
--- a/types/data_device/wlr_data_offer.c
+++ b/types/data_device/wlr_data_offer.c
@@ -55,6 +55,8 @@ static uint32_t data_offer_choose_action(struct wlr_data_offer *offer) {
}
void data_offer_update_action(struct wlr_data_offer *offer) {
+ assert(offer->type == WLR_DATA_OFFER_DRAG);
+
uint32_t action = data_offer_choose_action(offer);
if (offer->source->current_dnd_action == action) {
return;
@@ -160,6 +162,13 @@ static void data_offer_handle_set_actions(struct wl_client *client,
return;
}
+ if (offer->type != WLR_DATA_OFFER_DRAG) {
+ wl_resource_post_error(offer->resource,
+ WL_DATA_OFFER_ERROR_INVALID_OFFER,
+ "set_action can only be sent to drag-and-drop offers");
+ return;
+ }
+
offer->actions = actions;
offer->preferred_action = preferred_action;
@@ -199,7 +208,7 @@ static void data_offer_handle_source_destroy(struct wl_listener *listener,
}
struct wlr_data_offer *data_offer_create(struct wl_resource *device_resource,
- struct wlr_data_source *source) {
+ struct wlr_data_source *source, enum wlr_data_offer_type type) {
struct wlr_seat_client *seat_client =
seat_client_from_data_device_resource(device_resource);
assert(seat_client != NULL);
@@ -210,6 +219,7 @@ struct wlr_data_offer *data_offer_create(struct wl_resource *device_resource,
return NULL;
}
offer->source = source;
+ offer->type = type;
struct wl_client *client = wl_resource_get_client(device_resource);
uint32_t version = wl_resource_get_version(device_resource);
diff --git a/types/data_device/wlr_data_source.c b/types/data_device/wlr_data_source.c
index d4265132..ed794454 100644
--- a/types/data_device/wlr_data_source.c
+++ b/types/data_device/wlr_data_source.c
@@ -186,7 +186,7 @@ static void data_source_offer(struct wl_client *client,
return;
}
if (source->finalized) {
- wlr_log(WLR_DEBUG, "offering additional MIME type after "
+ wlr_log(WLR_DEBUG, "Offering additional MIME type after "
"wl_data_device.set_selection");
}
diff --git a/types/data_device/wlr_drag.c b/types/data_device/wlr_drag.c
index ba5e384c..d6e93cb2 100644
--- a/types/data_device/wlr_drag.c
+++ b/types/data_device/wlr_drag.c
@@ -61,8 +61,8 @@ 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_offer_create(device_resource, drag->source);
+ struct wlr_data_offer *offer = data_offer_create(device_resource,
+ drag->source, WLR_DATA_OFFER_DRAG);
if (offer == NULL) {
wl_resource_post_no_memory(device_resource);
return;