Alexandre Julliard : winex11: Support import multiple drag&drop properties in a single call.

Alexandre Julliard julliard at winehq.org
Thu Sep 22 10:00:02 CDT 2016


Module: wine
Branch: master
Commit: 80d02bc849e2a16bfda6fe3b7181c35511030d85
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=80d02bc849e2a16bfda6fe3b7181c35511030d85

Author: Alexandre Julliard <julliard at winehq.org>
Date:   Thu Sep 22 13:07:44 2016 +0900

winex11: Support import multiple drag&drop properties in a single call.

Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 dlls/winex11.drv/clipboard.c | 20 ++++++++++++++------
 dlls/winex11.drv/x11drv.h    |  5 +++--
 dlls/winex11.drv/xdnd.c      | 22 ++++------------------
 3 files changed, 21 insertions(+), 26 deletions(-)

diff --git a/dlls/winex11.drv/clipboard.c b/dlls/winex11.drv/clipboard.c
index 8457a03..d7480ae 100644
--- a/dlls/winex11.drv/clipboard.c
+++ b/dlls/winex11.drv/clipboard.c
@@ -1267,13 +1267,21 @@ static HANDLE import_selection( Display *display, Window win, Atom selection,
  *
  *  Import the X selection into the clipboard format registered for the given X target.
  */
-HANDLE X11DRV_CLIPBOARD_ImportSelection( Display *display, Window win, Atom selection,
-                                         Atom target, UINT *windowsFormat )
+void X11DRV_CLIPBOARD_ImportSelection( Display *display, Window win, Atom selection,
+                                       Atom *targets, UINT count,
+                                       void (*callback)( Atom, UINT, HANDLE ))
 {
-    struct clipboard_format *format = X11DRV_CLIPBOARD_LookupProperty( NULL, target );
-    if (!format) return 0;
-    *windowsFormat = format->id;
-    return import_selection( display, win, selection, format );
+    UINT i;
+    HANDLE handle;
+    struct clipboard_format *format;
+
+    for (i = 0; i < count; i++)
+    {
+        if (!(format = X11DRV_CLIPBOARD_LookupProperty( NULL, targets[i] ))) continue;
+        if (!format->id) continue;
+        if (!(handle = import_selection( display, win, selection, format ))) continue;
+        callback( targets[i], format->id, handle );
+    }
 }
 
 
diff --git a/dlls/winex11.drv/x11drv.h b/dlls/winex11.drv/x11drv.h
index 48f3999..d88e65b 100644
--- a/dlls/winex11.drv/x11drv.h
+++ b/dlls/winex11.drv/x11drv.h
@@ -239,8 +239,9 @@ extern void X11DRV_XDND_EnterEvent( HWND hWnd, XClientMessageEvent *event ) DECL
 extern void X11DRV_XDND_PositionEvent( HWND hWnd, XClientMessageEvent *event ) DECLSPEC_HIDDEN;
 extern void X11DRV_XDND_DropEvent( HWND hWnd, XClientMessageEvent *event ) DECLSPEC_HIDDEN;
 extern void X11DRV_XDND_LeaveEvent( HWND hWnd, XClientMessageEvent *event ) DECLSPEC_HIDDEN;
-extern HANDLE X11DRV_CLIPBOARD_ImportSelection( Display *display, Window win, Atom selection,
-                                                Atom target, UINT *windowsFormat ) DECLSPEC_HIDDEN;
+extern void X11DRV_CLIPBOARD_ImportSelection( Display *display, Window win, Atom selection,
+                                              Atom *targets, UINT count,
+                                              void (*callback)( Atom, UINT, HANDLE )) DECLSPEC_HIDDEN;
 
 /**************************************************************************
  * X11 GDI driver
diff --git a/dlls/winex11.drv/xdnd.c b/dlls/winex11.drv/xdnd.c
index eb9b117..2ab28e4 100644
--- a/dlls/winex11.drv/xdnd.c
+++ b/dlls/winex11.drv/xdnd.c
@@ -67,7 +67,7 @@ static HWND XDNDLastTargetWnd;
 /* might be an ancestor of XDNDLastTargetWnd */
 static HWND XDNDLastDropTargetWnd;
 
-static void X11DRV_XDND_InsertXDNDData(int property, int format, HANDLE contents);
+static void X11DRV_XDND_InsertXDNDData( Atom property, UINT format, HANDLE contents );
 static void X11DRV_XDND_ResolveProperty(Display *display, Window xwin, Time tm,
     Atom *types, unsigned long count);
 static BOOL X11DRV_XDND_HasHDROP(void);
@@ -492,7 +492,6 @@ void X11DRV_XDND_LeaveEvent( HWND hWnd, XClientMessageEvent *event )
 static void X11DRV_XDND_ResolveProperty(Display *display, Window xwin, Time tm,
                                         Atom *types, unsigned long count)
 {
-    unsigned int i;
     XDNDDATA *current, *next;
     BOOL haveHDROP = FALSE;
 
@@ -500,21 +499,8 @@ static void X11DRV_XDND_ResolveProperty(Display *display, Window xwin, Time tm,
 
     X11DRV_XDND_FreeDragDropOp(); /* Clear previously cached data */
 
-    for (i = 0; i < count; i++)
-    {
-        HANDLE contents;
-        UINT windowsFormat;
-
-        TRACE("requesting atom %ld from xwin %ld\n", types[i], xwin);
-
-        if (types[i] == 0)
-            continue;
-
-        contents = X11DRV_CLIPBOARD_ImportSelection( display, xwin, x11drv_atom(XdndSelection),
-                                                     types[i], &windowsFormat );
-        if (contents)
-            X11DRV_XDND_InsertXDNDData(types[i], windowsFormat, contents);
-    }
+    X11DRV_CLIPBOARD_ImportSelection( display, xwin, x11drv_atom(XdndSelection),
+                                      types, count, X11DRV_XDND_InsertXDNDData );
 
     /* On Windows when there is a CF_HDROP, there are no other CF_ formats.
      * foobar2000 relies on this (spaces -> %20's without it).
@@ -547,7 +533,7 @@ static void X11DRV_XDND_ResolveProperty(Display *display, Window xwin, Time tm,
  *
  * Cache available XDND property
  */
-static void X11DRV_XDND_InsertXDNDData(int property, int format, HANDLE contents)
+static void X11DRV_XDND_InsertXDNDData( Atom property, UINT format, HANDLE contents )
 {
     LPXDNDDATA current = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(XDNDDATA));
 




More information about the wine-cvs mailing list