Commit 4938929c authored by Jacek Caban's avatar Jacek Caban Committed by Alexandre Julliard

winemac: Use unixlib interface for query_drag_operation.

parent 3aa1a86b
...@@ -29,6 +29,7 @@ HMODULE macdrv_module = 0; ...@@ -29,6 +29,7 @@ HMODULE macdrv_module = 0;
typedef NTSTATUS (WINAPI *kernel_callback)(void *params, ULONG size); typedef NTSTATUS (WINAPI *kernel_callback)(void *params, ULONG size);
static const kernel_callback kernel_callbacks[] = static const kernel_callback kernel_callbacks[] =
{ {
macdrv_dnd_query_drag,
macdrv_dnd_query_drop, macdrv_dnd_query_drop,
macdrv_dnd_query_exited, macdrv_dnd_query_exited,
macdrv_ime_query_char_rect, macdrv_ime_query_char_rect,
......
...@@ -325,37 +325,6 @@ static IDataObject *create_data_object_for_pasteboard(CFTypeRef pasteboard) ...@@ -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 */ /* Based on functions in dlls/ole32/ole2.c */
static HANDLE get_droptarget_local_handle(HWND hwnd) static HANDLE get_droptarget_local_handle(HWND hwnd)
{ {
...@@ -547,31 +516,22 @@ NTSTATUS WINAPI macdrv_dnd_query_exited(void *arg, ULONG size) ...@@ -547,31 +516,22 @@ NTSTATUS WINAPI macdrv_dnd_query_exited(void *arg, ULONG size)
/************************************************************************** /**************************************************************************
* query_drag_operation * 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; BOOL ret = FALSE;
HWND hwnd = macdrv_get_window_hwnd(query->window);
struct macdrv_win_data *data = get_win_data(hwnd);
POINT pt; POINT pt;
DWORD effect; DWORD effect;
IDropTarget *droptarget; IDropTarget *droptarget;
HRESULT hr; HRESULT hr;
TRACE("win %p/%p x,y %d,%d offered_ops 0x%x pasteboard %p\n", hwnd, query->window, TRACE("win %p x,y %d,%d effect %x pasteboard %s\n", hwnd, params->x, params->y,
query->drag_operation.x, query->drag_operation.y, query->drag_operation.offered_ops, params->effect, wine_dbgstr_longlong(params->handle));
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);
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 /* 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 child under the cursor. Travel up the hierarchy looking for a window that
...@@ -604,16 +564,14 @@ BOOL query_drag_operation(macdrv_query* query) ...@@ -604,16 +564,14 @@ BOOL query_drag_operation(macdrv_query* query)
POINTL pointl = { pt.x, pt.y }; POINTL pointl = { pt.x, pt.y };
if (!active_data_object) 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); TRACE("DragEnter hwnd %p droptarget %p\n", hwnd, droptarget);
hr = IDropTarget_DragEnter(droptarget, active_data_object, MK_LBUTTON, hr = IDropTarget_DragEnter(droptarget, active_data_object, MK_LBUTTON,
pointl, &effect); pointl, &effect);
if (SUCCEEDED(hr)) if (SUCCEEDED(hr))
{ {
query->drag_operation.accepted_op = dropeffect_to_drag_operation(effect, TRACE(" effect %d\n", effect);
query->drag_operation.offered_ops);
TRACE(" effect %d accepted op %d\n", effect, query->drag_operation.accepted_op);
ret = TRUE; ret = TRUE;
} }
else else
...@@ -629,9 +587,7 @@ BOOL query_drag_operation(macdrv_query* query) ...@@ -629,9 +587,7 @@ BOOL query_drag_operation(macdrv_query* query)
hr = IDropTarget_DragOver(droptarget, MK_LBUTTON, pointl, &effect); hr = IDropTarget_DragOver(droptarget, MK_LBUTTON, pointl, &effect);
if (SUCCEEDED(hr)) if (SUCCEEDED(hr))
{ {
query->drag_operation.accepted_op = dropeffect_to_drag_operation(effect, TRACE(" effect %d\n", effect);
query->drag_operation.offered_ops);
TRACE(" effect %d accepted op %d\n", effect, query->drag_operation.accepted_op);
ret = TRUE; ret = TRUE;
} }
else else
...@@ -649,7 +605,7 @@ BOOL query_drag_operation(macdrv_query* query) ...@@ -649,7 +605,7 @@ BOOL query_drag_operation(macdrv_query* query)
FORMATETC formatEtc; FORMATETC formatEtc;
if (!active_data_object) 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.cfFormat = CF_HDROP;
formatEtc.ptd = NULL; formatEtc.ptd = NULL;
...@@ -659,12 +615,12 @@ BOOL query_drag_operation(macdrv_query* query) ...@@ -659,12 +615,12 @@ BOOL query_drag_operation(macdrv_query* query)
if (SUCCEEDED(IDataObject_QueryGetData(active_data_object, &formatEtc))) if (SUCCEEDED(IDataObject_QueryGetData(active_data_object, &formatEtc)))
{ {
TRACE("WS_EX_ACCEPTFILES hwnd %p\n", hwnd); TRACE("WS_EX_ACCEPTFILES hwnd %p\n", hwnd);
query->drag_operation.accepted_op = DRAG_OP_GENERIC; effect = DROPEFFECT_COPY | DROPEFFECT_LINK;
ret = TRUE; ret = TRUE;
} }
} }
} }
TRACE(" -> %s\n", ret ? "TRUE" : "FALSE"); TRACE(" -> %s\n", ret ? "TRUE" : "FALSE");
return ret; return ret ? effect : 0;
} }
...@@ -196,6 +196,21 @@ static DWORD drag_operations_to_dropeffects(uint32_t ops) ...@@ -196,6 +196,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 * query_drag_drop
*/ */
static BOOL query_drag_drop(macdrv_query *query) static BOOL query_drag_drop(macdrv_query *query)
...@@ -231,6 +246,38 @@ static BOOL query_drag_exited(macdrv_query *query) ...@@ -231,6 +246,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, &params, 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 * query_ime_char_rect
*/ */
BOOL query_ime_char_rect(macdrv_query* query) BOOL query_ime_char_rect(macdrv_query* query)
......
...@@ -259,8 +259,6 @@ extern HANDLE macdrv_get_pasteboard_data(CFTypeRef pasteboard, UINT desired_form ...@@ -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 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 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 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 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; 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; ...@@ -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, extern NTSTATUS macdrv_client_func(enum macdrv_client_funcs func, const void *params,
ULONG size) DECLSPEC_HIDDEN; 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_drop(void *arg, ULONG size) DECLSPEC_HIDDEN;
extern NTSTATUS WINAPI macdrv_dnd_query_exited(void *arg, ULONG size) DECLSPEC_HIDDEN; extern NTSTATUS WINAPI macdrv_dnd_query_exited(void *arg, ULONG size) DECLSPEC_HIDDEN;
......
...@@ -67,13 +67,24 @@ struct notify_icon_params ...@@ -67,13 +67,24 @@ struct notify_icon_params
/* driver client callbacks exposed with KernelCallbackTable interface */ /* driver client callbacks exposed with KernelCallbackTable interface */
enum macdrv_client_funcs 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_dnd_query_exited,
client_func_ime_query_char_rect, client_func_ime_query_char_rect,
client_func_ime_set_text, client_func_ime_set_text,
client_func_last 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 */ /* macdrv_dnd_query_drop params */
struct dnd_query_drop_params struct dnd_query_drop_params
{ {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment