[mutter/wip/carlosg/selection-fixes: 8/8] wayland: Figure out better the right selection source for a wl_data_offer



commit 0e00e2a0b98cc9af8c6e7e4e212abac84be76a1d
Author: Carlos Garnacho <carlosg gnome org>
Date:   Fri Oct 11 19:32:42 2019 +0200

    wayland: Figure out better the right selection source for a wl_data_offer
    
    We were just looking at DnD actions which might be unset at that point.
    Instead of doing these heuristics, check the matching data source on the
    MetaWaylandDataDevice before picking a selection source.
    
    Fixes: https://gitlab.gnome.org/GNOME/mutter/issues/845

 src/wayland/meta-wayland-data-device.c | 17 ++++++++++++++---
 1 file changed, 14 insertions(+), 3 deletions(-)
---
diff --git a/src/wayland/meta-wayland-data-device.c b/src/wayland/meta-wayland-data-device.c
index f95be0bf8..284098a34 100644
--- a/src/wayland/meta-wayland-data-device.c
+++ b/src/wayland/meta-wayland-data-device.c
@@ -394,15 +394,26 @@ data_offer_receive (struct wl_client *client, struct wl_resource *resource,
                     const char *mime_type, int32_t fd)
 {
   MetaWaylandDataOffer *offer = wl_resource_get_user_data (resource);
+  MetaWaylandCompositor *compositor = meta_wayland_compositor_get_default ();
+  MetaWaylandDataDevice *data_device = &compositor->seat->data_device;
   MetaDisplay *display = meta_get_display ();
   MetaSelectionType selection_type;
   GList *mime_types;
   gboolean found;
 
-  if (offer->dnd_actions != 0)
-    selection_type = META_SELECTION_DND;
+  if (offer->source == data_device->dnd_data_source)
+    {
+      selection_type = META_SELECTION_DND;
+    }
+  else if (offer->source == data_device->selection_data_source)
+    {
+      selection_type = META_SELECTION_CLIPBOARD;
+    }
   else
-    selection_type = META_SELECTION_CLIPBOARD;
+    {
+      close (fd);
+      return;
+    }
 
   mime_types = meta_selection_get_mimetypes (meta_display_get_selection (display),
                                              selection_type);


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