winex11: Move XdndDrop event handler to event.c.

Signed-off-by: Jacek Caban <jacek@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Jacek Caban 2022-04-24 22:33:34 +02:00 committed by Alexandre Julliard
parent 1d337249f1
commit e510f8650e
4 changed files with 39 additions and 38 deletions

View File

@ -1896,6 +1896,30 @@ static void handle_xdnd_position_event( HWND hwnd, XClientMessageEvent *event )
} }
static void handle_xdnd_drop_event( HWND hwnd, XClientMessageEvent *event )
{
struct dnd_drop_event_params params;
XClientMessageEvent e;
DWORD effect;
params.type = DND_DROP_EVENT;
params.hwnd = hwnd;
effect = handle_dnd_event( &params );
/* Tell the target we are finished. */
memset( &e, 0, sizeof(e) );
e.type = ClientMessage;
e.display = event->display;
e.window = event->data.l[0];
e.message_type = x11drv_atom(XdndFinished);
e.format = 32;
e.data.l[0] = event->window;
e.data.l[1] = !!effect;
e.data.l[2] = drop_effect_to_xdnd_action( effect );
XSendEvent( event->display, event->data.l[0], False, NoEventMask, (XEvent *)&e );
}
struct client_message_handler struct client_message_handler
{ {
int atom; /* protocol atom */ int atom; /* protocol atom */
@ -1910,7 +1934,7 @@ static const struct client_message_handler client_messages[] =
{ XATOM_DndProtocol, handle_dnd_protocol }, { XATOM_DndProtocol, handle_dnd_protocol },
{ XATOM_XdndEnter, handle_xdnd_enter_event }, { XATOM_XdndEnter, handle_xdnd_enter_event },
{ XATOM_XdndPosition, handle_xdnd_position_event }, { XATOM_XdndPosition, handle_xdnd_position_event },
{ XATOM_XdndDrop, X11DRV_XDND_DropEvent }, { XATOM_XdndDrop, handle_xdnd_drop_event },
{ XATOM_XdndLeave, X11DRV_XDND_LeaveEvent } { XATOM_XdndLeave, X11DRV_XDND_LeaveEvent }
}; };

View File

