From: Jacek Caban jacek@codeweavers.com
Signed-off-by: Jacek Caban jacek@codeweavers.com --- dlls/winemac.drv/clipboard.c | 61 +++++++++++++++++++++++----------- dlls/winemac.drv/dragdrop.c | 34 ++++++++++--------- dlls/winemac.drv/macdrv.h | 6 ++-- dlls/winemac.drv/macdrv_main.c | 4 +++ dlls/winemac.drv/unixlib.h | 18 ++++++++++ 5 files changed, 86 insertions(+), 37 deletions(-)
diff --git a/dlls/winemac.drv/clipboard.c b/dlls/winemac.drv/clipboard.c index 16c44ddfde6..f46bb389cc9 100644 --- a/dlls/winemac.drv/clipboard.c +++ b/dlls/winemac.drv/clipboard.c @@ -248,6 +248,12 @@ static const char *debugstr_format(UINT id) }
+static CFTypeRef pasteboard_from_handle(UINT64 handle) +{ + return (CFTypeRef)(UINT_PTR)handle; +} + + /************************************************************************** * insert_clipboard_format */ @@ -1201,14 +1207,16 @@ HANDLE macdrv_get_pasteboard_data(CFTypeRef pasteboard, UINT desired_format) /************************************************************************** * macdrv_pasteboard_has_format */ -BOOL macdrv_pasteboard_has_format(CFTypeRef pasteboard, UINT desired_format) +NTSTATUS macdrv_dnd_have_format(void *arg) { + struct dnd_have_format_params *params = arg; + CFTypeRef pasteboard = pasteboard_from_handle(params->handle); CFArrayRef types; int count; UINT i; BOOL found = FALSE;
- TRACE("pasteboard %p, desired_format %s\n", pasteboard, debugstr_format(desired_format)); + TRACE("pasteboard %p, desired_format %s\n", pasteboard, debugstr_format(params->format));
types = macdrv_copy_pasteboard_types(pasteboard); if (!types) @@ -1229,7 +1237,7 @@ BOOL macdrv_pasteboard_has_format(CFTypeRef pasteboard, UINT desired_format) { TRACE("for type %s got format %s\n", debugstr_cf(type), debugstr_format(format->format_id));
- if (format->format_id == desired_format) + if (format->format_id == params->format) { found = TRUE; break; @@ -1365,33 +1373,24 @@ static WINE_CLIPFORMAT** get_formats_for_pasteboard(CFTypeRef pasteboard, UINT *
/************************************************************************** - * macdrv_get_pasteboard_formats + * macdrv_dnd_get_formats */ -UINT* macdrv_get_pasteboard_formats(CFTypeRef pasteboard, UINT* num_formats) +NTSTATUS macdrv_dnd_get_formats(void *arg) { + struct dnd_get_formats_params *params = arg; + CFTypeRef pasteboard = pasteboard_from_handle(params->handle); WINE_CLIPFORMAT** formats; UINT count, i; - UINT* format_ids;
formats = get_formats_for_pasteboard(pasteboard, &count); if (!formats) - return NULL; - - format_ids = malloc(count); - if (!format_ids) - { - WARN("Failed to allocate formats IDs array\n"); - free(formats); - return NULL; - } + return 0; + count = min(count, ARRAYSIZE(params->formats));
for (i = 0; i < count; i++) - format_ids[i] = formats[i]->format_id; - - free(formats); + params->formats[i] = formats[i]->format_id;
- *num_formats = count; - return format_ids; + return count; }
@@ -1746,3 +1745,25 @@ void macdrv_lost_pasteboard_ownership(HWND hwnd) if (!macdrv_is_pasteboard_owner(clipboard_cocoa_window)) grab_win32_clipboard(); } + + +/************************************************************************** + * macdrv_dnd_release + */ +NTSTATUS macdrv_dnd_release(void *arg) +{ + UINT64 handle = *(UINT64 *)arg; + CFRelease(pasteboard_from_handle(handle)); + return 0; +} + + +/************************************************************************** + * macdrv_dnd_retain + */ +NTSTATUS macdrv_dnd_retain(void *arg) +{ + UINT64 handle = *(UINT64 *)arg; + CFRetain(pasteboard_from_handle(handle)); + return 0; +} diff --git a/dlls/winemac.drv/dragdrop.c b/dlls/winemac.drv/dragdrop.c index c3172a29467..962a9d8c24b 100644 --- a/dlls/winemac.drv/dragdrop.c +++ b/dlls/winemac.drv/dragdrop.c @@ -42,7 +42,7 @@ typedef struct { IDataObject IDataObject_iface; LONG ref; - CFTypeRef pasteboard; + UINT64 pasteboard; } DragDropDataObject;
@@ -131,7 +131,7 @@ static ULONG WINAPI dddo_Release(IDataObject* iface) return refCount;
TRACE("-- destroying DragDropDataObject (%p)\n", This); - CFRelease(This->pasteboard); + MACDRV_CALL(dnd_release, &This->pasteboard); HeapFree(GetProcessHeap(), 0, This); return 0; } @@ -148,7 +148,7 @@ static HRESULT WINAPI dddo_GetData(IDataObject* iface, FORMATETC* formatEtc, STG if (SUCCEEDED(hr)) { medium->tymed = TYMED_HGLOBAL; - medium->u.hGlobal = macdrv_get_pasteboard_data(This->pasteboard, formatEtc->cfFormat); + medium->u.hGlobal = macdrv_get_pasteboard_data((void *)(UINT_PTR)This->pasteboard, formatEtc->cfFormat); medium->pUnkForRelease = NULL; hr = medium->u.hGlobal ? S_OK : E_OUTOFMEMORY; } @@ -168,6 +168,7 @@ static HRESULT WINAPI dddo_GetDataHere(IDataObject* iface, FORMATETC* formatEtc, static HRESULT WINAPI dddo_QueryGetData(IDataObject* iface, FORMATETC* formatEtc) { DragDropDataObject *This = impl_from_IDataObject(iface); + struct dnd_have_format_params params; HRESULT hr = DV_E_FORMATETC;
TRACE("This %p formatEtc %p={.tymed=0x%x, .dwAspect=%d, .cfFormat=%s}\n", @@ -185,7 +186,9 @@ static HRESULT WINAPI dddo_QueryGetData(IDataObject* iface, FORMATETC* formatEtc return E_NOTIMPL; }
- if (macdrv_pasteboard_has_format(This->pasteboard, formatEtc->cfFormat)) + params.handle = This->pasteboard; + params.format = formatEtc->cfFormat; + if (MACDRV_CALL(dnd_have_format, ¶ms)) hr = S_OK;
TRACE(" -> 0x%x\n", hr); @@ -225,7 +228,8 @@ static HRESULT WINAPI dddo_EnumFormatEtc(IDataObject* iface, DWORD direction, IEnumFORMATETC** enumFormatEtc) { DragDropDataObject *This = impl_from_IDataObject(iface); - UINT *formats, count; + struct dnd_get_formats_params params; + UINT count; HRESULT hr;
TRACE("This %p direction %u enumFormatEtc %p\n", This, direction, enumFormatEtc); @@ -236,8 +240,9 @@ static HRESULT WINAPI dddo_EnumFormatEtc(IDataObject* iface, DWORD direction, return E_NOTIMPL; }
- formats = macdrv_get_pasteboard_formats(This->pasteboard, &count); - if (formats) + params.handle = This->pasteboard; + count = MACDRV_CALL(dnd_get_formats, ¶ms); + if (count) { FORMATETC *formatEtcs = HeapAlloc(GetProcessHeap(), 0, count * sizeof(FORMATETC)); if (formatEtcs) @@ -246,7 +251,7 @@ static HRESULT WINAPI dddo_EnumFormatEtc(IDataObject* iface, DWORD direction,
for (i = 0; i < count; i++) { - formatEtcs[i].cfFormat = formats[i]; + formatEtcs[i].cfFormat = params.formats[i]; formatEtcs[i].ptd = NULL; formatEtcs[i].dwAspect = DVASPECT_CONTENT; formatEtcs[i].lindex = -1; @@ -258,8 +263,6 @@ static HRESULT WINAPI dddo_EnumFormatEtc(IDataObject* iface, DWORD direction, } else hr = E_OUTOFMEMORY; - - HeapFree(GetProcessHeap(), 0, formats); } else hr = SHCreateStdEnumFmtEtc(0, NULL, enumFormatEtc); @@ -309,7 +312,7 @@ static const IDataObjectVtbl dovt = };
-static IDataObject *create_data_object_for_pasteboard(CFTypeRef pasteboard) +static IDataObject *create_data_object_for_pasteboard(UINT64 pasteboard) { DragDropDataObject *dddo;
@@ -319,7 +322,8 @@ static IDataObject *create_data_object_for_pasteboard(CFTypeRef pasteboard)
dddo->ref = 1; dddo->IDataObject_iface.lpVtbl = &dovt; - dddo->pasteboard = CFRetain(pasteboard); + dddo->pasteboard = pasteboard; + MACDRV_CALL(dnd_retain, &dddo->pasteboard);
return &dddo->IDataObject_iface; } @@ -421,7 +425,7 @@ NTSTATUS WINAPI macdrv_dnd_query_drop(void *arg, ULONG size) if (!active_data_object) { WARN("shouldn't happen: no active IDataObject\n"); - active_data_object = create_data_object_for_pasteboard((void *)(UINT_PTR)params->handle); + active_data_object = create_data_object_for_pasteboard(params->handle); }
pointl.x = pt.x; @@ -564,7 +568,7 @@ NTSTATUS WINAPI macdrv_dnd_query_drag(void *arg, ULONG size) POINTL pointl = { pt.x, pt.y };
if (!active_data_object) - active_data_object = create_data_object_for_pasteboard((void *)(UINT_PTR)params->handle); + active_data_object = create_data_object_for_pasteboard(params->handle);
TRACE("DragEnter hwnd %p droptarget %p\n", hwnd, droptarget); hr = IDropTarget_DragEnter(droptarget, active_data_object, MK_LBUTTON, @@ -605,7 +609,7 @@ NTSTATUS WINAPI macdrv_dnd_query_drag(void *arg, ULONG size) FORMATETC formatEtc;
if (!active_data_object) - active_data_object = create_data_object_for_pasteboard((void *)(UINT_PTR)params->handle); + active_data_object = create_data_object_for_pasteboard(params->handle);
formatEtc.cfFormat = CF_HDROP; formatEtc.ptd = NULL; diff --git a/dlls/winemac.drv/macdrv.h b/dlls/winemac.drv/macdrv.h index ce71baa5735..4c1a21a3fe8 100644 --- a/dlls/winemac.drv/macdrv.h +++ b/dlls/winemac.drv/macdrv.h @@ -256,8 +256,6 @@ extern void macdrv_UpdateClipboard(void) DECLSPEC_HIDDEN; extern BOOL query_pasteboard_data(HWND hwnd, CFStringRef type) DECLSPEC_HIDDEN; extern void macdrv_lost_pasteboard_ownership(HWND hwnd) DECLSPEC_HIDDEN; extern HANDLE macdrv_get_pasteboard_data(CFTypeRef pasteboard, UINT desired_format) DECLSPEC_HIDDEN; -extern BOOL macdrv_pasteboard_has_format(CFTypeRef pasteboard, UINT desired_format) DECLSPEC_HIDDEN; -extern UINT* macdrv_get_pasteboard_formats(CFTypeRef pasteboard, UINT* num_formats) DECLSPEC_HIDDEN;
extern struct opengl_funcs *macdrv_wine_get_wgl_driver(UINT version) DECLSPEC_HIDDEN; extern const struct vulkan_funcs *macdrv_wine_get_vulkan_driver(UINT version) DECLSPEC_HIDDEN; @@ -287,6 +285,10 @@ extern NTSTATUS WINAPI macdrv_ime_query_char_rect(void *params, ULONG size) DECL
/* unixlib interface */
+extern NTSTATUS macdrv_dnd_get_formats(void *arg) DECLSPEC_HIDDEN; +extern NTSTATUS macdrv_dnd_have_format(void *arg) DECLSPEC_HIDDEN; +extern NTSTATUS macdrv_dnd_release(void *arg) DECLSPEC_HIDDEN; +extern NTSTATUS macdrv_dnd_retain(void *arg) DECLSPEC_HIDDEN; extern NTSTATUS macdrv_ime_process_text_input(void *arg) DECLSPEC_HIDDEN; extern NTSTATUS macdrv_notify_icon(void *arg) DECLSPEC_HIDDEN;
diff --git a/dlls/winemac.drv/macdrv_main.c b/dlls/winemac.drv/macdrv_main.c index 4ef9060ea4b..a0b29604e62 100644 --- a/dlls/winemac.drv/macdrv_main.c +++ b/dlls/winemac.drv/macdrv_main.c @@ -630,6 +630,10 @@ static NTSTATUS macdrv_ime_using_input_method(void *arg)
const unixlib_entry_t __wine_unix_call_funcs[] = { + macdrv_dnd_get_formats, + macdrv_dnd_have_format, + macdrv_dnd_release, + macdrv_dnd_retain, macdrv_ime_clear, macdrv_ime_process_text_input, macdrv_ime_using_input_method, diff --git a/dlls/winemac.drv/unixlib.h b/dlls/winemac.drv/unixlib.h index f4a8b7982f5..b29bf99e7f4 100644 --- a/dlls/winemac.drv/unixlib.h +++ b/dlls/winemac.drv/unixlib.h @@ -21,6 +21,10 @@
enum macdrv_funcs { + unix_dnd_get_formats, + unix_dnd_have_format, + unix_dnd_release, + unix_dnd_retain, unix_ime_clear, unix_ime_process_text_input, unix_ime_using_input_method, @@ -33,6 +37,20 @@ enum macdrv_funcs extern NTSTATUS unix_call(enum macdrv_funcs code, void *params) DECLSPEC_HIDDEN; #define MACDRV_CALL(func, params) unix_call( unix_ ## func, params )
+/* macdrv_dnd_get_formats params */ +struct dnd_get_formats_params +{ + UINT64 handle; + UINT formats[64]; +}; + +/* macdrv_dnd_have_format params */ +struct dnd_have_format_params +{ + UINT64 handle; + UINT format; +}; + /* macdrv_ime_process_text_input params */ struct process_text_input_params {