[gtk/fix-x11-drop] x11: More dnd fixes




commit 0bce63e3ab47925328ef11f0093dd4fad3209240
Author: Matthias Clasen <mclasen redhat com>
Date:   Sun Feb 7 09:00:09 2021 -0500

    x11: More dnd fixes
    
    Whenever we communicate targets, we need to the union, otherwise
    we don't tell the other side about our serialization. This makes
    drops of images from gtk4-icon-browser to gimp and libreoffice
    succeed in transferring data.
    
    Fixes: #3654

 gdk/x11/gdkdrag-x11.c | 15 +++++++++++++--
 1 file changed, 13 insertions(+), 2 deletions(-)
---
diff --git a/gdk/x11/gdkdrag-x11.c b/gdk/x11/gdkdrag-x11.c
index 05e1c58377..d8c9ac28b8 100644
--- a/gdk/x11/gdkdrag-x11.c
+++ b/gdk/x11/gdkdrag-x11.c
@@ -296,15 +296,20 @@ gdk_x11_drag_find (GdkDisplay *display,
 static void
 precache_target_list (GdkDrag *drag)
 {
-  GdkContentFormats *formats = gdk_drag_get_formats (drag);
+  GdkContentFormats *formats;
   const char * const *atoms;
   gsize n_atoms;
 
+  formats = gdk_content_formats_ref (gdk_drag_get_formats (drag));
+  formats = gdk_content_formats_union_serialize_mime_types (formats);
+
   atoms = gdk_content_formats_get_mime_types (formats, &n_atoms);
 
   _gdk_x11_precache_atoms (gdk_drag_get_display (drag),
                            (const char **) atoms,
                            n_atoms);
+
+  gdk_content_formats_unref (formats);
 }
 
 /* Utility functions */
@@ -917,8 +922,12 @@ xdnd_set_targets (GdkX11Drag *drag_x11)
   const char * const *atoms;
   gsize i, n_atoms;
   GdkDisplay *display = gdk_drag_get_display (drag);
+  GdkContentFormats *formats;
 
-  atoms = gdk_content_formats_get_mime_types (gdk_drag_get_formats (drag), &n_atoms);
+  formats = gdk_content_formats_ref (gdk_drag_get_formats (drag));
+  formats = gdk_content_formats_union_serialize_mime_types (formats);
+
+  atoms = gdk_content_formats_get_mime_types (formats, &n_atoms);
   atomlist = g_new (Atom, n_atoms);
   for (i = 0; i < n_atoms; i++)
     atomlist[i] = gdk_x11_get_xatom_by_name_for_display (display, atoms[i]);
@@ -932,6 +941,8 @@ xdnd_set_targets (GdkX11Drag *drag_x11)
   g_free (atomlist);
 
   drag_x11->xdnd_targets_set = 1;
+
+  gdk_content_formats_unref (formats);
 }
 
 static void


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