[mutter/wip/carlosg/dnd-with-v1-data-manager] wayland: Handle dragging from/dropping to v1 data device users



commit 71fb737a18987fb5f10becec6de0d347e5413c82
Author: Carlos Garnacho <carlosg gnome org>
Date:   Wed Jan 29 15:57:01 2020 +0100

    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

 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 7e0a254b4..0d04fbdf6 100644
--- a/src/wayland/meta-wayland-data-device.c
+++ b/src/wayland/meta-wayland-data-device.c
@@ -102,6 +102,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)
@@ -134,8 +135,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;
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]