winemac: Reimplement query_pasteboard_data() using the user32 clipboard API.

Signed-off-by: Ken Thomases <ken@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Ken Thomases 2016-10-23 13:03:30 -05:00 committed by Alexandre Julliard
parent 33b9494ecf
commit 019983e2c6

View File

@ -40,12 +40,6 @@ WINE_DEFAULT_DEBUG_CHANNEL(clipboard);
* Types * Types
**************************************************************************/ **************************************************************************/
typedef struct
{
HWND hwnd_owner;
UINT flags;
} CLIPBOARDINFO, *LPCLIPBOARDINFO;
typedef HANDLE (*DRVIMPORTFUNC)(CFDataRef data); typedef HANDLE (*DRVIMPORTFUNC)(CFDataRef data);
typedef CFDataRef (*DRVEXPORTFUNC)(HANDLE data); typedef CFDataRef (*DRVEXPORTFUNC)(HANDLE data);
@ -1197,35 +1191,6 @@ static CFDataRef export_unicodetext_to_utf16(HANDLE data)
} }
/**************************************************************************
* get_clipboard_info
*/
static BOOL get_clipboard_info(LPCLIPBOARDINFO cbinfo)
{
BOOL ret = FALSE;
SERVER_START_REQ(set_clipboard_info)
{
req->flags = 0;
if (wine_server_call_err(req))
{
ERR("Failed to get clipboard owner.\n");
}
else
{
cbinfo->hwnd_owner = wine_server_ptr_handle(reply->old_owner);
cbinfo->flags = reply->flags;
ret = TRUE;
}
}
SERVER_END_REQ;
return ret;
}
/************************************************************************** /**************************************************************************
* macdrv_get_pasteboard_data * macdrv_get_pasteboard_data
*/ */
@ -1488,47 +1453,35 @@ void macdrv_clipboard_process_attach(void)
*/ */
BOOL query_pasteboard_data(HWND hwnd, CFStringRef type) BOOL query_pasteboard_data(HWND hwnd, CFStringRef type)
{ {
WINE_CLIPFORMAT *format;
BOOL ret = FALSE; BOOL ret = FALSE;
CLIPBOARDINFO cbinfo; HANDLE handle;
WINE_CLIPFORMAT* format;
CFArrayRef types = NULL;
TRACE("hwnd %p type %s\n", hwnd, debugstr_cf(type)); TRACE("win %p type %s\n", hwnd, debugstr_cf(type));
if (get_clipboard_info(&cbinfo))
hwnd = cbinfo.hwnd_owner;
format = format_for_type(type); format = format_for_type(type);
if (!format) goto done; if (!format) return FALSE;
TRACE("for type %s got format %p/%s\n", debugstr_cf(type), format, debugstr_format(format->format_id)); if (!OpenClipboard(NULL))
if (!format->synthesized)
{ {
TRACE("Sending WM_RENDERFORMAT message for format %s to hwnd %p\n", debugstr_format(format->format_id), hwnd); ERR("failed to open clipboard for %s\n", debugstr_cf(type));
SendMessageW(hwnd, WM_RENDERFORMAT, format->format_id, 0); return FALSE;
ret = TRUE;
goto done;
} }
types = macdrv_copy_pasteboard_types(NULL); if ((handle = GetClipboardData(format->format_id)))
if (!types)
{ {
WARN("Failed to copy pasteboard types\n"); CFDataRef data;
goto done;
TRACE("exporting %s %p\n", debugstr_format(format->format_id), handle);
if ((data = format->export_func(handle)))
{
ret = macdrv_set_pasteboard_data(format->type, data, macdrv_get_cocoa_window(hwnd, FALSE));
CFRelease(data);
}
} }
if (format->natural_format && CloseClipboard();
CFArrayContainsValue(types, CFRangeMake(0, CFArrayGetCount(types)), format->natural_format->type))
{
TRACE("Sending WM_RENDERFORMAT message for format %s to hwnd %p\n", debugstr_format(format->format_id), hwnd);
SendMessageW(hwnd, WM_RENDERFORMAT, format->format_id, 0);
ret = TRUE;
goto done;
}
done:
if (types) CFRelease(types);
return ret; return ret;
} }