winemac: Use unixlib interface for query_drag_drop.

Signed-off-by: Jacek Caban <jacek@codeweavers.com>
This commit is contained in:
Jacek Caban 2022-06-01 01:21:53 +02:00 committed by Alexandre Julliard
parent 4998bbacef
commit 3aa1a86b3f
5 changed files with 68 additions and 24 deletions

View file

@ -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_drop,
macdrv_dnd_query_exited,
macdrv_ime_query_char_rect,
macdrv_ime_set_text,

View file

@ -427,40 +427,32 @@ static IDropTarget* get_droptarget_pointer(HWND hwnd)
/**************************************************************************
* query_drag_drop
* macdrv_dnd_query_drop
*/
BOOL query_drag_drop(macdrv_query* query)
NTSTATUS WINAPI macdrv_dnd_query_drop(void *arg, ULONG size)
{
BOOL ret = FALSE;
HWND hwnd = macdrv_get_window_hwnd(query->window);
struct macdrv_win_data *data = get_win_data(hwnd);
POINT pt;
struct dnd_query_drop_params *params = arg;
IDropTarget *droptarget;
BOOL ret = FALSE;
POINT pt;
TRACE("win %p/%p x,y %d,%d op 0x%08x pasteboard %p\n", hwnd, query->window,
query->drag_drop.x, query->drag_drop.y, query->drag_drop.op, query->drag_drop.pasteboard);
TRACE("win %p x,y %d,%d effect %x pasteboard %s\n", params->hwnd, params->x, params->y,
params->effect, wine_dbgstr_longlong(params->handle));
if (!data)
{
WARN("no win_data for win %p/%p\n", hwnd, query->window);
return FALSE;
}
pt.x = query->drag_drop.x + data->whole_rect.left;
pt.y = query->drag_drop.y + data->whole_rect.top;
release_win_data(data);
pt.x = params->x;
pt.y = params->y;
droptarget = get_droptarget_pointer(last_droptarget_hwnd);
if (droptarget)
{
HRESULT hr;
POINTL pointl;
DWORD effect = drag_operations_to_dropeffects(query->drag_drop.op);
DWORD effect = params->effect;
if (!active_data_object)
{
WARN("shouldn't happen: no active IDataObject\n");
active_data_object = create_data_object_for_pasteboard(query->drag_drop.pasteboard);
active_data_object = create_data_object_for_pasteboard((void *)(UINT_PTR)params->handle);
}
pointl.x = pt.x;
@ -484,12 +476,12 @@ BOOL query_drag_drop(macdrv_query* query)
}
else
{
hwnd = WindowFromPoint(pt);
HWND hwnd = WindowFromPoint(pt);
while (hwnd && !(GetWindowLongW(hwnd, GWL_EXSTYLE) & WS_EX_ACCEPTFILES))
hwnd = GetParent(hwnd);
if (hwnd)
{
HDROP hdrop = macdrv_get_pasteboard_data(query->drag_drop.pasteboard, CF_HDROP);
HDROP hdrop = macdrv_get_pasteboard_data((void *)(UINT_PTR)params->handle, CF_HDROP);
DROPFILES *dropfiles = GlobalLock(hdrop);
if (dropfiles)
{

View file

@ -23,7 +23,7 @@
#include "config.h"
#include "macdrv.h"
#include "winuser.h"
#include "oleidl.h"
WINE_DEFAULT_DEBUG_CHANNEL(event);
WINE_DECLARE_DEBUG_CHANNEL(imm);
@ -179,6 +179,46 @@ static void macdrv_sent_text_input(const macdrv_event *event)
}
/**************************************************************************
* drag_operations_to_dropeffects
*/
static DWORD drag_operations_to_dropeffects(uint32_t ops)
{
DWORD effects = 0;
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;
}
/**************************************************************************
* query_drag_drop
*/
static BOOL query_drag_drop(macdrv_query *query)
{
HWND hwnd = macdrv_get_window_hwnd(query->window);
struct macdrv_win_data *data = get_win_data(hwnd);
struct dnd_query_drop_params params;
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_drop.op);
params.x = query->drag_drop.x + data->whole_rect.left;
params.y = query->drag_drop.y + data->whole_rect.top;
params.handle = (UINT_PTR)query->drag_drop.pasteboard;
release_win_data(data);
return macdrv_client_func(client_func_dnd_query_drop, &params, sizeof(params));
}
/**************************************************************************
* query_drag_exited
*/

View file

@ -260,7 +260,6 @@ extern NTSTATUS macdrv_MsgWaitForMultipleObjectsEx(DWORD count, const HANDLE *ha
extern UINT* macdrv_get_pasteboard_formats(CFTypeRef pasteboard, UINT* num_formats) DECLSPEC_HIDDEN;
extern BOOL query_drag_operation(macdrv_query* query) DECLSPEC_HIDDEN;
extern BOOL query_drag_drop(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;
@ -296,6 +295,7 @@ extern CGImageRef create_cgimage_from_icon_bitmaps(HDC hdc, HANDLE icon, HBITMAP
extern NTSTATUS macdrv_client_func(enum macdrv_client_funcs func, const void *params,
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;
/* user helpers */

View file

@ -67,12 +67,23 @@
/* driver client callbacks exposed with KernelCallbackTable interface */
enum macdrv_client_funcs
{
client_func_dnd_query_exited = NtUserDriverCallbackFirst,
client_func_dnd_query_drop = NtUserDriverCallbackFirst,
client_func_dnd_query_exited,
client_func_ime_query_char_rect,
client_func_ime_set_text,
client_func_last
};
/* macdrv_dnd_query_drop params */
struct dnd_query_drop_params
{
HWND hwnd;
UINT32 effect;
INT32 x;
INT32 y;
UINT64 handle;
};
/* macdrv_dnd_query_exited params */
struct dnd_query_exited_params
{