From 666bd25005511684ba44fab693ce44772730c372 Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Wed, 29 Jan 2020 15:57:01 +0100 Subject: [PATCH] wayland: Handle dragging from/dropping to v1 data device users Interoperation between wl_data_device_manager v1 and v3 got broken at some point. Ensure that we resort to the "copy" action if either the drop site or the drag source are from a client that requested v1. Closes: https://gitlab.gnome.org/GNOME/mutter/issues/965 (cherry picked from commit ffad55c66f5b131cdaa92ef61c44d99b7c7312b5) --- src/wayland/meta-wayland-data-device.c | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/src/wayland/meta-wayland-data-device.c b/src/wayland/meta-wayland-data-device.c index 6d310d5bc..f12facef3 100644 --- a/src/wayland/meta-wayland-data-device.c +++ b/src/wayland/meta-wayland-data-device.c @@ -106,6 +106,7 @@ static struct wl_resource * create_and_send_clipboard_offer (MetaWaylandDataDevi struct wl_resource *target); static struct wl_resource * create_and_send_primary_offer (MetaWaylandDataDevice *data_device, struct wl_resource *target); +static struct wl_resource * meta_wayland_data_source_get_resource (MetaWaylandDataSource *source); static void unbind_resource (struct wl_resource *resource) @@ -138,8 +139,20 @@ data_offer_choose_action (MetaWaylandDataOffer *offer) MetaWaylandDataSource *source = offer->source; uint32_t actions, user_action, available_actions; - actions = meta_wayland_data_source_get_actions (source); - user_action = meta_wayland_data_source_get_user_action (source); + if (wl_resource_get_version (offer->resource) < + WL_DATA_OFFER_ACTION_SINCE_VERSION) + return WL_DATA_DEVICE_MANAGER_DND_ACTION_COPY; + + if (wl_resource_get_version (meta_wayland_data_source_get_resource (source)) < + WL_DATA_SOURCE_ACTION_SINCE_VERSION) + { + actions = user_action = WL_DATA_DEVICE_MANAGER_DND_ACTION_COPY; + } + else + { + actions = meta_wayland_data_source_get_actions (source); + user_action = meta_wayland_data_source_get_user_action (source); + } available_actions = actions & offer->dnd_actions;