Commit 5cd38614 authored by Alexandre Julliard's avatar Alexandre Julliard

winex11.drv: Return result through NtCallbackReturn for the drag and drop callbacks.

parent be44253c
......@@ -25,28 +25,14 @@
HMODULE x11drv_module = 0;
typedef NTSTATUS (*callback_func)( UINT arg );
static const callback_func callback_funcs[] =
{
x11drv_dnd_drop_event,
x11drv_dnd_leave_event,
};
C_ASSERT( ARRAYSIZE(callback_funcs) == client_funcs_count );
static NTSTATUS WINAPI x11drv_callback( void *arg, ULONG size )
{
struct client_callback_params *params = arg;
return callback_funcs[params->id]( params->arg );
}
typedef NTSTATUS (WINAPI *kernel_callback)( void *params, ULONG size );
static const kernel_callback kernel_callbacks[] =
{
x11drv_callback,
x11drv_dnd_enter_event,
x11drv_dnd_position_event,
x11drv_dnd_post_drop,
x11drv_dnd_drop_event,
x11drv_dnd_leave_event,
};
C_ASSERT( NtUserDriverCallbackFirst + ARRAYSIZE(kernel_callbacks) == client_func_last );
......
......@@ -1754,13 +1754,18 @@ static void handle_xdnd_position_event( HWND hwnd, XClientMessageEvent *event )
{
struct dnd_position_event_params params;
XClientMessageEvent e;
void *ret_ptr;
ULONG ret_len;
UINT effect;
params.hwnd = HandleToUlong( hwnd );
params.point = root_to_virtual_screen( event->data.l[2] >> 16, event->data.l[2] & 0xFFFF );
params.effect = effect = xdnd_action_to_drop_effect( event->data.l[4] );
effect = x11drv_client_func( client_func_dnd_position_event, &params, sizeof(params) );
if (KeUserModeCallback( client_func_dnd_position_event, &params, sizeof(params),
&ret_ptr, &ret_len ) || ret_len != sizeof(effect))
return;
effect = *(UINT *)ret_ptr;
TRACE( "actionRequested(%ld) chosen(0x%x) at x(%d),y(%d)\n",
event->data.l[4], effect, (int)params.point.x, (int)params.point.y );
......@@ -1786,9 +1791,15 @@ static void handle_xdnd_position_event( HWND hwnd, XClientMessageEvent *event )
static void handle_xdnd_drop_event( HWND hwnd, XClientMessageEvent *event )
{
XClientMessageEvent e;
DWORD effect;
void *ret_ptr;
ULONG ret_len;
ULONG arg = HandleToUlong( hwnd );
UINT effect;
effect = x11drv_client_call( client_dnd_drop_event, HandleToUlong( hwnd ));
if (KeUserModeCallback( client_func_dnd_drop_event, &arg, sizeof(arg),
&ret_ptr, &ret_len ) || ret_len != sizeof(effect))
return;
effect = *(UINT *)ret_ptr;
/* Tell the target we are finished. */
memset( &e, 0, sizeof(e) );
......@@ -1806,7 +1817,7 @@ static void handle_xdnd_drop_event( HWND hwnd, XClientMessageEvent *event )
static void handle_xdnd_leave_event( HWND hwnd, XClientMessageEvent *event )
{
x11drv_client_call( client_dnd_leave_event, 0 );
x11drv_client_func( client_func_dnd_leave_event, NULL, 0 );
}
......
......@@ -55,30 +55,16 @@ struct xim_preedit_state_params
/* driver client callbacks exposed with KernelCallbackTable interface */
enum x11drv_client_funcs
{
client_func_callback = NtUserDriverCallbackFirst,
client_func_dnd_enter_event,
client_func_dnd_enter_event = NtUserDriverCallbackFirst,
client_func_dnd_position_event,
client_func_dnd_post_drop,
client_func_dnd_drop_event,
client_func_dnd_leave_event,
client_func_last
};
C_ASSERT( client_func_last <= NtUserDriverCallbackLast + 1 );
/* simplified interface for client callbacks requiring only a single UINT parameter */
enum client_callback
{
client_dnd_drop_event,
client_dnd_leave_event,
client_funcs_count
};
/* x11drv_callback params */
struct client_callback_params
{
UINT id;
UINT arg;
};
/* x11drv_dnd_enter_event and x11drv_dnd_post_drop params */
struct format_entry
{
......
......@@ -844,7 +844,6 @@ extern NTSTATUS x11drv_tablet_info( void *arg );
extern NTSTATUS x11drv_client_func( enum x11drv_client_funcs func, const void *params,
ULONG size );
extern NTSTATUS x11drv_client_call( enum client_callback func, UINT arg );
/* GDI helpers */
......
......@@ -30,9 +30,8 @@
extern NTSTATUS WINAPI x11drv_dnd_enter_event( void *params, ULONG size );
extern NTSTATUS WINAPI x11drv_dnd_position_event( void *params, ULONG size );
extern NTSTATUS WINAPI x11drv_dnd_post_drop( void *data, ULONG size );
extern NTSTATUS x11drv_dnd_drop_event( UINT arg );
extern NTSTATUS x11drv_dnd_leave_event( UINT arg );
extern NTSTATUS WINAPI x11drv_dnd_drop_event( void *params, ULONG size );
extern NTSTATUS WINAPI x11drv_dnd_leave_event( void *params, ULONG size );
extern LRESULT WINAPI foreign_window_proc( HWND hwnd, UINT msg, WPARAM wparam,
LPARAM lparam );
......
......@@ -1305,13 +1305,6 @@ NTSTATUS x11drv_client_func( enum x11drv_client_funcs id, const void *params, UL
}
NTSTATUS x11drv_client_call( enum client_callback func, UINT arg )
{
struct client_callback_params params = { .id = func, .arg = arg };
return x11drv_client_func( client_func_callback, &params, sizeof(params) );
}
const unixlib_entry_t __wine_unix_call_funcs[] =
{
x11drv_init,
......
......@@ -20,6 +20,8 @@
*/
#define COBJMACROS
#include "ntstatus.h"
#define WIN32_NO_STATUS
#include "x11drv_dll.h"
#include "shellapi.h"
#include "shlobj.h"
......@@ -246,11 +248,13 @@ NTSTATUS WINAPI x11drv_dnd_position_event( void *arg, ULONG size )
}
}
return accept ? effect : DROPEFFECT_NONE;
if (!accept) effect = DROPEFFECT_NONE;
return NtCallbackReturn( &effect, sizeof(effect), STATUS_SUCCESS );
}
NTSTATUS x11drv_dnd_drop_event( UINT arg )
NTSTATUS WINAPI x11drv_dnd_drop_event( void *args, ULONG size )
{
HWND hwnd = UlongToHandle( *(ULONG *)args );
IDropTarget *dropTarget;
DWORD effect = XDNDDropEffect;
int accept = 0; /* Assume we're not accepting */
......@@ -303,7 +307,7 @@ NTSTATUS x11drv_dnd_drop_event( UINT arg )
/* Only send WM_DROPFILES if Drop didn't succeed or DROPEFFECT_NONE was set.
* Doing both causes winamp to duplicate the dropped files (#29081) */
HWND hwnd_drop = window_accepting_files(window_from_point_dnd( UlongToHandle(arg), XDNDxy ));
HWND hwnd_drop = window_accepting_files(window_from_point_dnd( hwnd, XDNDxy ));
if (hwnd_drop && X11DRV_XDND_HasHDROP())
{
......@@ -319,7 +323,8 @@ NTSTATUS x11drv_dnd_drop_event( UINT arg )
TRACE("effectRequested(0x%lx) accept(%d) performed(0x%lx) at x(%ld),y(%ld)\n",
XDNDDropEffect, accept, effect, XDNDxy.x, XDNDxy.y);
return accept ? effect : DROPEFFECT_NONE;
if (!accept) effect = DROPEFFECT_NONE;
return NtCallbackReturn( &effect, sizeof(effect), STATUS_SUCCESS );
}
/**************************************************************************
......@@ -327,7 +332,7 @@ NTSTATUS x11drv_dnd_drop_event( UINT arg )
*
* Handle an XdndLeave event.
*/
NTSTATUS x11drv_dnd_leave_event( UINT arg )
NTSTATUS WINAPI x11drv_dnd_leave_event( void *params, ULONG size )
{
IDropTarget *dropTarget;
......@@ -347,7 +352,7 @@ NTSTATUS x11drv_dnd_leave_event( UINT arg )
}
X11DRV_XDND_FreeDragDropOp();
return 0;
return STATUS_SUCCESS;
}
......@@ -365,7 +370,7 @@ NTSTATUS WINAPI x11drv_dnd_enter_event( void *params, ULONG size )
memcpy( xdnd_formats, formats, size );
xdnd_formats_end = (struct format_entry *)((char *)xdnd_formats + size);
}
return 0;
return STATUS_SUCCESS;
}
......@@ -731,5 +736,5 @@ NTSTATUS WINAPI x11drv_dnd_post_drop( void *data, ULONG size )
PostMessageW( hwnd, WM_DROPFILES, (WPARAM)handle, 0 );
}
return 0;
return STATUS_SUCCESS;
}
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