winex11: Move XdndEnter event handler to event.c.

In preparation for xdnd.c being in PE file.

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-27 23:07:55 +02:00 committed by Alexandre Julliard
parent 3b4dbc2971
commit 3b06509f46
3 changed files with 80 additions and 85 deletions

View File

@ -49,6 +49,7 @@
#include "wine/debug.h"
WINE_DEFAULT_DEBUG_CHANNEL(event);
WINE_DECLARE_DEBUG_CHANNEL(xdnd);
extern BOOL ximInComposeMode;
@ -1752,6 +1753,79 @@ static void handle_dnd_protocol( HWND hwnd, XClientMessageEvent *event )
}
/**************************************************************************
* handle_xdnd_enter_event
*
* Handle an XdndEnter event.
*/
static void handle_xdnd_enter_event( HWND hWnd, XClientMessageEvent *event )
{
struct format_entry *data;
unsigned long count = 0;
Atom *xdndtypes;
size_t size;
int version;
version = (event->data.l[1] & 0xFF000000) >> 24;
TRACE( "ver(%d) check-XdndTypeList(%ld) data=%ld,%ld,%ld,%ld,%ld\n",
version, (event->data.l[1] & 1),
event->data.l[0], event->data.l[1], event->data.l[2],
event->data.l[3], event->data.l[4] );
if (version > WINE_XDND_VERSION)
{
ERR("ignoring unsupported XDND version %d\n", version);
return;
}
/* If the source supports more than 3 data types we retrieve
* the entire list. */
if (event->data.l[1] & 1)
{
Atom acttype;
int actfmt;
unsigned long bytesret;
/* Request supported formats from source window */
XGetWindowProperty( event->display, event->data.l[0], x11drv_atom(XdndTypeList),
0, 65535, FALSE, AnyPropertyType, &acttype, &actfmt, &count,
&bytesret, (unsigned char **)&xdndtypes );
}
else
{
count = 3;
xdndtypes = (Atom *)&event->data.l[2];
}
if (TRACE_ON(xdnd))
{
unsigned int i;
for (i = 0; i < count; i++)
{
if (xdndtypes[i] != 0)
{
char * pn = XGetAtomName( event->display, xdndtypes[i] );
TRACE( "XDNDEnterAtom %ld: %s\n", xdndtypes[i], pn );
XFree( pn );
}
}
}
data = import_xdnd_selection( event->display, event->window, x11drv_atom(XdndSelection),
xdndtypes, count, &size );
if (data)
{
handle_dnd_enter_event( data, size );
free( data );
}
if (event->data.l[1] & 1)
XFree(xdndtypes);
}
struct client_message_handler
{
int atom; /* protocol atom */
@ -1764,7 +1838,7 @@ static const struct client_message_handler client_messages[] =
{ XATOM_WM_PROTOCOLS, handle_wm_protocols },
{ XATOM__XEMBED, handle_xembed_protocol },
{ XATOM_DndProtocol, handle_dnd_protocol },
{ XATOM_XdndEnter, X11DRV_XDND_EnterEvent },
{ XATOM_XdndEnter, handle_xdnd_enter_event },
{ XATOM_XdndPosition, X11DRV_XDND_PositionEvent },
{ XATOM_XdndDrop, X11DRV_XDND_DropEvent },
{ XATOM_XdndLeave, X11DRV_XDND_LeaveEvent }

View File

@ -293,7 +293,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_EnterEvent( HWND hWnd, XClientMessageEvent *event ) DECLSPEC_HIDDEN;
extern void X11DRV_XDND_PositionEvent( HWND hWnd, XClientMessageEvent *event ) DECLSPEC_HIDDEN;
extern void X11DRV_XDND_DropEvent( HWND hWnd, XClientMessageEvent *event ) DECLSPEC_HIDDEN;
extern void X11DRV_XDND_LeaveEvent( HWND hWnd, XClientMessageEvent *event ) DECLSPEC_HIDDEN;
@ -305,6 +304,8 @@ struct format_entry
char data[1];
};
extern void handle_dnd_enter_event( struct format_entry *formats, ULONG size ) DECLSPEC_HIDDEN;
extern struct format_entry *import_xdnd_selection( Display *display, Window win, Atom selection,
Atom *targets, UINT count,
size_t *size ) DECLSPEC_HIDDEN;

