[PATCH v2 5/6] winex11: Move CF_HDROP filtering to import_xdnd_selection.

Huw Davies huw at codeweavers.com
Wed Apr 27 08:01:16 CDT 2022


From: Jacek Caban <jacek at codeweavers.com>

Signed-off-by: Jacek Caban <jacek at codeweavers.com>
Signed-off-by: Huw Davies <huw at codeweavers.com>
---
 dlls/winex11.drv/clipboard.c | 11 +++++++++++
 dlls/winex11.drv/xdnd.c      | 26 --------------------------
 2 files changed, 11 insertions(+), 26 deletions(-)

diff --git a/dlls/winex11.drv/clipboard.c b/dlls/winex11.drv/clipboard.c
index 92284d436dd..6baa87c5ce1 100644
--- a/dlls/winex11.drv/clipboard.c
+++ b/dlls/winex11.drv/clipboard.c
@@ -1108,14 +1108,25 @@ struct format_entry *import_xdnd_selection( Display *display, Window win, Atom s
     void *data;
     struct clipboard_format *format;
     struct format_entry *ret = NULL, *entry;
+    BOOL have_hdrop = FALSE;
 
     register_x11_formats( targets, count );
     *ret_size = 0;
 
+    for (i = 0; i < count; i++)
+    {
+        if (!(format = find_x11_format( targets[i] ))) continue;
+        if (format->id != CF_HDROP) continue;
+        have_hdrop = TRUE;
+        break;
+    }
+
     for (i = 0; i < count; i++)
     {
         if (!(format = find_x11_format( targets[i] ))) continue;
         if (!format->id) continue;
+        if (have_hdrop && format->id != CF_HDROP && format->id < CF_MAX) continue;
+
         if (!(data = import_selection( display, win, selection, format, &size ))) continue;
 
         entry_size = (FIELD_OFFSET( struct format_entry, data[size] ) + 7) & ~7;
diff --git a/dlls/winex11.drv/xdnd.c b/dlls/winex11.drv/xdnd.c
index aa46467f6f7..b892a70949a 100644
--- a/dlls/winex11.drv/xdnd.c
+++ b/dlls/winex11.drv/xdnd.c
@@ -530,8 +530,6 @@ static void X11DRV_XDND_ResolveProperty(Display *display, Window xwin, Time tm,
                                         Atom *types, unsigned long count)
 {
     struct format_entry *formats, *formats_end, *iter;
-    XDNDDATA *current, *next;
-    BOOL haveHDROP = FALSE;
     size_t size;
 
     TRACE("count(%ld)\n", count);
@@ -554,30 +552,6 @@ static void X11DRV_XDND_ResolveProperty(Display *display, Window xwin, Time tm,
             }
         }
     }
-
-    /* On Windows when there is a CF_HDROP, there are no other CF_ formats.
-     * foobar2000 relies on this (spaces -> %20's without it).
-     */
-    LIST_FOR_EACH_ENTRY(current, &xdndData, XDNDDATA, entry)
-    {
-        if (current->cf_win == CF_HDROP)
-        {
-            haveHDROP = TRUE;
-            break;
-        }
-    }
-    if (haveHDROP)
-    {
-        LIST_FOR_EACH_ENTRY_SAFE(current, next, &xdndData, XDNDDATA, entry)
-        {
-            if (current->cf_win != CF_HDROP && current->cf_win < CF_MAX)
-            {
-                list_remove(&current->entry);
-                GlobalFree(current->contents);
-                HeapFree(GetProcessHeap(), 0, current);
-            }
-        }
-    }
 }
 
 
-- 
2.25.1




More information about the wine-devel mailing list