From: Jacek Caban jacek@codeweavers.com
--- dlls/winex11.drv/event.c | 26 ++++++++++++++++++++++- dlls/winex11.drv/unixlib.h | 8 ++++++++ dlls/winex11.drv/x11drv.h | 1 - dlls/winex11.drv/xdnd.c | 42 ++++++-------------------------------- 4 files changed, 39 insertions(+), 38 deletions(-)
diff --git a/dlls/winex11.drv/event.c b/dlls/winex11.drv/event.c index 2bfcd3211ae..a02f0340010 100644 --- a/dlls/winex11.drv/event.c +++ b/dlls/winex11.drv/event.c @@ -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( ¶ms ); + + /* 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 { int atom; /* protocol atom */ @@ -1910,7 +1934,7 @@ static const struct client_message_handler client_messages[] = { XATOM_DndProtocol, handle_dnd_protocol }, { XATOM_XdndEnter, handle_xdnd_enter_event }, { XATOM_XdndPosition, handle_xdnd_position_event }, - { XATOM_XdndDrop, X11DRV_XDND_DropEvent }, + { XATOM_XdndDrop, handle_xdnd_drop_event }, { XATOM_XdndLeave, X11DRV_XDND_LeaveEvent } };
diff --git a/dlls/winex11.drv/unixlib.h b/dlls/winex11.drv/unixlib.h index 7f8ec28b7cf..41120385e60 100644 --- a/dlls/winex11.drv/unixlib.h +++ b/dlls/winex11.drv/unixlib.h @@ -30,9 +30,17 @@ struct format_entry
enum dnd_event_type { + DND_DROP_EVENT, DND_POSITION_EVENT, };
+/* DND_DROP_EVENT params */ +struct dnd_drop_event_params +{ + UINT type; + HWND hwnd; +}; + /* DND_POSITION_EVENT params */ struct dnd_position_event_params { diff --git a/dlls/winex11.drv/x11drv.h b/dlls/winex11.drv/x11drv.h index d49643a890b..c17dc45594c 100644 --- a/dlls/winex11.drv/x11drv.h +++ b/dlls/winex11.drv/x11drv.h @@ -294,7 +294,6 @@ extern BOOL IME_SetCompositionString(DWORD dwIndex, LPCVOID lpComp, DWORD dwReadLen) 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 handle_dnd_enter_event( struct format_entry *formats, ULONG size ) DECLSPEC_HIDDEN; diff --git a/dlls/winex11.drv/xdnd.c b/dlls/winex11.drv/xdnd.c index 7633738917f..9de0b60d0cd 100644 --- a/dlls/winex11.drv/xdnd.c +++ b/dlls/winex11.drv/xdnd.c @@ -142,20 +142,6 @@ static IDropTarget* get_droptarget_pointer(HWND hwnd) 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. * @@ -278,14 +264,8 @@ static BOOL handle_position_event( struct dnd_position_event_params *params ) return accept ? effect : 0; }
-/************************************************************************** - * X11DRV_XDND_DropEvent - * - * Handle an XdndDrop event. - */ -void X11DRV_XDND_DropEvent( HWND hWnd, XClientMessageEvent *event ) +static DWORD handle_drop_event( struct dnd_drop_event_params *params ) { - XClientMessageEvent e; IDropTarget *dropTarget; DWORD effect = XDNDDropEffect; 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. * 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()) { @@ -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", XDNDDropEffect, accept, effect, XDNDxy.x, XDNDxy.y);
- /* 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] = 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); + return accept ? effect : 0; }
/************************************************************************** @@ -766,6 +733,9 @@ UINT handle_dnd_event( void *params )
switch (*(UINT *)params) { + case DND_DROP_EVENT: + return handle_drop_event( params ); + case DND_POSITION_EVENT: return handle_position_event( params );