aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDrew DeVault <sir@cmpwn.com>2018-10-19 14:18:05 +0200
committerGitHub <noreply@github.com>2018-10-19 14:18:05 +0200
commitac26d23711cbfe78ca392d14fa439a0e8f660884 (patch)
tree2c827c70b22f79b09e9b4ba8ab08f289335fe88e
parent6730f5ba93577d0d1d466063e84aeae9a45355fb (diff)
parentf44003f04bcffcaa64d811a45efea569c0dee23e (diff)
Merge pull request #1287 from emersion/source-seat-client
data-device: remove wlr_data_source.seat_client
-rw-r--r--include/types/wlr_data_device.h1
-rw-r--r--include/wlr/types/wlr_data_device.h1
-rw-r--r--types/data_device/wlr_data_device.c32
-rw-r--r--types/data_device/wlr_data_offer.c3
-rw-r--r--types/data_device/wlr_data_source.c5
5 files changed, 23 insertions, 19 deletions
diff --git a/include/types/wlr_data_device.h b/include/types/wlr_data_device.h
index 972294ff..388e91a5 100644
--- a/include/types/wlr_data_device.h
+++ b/include/types/wlr_data_device.h
@@ -11,6 +11,7 @@ struct wlr_client_data_source {
struct wlr_data_source source;
struct wlr_data_source_impl impl;
struct wl_resource *resource;
+ bool finalized;
};
extern const struct wlr_surface_role drag_icon_surface_role;
diff --git a/include/wlr/types/wlr_data_device.h b/include/wlr/types/wlr_data_device.h
index c45e8d1c..9ce8f400 100644
--- a/include/wlr/types/wlr_data_device.h
+++ b/include/wlr/types/wlr_data_device.h
@@ -73,7 +73,6 @@ struct wlr_data_source {
// source status
bool accepted;
struct wlr_data_offer *offer;
- struct wlr_seat_client *seat_client;
// drag'n'drop status
enum wl_data_device_manager_dnd_action current_dnd_action;
diff --git a/types/data_device/wlr_data_device.c b/types/data_device/wlr_data_device.c
index 40974de7..111c2de0 100644
--- a/types/data_device/wlr_data_device.c
+++ b/types/data_device/wlr_data_device.c
@@ -25,16 +25,21 @@ static struct wlr_seat_client *seat_client_from_data_device_resource(
static void data_device_set_selection(struct wl_client *client,
struct wl_resource *device_resource,
struct wl_resource *source_resource, uint32_t serial) {
+ struct wlr_seat_client *seat_client =
+ seat_client_from_data_device_resource(device_resource);
+
struct wlr_client_data_source *source = NULL;
if (source_resource != NULL) {
source = client_data_source_from_resource(source_resource);
}
- struct wlr_seat_client *seat_client =
- seat_client_from_data_device_resource(device_resource);
-
- struct wlr_data_source *wlr_source = (struct wlr_data_source *)source;
+ struct wlr_data_source *wlr_source =
+ source != NULL ? &source->source : NULL;
wlr_seat_set_selection(seat_client->seat, wlr_source, serial);
+
+ if (source != NULL) {
+ source->finalized = true;
+ }
}
static void data_device_start_drag(struct wl_client *client,
@@ -45,15 +50,13 @@ static void data_device_start_drag(struct wl_client *client,
struct wlr_seat_client *seat_client =
seat_client_from_data_device_resource(device_resource);
struct wlr_surface *origin = wlr_surface_from_resource(origin_resource);
- struct wlr_data_source *source = NULL;
- struct wlr_surface *icon = NULL;
- if (source_resource) {
- struct wlr_client_data_source *client_source =
- client_data_source_from_resource(source_resource);
- source = (struct wlr_data_source *)client_source;
+ struct wlr_client_data_source *source = NULL;
+ if (source_resource != NULL) {
+ source = client_data_source_from_resource(source_resource);
}
+ struct wlr_surface *icon = NULL;
if (icon_resource) {
icon = wlr_surface_from_resource(icon_resource);
if (!wlr_surface_set_role(icon, &drag_icon_surface_role, NULL,
@@ -62,13 +65,16 @@ static void data_device_start_drag(struct wl_client *client,
}
}
- if (!seat_client_start_drag(seat_client, source, icon, origin, serial)) {
+ struct wlr_data_source *wlr_source =
+ source != NULL ? &source->source : NULL;
+ if (!seat_client_start_drag(seat_client, wlr_source, icon,
+ origin, serial)) {
wl_resource_post_no_memory(device_resource);
return;
}
- if (source) {
- source->seat_client = seat_client;
+ if (source != NULL) {
+ source->finalized = true;
}
}
diff --git a/types/data_device/wlr_data_offer.c b/types/data_device/wlr_data_offer.c
index a5ea9183..9847e07c 100644
--- a/types/data_device/wlr_data_offer.c
+++ b/types/data_device/wlr_data_offer.c
@@ -41,8 +41,7 @@ static uint32_t data_offer_choose_action(struct wlr_data_offer *offer) {
return WL_DATA_DEVICE_MANAGER_DND_ACTION_NONE;
}
- if (offer->source->seat_client &&
- offer->source->compositor_action & available_actions) {
+ if (offer->source->compositor_action & available_actions) {
return offer->source->compositor_action;
}
diff --git a/types/data_device/wlr_data_source.c b/types/data_device/wlr_data_source.c
index bf638f5a..59650170 100644
--- a/types/data_device/wlr_data_source.c
+++ b/types/data_device/wlr_data_source.c
@@ -207,11 +207,10 @@ static void data_source_set_actions(struct wl_client *client,
return;
}
- if (source->source.seat_client) {
+ if (source->finalized) {
wl_resource_post_error(source->resource,
WL_DATA_SOURCE_ERROR_INVALID_ACTION_MASK,
- "invalid action change after "
- "wl_data_device.start_drag");
+ "invalid action change after wl_data_device.start_drag");
return;
}