wayland/data-device: Don't disconnect valid dnd client

We cannot check 'has-target' or 'has-seat' when verifying a
wl_data_offer.finish request is valid or not, since the source may have
effected 'has-target' or whether theh source has a seat or not when the
finish request was already on the wire.

Instead of checking against the source state, keep track whether the
required operations has been done on the offer in question (i.e.
whether an action has been sent, or a mime type been accepted).

This fixes incorrectly raised error when dragging from gtk+'s testdnd
via Xwayland onto gtk+'s testdnd using Wayland.

https://bugzilla.gnome.org/show_bug.cgi?id=770937
This commit is contained in:
Jonas Ådahl 2016-09-06 18:01:54 +08:00
parent 342532a98d
commit 60bc6798f4

View File

@ -51,6 +51,8 @@ struct _MetaWaylandDataOffer
struct wl_resource *resource;
MetaWaylandDataSource *source;
struct wl_listener source_destroy_listener;
gboolean accepted;
gboolean action_sent;
uint32_t dnd_actions;
enum wl_data_device_manager_dnd_action preferred_dnd_action;
};
@ -169,7 +171,10 @@ data_offer_update_action (MetaWaylandDataOffer *offer)
if (!meta_wayland_source_get_in_ask (source) &&
wl_resource_get_version (offer->resource) >=
WL_DATA_OFFER_ACTION_SINCE_VERSION)
wl_data_offer_send_action (offer->resource, action);
{
wl_data_offer_send_action (offer->resource, action);
offer->action_sent = TRUE;
}
}
static void
@ -353,6 +358,8 @@ data_offer_accept (struct wl_client *client,
meta_wayland_data_source_set_has_target (offer->source,
mime_type != NULL);
}
offer->accepted = mime_type != NULL;
}
static void
@ -385,8 +392,7 @@ data_offer_finish (struct wl_client *client,
offer != meta_wayland_data_source_get_current_offer (offer->source))
return;
if (meta_wayland_data_source_get_seat (offer->source) ||
!meta_wayland_data_source_has_target (offer->source))
if (!offer->accepted || !offer->action_sent)
{
wl_resource_post_error (offer->resource,
WL_DATA_OFFER_ERROR_INVALID_FINISH,