View File

@ -55,8 +55,6 @@ static HWND XDNDLastTargetWnd;
/* might be an ancestor of XDNDLastTargetWnd */
static HWND XDNDLastDropTargetWnd;
static void X11DRV_XDND_ResolveProperty(Display *display, Window xwin, Time tm,
Atom *types, unsigned long count);
static BOOL X11DRV_XDND_HasHDROP(void);
static HRESULT X11DRV_XDND_SendDropFiles(HWND hwnd);
static void X11DRV_XDND_FreeDragDropOp(void);
@ -180,73 +178,6 @@ static long X11DRV_XDND_DROPEFFECTToXdndAction(DWORD effect)
return x11drv_atom(XdndActionCopy);
}
/**************************************************************************
* X11DRV_XDND_EnterEvent
*
* Handle an XdndEnter event.
*/
void X11DRV_XDND_EnterEvent( HWND hWnd, XClientMessageEvent *event )
{
int version;
Atom *xdndtypes;
unsigned long count = 0;
version = (event->data.l[1] & 0xFF000000) >> 24;
TRACE("ver(%d) check-XdndTypeList(%ld) data=%ld,%ld,%ld,%ld,%ld\n",
version, (event->data.l[1] & 1),
event->data.l[0], event->data.l[1], event->data.l[2],
event->data.l[3], event->data.l[4]);
if (version > WINE_XDND_VERSION)
{
ERR("ignoring unsupported XDND version %d\n", version);
return;
}
XDNDAccepted = FALSE;
/* If the source supports more than 3 data types we retrieve
* the entire list. */
if (event->data.l[1] & 1)
{
Atom acttype;
int actfmt;
unsigned long bytesret;
/* Request supported formats from source window */
XGetWindowProperty(event->display, event->data.l[0], x11drv_atom(XdndTypeList),
0, 65535, FALSE, AnyPropertyType, &acttype, &actfmt, &count,
&bytesret, (unsigned char**)&xdndtypes);
}
else
{
count = 3;
xdndtypes = (Atom*) &event->data.l[2];
}
if (TRACE_ON(xdnd))
{
unsigned int i;
for (i = 0; i < count; i++)
{
if (xdndtypes[i] != 0)
{
char * pn = XGetAtomName(event->display, xdndtypes[i]);
TRACE("XDNDEnterAtom %ld: %s\n", xdndtypes[i], pn);
XFree(pn);
}
}
}
/* Do a one-time data read and cache results */
X11DRV_XDND_ResolveProperty(event->display, event->window,
event->data.l[1], xdndtypes, count);
if (event->data.l[1] & 1)
XFree(xdndtypes);
}
/* Recursively searches for a window on given coordinates in a drag&drop specific manner.
*
* Don't use WindowFromPoint instead, because it omits the STATIC and transparent
@ -514,29 +445,18 @@ void X11DRV_XDND_LeaveEvent( HWND hWnd, XClientMessageEvent *event )
/**************************************************************************
* X11DRV_XDND_ResolveProperty
*
* Resolve all MIME types to windows clipboard formats. All data is cached.
* handle_dnd_enter_event
*/
static void X11DRV_XDND_ResolveProperty(Display *display, Window xwin, Time tm,
Atom *types, unsigned long count)
void handle_dnd_enter_event( struct format_entry *formats, ULONG size )
{
struct format_entry *formats;
size_t size;
TRACE("count(%ld)\n", count);
XDNDAccepted = FALSE;
X11DRV_XDND_FreeDragDropOp(); /* Clear previously cached data */
formats = import_xdnd_selection( display, xwin, x11drv_atom(XdndSelection), types, count, &size );
if (!formats) return;
if ((xdnd_formats = HeapAlloc( GetProcessHeap(), 0, size )))
{
memcpy( xdnd_formats, formats, size );
xdnd_formats_end = (struct format_entry *)((char *)xdnd_formats + size);
}
free( formats );
}