Module: wine Branch: master Commit: e339e0d476a8eae572493a7c83f6f972b41793f1 URL: http://source.winehq.org/git/wine.git/?a=commit;h=e339e0d476a8eae572493a7c83...
Author: Damjan Jovanovic damjan.jov@gmail.com Date: Tue May 27 02:22:07 2014 +0200
winex11.drv: Use the clipboard functions and formats to import selections that XDND doesn't support.
---
dlls/winex11.drv/clipboard.c | 18 ++++++++++++++++++ dlls/winex11.drv/x11drv.h | 1 + dlls/winex11.drv/xdnd.c | 26 +++++++++++++++++++++++--- 3 files changed, 42 insertions(+), 3 deletions(-)
diff --git a/dlls/winex11.drv/clipboard.c b/dlls/winex11.drv/clipboard.c index 730b6c9..350eeab 100644 --- a/dlls/winex11.drv/clipboard.c +++ b/dlls/winex11.drv/clipboard.c @@ -1519,6 +1519,24 @@ static HANDLE X11DRV_CLIPBOARD_ImportClipboardData(Display *display, Window w, A return hClipData; }
+/************************************************************************** + * X11DRV_CLIPBOARD_ImportSelection + * + * Import the X selection into the clipboard format registered for the given X target. + */ +HANDLE X11DRV_CLIPBOARD_ImportSelection(Display *d, Atom target, Window w, Atom prop, UINT *windowsFormat) +{ + WINE_CLIPFORMAT *clipFormat; + + clipFormat = X11DRV_CLIPBOARD_LookupProperty(NULL, target); + if (clipFormat) + { + *windowsFormat = clipFormat->wFormatID; + return clipFormat->lpDrvImportFunc(d, w, prop); + } + return NULL; +} +
/************************************************************************** X11DRV_CLIPBOARD_ExportClipboardData diff --git a/dlls/winex11.drv/x11drv.h b/dlls/winex11.drv/x11drv.h index 7a3374d..bcbfe14 100644 --- a/dlls/winex11.drv/x11drv.h +++ b/dlls/winex11.drv/x11drv.h @@ -238,6 +238,7 @@ 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 *d, Atom target, Window w, Atom prop, UINT *windowsFormat) DECLSPEC_HIDDEN;
/************************************************************************** * X11 GDI driver diff --git a/dlls/winex11.drv/xdnd.c b/dlls/winex11.drv/xdnd.c index 4db938f..3941900 100644 --- a/dlls/winex11.drv/xdnd.c +++ b/dlls/winex11.drv/xdnd.c @@ -75,7 +75,7 @@ static void X11DRV_XDND_InsertXDNDData(int property, int format, void* data, uns static int X11DRV_XDND_DeconstructTextURIList(int property, void* data, int len); static int X11DRV_XDND_DeconstructTextPlain(int property, void* data, int len); static int X11DRV_XDND_DeconstructTextHTML(int property, void* data, int len); -static void X11DRV_XDND_MapFormat(unsigned int property, unsigned char *data, int len); +static void X11DRV_XDND_MapFormat(Display *display, Window xwin, unsigned int property, unsigned char *data, int len); static void X11DRV_XDND_ResolveProperty(Display *display, Window xwin, Time tm, Atom *types, unsigned long count); static void X11DRV_XDND_SendDropFiles(HWND hwnd); @@ -497,7 +497,7 @@ static void X11DRV_XDND_ResolveProperty(Display *display, Window xwin, Time tm, XGetWindowProperty(display, xwin, x11drv_atom(XdndTarget), 0, 65535, FALSE, AnyPropertyType, &acttype, &actfmt, &icount, &bytesret, &data);
- X11DRV_XDND_MapFormat(types[i], data, get_property_size( actfmt, icount )); + X11DRV_XDND_MapFormat(display, xwin, types[i], data, get_property_size( actfmt, icount )); XFree(data); }
@@ -554,7 +554,7 @@ static void X11DRV_XDND_InsertXDNDData(int property, int format, void* data, uns * * Map XDND MIME format to windows clipboard format. */ -static void X11DRV_XDND_MapFormat(unsigned int property, unsigned char *data, int len) +static void X11DRV_XDND_MapFormat(Display *display, Window xwin, unsigned int property, unsigned char *data, int len) { void* xdata;
@@ -571,6 +571,26 @@ static void X11DRV_XDND_MapFormat(unsigned int property, unsigned char *data, in X11DRV_XDND_DeconstructTextPlain(property, data, len); else if (property == x11drv_atom(text_html)) X11DRV_XDND_DeconstructTextHTML(property, data, len); + else + { + /* use the clipboard import functions for other types */ + HANDLE *contents; + UINT windowsFormat; + contents = X11DRV_CLIPBOARD_ImportSelection(display, property, xwin, x11drv_atom(XdndTarget), &windowsFormat); + if (contents) + { + void *data = HeapAlloc(GetProcessHeap(), 0, GlobalSize(contents)); + if (data) + { + memcpy(data, GlobalLock(contents), GlobalSize(contents)); + GlobalUnlock(contents); + X11DRV_XDND_InsertXDNDData(property, windowsFormat, data, GlobalSize(contents)); + } + else + ERR("out of memory\n"); + GlobalFree(contents); + } + } }