From: Jacek Caban jacek@codeweavers.com
Signed-off-by: Jacek Caban jacek@codeweavers.com --- dlls/winemac.drv/dllmain.c | 1 + dlls/winemac.drv/dragdrop.c | 72 ++++++++----------------------------- dlls/winemac.drv/event.c | 47 ++++++++++++++++++++++++ dlls/winemac.drv/macdrv.h | 3 +- dlls/winemac.drv/unixlib.h | 13 ++++++- 5 files changed, 75 insertions(+), 61 deletions(-)
diff --git a/dlls/winemac.drv/dllmain.c b/dlls/winemac.drv/dllmain.c index 69bc02e46c2..4bedb2aaf61 100644 --- a/dlls/winemac.drv/dllmain.c +++ b/dlls/winemac.drv/dllmain.c @@ -29,6 +29,7 @@ HMODULE macdrv_module = 0; typedef NTSTATUS (WINAPI *kernel_callback)(void *params, ULONG size); static const kernel_callback kernel_callbacks[] = { + macdrv_dnd_query_drag, macdrv_dnd_query_drop, macdrv_dnd_query_exited, macdrv_ime_query_char_rect, diff --git a/dlls/winemac.drv/dragdrop.c b/dlls/winemac.drv/dragdrop.c index a57caab423b..c3172a29467 100644 --- a/dlls/winemac.drv/dragdrop.c +++ b/dlls/winemac.drv/dragdrop.c @@ -325,37 +325,6 @@ static IDataObject *create_data_object_for_pasteboard(CFTypeRef pasteboard) }
-/************************************************************************** - * drag_operations_to_dropeffects - */ -static DWORD drag_operations_to_dropeffects(uint32_t ops) -{ - DWORD effects = DROPEFFECT_NONE; - if (ops & (DRAG_OP_COPY | DRAG_OP_GENERIC)) - effects |= DROPEFFECT_COPY; - if (ops & DRAG_OP_MOVE) - effects |= DROPEFFECT_MOVE; - if (ops & (DRAG_OP_LINK | DRAG_OP_GENERIC)) - effects |= DROPEFFECT_LINK; - return effects; -} - - -/************************************************************************** - * dropeffect_to_drag_operation - */ -static uint32_t dropeffect_to_drag_operation(DWORD effect, uint32_t ops) -{ - if (effect & DROPEFFECT_LINK && ops & DRAG_OP_LINK) return DRAG_OP_LINK; - if (effect & DROPEFFECT_COPY && ops & DRAG_OP_COPY) return DRAG_OP_COPY; - if (effect & DROPEFFECT_MOVE && ops & DRAG_OP_MOVE) return DRAG_OP_MOVE; - if (effect & DROPEFFECT_LINK && ops & DRAG_OP_GENERIC) return DRAG_OP_GENERIC; - if (effect & DROPEFFECT_COPY && ops & DRAG_OP_GENERIC) return DRAG_OP_GENERIC; - - return DRAG_OP_NONE; -} - - /* Based on functions in dlls/ole32/ole2.c */ static HANDLE get_droptarget_local_handle(HWND hwnd) { @@ -547,31 +516,22 @@ NTSTATUS WINAPI macdrv_dnd_query_exited(void *arg, ULONG size) /************************************************************************** * query_drag_operation */ -BOOL query_drag_operation(macdrv_query* query) +NTSTATUS WINAPI macdrv_dnd_query_drag(void *arg, ULONG size) { + struct dnd_query_drag_params *params = arg; + HWND hwnd = params->hwnd; BOOL ret = FALSE; - HWND hwnd = macdrv_get_window_hwnd(query->window); - struct macdrv_win_data *data = get_win_data(hwnd); POINT pt; DWORD effect; IDropTarget *droptarget; HRESULT hr;
- TRACE("win %p/%p x,y %d,%d offered_ops 0x%x pasteboard %p\n", hwnd, query->window, - query->drag_operation.x, query->drag_operation.y, query->drag_operation.offered_ops, - query->drag_operation.pasteboard); - - if (!data) - { - WARN("no win_data for win %p/%p\n", hwnd, query->window); - return FALSE; - } - - pt.x = query->drag_operation.x + data->whole_rect.left; - pt.y = query->drag_operation.y + data->whole_rect.top; - release_win_data(data); + TRACE("win %p x,y %d,%d effect %x pasteboard %s\n", hwnd, params->x, params->y, + params->effect, wine_dbgstr_longlong(params->handle));
- effect = drag_operations_to_dropeffects(query->drag_operation.offered_ops); + pt.x = params->x; + pt.y = params->y; + effect = params->effect;
/* Instead of the top-level window we got in the query, start with the deepest child under the cursor. Travel up the hierarchy looking for a window that @@ -604,16 +564,14 @@ BOOL query_drag_operation(macdrv_query* query) POINTL pointl = { pt.x, pt.y };
if (!active_data_object) - active_data_object = create_data_object_for_pasteboard(query->drag_operation.pasteboard); + active_data_object = create_data_object_for_pasteboard((void *)(UINT_PTR)params->handle);
TRACE("DragEnter hwnd %p droptarget %p\n", hwnd, droptarget); hr = IDropTarget_DragEnter(droptarget, active_data_object, MK_LBUTTON, pointl, &effect); if (SUCCEEDED(hr)) { - query->drag_operation.accepted_op = dropeffect_to_drag_operation(effect, - query->drag_operation.offered_ops); - TRACE(" effect %d accepted op %d\n", effect, query->drag_operation.accepted_op); + TRACE(" effect %d\n", effect); ret = TRUE; } else @@ -629,9 +587,7 @@ BOOL query_drag_operation(macdrv_query* query) hr = IDropTarget_DragOver(droptarget, MK_LBUTTON, pointl, &effect); if (SUCCEEDED(hr)) { - query->drag_operation.accepted_op = dropeffect_to_drag_operation(effect, - query->drag_operation.offered_ops); - TRACE(" effect %d accepted op %d\n", effect, query->drag_operation.accepted_op); + TRACE(" effect %d\n", effect); ret = TRUE; } else @@ -649,7 +605,7 @@ BOOL query_drag_operation(macdrv_query* query) FORMATETC formatEtc;
if (!active_data_object) - active_data_object = create_data_object_for_pasteboard(query->drag_operation.pasteboard); + active_data_object = create_data_object_for_pasteboard((void *)(UINT_PTR)params->handle);
formatEtc.cfFormat = CF_HDROP; formatEtc.ptd = NULL; @@ -659,12 +615,12 @@ BOOL query_drag_operation(macdrv_query* query) if (SUCCEEDED(IDataObject_QueryGetData(active_data_object, &formatEtc))) { TRACE("WS_EX_ACCEPTFILES hwnd %p\n", hwnd); - query->drag_operation.accepted_op = DRAG_OP_GENERIC; + effect = DROPEFFECT_COPY | DROPEFFECT_LINK; ret = TRUE; } } }
TRACE(" -> %s\n", ret ? "TRUE" : "FALSE"); - return ret; + return ret ? effect : 0; } diff --git a/dlls/winemac.drv/event.c b/dlls/winemac.drv/event.c index 8432218d8d1..ce7f06b07dd 100644 --- a/dlls/winemac.drv/event.c +++ b/dlls/winemac.drv/event.c @@ -195,6 +195,21 @@ static DWORD drag_operations_to_dropeffects(uint32_t ops) }
+/************************************************************************** + * dropeffect_to_drag_operation + */ +static uint32_t dropeffect_to_drag_operation(DWORD effect, uint32_t ops) +{ + if (effect & DROPEFFECT_LINK && ops & DRAG_OP_LINK) return DRAG_OP_LINK; + if (effect & DROPEFFECT_COPY && ops & DRAG_OP_COPY) return DRAG_OP_COPY; + if (effect & DROPEFFECT_MOVE && ops & DRAG_OP_MOVE) return DRAG_OP_MOVE; + if (effect & DROPEFFECT_LINK && ops & DRAG_OP_GENERIC) return DRAG_OP_GENERIC; + if (effect & DROPEFFECT_COPY && ops & DRAG_OP_GENERIC) return DRAG_OP_GENERIC; + + return DRAG_OP_NONE; +} + + /************************************************************************** * query_drag_drop */ @@ -230,6 +245,38 @@ static BOOL query_drag_exited(macdrv_query *query) }
+/************************************************************************** + * query_drag_operation + */ +static BOOL query_drag_operation(macdrv_query *query) +{ + struct dnd_query_drag_params params; + HWND hwnd = macdrv_get_window_hwnd(query->window); + struct macdrv_win_data *data = get_win_data(hwnd); + DWORD effect; + + if (!data) + { + WARN("no win_data for win %p/%p\n", hwnd, query->window); + return FALSE; + } + + params.hwnd = hwnd; + params.effect = drag_operations_to_dropeffects(query->drag_operation.offered_ops); + params.x = query->drag_operation.x + data->whole_rect.left; + params.y = query->drag_operation.y + data->whole_rect.top; + params.handle = (UINT_PTR)query->drag_operation.pasteboard; + release_win_data(data); + + effect = macdrv_client_func(client_func_dnd_query_drag, ¶ms, sizeof(params)); + if (!effect) return FALSE; + + query->drag_operation.accepted_op = dropeffect_to_drag_operation(effect, + query->drag_operation.offered_ops); + return TRUE; +} + + /************************************************************************** * query_ime_char_rect */ diff --git a/dlls/winemac.drv/macdrv.h b/dlls/winemac.drv/macdrv.h index a0ae0225423..ce71baa5735 100644 --- a/dlls/winemac.drv/macdrv.h +++ b/dlls/winemac.drv/macdrv.h @@ -259,8 +259,6 @@ extern HANDLE macdrv_get_pasteboard_data(CFTypeRef pasteboard, UINT desired_form 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 BOOL query_drag_operation(macdrv_query* query) 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; extern void sync_gl_view(struct macdrv_win_data* data, const RECT* old_whole_rect, const RECT* old_client_rect) DECLSPEC_HIDDEN; @@ -295,6 +293,7 @@ extern NTSTATUS macdrv_notify_icon(void *arg) DECLSPEC_HIDDEN; extern NTSTATUS macdrv_client_func(enum macdrv_client_funcs func, const void *params, ULONG size) DECLSPEC_HIDDEN;
+extern NTSTATUS WINAPI macdrv_dnd_query_drag(void *arg, ULONG size) DECLSPEC_HIDDEN; extern NTSTATUS WINAPI macdrv_dnd_query_drop(void *arg, ULONG size) DECLSPEC_HIDDEN; extern NTSTATUS WINAPI macdrv_dnd_query_exited(void *arg, ULONG size) DECLSPEC_HIDDEN;
diff --git a/dlls/winemac.drv/unixlib.h b/dlls/winemac.drv/unixlib.h index a858b29baaa..f4a8b7982f5 100644 --- a/dlls/winemac.drv/unixlib.h +++ b/dlls/winemac.drv/unixlib.h @@ -67,13 +67,24 @@ struct notify_icon_params /* driver client callbacks exposed with KernelCallbackTable interface */ enum macdrv_client_funcs { - client_func_dnd_query_drop = NtUserDriverCallbackFirst, + client_func_dnd_query_drag = NtUserDriverCallbackFirst, + client_func_dnd_query_drop, client_func_dnd_query_exited, client_func_ime_query_char_rect, client_func_ime_set_text, client_func_last };
+/* macdrv_dnd_query_drag params */ +struct dnd_query_drag_params +{ + HWND hwnd; + UINT32 effect; + INT32 x; + INT32 y; + UINT64 handle; +}; + /* macdrv_dnd_query_drop params */ struct dnd_query_drop_params {