summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJonas Ådahl <jadahl@gmail.com>2016-03-15 15:23:50 +0800
committerJonas Ådahl <jadahl@gmail.com>2016-04-22 10:31:21 +0800
commit8b6c9fcd4e471c0ca003877e58ac981461f9ae23 (patch)
treee566b0c8af47516c320cacd93ab149b7d121a974
parent10257ee5d9174014a1e776ae2710120f8951b968 (diff)
data-device: Update current action even if source version is old
If the version of the source object is old enough to not have wl_data_source.set_actions() the current action would never be updated since source->set_actions would never be set. To fix this, instead of checking whether source->set_actions before proceeding with updating the current action, just always update the action when we know all parts are valid dnd data device objects. Signed-off-by: Jonas Ådahl <jadahl@gmail.com> Reviewed-by: Mike Blumenkrantz <zmike@osg.samsung.com> Reviewed-by: Carlos Garnacho <carlosg@gnome.org>
-rw-r--r--src/data-device.c22
1 files changed, 12 insertions, 10 deletions
diff --git a/src/data-device.c b/src/data-device.c
index 862a4e02..f04f0308 100644
--- a/src/data-device.c
+++ b/src/data-device.c
@@ -160,7 +160,7 @@ data_offer_update_action(struct weston_data_offer *offer)
{
uint32_t action;
- if (!offer->source || !offer->source->actions_set)
+ if (!offer->source)
return;
action = data_offer_choose_action(offer);
@@ -293,7 +293,7 @@ destroy_offer_data_source(struct wl_listener *listener, void *data)
offer->source = NULL;
}
-static struct wl_resource *
+static struct weston_data_offer *
weston_data_source_send_offer(struct weston_data_source *source,
struct wl_resource *target)
{
@@ -331,9 +331,8 @@ weston_data_source_send_offer(struct weston_data_source *source,
source->offer = offer;
source->accepted = false;
- data_offer_update_action(offer);
- return offer->resource;
+ return offer;
}
static void
@@ -533,11 +532,13 @@ weston_drag_set_focus(struct weston_drag *drag,
if (drag->data_source) {
drag->data_source->accepted = false;
- offer_resource = weston_data_source_send_offer(drag->data_source,
- resource);
- if (offer_resource == NULL)
+ offer = weston_data_source_send_offer(drag->data_source, resource);
+ if (offer == NULL)
return;
+ data_offer_update_action(offer);
+
+ offer_resource = offer->resource;
if (wl_resource_get_version (offer_resource) >=
WL_DATA_OFFER_SOURCE_ACTIONS_SINCE_VERSION) {
wl_data_offer_send_source_actions (offer_resource,
@@ -1095,7 +1096,8 @@ destroy_selection_data_source(struct wl_listener *listener, void *data)
WL_EXPORT void
weston_seat_send_selection(struct weston_seat *seat, struct wl_client *client)
{
- struct wl_resource *data_device, *offer;
+ struct weston_data_offer *offer;
+ struct wl_resource *data_device;
wl_resource_for_each(data_device, &seat->drag_resource_list) {
if (wl_resource_get_client(data_device) != client)
@@ -1103,8 +1105,8 @@ weston_seat_send_selection(struct weston_seat *seat, struct wl_client *client)
if (seat->selection_data_source) {
offer = weston_data_source_send_offer(seat->selection_data_source,
- data_device);
- wl_data_device_send_selection(data_device, offer);
+ data_device);
+ wl_data_device_send_selection(data_device, offer->resource);
} else {
wl_data_device_send_selection(data_device, NULL);
}