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>
dev
Jonas Ådahl 9 years ago
parent 10257ee5d9
commit 8b6c9fcd4e
  1. 20
      src/data-device.c

@ -160,7 +160,7 @@ data_offer_update_action(struct weston_data_offer *offer)
{ {
uint32_t action; uint32_t action;
if (!offer->source || !offer->source->actions_set) if (!offer->source)
return; return;
action = data_offer_choose_action(offer); action = data_offer_choose_action(offer);
@ -293,7 +293,7 @@ destroy_offer_data_source(struct wl_listener *listener, void *data)
offer->source = NULL; offer->source = NULL;
} }
static struct wl_resource * static struct weston_data_offer *
weston_data_source_send_offer(struct weston_data_source *source, weston_data_source_send_offer(struct weston_data_source *source,
struct wl_resource *target) struct wl_resource *target)
{ {
@ -331,9 +331,8 @@ weston_data_source_send_offer(struct weston_data_source *source,
source->offer = offer; source->offer = offer;
source->accepted = false; source->accepted = false;
data_offer_update_action(offer);
return offer->resource; return offer;
} }
static void static void
@ -533,11 +532,13 @@ weston_drag_set_focus(struct weston_drag *drag,
if (drag->data_source) { if (drag->data_source) {
drag->data_source->accepted = false; drag->data_source->accepted = false;
offer_resource = weston_data_source_send_offer(drag->data_source, offer = weston_data_source_send_offer(drag->data_source, resource);
resource); if (offer == NULL)
if (offer_resource == NULL)
return; return;
data_offer_update_action(offer);
offer_resource = offer->resource;
if (wl_resource_get_version (offer_resource) >= if (wl_resource_get_version (offer_resource) >=
WL_DATA_OFFER_SOURCE_ACTIONS_SINCE_VERSION) { WL_DATA_OFFER_SOURCE_ACTIONS_SINCE_VERSION) {
wl_data_offer_send_source_actions (offer_resource, 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 WL_EXPORT void
weston_seat_send_selection(struct weston_seat *seat, struct wl_client *client) 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) { wl_resource_for_each(data_device, &seat->drag_resource_list) {
if (wl_resource_get_client(data_device) != client) if (wl_resource_get_client(data_device) != client)
@ -1104,7 +1106,7 @@ weston_seat_send_selection(struct weston_seat *seat, struct wl_client *client)
if (seat->selection_data_source) { if (seat->selection_data_source) {
offer = weston_data_source_send_offer(seat->selection_data_source, offer = weston_data_source_send_offer(seat->selection_data_source,
data_device); data_device);
wl_data_device_send_selection(data_device, offer); wl_data_device_send_selection(data_device, offer->resource);
} else { } else {
wl_data_device_send_selection(data_device, NULL); wl_data_device_send_selection(data_device, NULL);
} }

Loading…
Cancel
Save