Use a dispatch table to handle X client messages.
This commit is contained in:
parent
aa34768677
commit
2fd19dfb98
@ -347,9 +347,9 @@ static void set_focus( HWND hwnd, Time time )
|
||||
|
||||
|
||||
/**********************************************************************
|
||||
* handle_wm_protocols_message
|
||||
* handle_wm_protocols
|
||||
*/
|
||||
static void handle_wm_protocols_message( HWND hwnd, XClientMessageEvent *event )
|
||||
static void handle_wm_protocols( HWND hwnd, XClientMessageEvent *event )
|
||||
{
|
||||
Atom protocol = (Atom)event->data.l[0];
|
||||
|
||||
@ -837,57 +837,68 @@ static void EVENT_DropURLs( HWND hWnd, XClientMessageEvent *event )
|
||||
}
|
||||
|
||||
/**********************************************************************
|
||||
* EVENT_ClientMessage
|
||||
* handle_dnd_protocol
|
||||
*/
|
||||
static void EVENT_ClientMessage( HWND hWnd, XEvent *xev )
|
||||
static void handle_dnd_protocol( HWND hwnd, XClientMessageEvent *event )
|
||||
{
|
||||
XClientMessageEvent *event = &xev->xclient;
|
||||
|
||||
if (!hWnd) return;
|
||||
|
||||
if (event->message_type != None && event->format == 32) {
|
||||
if (event->message_type == x11drv_atom(WM_PROTOCOLS))
|
||||
handle_wm_protocols_message( hWnd, event );
|
||||
else if (event->message_type == x11drv_atom(DndProtocol))
|
||||
{
|
||||
/* query window (drag&drop event contains only drag window) */
|
||||
Window root, child;
|
||||
int root_x, root_y, child_x, child_y;
|
||||
unsigned int u;
|
||||
|
||||
/* query window (drag&drop event contains only drag window) */
|
||||
wine_tsx11_lock();
|
||||
XQueryPointer( event->display, root_window, &root, &child,
|
||||
&root_x, &root_y, &child_x, &child_y, &u);
|
||||
if (XFindContext( event->display, child, winContext, (char **)&hWnd ) != 0) hWnd = 0;
|
||||
if (XFindContext( event->display, child, winContext, (char **)&hwnd ) != 0) hwnd = 0;
|
||||
wine_tsx11_unlock();
|
||||
if (!hWnd) return;
|
||||
if (!hwnd) return;
|
||||
if (event->data.l[0] == DndFile || event->data.l[0] == DndFiles)
|
||||
EVENT_DropFromOffiX(hWnd, event);
|
||||
EVENT_DropFromOffiX(hwnd, event);
|
||||
else if (event->data.l[0] == DndURL)
|
||||
EVENT_DropURLs(hWnd, event);
|
||||
}
|
||||
else if (!X11DRV_XDND_Event(hWnd, event))
|
||||
{
|
||||
#if 0
|
||||
/* enable this if you want to see the message */
|
||||
unsigned char* p_data = NULL;
|
||||
union {
|
||||
unsigned long l;
|
||||
int i;
|
||||
Atom atom;
|
||||
} u; /* unused */
|
||||
wine_tsx11_lock();
|
||||
XGetWindowProperty( event->display, DefaultRootWindow(event->display),
|
||||
dndSelection, 0, 65535, FALSE,
|
||||
AnyPropertyType, &u.atom, &u.i,
|
||||
&u.l, &u.l, &p_data);
|
||||
wine_tsx11_unlock();
|
||||
TRACE("message_type=%ld, data=%ld,%ld,%ld,%ld,%ld, msg=%s\n",
|
||||
event->message_type, event->data.l[0], event->data.l[1],
|
||||
event->data.l[2], event->data.l[3], event->data.l[4],
|
||||
p_data);
|
||||
#endif
|
||||
TRACE("unrecognized ClientMessage\n" );
|
||||
}
|
||||
}
|
||||
EVENT_DropURLs(hwnd, event);
|
||||
}
|
||||
|
||||
|
||||
struct client_message_handler
|
||||
{
|
||||
int atom; /* protocol atom */
|
||||
void (*handler)(HWND, XClientMessageEvent *); /* corresponding handler function */
|
||||
};
|
||||
|
||||
static const struct client_message_handler client_messages[] =
|
||||
{
|
||||
{ XATOM_WM_PROTOCOLS, handle_wm_protocols },
|
||||
{ XATOM_DndProtocol, handle_dnd_protocol },
|
||||
{ XATOM_XdndEnter, X11DRV_XDND_EnterEvent },
|
||||
{ XATOM_XdndPosition, X11DRV_XDND_PositionEvent },
|
||||
{ XATOM_XdndDrop, X11DRV_XDND_DropEvent },
|
||||
{ XATOM_XdndLeave, X11DRV_XDND_LeaveEvent }
|
||||
};
|
||||
|
||||
|
||||
/**********************************************************************
|
||||
* EVENT_ClientMessage
|
||||
*/
|
||||
static void EVENT_ClientMessage( HWND hwnd, XEvent *xev )
|
||||
{
|
||||
XClientMessageEvent *event = &xev->xclient;
|
||||
unsigned int i;
|
||||
|
||||
if (!hwnd) return;
|
||||
|
||||
if (event->format != 32)
|
||||
{
|
||||
WARN( "Don't know how to handle format %d\n", event->format );
|
||||
return;
|
||||
}
|
||||
|
||||
for (i = 0; i < sizeof(client_messages)/sizeof(client_messages[0]); i++)
|
||||
{
|
||||
if (event->message_type == X11DRV_Atoms[client_messages[i].atom - FIRST_XATOM])
|
||||
{
|
||||
client_messages[i].handler( hwnd, event );
|
||||
return;
|
||||
}
|
||||
}
|
||||
TRACE( "no handler found for %ld\n", event->message_type );
|
||||
}
|
||||
|
@ -243,7 +243,10 @@ extern XIC X11DRV_CreateIC(XIM xim, Display *display, Window win);
|
||||
extern XIM X11DRV_SetupXIM(Display *display, const char *input_style);
|
||||
extern void X11DRV_XIMLookupChars( const char *str, DWORD count );
|
||||
|
||||
extern int X11DRV_XDND_Event(HWND hWnd, XClientMessageEvent *event);
|
||||
extern void X11DRV_XDND_EnterEvent( HWND hWnd, XClientMessageEvent *event );
|
||||
extern void X11DRV_XDND_PositionEvent( HWND hWnd, XClientMessageEvent *event );
|
||||
extern void X11DRV_XDND_DropEvent( HWND hWnd, XClientMessageEvent *event );
|
||||
extern void X11DRV_XDND_LeaveEvent( HWND hWnd, XClientMessageEvent *event );
|
||||
|
||||
/* exported dib functions for now */
|
||||
|
||||
|
@ -77,23 +77,18 @@ static CRITICAL_SECTION_DEBUG critsect_debug =
|
||||
};
|
||||
static CRITICAL_SECTION xdnd_cs = { &critsect_debug, -1, 0, 0, 0, 0 };
|
||||
|
||||
|
||||
/**************************************************************************
|
||||
* X11DRV_XDND_Event
|
||||
* X11DRV_XDND_EnterEvent
|
||||
*
|
||||
* Entry point for X11 XDND events. Returns FALSE if event is not handled.
|
||||
* Handle an XdndEnter event.
|
||||
*/
|
||||
int X11DRV_XDND_Event(HWND hWnd, XClientMessageEvent *event)
|
||||
void X11DRV_XDND_EnterEvent( HWND hWnd, XClientMessageEvent *event )
|
||||
{
|
||||
int isXDNDMsg = 1;
|
||||
|
||||
TRACE("0x%p\n", hWnd);
|
||||
|
||||
if (event->message_type == x11drv_atom(XdndEnter))
|
||||
{
|
||||
Atom *xdndtypes;
|
||||
unsigned long count = 0;
|
||||
|
||||
TRACE("XDNDEnter: ver(%ld) check-XdndTypeList(%ld) data=%ld,%ld,%ld,%ld,%ld\n",
|
||||
TRACE("ver(%ld) check-XdndTypeList(%ld) data=%ld,%ld,%ld,%ld,%ld\n",
|
||||
(event->data.l[1] & 0xFF000000) >> 24, (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]);
|
||||
@ -142,9 +137,15 @@ int X11DRV_XDND_Event(HWND hWnd, XClientMessageEvent *event)
|
||||
|
||||
if (event->data.l[1] & 1)
|
||||
XFree(xdndtypes);
|
||||
}
|
||||
else if (event->message_type == x11drv_atom(XdndPosition))
|
||||
{
|
||||
}
|
||||
|
||||
/**************************************************************************
|
||||
* X11DRV_XDND_PositionEvent
|
||||
*
|
||||
* Handle an XdndPosition event.
|
||||
*/
|
||||
void X11DRV_XDND_PositionEvent( HWND hWnd, XClientMessageEvent *event )
|
||||
{
|
||||
XClientMessageEvent e;
|
||||
int accept = 0; /* Assume we're not accepting */
|
||||
|
||||
@ -156,7 +157,7 @@ int X11DRV_XDND_Event(HWND hWnd, XClientMessageEvent *event)
|
||||
if (GetWindowLongW( hWnd, GWL_EXSTYLE ) & WS_EX_ACCEPTFILES)
|
||||
accept = 1;
|
||||
|
||||
TRACE("XDNDPosition. action req: %ld accept(%d) at x(%ld),y(%ld)\n",
|
||||
TRACE("action req: %ld accept(%d) at x(%ld),y(%ld)\n",
|
||||
event->data.l[4], accept, XDNDxy.x, XDNDxy.y);
|
||||
|
||||
/*
|
||||
@ -181,12 +182,18 @@ int X11DRV_XDND_Event(HWND hWnd, XClientMessageEvent *event)
|
||||
wine_tsx11_unlock();
|
||||
|
||||
/* FIXME: if drag accepted notify OLE of DragOver */
|
||||
}
|
||||
else if (event->message_type == x11drv_atom(XdndDrop))
|
||||
{
|
||||
}
|
||||
|
||||
/**************************************************************************
|
||||
* X11DRV_XDND_DropEvent
|
||||
*
|
||||
* Handle an XdndDrop event.
|
||||
*/
|
||||
void X11DRV_XDND_DropEvent( HWND hWnd, XClientMessageEvent *event )
|
||||
{
|
||||
XClientMessageEvent e;
|
||||
|
||||
TRACE("XDNDDrop\n");
|
||||
TRACE("\n");
|
||||
|
||||
/* If we have a HDROP type we send a WM_ACCEPTFILES.*/
|
||||
if (GetWindowLongW( hWnd, GWL_EXSTYLE ) & WS_EX_ACCEPTFILES)
|
||||
@ -206,19 +213,20 @@ int X11DRV_XDND_Event(HWND hWnd, XClientMessageEvent *event)
|
||||
wine_tsx11_lock();
|
||||
XSendEvent(event->display, event->data.l[0], False, NoEventMask, (XEvent*)&e);
|
||||
wine_tsx11_unlock();
|
||||
}
|
||||
else if (event->message_type == x11drv_atom(XdndLeave))
|
||||
{
|
||||
}
|
||||
|
||||
/**************************************************************************
|
||||
* X11DRV_XDND_LeaveEvent
|
||||
*
|
||||
* Handle an XdndLeave event.
|
||||
*/
|
||||
void X11DRV_XDND_LeaveEvent( HWND hWnd, XClientMessageEvent *event )
|
||||
{
|
||||
TRACE("DND Operation canceled\n");
|
||||
|
||||
X11DRV_XDND_FreeDragDropOp();
|
||||
|
||||
/* FIXME: Notify OLE of DragLeave */
|
||||
}
|
||||
else /* Not an XDND message */
|
||||
isXDNDMsg = 0;
|
||||
|
||||
return isXDNDMsg;
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user