@ -30,9 +30,17 @@ struct format_entry
enum dnd_event_type enum dnd_event_type
{ {
DND_DROP_EVENT,
DND_POSITION_EVENT, DND_POSITION_EVENT,
}; };
/* DND_DROP_EVENT params */
struct dnd_drop_event_params
{
UINT type;
HWND hwnd;
};
/* DND_POSITION_EVENT params */ /* DND_POSITION_EVENT params */
struct dnd_position_event_params struct dnd_position_event_params
{ {

View File

@ -294,7 +294,6 @@ extern BOOL IME_SetCompositionString(DWORD dwIndex, LPCVOID lpComp,
DWORD dwReadLen) DECLSPEC_HIDDEN; DWORD dwReadLen) DECLSPEC_HIDDEN;
extern void IME_SetResultString(LPWSTR lpResult, DWORD dwResultlen) DECLSPEC_HIDDEN; extern void IME_SetResultString(LPWSTR lpResult, DWORD dwResultlen) DECLSPEC_HIDDEN;
extern void X11DRV_XDND_DropEvent( HWND hWnd, XClientMessageEvent *event ) DECLSPEC_HIDDEN;
extern void X11DRV_XDND_LeaveEvent( HWND hWnd, XClientMessageEvent *event ) DECLSPEC_HIDDEN; extern void X11DRV_XDND_LeaveEvent( HWND hWnd, XClientMessageEvent *event ) DECLSPEC_HIDDEN;
extern void handle_dnd_enter_event( struct format_entry *formats, ULONG size ) DECLSPEC_HIDDEN; extern void handle_dnd_enter_event( struct format_entry *formats, ULONG size ) DECLSPEC_HIDDEN;

View File

@ -142,20 +142,6 @@ static IDropTarget* get_droptarget_pointer(HWND hwnd)
return droptarget; return droptarget;
} }
/**************************************************************************
* X11DRV_XDND_DROPEFFECTToXdndAction
*/
static long X11DRV_XDND_DROPEFFECTToXdndAction(DWORD effect)
{
if (effect == DROPEFFECT_COPY)
return x11drv_atom(XdndActionCopy);
else if (effect == DROPEFFECT_MOVE)
return x11drv_atom(XdndActionMove);
else if (effect == DROPEFFECT_LINK)
return x11drv_atom(XdndActionLink);
FIXME("unknown drop effect %u, assuming XdndActionCopy\n", effect);
return x11drv_atom(XdndActionCopy);
}
/* Recursively searches for a window on given coordinates in a drag&drop specific manner. /* Recursively searches for a window on given coordinates in a drag&drop specific manner.
* *
@ -278,14 +264,8 @@ static BOOL handle_position_event( struct dnd_position_event_params *params )
return accept ? effect : 0; return accept ? effect : 0;
} }
/************************************************************************** static DWORD handle_drop_event( struct dnd_drop_event_params *params )
* X11DRV_XDND_DropEvent
*
* Handle an XdndDrop event.
*/
void X11DRV_XDND_DropEvent( HWND hWnd, XClientMessageEvent *event )
{ {
XClientMessageEvent e;
IDropTarget *dropTarget; IDropTarget *dropTarget;
DWORD effect = XDNDDropEffect; DWORD effect = XDNDDropEffect;
int accept = 0; /* Assume we're not accepting */ int accept = 0; /* Assume we're not accepting */
@ -338,7 +318,7 @@ void X11DRV_XDND_DropEvent( HWND hWnd, XClientMessageEvent *event )
/* Only send WM_DROPFILES if Drop didn't succeed or DROPEFFECT_NONE was set. /* Only send WM_DROPFILES if Drop didn't succeed or DROPEFFECT_NONE was set.
* Doing both causes winamp to duplicate the dropped files (#29081) */ * Doing both causes winamp to duplicate the dropped files (#29081) */
HWND hwnd_drop = window_accepting_files(window_from_point_dnd(hWnd, XDNDxy)); HWND hwnd_drop = window_accepting_files(window_from_point_dnd( params->hwnd, XDNDxy ));
if (hwnd_drop && X11DRV_XDND_HasHDROP()) if (hwnd_drop && X11DRV_XDND_HasHDROP())
{ {
@ -354,20 +334,7 @@ void X11DRV_XDND_DropEvent( HWND hWnd, XClientMessageEvent *event )
TRACE("effectRequested(0x%x) accept(%d) performed(0x%x) at x(%d),y(%d)\n", TRACE("effectRequested(0x%x) accept(%d) performed(0x%x) at x(%d),y(%d)\n",
XDNDDropEffect, accept, effect, XDNDxy.x, XDNDxy.y); XDNDDropEffect, accept, effect, XDNDxy.x, XDNDxy.y);
/* Tell the target we are finished. */ return accept ? effect : 0;
memset(&e, 0, sizeof(e));
e.type = ClientMessage;
e.display = event->display;
e.window = event->data.l[0];
e.message_type = x11drv_atom(XdndFinished);
e.format = 32;
e.data.l[0] = event->window;
e.data.l[1] = accept;
if (accept)
e.data.l[2] = X11DRV_XDND_DROPEFFECTToXdndAction(effect);
else
e.data.l[2] = None;
XSendEvent(event->display, event->data.l[0], False, NoEventMask, (XEvent*)&e);
} }
/************************************************************************** /**************************************************************************
@ -766,6 +733,9 @@ UINT handle_dnd_event( void *params )
switch (*(UINT *)params) switch (*(UINT *)params)
{ {
case DND_DROP_EVENT:
return handle_drop_event( params );
case DND_POSITION_EVENT: case DND_POSITION_EVENT:
return handle_position_event( params ); return handle_position_event( params );