winex11: Store the list of X11 formats when retrieving the TARGETS property.
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
548ce58b4f
commit
a502a36af8
|
@ -118,8 +118,6 @@ typedef struct tagWINE_CLIPDATA {
|
||||||
struct list entry;
|
struct list entry;
|
||||||
UINT wFormatID;
|
UINT wFormatID;
|
||||||
HANDLE hData;
|
HANDLE hData;
|
||||||
UINT drvData;
|
|
||||||
LPWINE_CLIPFORMAT lpFormat;
|
|
||||||
} WINE_CLIPDATA, *LPWINE_CLIPDATA;
|
} WINE_CLIPDATA, *LPWINE_CLIPDATA;
|
||||||
|
|
||||||
static int selectionAcquired = 0; /* Contains the current selection masks */
|
static int selectionAcquired = 0; /* Contains the current selection masks */
|
||||||
|
@ -216,6 +214,9 @@ static struct list format_list = LIST_INIT( format_list );
|
||||||
#define NB_BUILTIN_FORMATS (sizeof(builtin_formats) / sizeof(builtin_formats[0]))
|
#define NB_BUILTIN_FORMATS (sizeof(builtin_formats) / sizeof(builtin_formats[0]))
|
||||||
#define GET_ATOM(prop) (((prop) < FIRST_XATOM) ? (Atom)(prop) : X11DRV_Atoms[(prop) - FIRST_XATOM])
|
#define GET_ATOM(prop) (((prop) < FIRST_XATOM) ? (Atom)(prop) : X11DRV_Atoms[(prop) - FIRST_XATOM])
|
||||||
|
|
||||||
|
static struct clipboard_format **current_x11_formats;
|
||||||
|
static unsigned int nb_current_x11_formats;
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Cached clipboard data.
|
* Cached clipboard data.
|
||||||
|
@ -523,16 +524,11 @@ static BOOL X11DRV_CLIPBOARD_ReleaseOwnership(void)
|
||||||
*
|
*
|
||||||
* Caller *must* have the clipboard open and be the owner.
|
* Caller *must* have the clipboard open and be the owner.
|
||||||
*/
|
*/
|
||||||
static BOOL X11DRV_CLIPBOARD_InsertClipboardData(UINT wFormatID, HANDLE hData,
|
static BOOL X11DRV_CLIPBOARD_InsertClipboardData( UINT wFormatID, HANDLE hData )
|
||||||
LPWINE_CLIPFORMAT lpFormat, BOOL override)
|
|
||||||
{
|
{
|
||||||
LPWINE_CLIPDATA lpData = X11DRV_CLIPBOARD_LookupData(wFormatID);
|
LPWINE_CLIPDATA lpData = X11DRV_CLIPBOARD_LookupData(wFormatID);
|
||||||
|
|
||||||
TRACE("format=%04x lpData=%p hData=%p lpFormat=%p override=%d\n",
|
TRACE("format=%04x lpData=%p hData=%p\n", wFormatID, lpData, hData);
|
||||||
wFormatID, lpData, hData, lpFormat, override);
|
|
||||||
|
|
||||||
if (lpData && !override)
|
|
||||||
return TRUE;
|
|
||||||
|
|
||||||
if (lpData)
|
if (lpData)
|
||||||
{
|
{
|
||||||
|
@ -546,8 +542,6 @@ static BOOL X11DRV_CLIPBOARD_InsertClipboardData(UINT wFormatID, HANDLE hData,
|
||||||
|
|
||||||
lpData->wFormatID = wFormatID;
|
lpData->wFormatID = wFormatID;
|
||||||
lpData->hData = hData;
|
lpData->hData = hData;
|
||||||
lpData->lpFormat = lpFormat;
|
|
||||||
lpData->drvData = 0;
|
|
||||||
|
|
||||||
list_add_tail( &data_list, &lpData->entry );
|
list_add_tail( &data_list, &lpData->entry );
|
||||||
ClipDataCount++;
|
ClipDataCount++;
|
||||||
|
@ -575,10 +569,6 @@ static void X11DRV_CLIPBOARD_FreeData(LPWINE_CLIPDATA lpData)
|
||||||
case CF_PALETTE:
|
case CF_PALETTE:
|
||||||
DeleteObject(lpData->hData);
|
DeleteObject(lpData->hData);
|
||||||
break;
|
break;
|
||||||
case CF_DIB:
|
|
||||||
if (lpData->drvData) XFreePixmap(gdi_display, lpData->drvData);
|
|
||||||
GlobalFree(lpData->hData);
|
|
||||||
break;
|
|
||||||
case CF_METAFILEPICT:
|
case CF_METAFILEPICT:
|
||||||
case CF_DSPMETAFILEPICT:
|
case CF_DSPMETAFILEPICT:
|
||||||
DeleteMetaFile(((METAFILEPICT *)GlobalLock( lpData->hData ))->hMF );
|
DeleteMetaFile(((METAFILEPICT *)GlobalLock( lpData->hData ))->hMF );
|
||||||
|
@ -593,7 +583,6 @@ static void X11DRV_CLIPBOARD_FreeData(LPWINE_CLIPDATA lpData)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
lpData->hData = 0;
|
lpData->hData = 0;
|
||||||
lpData->drvData = 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -1245,14 +1234,19 @@ static HANDLE import_text_uri_list( Atom type, const void *data, size_t size )
|
||||||
*/
|
*/
|
||||||
static HANDLE import_targets( Atom type, const void *data, size_t size )
|
static HANDLE import_targets( Atom type, const void *data, size_t size )
|
||||||
{
|
{
|
||||||
UINT i, count = size / sizeof(Atom);
|
UINT i, pos, count = size / sizeof(Atom);
|
||||||
const Atom *properties = data;
|
const Atom *properties = data;
|
||||||
struct clipboard_format *format;
|
struct clipboard_format *format, **formats;
|
||||||
|
|
||||||
if (type != XA_ATOM && type != x11drv_atom(TARGETS)) return 0;
|
if (type != XA_ATOM && type != x11drv_atom(TARGETS)) return 0;
|
||||||
|
|
||||||
register_x11_formats( properties, count );
|
register_x11_formats( properties, count );
|
||||||
|
|
||||||
|
/* the builtin formats contain duplicates, so allocate some extra space */
|
||||||
|
if (!(formats = HeapAlloc( GetProcessHeap(), 0, (count + NB_BUILTIN_FORMATS) * sizeof(*formats ))))
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
pos = 0;
|
||||||
LIST_FOR_EACH_ENTRY( format, &format_list, struct clipboard_format, entry )
|
LIST_FOR_EACH_ENTRY( format, &format_list, struct clipboard_format, entry )
|
||||||
{
|
{
|
||||||
for (i = 0; i < count; i++) if (properties[i] == format->atom) break;
|
for (i = 0; i < count; i++) if (properties[i] == format->atom) break;
|
||||||
|
@ -1261,10 +1255,15 @@ static HANDLE import_targets( Atom type, const void *data, size_t size )
|
||||||
{
|
{
|
||||||
TRACE( "property %s -> format %s\n",
|
TRACE( "property %s -> format %s\n",
|
||||||
debugstr_xatom( properties[i] ), debugstr_format( format->id ));
|
debugstr_xatom( properties[i] ), debugstr_format( format->id ));
|
||||||
X11DRV_CLIPBOARD_InsertClipboardData( format->id, 0, format, FALSE );
|
X11DRV_CLIPBOARD_InsertClipboardData( format->id, 0 );
|
||||||
|
formats[pos++] = format;
|
||||||
}
|
}
|
||||||
else TRACE( "property %s (ignoring)\n", debugstr_xatom( properties[i] ));
|
else TRACE( "property %s (ignoring)\n", debugstr_xatom( properties[i] ));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
HeapFree( GetProcessHeap(), 0, current_x11_formats );
|
||||||
|
current_x11_formats = formats;
|
||||||
|
nb_current_x11_formats = pos;
|
||||||
return (HANDLE)1;
|
return (HANDLE)1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1343,6 +1342,25 @@ void X11DRV_CLIPBOARD_ImportSelection( Display *display, Window win, Atom select
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**************************************************************************
|
||||||
|
* render_format
|
||||||
|
*/
|
||||||
|
static BOOL render_format( Display *display, Window win, Atom selection, UINT id )
|
||||||
|
{
|
||||||
|
unsigned int i;
|
||||||
|
HANDLE handle = 0;
|
||||||
|
|
||||||
|
for (i = 0; i < nb_current_x11_formats; i++)
|
||||||
|
{
|
||||||
|
if (current_x11_formats[i]->id != id) continue;
|
||||||
|
handle = import_selection( display, win, selection, current_x11_formats[i] );
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (handle) X11DRV_CLIPBOARD_InsertClipboardData( id, handle );
|
||||||
|
return handle != 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**************************************************************************
|
/**************************************************************************
|
||||||
* export_data
|
* export_data
|
||||||
*
|
*
|
||||||
|
@ -1944,12 +1962,12 @@ static int X11DRV_CLIPBOARD_QueryAvailableData(Display *display)
|
||||||
/* Selection Owner doesn't understand TARGETS, try retrieving XA_STRING */
|
/* Selection Owner doesn't understand TARGETS, try retrieving XA_STRING */
|
||||||
if (use_primary_selection && (handle = import_selection( display, w, XA_PRIMARY, format )))
|
if (use_primary_selection && (handle = import_selection( display, w, XA_PRIMARY, format )))
|
||||||
{
|
{
|
||||||
X11DRV_CLIPBOARD_InsertClipboardData( format->id, handle, format, TRUE );
|
X11DRV_CLIPBOARD_InsertClipboardData( format->id, handle );
|
||||||
selectionCacheSrc = XA_PRIMARY;
|
selectionCacheSrc = XA_PRIMARY;
|
||||||
}
|
}
|
||||||
else if ((handle = import_selection( display, w, x11drv_atom(CLIPBOARD), format )))
|
else if ((handle = import_selection( display, w, x11drv_atom(CLIPBOARD), format )))
|
||||||
{
|
{
|
||||||
X11DRV_CLIPBOARD_InsertClipboardData( format->id, handle, format, TRUE );
|
X11DRV_CLIPBOARD_InsertClipboardData( format->id, handle );
|
||||||
selectionCacheSrc = x11drv_atom(CLIPBOARD);
|
selectionCacheSrc = x11drv_atom(CLIPBOARD);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -1974,37 +1992,14 @@ static int X11DRV_CLIPBOARD_QueryAvailableData(Display *display)
|
||||||
*/
|
*/
|
||||||
static BOOL X11DRV_CLIPBOARD_ReadSelectionData(Display *display, LPWINE_CLIPDATA lpData)
|
static BOOL X11DRV_CLIPBOARD_ReadSelectionData(Display *display, LPWINE_CLIPDATA lpData)
|
||||||
{
|
{
|
||||||
BOOL bRet = FALSE;
|
Window w = thread_selection_wnd();
|
||||||
HANDLE hData;
|
|
||||||
|
|
||||||
if (!lpData->lpFormat)
|
if (!w)
|
||||||
{
|
{
|
||||||
ERR("Requesting format %04x but no source format linked to data.\n",
|
ERR("No window available to read selection data!\n");
|
||||||
lpData->wFormatID);
|
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
return render_format( display, w, selectionCacheSrc, lpData->wFormatID );
|
||||||
if (!selectionAcquired)
|
|
||||||
{
|
|
||||||
Window w = thread_selection_wnd();
|
|
||||||
if(!w)
|
|
||||||
{
|
|
||||||
ERR("No window available to read selection data!\n");
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
hData = import_selection( display, w, selectionCacheSrc, lpData->lpFormat );
|
|
||||||
if (hData)
|
|
||||||
bRet = X11DRV_CLIPBOARD_InsertClipboardData(lpData->wFormatID, hData, lpData->lpFormat, TRUE);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
ERR("Received request to cache selection data but process is owner\n");
|
|
||||||
}
|
|
||||||
|
|
||||||
TRACE("Returning %d\n", bRet);
|
|
||||||
|
|
||||||
return bRet;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -2386,7 +2381,7 @@ BOOL CDECL X11DRV_SetClipboardData(UINT wFormat, HANDLE hData, BOOL owner)
|
||||||
{
|
{
|
||||||
if (!owner) X11DRV_CLIPBOARD_UpdateCache();
|
if (!owner) X11DRV_CLIPBOARD_UpdateCache();
|
||||||
|
|
||||||
return X11DRV_CLIPBOARD_InsertClipboardData(wFormat, hData, NULL, TRUE);
|
return X11DRV_CLIPBOARD_InsertClipboardData( wFormat, hData );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue