1998-12-07 10:13:40 +01:00
|
|
|
/*
|
1998-12-26 13:00:43 +01:00
|
|
|
* X11 event driver
|
1998-12-07 10:13:40 +01:00
|
|
|
*
|
|
|
|
* Copyright 1993 Alexandre Julliard
|
1999-09-20 17:42:47 +02:00
|
|
|
* 1999 Noel Borthwick
|
2002-03-10 00:29:33 +01:00
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
2006-05-18 14:49:52 +02:00
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
1998-12-07 10:13:40 +01:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
|
2008-02-27 19:13:09 +01:00
|
|
|
#ifdef HAVE_POLL_H
|
|
|
|
#include <poll.h>
|
|
|
|
#endif
|
|
|
|
#ifdef HAVE_SYS_POLL_H
|
|
|
|
#include <sys/poll.h>
|
|
|
|
#endif
|
1998-12-07 10:13:40 +01:00
|
|
|
#include <X11/Xatom.h>
|
|
|
|
#include <X11/keysym.h>
|
2003-11-21 22:48:36 +01:00
|
|
|
#include <X11/Xlib.h>
|
2002-09-24 20:36:51 +02:00
|
|
|
#include <X11/Xresource.h>
|
|
|
|
#include <X11/Xutil.h>
|
2011-04-27 16:00:02 +02:00
|
|
|
#ifdef HAVE_X11_EXTENSIONS_XINPUT2_H
|
|
|
|
#include <X11/extensions/XInput2.h>
|
|
|
|
#endif
|
1999-12-12 20:42:47 +01:00
|
|
|
|
1998-12-07 10:13:40 +01:00
|
|
|
#include <assert.h>
|
2003-09-06 01:08:26 +02:00
|
|
|
#include <stdarg.h>
|
1998-12-07 10:13:40 +01:00
|
|
|
#include <string.h>
|
2005-03-09 19:46:13 +01:00
|
|
|
|
2003-09-06 01:08:26 +02:00
|
|
|
#include "windef.h"
|
|
|
|
#include "winbase.h"
|
|
|
|
#include "winuser.h"
|
|
|
|
#include "wingdi.h"
|
2000-09-16 22:58:06 +02:00
|
|
|
|
1998-12-07 10:13:40 +01:00
|
|
|
#include "x11drv.h"
|
2007-12-17 16:24:08 +01:00
|
|
|
|
|
|
|
/* avoid conflict with field names in included win32 headers */
|
|
|
|
#undef Status
|
|
|
|
#include "shlobj.h" /* DROPFILES */
|
2001-01-02 22:00:46 +01:00
|
|
|
#include "shellapi.h"
|
2007-12-17 16:24:08 +01:00
|
|
|
|
2008-04-17 16:07:06 +02:00
|
|
|
#include "wine/server.h"
|
2002-12-04 00:34:52 +01:00
|
|
|
#include "wine/debug.h"
|
1999-04-19 16:56:29 +02:00
|
|
|
|
2002-03-10 00:29:33 +01:00
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(event);
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2004-01-21 03:22:26 +01:00
|
|
|
extern BOOL ximInComposeMode;
|
|
|
|
|
1998-12-07 10:13:40 +01:00
|
|
|
#define DndNotDnd -1 /* OffiX drag&drop */
|
|
|
|
#define DndUnknown 0
|
|
|
|
#define DndRawData 1
|
|
|
|
#define DndFile 2
|
|
|
|
#define DndFiles 3
|
|
|
|
#define DndText 4
|
|
|
|
#define DndDir 5
|
|
|
|
#define DndLink 6
|
|
|
|
#define DndExe 7
|
|
|
|
|
|
|
|
#define DndEND 8
|
|
|
|
|
|
|
|
#define DndURL 128 /* KDE drag&drop */
|
|
|
|
|
2010-11-01 19:45:12 +01:00
|
|
|
#define XEMBED_EMBEDDED_NOTIFY 0
|
|
|
|
#define XEMBED_WINDOW_ACTIVATE 1
|
|
|
|
#define XEMBED_WINDOW_DEACTIVATE 2
|
|
|
|
#define XEMBED_REQUEST_FOCUS 3
|
|
|
|
#define XEMBED_FOCUS_IN 4
|
|
|
|
#define XEMBED_FOCUS_OUT 5
|
|
|
|
#define XEMBED_FOCUS_NEXT 6
|
|
|
|
#define XEMBED_FOCUS_PREV 7
|
|
|
|
#define XEMBED_MODALITY_ON 10
|
|
|
|
#define XEMBED_MODALITY_OFF 11
|
|
|
|
#define XEMBED_REGISTER_ACCELERATOR 12
|
|
|
|
#define XEMBED_UNREGISTER_ACCELERATOR 13
|
|
|
|
#define XEMBED_ACTIVATE_ACCELERATOR 14
|
|
|
|
|
2011-04-12 21:16:15 +02:00
|
|
|
Bool (*pXGetEventData)( Display *display, XEvent /*XGenericEventCookie*/ *event ) = NULL;
|
|
|
|
void (*pXFreeEventData)( Display *display, XEvent /*XGenericEventCookie*/ *event ) = NULL;
|
|
|
|
|
2005-02-26 18:49:38 +01:00
|
|
|
/* Event handlers */
|
2016-08-23 15:13:26 +02:00
|
|
|
static BOOL X11DRV_FocusIn( HWND hwnd, XEvent *event );
|
|
|
|
static BOOL X11DRV_FocusOut( HWND hwnd, XEvent *event );
|
|
|
|
static BOOL X11DRV_Expose( HWND hwnd, XEvent *event );
|
|
|
|
static BOOL X11DRV_MapNotify( HWND hwnd, XEvent *event );
|
|
|
|
static BOOL X11DRV_UnmapNotify( HWND hwnd, XEvent *event );
|
|
|
|
static BOOL X11DRV_ReparentNotify( HWND hwnd, XEvent *event );
|
|
|
|
static BOOL X11DRV_ConfigureNotify( HWND hwnd, XEvent *event );
|
|
|
|
static BOOL X11DRV_PropertyNotify( HWND hwnd, XEvent *event );
|
|
|
|
static BOOL X11DRV_ClientMessage( HWND hwnd, XEvent *event );
|
|
|
|
static BOOL X11DRV_GravityNotify( HWND hwnd, XEvent *event );
|
2005-02-26 18:49:38 +01:00
|
|
|
|
2011-04-06 13:26:42 +02:00
|
|
|
#define MAX_EVENT_HANDLERS 128
|
2005-02-26 18:49:38 +01:00
|
|
|
|
2011-04-06 13:26:42 +02:00
|
|
|
static x11drv_event_handler handlers[MAX_EVENT_HANDLERS] =
|
2005-02-26 18:49:38 +01:00
|
|
|
{
|
2011-04-06 13:26:42 +02:00
|
|
|
NULL, /* 0 reserved */
|
|
|
|
NULL, /* 1 reserved */
|
|
|
|
X11DRV_KeyEvent, /* 2 KeyPress */
|
|
|
|
X11DRV_KeyEvent, /* 3 KeyRelease */
|
|
|
|
X11DRV_ButtonPress, /* 4 ButtonPress */
|
|
|
|
X11DRV_ButtonRelease, /* 5 ButtonRelease */
|
|
|
|
X11DRV_MotionNotify, /* 6 MotionNotify */
|
|
|
|
X11DRV_EnterNotify, /* 7 EnterNotify */
|
|
|
|
NULL, /* 8 LeaveNotify */
|
|
|
|
X11DRV_FocusIn, /* 9 FocusIn */
|
|
|
|
X11DRV_FocusOut, /* 10 FocusOut */
|
|
|
|
X11DRV_KeymapNotify, /* 11 KeymapNotify */
|
|
|
|
X11DRV_Expose, /* 12 Expose */
|
|
|
|
NULL, /* 13 GraphicsExpose */
|
|
|
|
NULL, /* 14 NoExpose */
|
|
|
|
NULL, /* 15 VisibilityNotify */
|
|
|
|
NULL, /* 16 CreateNotify */
|
|
|
|
X11DRV_DestroyNotify, /* 17 DestroyNotify */
|
|
|
|
X11DRV_UnmapNotify, /* 18 UnmapNotify */
|
|
|
|
X11DRV_MapNotify, /* 19 MapNotify */
|
|
|
|
NULL, /* 20 MapRequest */
|
|
|
|
X11DRV_ReparentNotify, /* 21 ReparentNotify */
|
|
|
|
X11DRV_ConfigureNotify, /* 22 ConfigureNotify */
|
|
|
|
NULL, /* 23 ConfigureRequest */
|
|
|
|
X11DRV_GravityNotify, /* 24 GravityNotify */
|
|
|
|
NULL, /* 25 ResizeRequest */
|
|
|
|
NULL, /* 26 CirculateNotify */
|
|
|
|
NULL, /* 27 CirculateRequest */
|
|
|
|
X11DRV_PropertyNotify, /* 28 PropertyNotify */
|
|
|
|
X11DRV_SelectionClear, /* 29 SelectionClear */
|
|
|
|
X11DRV_SelectionRequest, /* 30 SelectionRequest */
|
|
|
|
NULL, /* 31 SelectionNotify */
|
|
|
|
NULL, /* 32 ColormapNotify */
|
|
|
|
X11DRV_ClientMessage, /* 33 ClientMessage */
|
|
|
|
X11DRV_MappingNotify, /* 34 MappingNotify */
|
2011-04-13 18:56:37 +02:00
|
|
|
X11DRV_GenericEvent /* 35 GenericEvent */
|
2005-02-26 18:49:38 +01:00
|
|
|
};
|
1999-09-20 17:42:47 +02:00
|
|
|
|
2011-04-06 13:26:42 +02:00
|
|
|
static const char * event_names[MAX_EVENT_HANDLERS] =
|
|
|
|
{
|
|
|
|
NULL, NULL, "KeyPress", "KeyRelease", "ButtonPress", "ButtonRelease",
|
|
|
|
"MotionNotify", "EnterNotify", "LeaveNotify", "FocusIn", "FocusOut",
|
|
|
|
"KeymapNotify", "Expose", "GraphicsExpose", "NoExpose", "VisibilityNotify",
|
|
|
|
"CreateNotify", "DestroyNotify", "UnmapNotify", "MapNotify", "MapRequest",
|
|
|
|
"ReparentNotify", "ConfigureNotify", "ConfigureRequest", "GravityNotify", "ResizeRequest",
|
|
|
|
"CirculateNotify", "CirculateRequest", "PropertyNotify", "SelectionClear", "SelectionRequest",
|
|
|
|
"SelectionNotify", "ColormapNotify", "ClientMessage", "MappingNotify", "GenericEvent"
|
|
|
|
};
|
2011-04-12 21:16:15 +02:00
|
|
|
|
2019-08-30 12:17:59 +02:00
|
|
|
/* is someone else grabbing the keyboard, for example the WM, when manipulating the window */
|
|
|
|
BOOL keyboard_grabbed = FALSE;
|
|
|
|
|
2011-04-27 16:00:02 +02:00
|
|
|
int xinput2_opcode = 0;
|
|
|
|
|
2005-02-26 18:49:38 +01:00
|
|
|
/* return the name of an X event */
|
|
|
|
static const char *dbgstr_event( int type )
|
|
|
|
{
|
2011-04-12 21:16:15 +02:00
|
|
|
if (type < MAX_EVENT_HANDLERS && event_names[type]) return event_names[type];
|
2011-04-06 13:26:42 +02:00
|
|
|
return wine_dbg_sprintf( "Unknown event %d", type );
|
2005-02-26 18:49:38 +01:00
|
|
|
}
|
|
|
|
|
2011-04-12 21:16:15 +02:00
|
|
|
static inline void get_event_data( XEvent *event )
|
|
|
|
{
|
|
|
|
#if defined(GenericEvent) && defined(HAVE_XEVENT_XCOOKIE)
|
|
|
|
if (event->xany.type != GenericEvent) return;
|
|
|
|
if (!pXGetEventData || !pXGetEventData( event->xany.display, event )) event->xcookie.data = NULL;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void free_event_data( XEvent *event )
|
|
|
|
{
|
|
|
|
#if defined(GenericEvent) && defined(HAVE_XEVENT_XCOOKIE)
|
|
|
|
if (event->xany.type != GenericEvent) return;
|
|
|
|
if (event->xcookie.data) pXFreeEventData( event->xany.display, event );
|
|
|
|
#endif
|
|
|
|
}
|
2005-02-26 18:49:38 +01:00
|
|
|
|
2013-11-13 16:59:38 +01:00
|
|
|
/***********************************************************************
|
|
|
|
* xembed_request_focus
|
|
|
|
*/
|
|
|
|
static void xembed_request_focus( Display *display, Window window, DWORD timestamp )
|
|
|
|
{
|
|
|
|
XEvent xev;
|
|
|
|
|
|
|
|
xev.xclient.type = ClientMessage;
|
|
|
|
xev.xclient.window = window;
|
|
|
|
xev.xclient.message_type = x11drv_atom(_XEMBED);
|
|
|
|
xev.xclient.serial = 0;
|
|
|
|
xev.xclient.display = display;
|
|
|
|
xev.xclient.send_event = True;
|
|
|
|
xev.xclient.format = 32;
|
|
|
|
|
|
|
|
xev.xclient.data.l[0] = timestamp;
|
|
|
|
xev.xclient.data.l[1] = XEMBED_REQUEST_FOCUS;
|
|
|
|
xev.xclient.data.l[2] = 0;
|
|
|
|
xev.xclient.data.l[3] = 0;
|
|
|
|
xev.xclient.data.l[4] = 0;
|
|
|
|
|
|
|
|
XSendEvent(display, window, False, NoEventMask, &xev);
|
|
|
|
XFlush( display );
|
|
|
|
}
|
|
|
|
|
2005-02-26 18:49:38 +01:00
|
|
|
/***********************************************************************
|
|
|
|
* X11DRV_register_event_handler
|
|
|
|
*
|
|
|
|
* Register a handler for a given event type.
|
|
|
|
* If already registered, overwrite the previous handler.
|
|
|
|
*/
|
2011-04-06 13:26:42 +02:00
|
|
|
void X11DRV_register_event_handler( int type, x11drv_event_handler handler, const char *name )
|
2005-02-26 18:49:38 +01:00
|
|
|
{
|
2011-05-01 14:51:29 +02:00
|
|
|
assert( type < MAX_EVENT_HANDLERS );
|
2011-04-19 17:17:48 +02:00
|
|
|
assert( !handlers[type] || handlers[type] == handler );
|
2011-04-06 13:26:42 +02:00
|
|
|
handlers[type] = handler;
|
|
|
|
event_names[type] = name;
|
|
|
|
TRACE("registered handler %p for event %d %s\n", handler, type, debugstr_a(name) );
|
2005-02-26 18:49:38 +01:00
|
|
|
}
|
1998-12-07 10:13:40 +01:00
|
|
|
|
|
|
|
|
2005-03-08 20:20:14 +01:00
|
|
|
/***********************************************************************
|
|
|
|
* filter_event
|
|
|
|
*/
|
|
|
|
static Bool filter_event( Display *display, XEvent *event, char *arg )
|
|
|
|
{
|
2005-09-12 17:14:06 +02:00
|
|
|
ULONG_PTR mask = (ULONG_PTR)arg;
|
2005-03-08 20:20:14 +01:00
|
|
|
|
|
|
|
if ((mask & QS_ALLINPUT) == QS_ALLINPUT) return 1;
|
|
|
|
|
|
|
|
switch(event->type)
|
|
|
|
{
|
|
|
|
case KeyPress:
|
|
|
|
case KeyRelease:
|
|
|
|
case KeymapNotify:
|
2006-03-30 16:23:12 +02:00
|
|
|
case MappingNotify:
|
2011-06-17 21:01:13 +02:00
|
|
|
return (mask & (QS_KEY|QS_HOTKEY)) != 0;
|
2005-03-08 20:20:14 +01:00
|
|
|
case ButtonPress:
|
|
|
|
case ButtonRelease:
|
|
|
|
return (mask & QS_MOUSEBUTTON) != 0;
|
2015-12-02 07:31:34 +01:00
|
|
|
#ifdef GenericEvent
|
|
|
|
case GenericEvent:
|
|
|
|
#endif
|
2005-03-08 20:20:14 +01:00
|
|
|
case MotionNotify:
|
|
|
|
case EnterNotify:
|
|
|
|
case LeaveNotify:
|
|
|
|
return (mask & QS_MOUSEMOVE) != 0;
|
|
|
|
case Expose:
|
|
|
|
return (mask & QS_PAINT) != 0;
|
2006-03-30 16:23:12 +02:00
|
|
|
case FocusIn:
|
|
|
|
case FocusOut:
|
|
|
|
case MapNotify:
|
|
|
|
case UnmapNotify:
|
|
|
|
case ConfigureNotify:
|
|
|
|
case PropertyNotify:
|
2005-03-08 20:20:14 +01:00
|
|
|
case ClientMessage:
|
|
|
|
return (mask & QS_POSTMESSAGE) != 0;
|
|
|
|
default:
|
|
|
|
return (mask & QS_SENDMESSAGE) != 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-03-11 12:11:35 +01:00
|
|
|
enum event_merge_action
|
|
|
|
{
|
|
|
|
MERGE_DISCARD, /* discard the old event */
|
|
|
|
MERGE_HANDLE, /* handle the old event */
|
2011-04-27 16:00:02 +02:00
|
|
|
MERGE_KEEP, /* keep the old event for future merging */
|
|
|
|
MERGE_IGNORE /* ignore the new event, keep the old one */
|
2008-03-11 12:11:35 +01:00
|
|
|
};
|
|
|
|
|
2011-04-27 16:00:50 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* merge_raw_motion_events
|
|
|
|
*/
|
|
|
|
#ifdef HAVE_X11_EXTENSIONS_XINPUT2_H
|
|
|
|
static enum event_merge_action merge_raw_motion_events( XIRawEvent *prev, XIRawEvent *next )
|
|
|
|
{
|
|
|
|
int i, j, k;
|
|
|
|
unsigned char mask;
|
|
|
|
|
|
|
|
if (!prev->valuators.mask_len) return MERGE_HANDLE;
|
|
|
|
if (!next->valuators.mask_len) return MERGE_HANDLE;
|
|
|
|
|
|
|
|
mask = prev->valuators.mask[0] | next->valuators.mask[0];
|
|
|
|
if (mask == next->valuators.mask[0]) /* keep next */
|
|
|
|
{
|
|
|
|
for (i = j = k = 0; i < 8; i++)
|
|
|
|
{
|
|
|
|
if (XIMaskIsSet( prev->valuators.mask, i ))
|
|
|
|
next->valuators.values[j] += prev->valuators.values[k++];
|
|
|
|
if (XIMaskIsSet( next->valuators.mask, i )) j++;
|
|
|
|
}
|
|
|
|
TRACE( "merging duplicate GenericEvent\n" );
|
|
|
|
return MERGE_DISCARD;
|
|
|
|
}
|
|
|
|
if (mask == prev->valuators.mask[0]) /* keep prev */
|
|
|
|
{
|
|
|
|
for (i = j = k = 0; i < 8; i++)
|
|
|
|
{
|
|
|
|
if (XIMaskIsSet( next->valuators.mask, i ))
|
|
|
|
prev->valuators.values[j] += next->valuators.values[k++];
|
|
|
|
if (XIMaskIsSet( prev->valuators.mask, i )) j++;
|
|
|
|
}
|
|
|
|
TRACE( "merging duplicate GenericEvent\n" );
|
|
|
|
return MERGE_IGNORE;
|
|
|
|
}
|
|
|
|
/* can't merge events with disjoint masks */
|
|
|
|
return MERGE_HANDLE;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2008-03-11 12:11:35 +01:00
|
|
|
/***********************************************************************
|
|
|
|
* merge_events
|
|
|
|
*
|
|
|
|
* Try to merge 2 consecutive events.
|
|
|
|
*/
|
|
|
|
static enum event_merge_action merge_events( XEvent *prev, XEvent *next )
|
|
|
|
{
|
|
|
|
switch (prev->type)
|
|
|
|
{
|
|
|
|
case ConfigureNotify:
|
|
|
|
switch (next->type)
|
|
|
|
{
|
|
|
|
case ConfigureNotify:
|
2008-03-11 19:50:27 +01:00
|
|
|
if (prev->xany.window == next->xany.window)
|
|
|
|
{
|
|
|
|
TRACE( "discarding duplicate ConfigureNotify for window %lx\n", prev->xany.window );
|
|
|
|
return MERGE_DISCARD;
|
|
|
|
}
|
|
|
|
break;
|
2008-03-11 12:11:35 +01:00
|
|
|
case Expose:
|
|
|
|
case PropertyNotify:
|
|
|
|
return MERGE_KEEP;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case MotionNotify:
|
2011-11-09 15:45:13 +01:00
|
|
|
switch (next->type)
|
2008-03-11 12:11:35 +01:00
|
|
|
{
|
2011-11-09 15:45:13 +01:00
|
|
|
case MotionNotify:
|
|
|
|
if (prev->xany.window == next->xany.window)
|
|
|
|
{
|
|
|
|
TRACE( "discarding duplicate MotionNotify for window %lx\n", prev->xany.window );
|
|
|
|
return MERGE_DISCARD;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
#ifdef HAVE_X11_EXTENSIONS_XINPUT2_H
|
|
|
|
case GenericEvent:
|
|
|
|
if (next->xcookie.extension != xinput2_opcode) break;
|
|
|
|
if (next->xcookie.evtype != XI_RawMotion) break;
|
|
|
|
if (x11drv_thread_data()->warp_serial) break;
|
|
|
|
return MERGE_KEEP;
|
2008-03-11 12:11:35 +01:00
|
|
|
}
|
|
|
|
break;
|
2011-04-27 16:00:02 +02:00
|
|
|
case GenericEvent:
|
2011-11-09 15:45:13 +01:00
|
|
|
if (prev->xcookie.extension != xinput2_opcode) break;
|
|
|
|
if (prev->xcookie.evtype != XI_RawMotion) break;
|
|
|
|
switch (next->type)
|
2011-04-27 16:00:02 +02:00
|
|
|
{
|
2011-11-09 15:45:13 +01:00
|
|
|
case GenericEvent:
|
|
|
|
if (next->xcookie.extension != xinput2_opcode) break;
|
|
|
|
if (next->xcookie.evtype != XI_RawMotion) break;
|
|
|
|
if (x11drv_thread_data()->warp_serial) break;
|
|
|
|
return merge_raw_motion_events( prev->xcookie.data, next->xcookie.data );
|
|
|
|
#endif
|
2011-04-27 16:00:02 +02:00
|
|
|
}
|
|
|
|
break;
|
2008-03-11 12:11:35 +01:00
|
|
|
}
|
|
|
|
return MERGE_HANDLE;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* call_event_handler
|
|
|
|
*/
|
2016-08-23 15:13:26 +02:00
|
|
|
static inline BOOL call_event_handler( Display *display, XEvent *event )
|
2008-03-11 12:11:35 +01:00
|
|
|
{
|
|
|
|
HWND hwnd;
|
2008-03-13 13:35:02 +01:00
|
|
|
XEvent *prev;
|
|
|
|
struct x11drv_thread_data *thread_data;
|
2016-08-23 15:13:26 +02:00
|
|
|
BOOL ret;
|
2008-03-11 12:11:35 +01:00
|
|
|
|
2011-04-06 13:26:42 +02:00
|
|
|
if (!handlers[event->type])
|
2008-03-11 12:11:35 +01:00
|
|
|
{
|
|
|
|
TRACE( "%s for win %lx, ignoring\n", dbgstr_event( event->type ), event->xany.window );
|
2016-08-23 15:13:26 +02:00
|
|
|
return FALSE; /* no handler, ignore it */
|
2008-03-11 12:11:35 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
if (XFindContext( display, event->xany.window, winContext, (char **)&hwnd ) != 0)
|
|
|
|
hwnd = 0; /* not for a registered window */
|
|
|
|
if (!hwnd && event->xany.window == root_window) hwnd = GetDesktopWindow();
|
|
|
|
|
2010-01-04 17:56:32 +01:00
|
|
|
TRACE( "%lu %s for hwnd/window %p/%lx\n",
|
|
|
|
event->xany.serial, dbgstr_event( event->type ), hwnd, event->xany.window );
|
2008-03-13 13:35:02 +01:00
|
|
|
thread_data = x11drv_thread_data();
|
|
|
|
prev = thread_data->current_event;
|
|
|
|
thread_data->current_event = event;
|
2016-08-23 15:13:26 +02:00
|
|
|
ret = handlers[event->type]( hwnd, event );
|
2008-03-13 13:35:02 +01:00
|
|
|
thread_data->current_event = prev;
|
2016-08-23 15:13:26 +02:00
|
|
|
return ret;
|
2008-03-11 12:11:35 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
1999-07-10 12:24:31 +02:00
|
|
|
/***********************************************************************
|
2001-05-16 21:52:29 +02:00
|
|
|
* process_events
|
1999-07-10 12:24:31 +02:00
|
|
|
*/
|
2016-08-28 16:30:43 +02:00
|
|
|
static BOOL process_events( Display *display, Bool (*filter)(Display*, XEvent*,XPointer), ULONG_PTR arg )
|
1999-02-21 19:15:26 +01:00
|
|
|
{
|
2008-03-11 12:11:35 +01:00
|
|
|
XEvent event, prev_event;
|
2005-03-08 20:20:14 +01:00
|
|
|
int count = 0;
|
2016-08-23 15:13:26 +02:00
|
|
|
BOOL queued = FALSE;
|
2008-03-11 12:11:35 +01:00
|
|
|
enum event_merge_action action = MERGE_DISCARD;
|
1999-02-21 19:15:26 +01:00
|
|
|
|
2008-03-11 12:11:35 +01:00
|
|
|
prev_event.type = 0;
|
2008-02-27 19:13:09 +01:00
|
|
|
while (XCheckIfEvent( display, &event, filter, (char *)arg ))
|
1999-05-22 20:57:17 +02:00
|
|
|
{
|
2005-03-08 20:20:14 +01:00
|
|
|
count++;
|
2008-07-10 04:29:20 +02:00
|
|
|
if (XFilterEvent( &event, None ))
|
|
|
|
{
|
|
|
|
/*
|
|
|
|
* SCIM on linux filters key events strangely. It does not filter the
|
|
|
|
* KeyPress events for these keys however it does filter the
|
|
|
|
* KeyRelease events. This causes wine to become very confused as
|
|
|
|
* to the keyboard state.
|
|
|
|
*
|
|
|
|
* We need to let those KeyRelease events be processed so that the
|
|
|
|
* keyboard state is correct.
|
|
|
|
*/
|
|
|
|
if (event.type == KeyRelease)
|
|
|
|
{
|
|
|
|
KeySym keysym = 0;
|
|
|
|
XKeyEvent *keyevent = &event.xkey;
|
|
|
|
|
|
|
|
XLookupString(keyevent, NULL, 0, &keysym, NULL);
|
|
|
|
if (!(keysym == XK_Shift_L ||
|
|
|
|
keysym == XK_Shift_R ||
|
|
|
|
keysym == XK_Control_L ||
|
|
|
|
keysym == XK_Control_R ||
|
|
|
|
keysym == XK_Alt_R ||
|
|
|
|
keysym == XK_Alt_L ||
|
|
|
|
keysym == XK_Meta_R ||
|
|
|
|
keysym == XK_Meta_L))
|
|
|
|
continue; /* not a key we care about, ignore it */
|
|
|
|
}
|
|
|
|
else
|
|
|
|
continue; /* filtered, ignore it */
|
|
|
|
}
|
2011-04-12 21:16:15 +02:00
|
|
|
get_event_data( &event );
|
2008-03-11 12:11:35 +01:00
|
|
|
if (prev_event.type) action = merge_events( &prev_event, &event );
|
|
|
|
switch( action )
|
2005-02-26 18:49:38 +01:00
|
|
|
{
|
2008-03-11 12:11:35 +01:00
|
|
|
case MERGE_HANDLE: /* handle prev, keep new */
|
2016-08-23 15:13:26 +02:00
|
|
|
queued |= call_event_handler( display, &prev_event );
|
2011-04-12 21:16:15 +02:00
|
|
|
/* fall through */
|
|
|
|
case MERGE_DISCARD: /* discard prev, keep new */
|
|
|
|
free_event_data( &prev_event );
|
2008-03-11 12:11:35 +01:00
|
|
|
prev_event = event;
|
|
|
|
break;
|
|
|
|
case MERGE_KEEP: /* handle new, keep prev for future merging */
|
2016-08-23 15:13:26 +02:00
|
|
|
queued |= call_event_handler( display, &event );
|
2011-04-27 16:00:02 +02:00
|
|
|
/* fall through */
|
|
|
|
case MERGE_IGNORE: /* ignore new, keep prev for future merging */
|
2011-04-12 21:16:15 +02:00
|
|
|
free_event_data( &event );
|
2008-03-11 12:11:35 +01:00
|
|
|
break;
|
2005-02-26 18:49:38 +01:00
|
|
|
}
|
1999-05-22 20:57:17 +02:00
|
|
|
}
|
2016-08-23 15:13:26 +02:00
|
|
|
if (prev_event.type) queued |= call_event_handler( display, &prev_event );
|
2011-04-12 21:16:15 +02:00
|
|
|
free_event_data( &prev_event );
|
2010-04-22 16:33:35 +02:00
|
|
|
XFlush( gdi_display );
|
2016-08-28 16:30:41 +02:00
|
|
|
if (count) TRACE( "processed %d events, returning %d\n", count, queued );
|
2016-08-23 15:13:26 +02:00
|
|
|
return queued;
|
1998-12-07 10:13:40 +01:00
|
|
|
}
|
|
|
|
|
2001-05-16 21:52:29 +02:00
|
|
|
|
1998-12-07 10:13:40 +01:00
|
|
|
/***********************************************************************
|
2001-05-19 00:51:56 +02:00
|
|
|
* MsgWaitForMultipleObjectsEx (X11DRV.@)
|
1998-12-07 10:13:40 +01:00
|
|
|
*/
|
2008-12-16 15:32:08 +01:00
|
|
|
DWORD CDECL X11DRV_MsgWaitForMultipleObjectsEx( DWORD count, const HANDLE *handles,
|
|
|
|
DWORD timeout, DWORD mask, DWORD flags )
|
1998-12-07 10:13:40 +01:00
|
|
|
{
|
2007-04-04 18:02:53 +02:00
|
|
|
DWORD ret;
|
2005-06-01 13:08:39 +02:00
|
|
|
struct x11drv_thread_data *data = TlsGetValue( thread_data_tls_index );
|
2001-05-16 21:52:29 +02:00
|
|
|
|
2007-04-04 18:02:53 +02:00
|
|
|
if (!data)
|
2005-08-03 17:47:30 +02:00
|
|
|
{
|
|
|
|
if (!count && !timeout) return WAIT_TIMEOUT;
|
2001-05-19 00:51:56 +02:00
|
|
|
return WaitForMultipleObjectsEx( count, handles, flags & MWMO_WAITALL,
|
|
|
|
timeout, flags & MWMO_ALERTABLE );
|
2005-08-03 17:47:30 +02:00
|
|
|
}
|
2001-05-16 21:52:29 +02:00
|
|
|
|
2008-03-13 13:35:02 +01:00
|
|
|
if (data->current_event) mask = 0; /* don't process nested events */
|
2005-08-03 17:47:30 +02:00
|
|
|
|
2008-02-27 19:13:09 +01:00
|
|
|
if (process_events( data->display, filter_event, mask )) ret = count - 1;
|
2005-08-03 17:47:30 +02:00
|
|
|
else if (count || timeout)
|
2001-06-04 23:55:17 +02:00
|
|
|
{
|
2007-04-04 18:02:53 +02:00
|
|
|
ret = WaitForMultipleObjectsEx( count, handles, flags & MWMO_WAITALL,
|
2001-06-04 23:55:17 +02:00
|
|
|
timeout, flags & MWMO_ALERTABLE );
|
2008-02-27 19:13:09 +01:00
|
|
|
if (ret == count - 1) process_events( data->display, filter_event, mask );
|
2001-06-04 23:55:17 +02:00
|
|
|
}
|
2005-08-03 17:47:30 +02:00
|
|
|
else ret = WAIT_TIMEOUT;
|
|
|
|
|
2001-05-16 21:52:29 +02:00
|
|
|
return ret;
|
1998-12-07 10:13:40 +01:00
|
|
|
}
|
|
|
|
|
2005-01-14 18:06:40 +01:00
|
|
|
/***********************************************************************
|
|
|
|
* EVENT_x11_time_to_win32_time
|
|
|
|
*
|
|
|
|
* Make our timer and the X timer line up as best we can
|
|
|
|
* Pass 0 to retrieve the current adjustment value (times -1)
|
|
|
|
*/
|
|
|
|
DWORD EVENT_x11_time_to_win32_time(Time time)
|
|
|
|
{
|
|
|
|
static DWORD adjust = 0;
|
|
|
|
DWORD now = GetTickCount();
|
|
|
|
DWORD ret;
|
|
|
|
|
|
|
|
if (! adjust && time != 0)
|
|
|
|
{
|
|
|
|
ret = now;
|
|
|
|
adjust = time - now;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* If we got an event in the 'future', then our clock is clearly wrong.
|
|
|
|
If we got it more than 10000 ms in the future, then it's most likely
|
|
|
|
that the clock has wrapped. */
|
|
|
|
|
|
|
|
ret = time - adjust;
|
|
|
|
if (ret > now && ((ret - now) < 10000) && time != 0)
|
|
|
|
{
|
|
|
|
adjust += ret - now;
|
|
|
|
ret -= ret - now;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
|
|
|
|
}
|
2001-05-16 21:52:29 +02:00
|
|
|
|
2002-10-12 01:41:06 +02:00
|
|
|
/*******************************************************************
|
|
|
|
* can_activate_window
|
|
|
|
*
|
|
|
|
* Check if we can activate the specified window.
|
|
|
|
*/
|
2007-03-17 11:47:28 +01:00
|
|
|
static inline BOOL can_activate_window( HWND hwnd )
|
2002-10-12 01:41:06 +02:00
|
|
|
{
|
|
|
|
LONG style = GetWindowLongW( hwnd, GWL_STYLE );
|
2012-09-18 11:24:55 +02:00
|
|
|
RECT rect;
|
2012-02-01 15:33:51 +01:00
|
|
|
|
2002-10-12 01:41:06 +02:00
|
|
|
if (!(style & WS_VISIBLE)) return FALSE;
|
|
|
|
if ((style & (WS_POPUP|WS_CHILD)) == WS_CHILD) return FALSE;
|
2009-04-23 12:41:57 +02:00
|
|
|
if (style & WS_MINIMIZE) return FALSE;
|
2009-10-23 12:25:22 +02:00
|
|
|
if (GetWindowLongW( hwnd, GWL_EXSTYLE ) & WS_EX_NOACTIVATE) return FALSE;
|
2007-08-16 23:43:58 +02:00
|
|
|
if (hwnd == GetDesktopWindow()) return FALSE;
|
2012-09-18 11:24:55 +02:00
|
|
|
if (GetWindowRect( hwnd, &rect ) && IsRectEmpty( &rect )) return FALSE;
|
2002-10-12 01:41:06 +02:00
|
|
|
return !(style & WS_DISABLED);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-09-18 11:20:07 +02:00
|
|
|
/**********************************************************************
|
|
|
|
* set_input_focus
|
|
|
|
*
|
2013-11-13 16:59:38 +01:00
|
|
|
* Try to force focus for embedded or non-managed windows.
|
2012-09-18 11:20:07 +02:00
|
|
|
*/
|
2013-11-13 16:59:38 +01:00
|
|
|
static void set_input_focus( struct x11drv_win_data *data )
|
2012-09-18 11:20:07 +02:00
|
|
|
{
|
|
|
|
XWindowChanges changes;
|
|
|
|
DWORD timestamp;
|
|
|
|
|
2013-11-13 16:59:38 +01:00
|
|
|
if (!data->whole_window) return;
|
2012-09-18 11:20:07 +02:00
|
|
|
|
|
|
|
if (EVENT_x11_time_to_win32_time(0))
|
|
|
|
/* ICCCM says don't use CurrentTime, so try to use last message time if possible */
|
|
|
|
/* FIXME: this is not entirely correct */
|
|
|
|
timestamp = GetMessageTime() - EVENT_x11_time_to_win32_time(0);
|
|
|
|
else
|
|
|
|
timestamp = CurrentTime;
|
|
|
|
|
|
|
|
/* Set X focus and install colormap */
|
|
|
|
changes.stack_mode = Above;
|
2013-11-13 16:59:38 +01:00
|
|
|
XConfigureWindow( data->display, data->whole_window, CWStackMode, &changes );
|
|
|
|
|
|
|
|
if (data->embedder)
|
|
|
|
xembed_request_focus( data->display, data->embedder, timestamp );
|
|
|
|
else
|
|
|
|
XSetInputFocus( data->display, data->whole_window, RevertToParent, timestamp );
|
|
|
|
|
2012-09-18 11:20:07 +02:00
|
|
|
}
|
|
|
|
|
2002-09-19 01:09:50 +02:00
|
|
|
/**********************************************************************
|
|
|
|
* set_focus
|
|
|
|
*/
|
2008-06-26 16:20:02 +02:00
|
|
|
static void set_focus( Display *display, HWND hwnd, Time time )
|
2002-09-19 01:09:50 +02:00
|
|
|
{
|
2002-10-12 01:41:06 +02:00
|
|
|
HWND focus;
|
2002-09-19 01:09:50 +02:00
|
|
|
Window win;
|
2009-11-11 21:37:51 +01:00
|
|
|
GUITHREADINFO threadinfo;
|
2001-06-04 23:55:17 +02:00
|
|
|
|
2002-10-31 03:38:20 +01:00
|
|
|
TRACE( "setting foreground window to %p\n", hwnd );
|
2002-10-12 01:41:06 +02:00
|
|
|
SetForegroundWindow( hwnd );
|
2001-06-04 23:55:17 +02:00
|
|
|
|
2010-11-16 20:57:27 +01:00
|
|
|
threadinfo.cbSize = sizeof(threadinfo);
|
2009-11-11 21:37:51 +01:00
|
|
|
GetGUIThreadInfo(0, &threadinfo);
|
|
|
|
focus = threadinfo.hwndFocus;
|
2010-06-24 22:06:29 +02:00
|
|
|
if (!focus) focus = threadinfo.hwndActive;
|
2003-01-21 21:16:20 +01:00
|
|
|
if (focus) focus = GetAncestor( focus, GA_ROOT );
|
2002-09-19 01:09:50 +02:00
|
|
|
win = X11DRV_get_whole_window(focus);
|
|
|
|
|
|
|
|
if (win)
|
|
|
|
{
|
2002-10-31 03:38:20 +01:00
|
|
|
TRACE( "setting focus to %p (%lx) time=%ld\n", focus, win, time );
|
2008-06-26 16:20:02 +02:00
|
|
|
XSetInputFocus( display, win, RevertToParent, time );
|
2002-09-19 01:09:50 +02:00
|
|
|
}
|
1998-12-07 10:13:40 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-11-01 19:57:12 +01:00
|
|
|
/**********************************************************************
|
|
|
|
* handle_manager_message
|
|
|
|
*/
|
|
|
|
static void handle_manager_message( HWND hwnd, XClientMessageEvent *event )
|
|
|
|
{
|
|
|
|
if (hwnd != GetDesktopWindow()) return;
|
|
|
|
if (systray_atom && event->data.l[1] == systray_atom)
|
|
|
|
change_systray_owner( event->display, event->data.l[2] );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
1998-12-07 10:13:40 +01:00
|
|
|
/**********************************************************************
|
2005-03-01 12:52:02 +01:00
|
|
|
* handle_wm_protocols
|
1998-12-07 10:13:40 +01:00
|
|
|
*/
|
2005-03-01 12:52:02 +01:00
|
|
|
static void handle_wm_protocols( HWND hwnd, XClientMessageEvent *event )
|
1998-12-07 10:13:40 +01:00
|
|
|
{
|
2002-09-19 01:09:50 +02:00
|
|
|
Atom protocol = (Atom)event->data.l[0];
|
2010-06-29 11:08:51 +02:00
|
|
|
Time event_time = (Time)event->data.l[1];
|
2002-09-19 01:09:50 +02:00
|
|
|
|
|
|
|
if (!protocol) return;
|
1999-10-13 15:49:01 +02:00
|
|
|
|
2003-11-20 05:24:18 +01:00
|
|
|
if (protocol == x11drv_atom(WM_DELETE_WINDOW))
|
2002-09-19 01:09:50 +02:00
|
|
|
{
|
2010-06-29 11:08:51 +02:00
|
|
|
update_user_time( event_time );
|
|
|
|
|
2009-12-11 18:47:59 +01:00
|
|
|
if (hwnd == GetDesktopWindow())
|
|
|
|
{
|
|
|
|
/* The desktop window does not have a close button that we can
|
|
|
|
* pretend to click. Therefore, we simply send it a close command. */
|
|
|
|
SendMessageW(hwnd, WM_SYSCOMMAND, SC_CLOSE, 0);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2002-09-19 01:09:50 +02:00
|
|
|
/* Ignore the delete window request if the window has been disabled
|
|
|
|
* and we are in managed mode. This is to disallow applications from
|
|
|
|
* being closed by the window manager while in a modal state.
|
|
|
|
*/
|
2005-07-25 13:08:43 +02:00
|
|
|
if (IsWindowEnabled(hwnd))
|
|
|
|
{
|
|
|
|
HMENU hSysMenu;
|
|
|
|
|
|
|
|
if (GetClassLongW(hwnd, GCL_STYLE) & CS_NOCLOSE) return;
|
|
|
|
hSysMenu = GetSystemMenu(hwnd, FALSE);
|
|
|
|
if (hSysMenu)
|
|
|
|
{
|
|
|
|
UINT state = GetMenuState(hSysMenu, SC_CLOSE, MF_BYCOMMAND);
|
|
|
|
if (state == 0xFFFFFFFF || (state & (MF_DISABLED | MF_GRAYED)))
|
|
|
|
return;
|
|
|
|
}
|
2007-06-18 23:00:04 +02:00
|
|
|
if (GetActiveWindow() != hwnd)
|
|
|
|
{
|
|
|
|
LRESULT ma = SendMessageW( hwnd, WM_MOUSEACTIVATE,
|
|
|
|
(WPARAM)GetAncestor( hwnd, GA_ROOT ),
|
2009-09-09 10:21:52 +02:00
|
|
|
MAKELPARAM( HTCLOSE, WM_NCLBUTTONDOWN ) );
|
2007-06-18 23:00:04 +02:00
|
|
|
switch(ma)
|
|
|
|
{
|
|
|
|
case MA_NOACTIVATEANDEAT:
|
|
|
|
case MA_ACTIVATEANDEAT:
|
|
|
|
return;
|
|
|
|
case MA_NOACTIVATE:
|
|
|
|
break;
|
|
|
|
case MA_ACTIVATE:
|
|
|
|
case 0:
|
|
|
|
SetActiveWindow(hwnd);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
WARN( "unknown WM_MOUSEACTIVATE code %d\n", (int) ma );
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2010-05-28 08:06:14 +02:00
|
|
|
|
2010-06-16 10:06:15 +02:00
|
|
|
PostMessageW( hwnd, WM_SYSCOMMAND, SC_CLOSE, 0 );
|
2005-07-25 13:08:43 +02:00
|
|
|
}
|
2002-09-19 01:09:50 +02:00
|
|
|
}
|
2003-11-20 05:24:18 +01:00
|
|
|
else if (protocol == x11drv_atom(WM_TAKE_FOCUS))
|
2001-06-04 23:55:17 +02:00
|
|
|
{
|
2002-09-19 01:09:50 +02:00
|
|
|
HWND last_focus = x11drv_thread_data()->last_focus;
|
|
|
|
|
2006-10-08 01:34:01 +02:00
|
|
|
TRACE( "got take focus msg for %p, enabled=%d, visible=%d (style %08x), focus=%p, active=%p, fg=%p, last=%p\n",
|
2006-07-05 09:57:44 +02:00
|
|
|
hwnd, IsWindowEnabled(hwnd), IsWindowVisible(hwnd), GetWindowLongW(hwnd, GWL_STYLE),
|
|
|
|
GetFocus(), GetActiveWindow(), GetForegroundWindow(), last_focus );
|
2002-09-19 01:09:50 +02:00
|
|
|
|
2002-10-12 01:41:06 +02:00
|
|
|
if (can_activate_window(hwnd))
|
2001-06-04 23:55:17 +02:00
|
|
|
{
|
2020-10-30 09:20:10 +01:00
|
|
|
/* simulate a mouse click on the menu to find out
|
2002-09-19 01:09:50 +02:00
|
|
|
* whether the window wants to be activated */
|
|
|
|
LRESULT ma = SendMessageW( hwnd, WM_MOUSEACTIVATE,
|
2002-10-31 03:38:20 +01:00
|
|
|
(WPARAM)GetAncestor( hwnd, GA_ROOT ),
|
2019-12-26 12:51:23 +01:00
|
|
|
MAKELONG( HTMENU, WM_LBUTTONDOWN ) );
|
2007-06-22 00:38:00 +02:00
|
|
|
if (ma != MA_NOACTIVATEANDEAT && ma != MA_NOACTIVATE)
|
|
|
|
{
|
2008-06-26 16:20:02 +02:00
|
|
|
set_focus( event->display, hwnd, event_time );
|
2007-06-22 00:38:00 +02:00
|
|
|
return;
|
|
|
|
}
|
2002-09-19 01:09:50 +02:00
|
|
|
}
|
2009-08-17 16:32:45 +02:00
|
|
|
else if (hwnd == GetDesktopWindow())
|
|
|
|
{
|
|
|
|
hwnd = GetForegroundWindow();
|
|
|
|
if (!hwnd) hwnd = last_focus;
|
|
|
|
if (!hwnd) hwnd = GetDesktopWindow();
|
|
|
|
set_focus( event->display, hwnd, event_time );
|
|
|
|
return;
|
|
|
|
}
|
2007-06-22 00:38:00 +02:00
|
|
|
/* try to find some other window to give the focus to */
|
|
|
|
hwnd = GetFocus();
|
|
|
|
if (hwnd) hwnd = GetAncestor( hwnd, GA_ROOT );
|
|
|
|
if (!hwnd) hwnd = GetActiveWindow();
|
|
|
|
if (!hwnd) hwnd = last_focus;
|
2008-06-26 16:20:02 +02:00
|
|
|
if (hwnd && can_activate_window(hwnd)) set_focus( event->display, hwnd, event_time );
|
2003-11-20 05:24:18 +01:00
|
|
|
}
|
|
|
|
else if (protocol == x11drv_atom(_NET_WM_PING))
|
|
|
|
{
|
2003-05-04 04:27:20 +02:00
|
|
|
XClientMessageEvent xev;
|
|
|
|
xev = *event;
|
|
|
|
|
|
|
|
TRACE("NET_WM Ping\n");
|
|
|
|
xev.window = DefaultRootWindow(xev.display);
|
|
|
|
XSendEvent(xev.display, xev.window, False, SubstructureRedirectMask | SubstructureNotifyMask, (XEvent*)&xev);
|
2002-09-19 01:09:50 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static const char * const focus_details[] =
|
|
|
|
{
|
|
|
|
"NotifyAncestor",
|
|
|
|
"NotifyVirtual",
|
|
|
|
"NotifyInferior",
|
|
|
|
"NotifyNonlinear",
|
|
|
|
"NotifyNonlinearVirtual",
|
|
|
|
"NotifyPointer",
|
|
|
|
"NotifyPointerRoot",
|
|
|
|
"NotifyDetailNone"
|
|
|
|
};
|
|
|
|
|
2019-06-27 16:30:12 +02:00
|
|
|
static const char * const focus_modes[] =
|
|
|
|
{
|
|
|
|
"NotifyNormal",
|
|
|
|
"NotifyGrab",
|
|
|
|
"NotifyUngrab",
|
|
|
|
"NotifyWhileGrabbed"
|
|
|
|
};
|
|
|
|
|
2002-09-19 01:09:50 +02:00
|
|
|
/**********************************************************************
|
2008-04-17 16:07:06 +02:00
|
|
|
* X11DRV_FocusIn
|
2002-09-19 01:09:50 +02:00
|
|
|
*/
|
2016-08-23 15:13:26 +02:00
|
|
|
static BOOL X11DRV_FocusIn( HWND hwnd, XEvent *xev )
|
2002-09-19 01:09:50 +02:00
|
|
|
{
|
2005-02-26 18:49:38 +01:00
|
|
|
XFocusChangeEvent *event = &xev->xfocus;
|
2003-01-23 02:29:58 +01:00
|
|
|
XIC xic;
|
|
|
|
|
2016-08-23 15:13:26 +02:00
|
|
|
if (!hwnd) return FALSE;
|
2002-09-19 01:09:50 +02:00
|
|
|
|
2019-06-27 16:30:12 +02:00
|
|
|
TRACE( "win %p xwin %lx detail=%s mode=%s\n", hwnd, event->window, focus_details[event->detail], focus_modes[event->mode] );
|
2002-09-19 01:09:50 +02:00
|
|
|
|
2016-08-23 15:13:26 +02:00
|
|
|
if (event->detail == NotifyPointer) return FALSE;
|
|
|
|
if (hwnd == GetDesktopWindow()) return FALSE;
|
2002-09-19 01:09:50 +02:00
|
|
|
|
2019-08-30 12:17:58 +02:00
|
|
|
switch (event->mode)
|
|
|
|
{
|
|
|
|
case NotifyGrab:
|
2019-09-23 09:58:17 +02:00
|
|
|
/* these are received when moving undecorated managed windows on mutter */
|
|
|
|
keyboard_grabbed = TRUE;
|
|
|
|
return FALSE;
|
2019-08-30 12:17:58 +02:00
|
|
|
case NotifyWhileGrabbed:
|
2019-08-30 12:17:59 +02:00
|
|
|
keyboard_grabbed = TRUE;
|
2019-08-30 12:17:58 +02:00
|
|
|
break;
|
|
|
|
case NotifyNormal:
|
2019-08-30 12:17:59 +02:00
|
|
|
keyboard_grabbed = FALSE;
|
2019-08-30 12:17:58 +02:00
|
|
|
break;
|
|
|
|
case NotifyUngrab:
|
2019-08-30 12:17:59 +02:00
|
|
|
keyboard_grabbed = FALSE;
|
winex11.drv: Retry last ClipCursor when grab is released.
As we ignore these NotifyGrab / NotifyUngrab w.r.t focus decisions,
some applications are unaware of mouse grabs being lost and sometimes
cursor clipping is lost. We have to keep the last clip rectangle and
restore it when grab is released.
This has been squashed with the foreground window check from
Zhiyi Zhang <zzhang@codeweavers.com> to fix an issue that happens when
switching from a fullscreen window - because there's some additional
focus events involved - but in general, if the window that is getting
focus cannot be activated:
When FocusIn/NotifyWhileGrabbed is received, SetForegroundWindow is not
called if the window cannot be activated. When the FocusIn/NotifyUngrab
event arrives for the same window, we have to check the foreground
window before restoring cursor clipping rectangle.
For reference, the event sequence when pressing Alt-Tab - for WMs that
grab the keyboard - is the following:
1. FocusOut/NotifyGrab, when WM grabs the keyboard.
2. FocusOut/NotifyWhileGrabbed, while WM switches windows, this calls
SetForegroundWindow(GetDesktopWindow()).
The event sequence for normal windows ends here, but for fullscreen
windows, there may be these additional events:
3. FocusIn/NotifyWhileGrabbed, which may not change Wine foreground
window if it cannot be activated.
4. FocusIn/NotifyUnGrab, when WM releases the keyboard while switching
windows, this is ignored but it should not retry to grab the cursor,
because window is not foreground.
5. FocusOut/NotifyNormal, when WM finishes switching the windows.
Signed-off-by: Rémi Bernon <rbernon@codeweavers.com>
Signed-off-by: Huw Davies <huw@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2019-08-30 12:18:00 +02:00
|
|
|
retry_grab_clipping_window();
|
2019-08-30 12:17:58 +02:00
|
|
|
return TRUE; /* ignore wm specific NotifyUngrab / NotifyGrab events w.r.t focus */
|
|
|
|
}
|
|
|
|
|
2012-08-14 13:38:03 +02:00
|
|
|
if ((xic = X11DRV_get_ic( hwnd ))) XSetICFocus( xic );
|
2011-05-11 12:30:03 +02:00
|
|
|
if (use_take_focus)
|
|
|
|
{
|
2011-05-12 16:24:58 +02:00
|
|
|
if (hwnd == GetForegroundWindow()) clip_fullscreen_window( hwnd, FALSE );
|
2016-08-23 15:13:26 +02:00
|
|
|
return TRUE;
|
2011-05-11 12:30:03 +02:00
|
|
|
}
|
2003-01-23 02:29:58 +01:00
|
|
|
|
2002-10-12 01:41:06 +02:00
|
|
|
if (!can_activate_window(hwnd))
|
2002-09-19 01:09:50 +02:00
|
|
|
{
|
|
|
|
HWND hwnd = GetFocus();
|
2003-01-21 21:16:20 +01:00
|
|
|
if (hwnd) hwnd = GetAncestor( hwnd, GA_ROOT );
|
2002-09-19 01:09:50 +02:00
|
|
|
if (!hwnd) hwnd = GetActiveWindow();
|
|
|
|
if (!hwnd) hwnd = x11drv_thread_data()->last_focus;
|
2008-06-26 16:20:02 +02:00
|
|
|
if (hwnd && can_activate_window(hwnd)) set_focus( event->display, hwnd, CurrentTime );
|
2001-06-04 23:55:17 +02:00
|
|
|
}
|
2002-10-12 01:41:06 +02:00
|
|
|
else SetForegroundWindow( hwnd );
|
2016-08-23 15:13:26 +02:00
|
|
|
return TRUE;
|
1998-12-07 10:13:40 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/**********************************************************************
|
2013-10-26 18:34:32 +02:00
|
|
|
* focus_out
|
1998-12-07 10:13:40 +01:00
|
|
|
*/
|
2018-08-22 20:49:00 +02:00
|
|
|
static void focus_out( Display *display , HWND hwnd )
|
2013-10-26 18:34:32 +02:00
|
|
|
{
|
2002-09-19 01:09:50 +02:00
|
|
|
HWND hwnd_tmp;
|
|
|
|
Window focus_win;
|
|
|
|
int revert;
|
2003-01-23 02:29:58 +01:00
|
|
|
XIC xic;
|
2002-09-19 01:09:50 +02:00
|
|
|
|
2004-01-21 03:22:26 +01:00
|
|
|
if (ximInComposeMode) return;
|
|
|
|
|
2002-10-12 01:41:06 +02:00
|
|
|
x11drv_thread_data()->last_focus = hwnd;
|
2012-08-14 13:38:03 +02:00
|
|
|
if ((xic = X11DRV_get_ic( hwnd ))) XUnsetICFocus( xic );
|
|
|
|
|
2019-11-05 14:04:07 +01:00
|
|
|
if (is_virtual_desktop())
|
2011-05-11 12:07:37 +02:00
|
|
|
{
|
|
|
|
if (hwnd == GetDesktopWindow()) reset_clipping_window();
|
|
|
|
return;
|
|
|
|
}
|
2002-09-19 01:09:50 +02:00
|
|
|
if (hwnd != GetForegroundWindow()) return;
|
2006-05-10 21:32:56 +02:00
|
|
|
SendMessageW( hwnd, WM_CANCELMODE, 0, 0 );
|
2002-09-19 01:09:50 +02:00
|
|
|
|
|
|
|
/* don't reset the foreground window, if the window which is
|
|
|
|
getting the focus is a Wine window */
|
|
|
|
|
2013-10-26 18:34:32 +02:00
|
|
|
XGetInputFocus( display, &focus_win, &revert );
|
2002-09-24 20:36:51 +02:00
|
|
|
if (focus_win)
|
|
|
|
{
|
2013-10-26 18:34:32 +02:00
|
|
|
if (XFindContext( display, focus_win, winContext, (char **)&hwnd_tmp ) != 0)
|
2002-09-24 20:36:51 +02:00
|
|
|
focus_win = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!focus_win)
|
2002-09-19 01:09:50 +02:00
|
|
|
{
|
|
|
|
/* Abey : 6-Oct-99. Check again if the focus out window is the
|
|
|
|
Foreground window, because in most cases the messages sent
|
|
|
|
above must have already changed the foreground window, in which
|
|
|
|
case we don't have to change the foreground window to 0 */
|
|
|
|
if (hwnd == GetForegroundWindow())
|
|
|
|
{
|
2007-07-20 15:15:42 +02:00
|
|
|
TRACE( "lost focus, setting fg to desktop\n" );
|
|
|
|
SetForegroundWindow( GetDesktopWindow() );
|
2002-09-19 01:09:50 +02:00
|
|
|
}
|
|
|
|
}
|
2013-10-26 18:34:32 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**********************************************************************
|
|
|
|
* X11DRV_FocusOut
|
|
|
|
*
|
|
|
|
* Note: only top-level windows get FocusOut events.
|
|
|
|
*/
|
2016-08-23 15:13:26 +02:00
|
|
|
static BOOL X11DRV_FocusOut( HWND hwnd, XEvent *xev )
|
2013-10-26 18:34:32 +02:00
|
|
|
{
|
|
|
|
XFocusChangeEvent *event = &xev->xfocus;
|
|
|
|
|
2019-06-27 16:30:12 +02:00
|
|
|
TRACE( "win %p xwin %lx detail=%s mode=%s\n", hwnd, event->window, focus_details[event->detail], focus_modes[event->mode] );
|
2013-10-26 18:34:32 +02:00
|
|
|
|
|
|
|
if (event->detail == NotifyPointer)
|
|
|
|
{
|
|
|
|
if (!hwnd && event->window == x11drv_thread_data()->clip_window) reset_clipping_window();
|
2016-08-23 15:13:26 +02:00
|
|
|
return TRUE;
|
2013-10-26 18:34:32 +02:00
|
|
|
}
|
2016-08-23 15:13:26 +02:00
|
|
|
if (!hwnd) return FALSE;
|
2019-08-30 12:17:58 +02:00
|
|
|
|
|
|
|
switch (event->mode)
|
|
|
|
{
|
|
|
|
case NotifyUngrab:
|
2019-09-23 09:58:17 +02:00
|
|
|
/* these are received when moving undecorated managed windows on mutter */
|
|
|
|
keyboard_grabbed = FALSE;
|
|
|
|
return FALSE;
|
2019-08-30 12:17:58 +02:00
|
|
|
case NotifyNormal:
|
2019-08-30 12:17:59 +02:00
|
|
|
keyboard_grabbed = FALSE;
|
2019-08-30 12:17:58 +02:00
|
|
|
break;
|
|
|
|
case NotifyWhileGrabbed:
|
2019-08-30 12:17:59 +02:00
|
|
|
keyboard_grabbed = TRUE;
|
2019-08-30 12:17:58 +02:00
|
|
|
break;
|
|
|
|
case NotifyGrab:
|
2019-08-30 12:17:59 +02:00
|
|
|
keyboard_grabbed = TRUE;
|
winex11.drv: Retry last ClipCursor when grab is released.
As we ignore these NotifyGrab / NotifyUngrab w.r.t focus decisions,
some applications are unaware of mouse grabs being lost and sometimes
cursor clipping is lost. We have to keep the last clip rectangle and
restore it when grab is released.
This has been squashed with the foreground window check from
Zhiyi Zhang <zzhang@codeweavers.com> to fix an issue that happens when
switching from a fullscreen window - because there's some additional
focus events involved - but in general, if the window that is getting
focus cannot be activated:
When FocusIn/NotifyWhileGrabbed is received, SetForegroundWindow is not
called if the window cannot be activated. When the FocusIn/NotifyUngrab
event arrives for the same window, we have to check the foreground
window before restoring cursor clipping rectangle.
For reference, the event sequence when pressing Alt-Tab - for WMs that
grab the keyboard - is the following:
1. FocusOut/NotifyGrab, when WM grabs the keyboard.
2. FocusOut/NotifyWhileGrabbed, while WM switches windows, this calls
SetForegroundWindow(GetDesktopWindow()).
The event sequence for normal windows ends here, but for fullscreen
windows, there may be these additional events:
3. FocusIn/NotifyWhileGrabbed, which may not change Wine foreground
window if it cannot be activated.
4. FocusIn/NotifyUnGrab, when WM releases the keyboard while switching
windows, this is ignored but it should not retry to grab the cursor,
because window is not foreground.
5. FocusOut/NotifyNormal, when WM finishes switching the windows.
Signed-off-by: Rémi Bernon <rbernon@codeweavers.com>
Signed-off-by: Huw Davies <huw@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2019-08-30 12:18:00 +02:00
|
|
|
|
|
|
|
/* This will do nothing due to keyboard_grabbed == TRUE, but it
|
|
|
|
* will save the current clipping rect so we can restore it on
|
|
|
|
* FocusIn with NotifyUngrab mode.
|
|
|
|
*/
|
|
|
|
retry_grab_clipping_window();
|
|
|
|
|
2019-08-30 12:17:58 +02:00
|
|
|
return TRUE; /* ignore wm specific NotifyUngrab / NotifyGrab events w.r.t focus */
|
|
|
|
}
|
|
|
|
|
2013-10-26 18:34:32 +02:00
|
|
|
focus_out( event->display, hwnd );
|
2016-08-23 15:13:26 +02:00
|
|
|
return TRUE;
|
1998-12-07 10:13:40 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-04-17 16:07:06 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* X11DRV_Expose
|
|
|
|
*/
|
2016-08-23 15:13:26 +02:00
|
|
|
static BOOL X11DRV_Expose( HWND hwnd, XEvent *xev )
|
2008-04-17 16:07:06 +02:00
|
|
|
{
|
|
|
|
XExposeEvent *event = &xev->xexpose;
|
2018-08-27 14:24:15 +02:00
|
|
|
RECT rect, abs_rect;
|
2013-10-14 14:20:08 +02:00
|
|
|
POINT pos;
|
2008-04-17 16:07:06 +02:00
|
|
|
struct x11drv_win_data *data;
|
2012-12-03 15:27:04 +01:00
|
|
|
HRGN surface_region = 0;
|
|
|
|
UINT flags = RDW_INVALIDATE | RDW_ERASE | RDW_FRAME | RDW_ALLCHILDREN;
|
2008-04-17 16:07:06 +02:00
|
|
|
|
|
|
|
TRACE( "win %p (%lx) %d,%d %dx%d\n",
|
|
|
|
hwnd, event->window, event->x, event->y, event->width, event->height );
|
|
|
|
|
2013-10-14 14:20:08 +02:00
|
|
|
if (event->window != root_window)
|
|
|
|
{
|
|
|
|
pos.x = event->x;
|
|
|
|
pos.y = event->y;
|
|
|
|
}
|
|
|
|
else pos = root_to_virtual_screen( event->x, event->y );
|
|
|
|
|
2016-08-23 15:13:26 +02:00
|
|
|
if (!(data = get_win_data( hwnd ))) return FALSE;
|
2008-04-17 16:07:06 +02:00
|
|
|
|
2013-10-14 14:20:08 +02:00
|
|
|
rect.left = pos.x;
|
|
|
|
rect.top = pos.y;
|
|
|
|
rect.right = pos.x + event->width;
|
|
|
|
rect.bottom = pos.y + event->height;
|
2012-04-30 15:09:03 +02:00
|
|
|
|
2013-01-23 19:09:29 +01:00
|
|
|
if (event->window != data->client_window)
|
2008-04-17 16:07:06 +02:00
|
|
|
{
|
2013-01-23 19:09:29 +01:00
|
|
|
if (data->surface)
|
|
|
|
{
|
|
|
|
surface_region = expose_surface( data->surface, &rect );
|
|
|
|
if (!surface_region) flags = 0;
|
|
|
|
else OffsetRgn( surface_region, data->whole_rect.left - data->client_rect.left,
|
|
|
|
data->whole_rect.top - data->client_rect.top );
|
2008-04-17 16:07:06 +02:00
|
|
|
|
2013-01-23 19:09:29 +01:00
|
|
|
if (data->vis.visualid != default_visual.visualid)
|
|
|
|
data->surface->funcs->flush( data->surface );
|
|
|
|
}
|
2012-04-30 15:09:03 +02:00
|
|
|
OffsetRect( &rect, data->whole_rect.left - data->client_rect.left,
|
|
|
|
data->whole_rect.top - data->client_rect.top );
|
2013-01-23 19:09:29 +01:00
|
|
|
}
|
2012-04-30 15:09:03 +02:00
|
|
|
|
2013-01-23 19:09:29 +01:00
|
|
|
if (event->window != root_window)
|
|
|
|
{
|
2010-10-07 14:26:21 +02:00
|
|
|
if (GetWindowLongW( data->hwnd, GWL_EXSTYLE ) & WS_EX_LAYOUTRTL)
|
|
|
|
mirror_rect( &data->client_rect, &rect );
|
2018-08-27 14:24:15 +02:00
|
|
|
abs_rect = rect;
|
|
|
|
MapWindowPoints( hwnd, 0, (POINT *)&abs_rect, 2 );
|
2010-10-07 14:26:21 +02:00
|
|
|
|
2008-04-17 16:07:06 +02:00
|
|
|
SERVER_START_REQ( update_window_zorder )
|
|
|
|
{
|
2008-12-08 16:58:20 +01:00
|
|
|
req->window = wine_server_user_handle( hwnd );
|
2018-08-27 14:24:15 +02:00
|
|
|
req->rect.left = abs_rect.left;
|
|
|
|
req->rect.top = abs_rect.top;
|
|
|
|
req->rect.right = abs_rect.right;
|
|
|
|
req->rect.bottom = abs_rect.bottom;
|
2008-04-17 16:07:06 +02:00
|
|
|
wine_server_call( req );
|
|
|
|
}
|
|
|
|
SERVER_END_REQ;
|
|
|
|
}
|
2013-10-14 14:20:08 +02:00
|
|
|
else flags &= ~RDW_ALLCHILDREN;
|
|
|
|
|
2012-09-19 13:12:42 +02:00
|
|
|
release_win_data( data );
|
|
|
|
|
2012-12-03 15:27:04 +01:00
|
|
|
if (flags) RedrawWindow( hwnd, &rect, surface_region, flags );
|
|
|
|
if (surface_region) DeleteObject( surface_region );
|
2016-08-23 15:13:26 +02:00
|
|
|
return TRUE;
|
2008-04-17 16:07:06 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-04-17 16:13:12 +02:00
|
|
|
/**********************************************************************
|
|
|
|
* X11DRV_MapNotify
|
|
|
|
*/
|
2016-08-23 15:13:26 +02:00
|
|
|
static BOOL X11DRV_MapNotify( HWND hwnd, XEvent *event )
|
2008-04-17 16:13:12 +02:00
|
|
|
{
|
|
|
|
struct x11drv_win_data *data;
|
|
|
|
|
2019-08-30 12:18:01 +02:00
|
|
|
if (event->xany.window == x11drv_thread_data()->clip_window) return TRUE;
|
|
|
|
|
2016-08-23 15:13:26 +02:00
|
|
|
if (!(data = get_win_data( hwnd ))) return FALSE;
|
2008-04-17 16:13:12 +02:00
|
|
|
|
2012-09-18 11:24:55 +02:00
|
|
|
if (!data->managed && !data->embedded && data->mapped)
|
2008-04-17 16:13:12 +02:00
|
|
|
{
|
|
|
|
HWND hwndFocus = GetFocus();
|
2012-09-18 11:20:07 +02:00
|
|
|
if (hwndFocus && IsChild( hwnd, hwndFocus ))
|
2013-11-13 16:59:38 +01:00
|
|
|
set_input_focus( data );
|
2008-04-17 16:13:12 +02:00
|
|
|
}
|
2012-09-18 11:24:55 +02:00
|
|
|
release_win_data( data );
|
2016-08-23 15:13:26 +02:00
|
|
|
return TRUE;
|
2008-04-17 16:13:12 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-04-04 15:20:14 +02:00
|
|
|
/**********************************************************************
|
|
|
|
* X11DRV_UnmapNotify
|
|
|
|
*/
|
2016-08-23 15:13:26 +02:00
|
|
|
static BOOL X11DRV_UnmapNotify( HWND hwnd, XEvent *event )
|
2011-04-04 15:20:14 +02:00
|
|
|
{
|
2016-08-23 15:13:26 +02:00
|
|
|
return TRUE;
|
2011-04-04 15:20:14 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-10-26 18:34:32 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* reparent_notify
|
|
|
|
*/
|
|
|
|
static void reparent_notify( Display *display, HWND hwnd, Window xparent, int x, int y )
|
|
|
|
{
|
|
|
|
HWND parent, old_parent;
|
|
|
|
DWORD style;
|
|
|
|
|
|
|
|
style = GetWindowLongW( hwnd, GWL_STYLE );
|
|
|
|
if (xparent == root_window)
|
|
|
|
{
|
|
|
|
parent = GetDesktopWindow();
|
|
|
|
style = (style & ~WS_CHILD) | WS_POPUP;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (!(parent = create_foreign_window( display, xparent ))) return;
|
|
|
|
style = (style & ~WS_POPUP) | WS_CHILD;
|
|
|
|
}
|
|
|
|
|
|
|
|
ShowWindow( hwnd, SW_HIDE );
|
|
|
|
old_parent = SetParent( hwnd, parent );
|
|
|
|
SetWindowLongW( hwnd, GWL_STYLE, style );
|
|
|
|
SetWindowPos( hwnd, HWND_TOP, x, y, 0, 0,
|
|
|
|
SWP_NOACTIVATE | SWP_NOSIZE | SWP_NOCOPYBITS |
|
|
|
|
((style & WS_VISIBLE) ? SWP_SHOWWINDOW : 0) );
|
|
|
|
|
|
|
|
/* make old parent destroy itself if it no longer has children */
|
|
|
|
if (old_parent != GetDesktopWindow()) PostMessageW( old_parent, WM_CLOSE, 0, 0 );
|
|
|
|
}
|
|
|
|
|
2008-07-31 17:11:28 +02:00
|
|
|
|
2010-11-01 19:45:12 +01:00
|
|
|
/***********************************************************************
|
|
|
|
* X11DRV_ReparentNotify
|
|
|
|
*/
|
2016-08-23 15:13:26 +02:00
|
|
|
static BOOL X11DRV_ReparentNotify( HWND hwnd, XEvent *xev )
|
2010-11-01 19:45:12 +01:00
|
|
|
{
|
|
|
|
XReparentEvent *event = &xev->xreparent;
|
|
|
|
struct x11drv_win_data *data;
|
|
|
|
|
2016-08-23 15:13:26 +02:00
|
|
|
if (!(data = get_win_data( hwnd ))) return FALSE;
|
2012-09-19 13:13:40 +02:00
|
|
|
|
|
|
|
if (!data->embedded)
|
|
|
|
{
|
|
|
|
release_win_data( data );
|
2016-08-23 15:13:26 +02:00
|
|
|
return FALSE;
|
2012-09-19 13:13:40 +02:00
|
|
|
}
|
2010-11-08 15:28:09 +01:00
|
|
|
|
|
|
|
if (data->whole_window)
|
|
|
|
{
|
|
|
|
if (event->parent == root_window)
|
|
|
|
{
|
|
|
|
TRACE( "%p/%lx reparented to root\n", hwnd, data->whole_window );
|
|
|
|
data->embedder = 0;
|
2012-09-19 13:13:40 +02:00
|
|
|
release_win_data( data );
|
2010-11-08 15:28:09 +01:00
|
|
|
SendMessageW( hwnd, WM_CLOSE, 0, 0 );
|
2016-08-23 15:13:26 +02:00
|
|
|
return TRUE;
|
2010-11-08 15:28:09 +01:00
|
|
|
}
|
|
|
|
data->embedder = event->parent;
|
|
|
|
}
|
|
|
|
|
|
|
|
TRACE( "%p/%lx reparented to %lx\n", hwnd, data->whole_window, event->parent );
|
2012-09-19 13:13:40 +02:00
|
|
|
release_win_data( data );
|
2010-11-08 15:28:09 +01:00
|
|
|
|
2013-10-26 18:34:32 +02:00
|
|
|
reparent_notify( event->display, hwnd, event->parent, event->x, event->y );
|
2016-08-23 15:13:26 +02:00
|
|
|
return TRUE;
|
2010-11-01 19:45:12 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-04-22 16:56:31 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* X11DRV_ConfigureNotify
|
|
|
|
*/
|
2016-08-23 15:13:26 +02:00
|
|
|
static BOOL X11DRV_ConfigureNotify( HWND hwnd, XEvent *xev )
|
2008-04-22 16:56:31 +02:00
|
|
|
{
|
|
|
|
XConfigureEvent *event = &xev->xconfigure;
|
|
|
|
struct x11drv_win_data *data;
|
|
|
|
RECT rect;
|
2013-10-14 14:20:08 +02:00
|
|
|
POINT pos;
|
2008-04-22 16:56:31 +02:00
|
|
|
UINT flags;
|
2010-11-08 15:20:51 +01:00
|
|
|
HWND parent;
|
|
|
|
BOOL root_coords;
|
2008-04-22 16:56:31 +02:00
|
|
|
int cx, cy, x = event->x, y = event->y;
|
2012-09-28 01:06:52 +02:00
|
|
|
DWORD style;
|
2008-04-22 16:56:31 +02:00
|
|
|
|
2016-08-23 15:13:26 +02:00
|
|
|
if (!hwnd) return FALSE;
|
|
|
|
if (!(data = get_win_data( hwnd ))) return FALSE;
|
2012-09-19 13:13:23 +02:00
|
|
|
if (!data->mapped || data->iconic) goto done;
|
|
|
|
if (data->whole_window && !data->managed) goto done;
|
2010-11-08 15:28:09 +01:00
|
|
|
/* ignore synthetic events on foreign windows */
|
2012-09-19 13:13:23 +02:00
|
|
|
if (event->send_event && !data->whole_window) goto done;
|
2010-01-04 17:56:32 +01:00
|
|
|
if (data->configure_serial && (long)(data->configure_serial - event->serial) > 0)
|
|
|
|
{
|
|
|
|
TRACE( "win %p/%lx event %d,%d,%dx%d ignoring old serial %lu/%lu\n",
|
|
|
|
hwnd, data->whole_window, event->x, event->y, event->width, event->height,
|
|
|
|
event->serial, data->configure_serial );
|
2012-09-19 13:13:23 +02:00
|
|
|
goto done;
|
2010-01-04 17:56:32 +01:00
|
|
|
}
|
2008-04-22 16:56:31 +02:00
|
|
|
|
|
|
|
/* Get geometry */
|
|
|
|
|
2010-11-08 15:20:51 +01:00
|
|
|
parent = GetAncestor( hwnd, GA_PARENT );
|
|
|
|
root_coords = event->send_event; /* synthetic events are always in root coords */
|
|
|
|
|
|
|
|
if (!root_coords && parent == GetDesktopWindow()) /* normal event, map coordinates to the root */
|
2008-04-22 16:56:31 +02:00
|
|
|
{
|
|
|
|
Window child;
|
2010-11-08 15:20:51 +01:00
|
|
|
XTranslateCoordinates( event->display, event->window, root_window,
|
2008-04-22 16:56:31 +02:00
|
|
|
0, 0, &x, &y, &child );
|
2010-11-08 15:20:51 +01:00
|
|
|
root_coords = TRUE;
|
2008-04-22 16:56:31 +02:00
|
|
|
}
|
2013-10-14 14:20:08 +02:00
|
|
|
|
|
|
|
if (!root_coords)
|
|
|
|
{
|
|
|
|
pos.x = x;
|
|
|
|
pos.y = y;
|
|
|
|
}
|
|
|
|
else pos = root_to_virtual_screen( x, y );
|
|
|
|
|
2018-08-23 10:50:47 +02:00
|
|
|
X11DRV_X_to_window_rect( data, &rect, pos.x, pos.y, event->width, event->height );
|
|
|
|
if (root_coords) MapWindowPoints( 0, parent, (POINT *)&rect, 2 );
|
|
|
|
|
2008-07-31 17:11:28 +02:00
|
|
|
TRACE( "win %p/%lx new X rect %d,%d,%dx%d (event %d,%d,%dx%d)\n",
|
|
|
|
hwnd, data->whole_window, rect.left, rect.top, rect.right-rect.left, rect.bottom-rect.top,
|
2008-04-22 16:56:31 +02:00
|
|
|
event->x, event->y, event->width, event->height );
|
|
|
|
|
|
|
|
/* Compare what has changed */
|
|
|
|
|
2008-09-17 21:14:05 +02:00
|
|
|
x = rect.left;
|
|
|
|
y = rect.top;
|
|
|
|
cx = rect.right - rect.left;
|
|
|
|
cy = rect.bottom - rect.top;
|
|
|
|
flags = SWP_NOACTIVATE | SWP_NOZORDER;
|
|
|
|
|
2010-11-08 15:28:09 +01:00
|
|
|
if (!data->whole_window) flags |= SWP_NOCOPYBITS; /* we can't copy bits of foreign windows */
|
|
|
|
|
2008-09-17 21:14:05 +02:00
|
|
|
if (data->window_rect.left == x && data->window_rect.top == y) flags |= SWP_NOMOVE;
|
2008-04-22 16:56:31 +02:00
|
|
|
else
|
|
|
|
TRACE( "%p moving from (%d,%d) to (%d,%d)\n",
|
2008-09-17 21:14:05 +02:00
|
|
|
hwnd, data->window_rect.left, data->window_rect.top, x, y );
|
2008-04-22 16:56:31 +02:00
|
|
|
|
2008-09-17 21:14:05 +02:00
|
|
|
if ((data->window_rect.right - data->window_rect.left == cx &&
|
|
|
|
data->window_rect.bottom - data->window_rect.top == cy) ||
|
2015-01-08 13:44:42 +01:00
|
|
|
IsRectEmpty( &data->window_rect ))
|
2008-04-22 16:56:31 +02:00
|
|
|
flags |= SWP_NOSIZE;
|
|
|
|
else
|
|
|
|
TRACE( "%p resizing from (%dx%d) to (%dx%d)\n",
|
2008-09-17 21:14:05 +02:00
|
|
|
hwnd, data->window_rect.right - data->window_rect.left,
|
|
|
|
data->window_rect.bottom - data->window_rect.top, cx, cy );
|
2008-04-22 16:56:31 +02:00
|
|
|
|
2012-09-28 01:06:52 +02:00
|
|
|
style = GetWindowLongW( data->hwnd, GWL_STYLE );
|
2012-10-04 13:53:29 +02:00
|
|
|
if ((style & WS_CAPTION) == WS_CAPTION)
|
2011-04-05 11:31:27 +02:00
|
|
|
{
|
2015-07-01 20:43:48 +02:00
|
|
|
read_net_wm_states( event->display, data );
|
|
|
|
if ((data->net_wm_state & (1 << NET_WM_STATE_MAXIMIZED)))
|
2011-04-05 11:31:27 +02:00
|
|
|
{
|
2012-10-04 13:53:29 +02:00
|
|
|
if (!(style & WS_MAXIMIZE))
|
|
|
|
{
|
|
|
|
TRACE( "win %p/%lx is maximized\n", data->hwnd, data->whole_window );
|
|
|
|
release_win_data( data );
|
|
|
|
SendMessageW( data->hwnd, WM_SYSCOMMAND, SC_MAXIMIZE, 0 );
|
2016-08-23 15:13:26 +02:00
|
|
|
return TRUE;
|
2012-10-04 13:53:29 +02:00
|
|
|
}
|
2011-04-05 11:31:27 +02:00
|
|
|
}
|
2012-10-04 13:53:29 +02:00
|
|
|
else if (style & WS_MAXIMIZE)
|
2011-04-05 11:31:27 +02:00
|
|
|
{
|
|
|
|
TRACE( "window %p/%lx is no longer maximized\n", data->hwnd, data->whole_window );
|
2012-09-19 13:13:23 +02:00
|
|
|
release_win_data( data );
|
2011-04-05 11:31:27 +02:00
|
|
|
SendMessageW( data->hwnd, WM_SYSCOMMAND, SC_RESTORE, 0 );
|
2016-08-23 15:13:26 +02:00
|
|
|
return TRUE;
|
2011-04-05 11:31:27 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-09-06 14:09:06 +02:00
|
|
|
if ((flags & (SWP_NOSIZE | SWP_NOMOVE)) != (SWP_NOSIZE | SWP_NOMOVE))
|
2012-09-19 13:13:23 +02:00
|
|
|
{
|
|
|
|
release_win_data( data );
|
2012-09-06 14:09:06 +02:00
|
|
|
SetWindowPos( hwnd, 0, x, y, cx, cy, flags );
|
2016-08-23 15:13:26 +02:00
|
|
|
return TRUE;
|
2012-09-19 13:13:23 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
done:
|
|
|
|
release_win_data( data );
|
2016-08-23 15:13:26 +02:00
|
|
|
return FALSE;
|
2008-04-22 16:56:31 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-11-08 15:22:09 +01:00
|
|
|
/**********************************************************************
|
|
|
|
* X11DRV_GravityNotify
|
|
|
|
*/
|
2016-08-23 15:13:26 +02:00
|
|
|
static BOOL X11DRV_GravityNotify( HWND hwnd, XEvent *xev )
|
2010-11-08 15:22:09 +01:00
|
|
|
{
|
|
|
|
XGravityEvent *event = &xev->xgravity;
|
2012-09-19 13:13:51 +02:00
|
|
|
struct x11drv_win_data *data = get_win_data( hwnd );
|
2018-08-23 10:50:47 +02:00
|
|
|
RECT window_rect;
|
|
|
|
int x, y;
|
2010-11-08 15:22:09 +01:00
|
|
|
|
2016-08-23 15:13:26 +02:00
|
|
|
if (!data) return FALSE;
|
2012-09-19 13:13:51 +02:00
|
|
|
|
|
|
|
if (data->whole_window) /* only handle this for foreign windows */
|
|
|
|
{
|
|
|
|
release_win_data( data );
|
2016-08-23 15:13:26 +02:00
|
|
|
return FALSE;
|
2012-09-19 13:13:51 +02:00
|
|
|
}
|
2010-11-08 15:22:09 +01:00
|
|
|
|
2018-08-23 10:50:47 +02:00
|
|
|
x = event->x + data->window_rect.left - data->whole_rect.left;
|
|
|
|
y = event->y + data->window_rect.top - data->whole_rect.top;
|
2010-11-08 15:22:09 +01:00
|
|
|
|
2018-08-23 10:50:47 +02:00
|
|
|
TRACE( "win %p/%lx new X pos %d,%d (event %d,%d)\n",
|
|
|
|
hwnd, data->whole_window, x, y, event->x, event->y );
|
2010-11-08 15:22:09 +01:00
|
|
|
|
2012-09-19 13:13:51 +02:00
|
|
|
window_rect = data->window_rect;
|
|
|
|
release_win_data( data );
|
2010-11-08 15:22:09 +01:00
|
|
|
|
2018-08-23 10:50:47 +02:00
|
|
|
if (window_rect.left != x || window_rect.top != y)
|
|
|
|
SetWindowPos( hwnd, 0, x, y, 0, 0, SWP_NOSIZE | SWP_NOZORDER | SWP_NOACTIVATE | SWP_NOCOPYBITS );
|
|
|
|
|
2016-08-23 15:13:26 +02:00
|
|
|
return TRUE;
|
2010-11-08 15:22:09 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-02-27 19:11:43 +01:00
|
|
|
/***********************************************************************
|
|
|
|
* get_window_wm_state
|
|
|
|
*/
|
2012-09-13 20:08:01 +02:00
|
|
|
static int get_window_wm_state( Display *display, Window window )
|
2008-02-27 19:11:43 +01:00
|
|
|
{
|
|
|
|
struct
|
|
|
|
{
|
|
|
|
CARD32 state;
|
|
|
|
XID icon;
|
|
|
|
} *state;
|
|
|
|
Atom type;
|
|
|
|
int format, ret = -1;
|
|
|
|
unsigned long count, remaining;
|
|
|
|
|
2012-09-13 20:08:01 +02:00
|
|
|
if (!XGetWindowProperty( display, window, x11drv_atom(WM_STATE), 0,
|
2008-02-27 19:11:43 +01:00
|
|
|
sizeof(*state)/sizeof(CARD32), False, x11drv_atom(WM_STATE),
|
|
|
|
&type, &format, &count, &remaining, (unsigned char **)&state ))
|
|
|
|
{
|
2008-04-07 11:41:54 +02:00
|
|
|
if (type == x11drv_atom(WM_STATE) && get_property_size( format, count ) >= sizeof(*state))
|
2008-02-27 19:11:43 +01:00
|
|
|
ret = state->state;
|
|
|
|
XFree( state );
|
|
|
|
}
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
1999-09-20 17:42:47 +02:00
|
|
|
/***********************************************************************
|
2008-04-02 15:55:25 +02:00
|
|
|
* handle_wm_state_notify
|
|
|
|
*
|
|
|
|
* Handle a PropertyNotify for WM_STATE.
|
1999-09-20 17:42:47 +02:00
|
|
|
*/
|
2012-09-13 20:08:01 +02:00
|
|
|
static void handle_wm_state_notify( HWND hwnd, XPropertyEvent *event, BOOL update_window )
|
1999-09-20 17:42:47 +02:00
|
|
|
{
|
2012-09-21 16:50:17 +02:00
|
|
|
struct x11drv_win_data *data = get_win_data( hwnd );
|
2010-05-24 16:54:59 +02:00
|
|
|
DWORD style;
|
|
|
|
|
2012-09-13 20:08:01 +02:00
|
|
|
if (!data) return;
|
|
|
|
|
2008-02-27 19:11:43 +01:00
|
|
|
switch(event->state)
|
1999-09-20 17:42:47 +02:00
|
|
|
{
|
2008-02-27 19:11:43 +01:00
|
|
|
case PropertyDelete:
|
2008-09-17 21:13:38 +02:00
|
|
|
TRACE( "%p/%lx: WM_STATE deleted from %d\n", data->hwnd, data->whole_window, data->wm_state );
|
2008-04-02 15:55:25 +02:00
|
|
|
data->wm_state = WithdrawnState;
|
2008-02-27 19:11:43 +01:00
|
|
|
break;
|
1999-09-20 17:42:47 +02:00
|
|
|
case PropertyNewValue:
|
2008-02-27 19:11:43 +01:00
|
|
|
{
|
2008-09-17 21:13:38 +02:00
|
|
|
int old_state = data->wm_state;
|
2012-09-13 20:08:01 +02:00
|
|
|
int new_state = get_window_wm_state( event->display, data->whole_window );
|
2008-02-27 19:11:43 +01:00
|
|
|
if (new_state != -1 && new_state != data->wm_state)
|
|
|
|
{
|
2008-09-17 21:13:38 +02:00
|
|
|
TRACE( "%p/%lx: new WM_STATE %d from %d\n",
|
|
|
|
data->hwnd, data->whole_window, new_state, old_state );
|
2008-02-27 19:11:43 +01:00
|
|
|
data->wm_state = new_state;
|
2008-09-17 21:13:38 +02:00
|
|
|
/* ignore the initial state transition out of withdrawn state */
|
|
|
|
/* metacity does Withdrawn->NormalState->IconicState when mapping an iconic window */
|
2012-09-21 16:50:17 +02:00
|
|
|
if (!old_state) goto done;
|
2008-02-27 19:11:43 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
1999-09-20 17:42:47 +02:00
|
|
|
}
|
2008-04-02 15:58:59 +02:00
|
|
|
|
2012-09-21 16:50:17 +02:00
|
|
|
if (!update_window || !data->managed || !data->mapped) goto done;
|
2008-04-02 15:58:59 +02:00
|
|
|
|
2010-05-24 16:54:59 +02:00
|
|
|
style = GetWindowLongW( data->hwnd, GWL_STYLE );
|
|
|
|
|
2008-04-02 15:58:59 +02:00
|
|
|
if (data->iconic && data->wm_state == NormalState) /* restore window */
|
|
|
|
{
|
|
|
|
data->iconic = FALSE;
|
2015-07-01 20:43:48 +02:00
|
|
|
read_net_wm_states( event->display, data );
|
|
|
|
if ((style & WS_CAPTION) == WS_CAPTION && (data->net_wm_state & (1 << NET_WM_STATE_MAXIMIZED)))
|
2008-07-31 17:12:16 +02:00
|
|
|
{
|
2010-05-24 16:54:59 +02:00
|
|
|
if ((style & WS_MAXIMIZEBOX) && !(style & WS_DISABLED))
|
|
|
|
{
|
|
|
|
TRACE( "restoring to max %p/%lx\n", data->hwnd, data->whole_window );
|
2012-09-21 16:50:17 +02:00
|
|
|
release_win_data( data );
|
|
|
|
SendMessageW( hwnd, WM_SYSCOMMAND, SC_MAXIMIZE, 0 );
|
|
|
|
return;
|
2010-05-24 16:54:59 +02:00
|
|
|
}
|
2012-09-21 16:50:17 +02:00
|
|
|
TRACE( "not restoring to max win %p/%lx style %08x\n", data->hwnd, data->whole_window, style );
|
2008-07-31 17:12:16 +02:00
|
|
|
}
|
2012-09-22 22:44:42 +02:00
|
|
|
else
|
2008-07-31 17:12:16 +02:00
|
|
|
{
|
2012-09-22 22:44:42 +02:00
|
|
|
if (style & (WS_MINIMIZE | WS_MAXIMIZE))
|
|
|
|
{
|
|
|
|
TRACE( "restoring win %p/%lx\n", data->hwnd, data->whole_window );
|
|
|
|
release_win_data( data );
|
2019-06-05 11:04:58 +02:00
|
|
|
if ((style & (WS_MINIMIZE | WS_VISIBLE)) == (WS_MINIMIZE | WS_VISIBLE))
|
|
|
|
SetActiveWindow( hwnd );
|
2012-09-22 22:44:42 +02:00
|
|
|
SendMessageW( hwnd, WM_SYSCOMMAND, SC_RESTORE, 0 );
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
TRACE( "not restoring win %p/%lx style %08x\n", data->hwnd, data->whole_window, style );
|
2008-07-31 17:12:16 +02:00
|
|
|
}
|
2008-04-02 15:58:59 +02:00
|
|
|
}
|
|
|
|
else if (!data->iconic && data->wm_state == IconicState)
|
|
|
|
{
|
|
|
|
data->iconic = TRUE;
|
2010-05-24 16:54:59 +02:00
|
|
|
if ((style & WS_MINIMIZEBOX) && !(style & WS_DISABLED))
|
|
|
|
{
|
|
|
|
TRACE( "minimizing win %p/%lx\n", data->hwnd, data->whole_window );
|
2012-09-21 16:50:17 +02:00
|
|
|
release_win_data( data );
|
|
|
|
SendMessageW( hwnd, WM_SYSCOMMAND, SC_MINIMIZE, 0 );
|
|
|
|
return;
|
2010-05-24 16:54:59 +02:00
|
|
|
}
|
2012-09-21 16:50:17 +02:00
|
|
|
TRACE( "not minimizing win %p/%lx style %08x\n", data->hwnd, data->whole_window, style );
|
2008-04-02 15:58:59 +02:00
|
|
|
}
|
2012-09-21 16:50:17 +02:00
|
|
|
done:
|
|
|
|
release_win_data( data );
|
1999-09-20 17:42:47 +02:00
|
|
|
}
|
1998-12-07 10:13:40 +01:00
|
|
|
|
2008-02-27 19:13:09 +01:00
|
|
|
|
2008-04-02 15:55:25 +02:00
|
|
|
/***********************************************************************
|
2008-04-17 16:07:06 +02:00
|
|
|
* X11DRV_PropertyNotify
|
2008-04-02 15:55:25 +02:00
|
|
|
*/
|
2016-08-23 15:13:26 +02:00
|
|
|
static BOOL X11DRV_PropertyNotify( HWND hwnd, XEvent *xev )
|
2008-04-02 15:55:25 +02:00
|
|
|
{
|
|
|
|
XPropertyEvent *event = &xev->xproperty;
|
|
|
|
|
2016-08-23 15:13:26 +02:00
|
|
|
if (!hwnd) return FALSE;
|
2012-09-13 20:08:01 +02:00
|
|
|
if (event->atom == x11drv_atom(WM_STATE)) handle_wm_state_notify( hwnd, event, TRUE );
|
2016-08-23 15:13:26 +02:00
|
|
|
return TRUE;
|
2008-04-02 15:55:25 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-02-27 19:13:09 +01:00
|
|
|
/* event filter to wait for a WM_STATE change notification on a window */
|
|
|
|
static Bool is_wm_state_notify( Display *display, XEvent *event, XPointer arg )
|
|
|
|
{
|
2008-03-05 16:52:22 +01:00
|
|
|
if (event->xany.window != (Window)arg) return 0;
|
|
|
|
return (event->type == DestroyNotify ||
|
|
|
|
(event->type == PropertyNotify && event->xproperty.atom == x11drv_atom(WM_STATE)));
|
2008-02-27 19:13:09 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* wait_for_withdrawn_state
|
|
|
|
*/
|
2012-09-13 20:08:01 +02:00
|
|
|
void wait_for_withdrawn_state( HWND hwnd, BOOL set )
|
2008-02-27 19:13:09 +01:00
|
|
|
{
|
2012-09-13 20:08:01 +02:00
|
|
|
Display *display = thread_display();
|
2012-09-21 16:50:17 +02:00
|
|
|
struct x11drv_win_data *data;
|
2008-02-27 19:13:09 +01:00
|
|
|
DWORD end = GetTickCount() + 2000;
|
|
|
|
|
2012-09-21 16:50:17 +02:00
|
|
|
TRACE( "waiting for window %p to become %swithdrawn\n", hwnd, set ? "" : "not " );
|
2008-02-27 19:13:09 +01:00
|
|
|
|
2012-09-21 16:50:17 +02:00
|
|
|
for (;;)
|
2008-03-05 16:52:22 +01:00
|
|
|
{
|
2008-04-02 15:55:25 +02:00
|
|
|
XEvent event;
|
2012-09-21 16:50:17 +02:00
|
|
|
Window window;
|
2008-04-02 15:55:25 +02:00
|
|
|
int count = 0;
|
|
|
|
|
2012-09-21 16:50:17 +02:00
|
|
|
if (!(data = get_win_data( hwnd ))) break;
|
|
|
|
if (!data->managed || data->embedded || data->display != display) break;
|
|
|
|
if (!(window = data->whole_window)) break;
|
|
|
|
if (!data->mapped == !set)
|
|
|
|
{
|
|
|
|
TRACE( "window %p/%lx now %smapped\n", hwnd, window, data->mapped ? "" : "un" );
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if ((data->wm_state == WithdrawnState) != !set)
|
|
|
|
{
|
|
|
|
TRACE( "window %p/%lx state now %d\n", hwnd, window, data->wm_state );
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
release_win_data( data );
|
|
|
|
|
|
|
|
while (XCheckIfEvent( display, &event, is_wm_state_notify, (char *)window ))
|
2008-04-02 15:55:25 +02:00
|
|
|
{
|
|
|
|
count++;
|
|
|
|
if (XFilterEvent( &event, None )) continue; /* filtered, ignore it */
|
|
|
|
if (event.type == DestroyNotify) call_event_handler( display, &event );
|
2012-09-13 20:08:01 +02:00
|
|
|
else handle_wm_state_notify( hwnd, &event.xproperty, FALSE );
|
2008-04-02 15:55:25 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if (!count)
|
2008-02-27 19:13:09 +01:00
|
|
|
{
|
2008-03-05 16:52:22 +01:00
|
|
|
struct pollfd pfd;
|
|
|
|
int timeout = end - GetTickCount();
|
|
|
|
|
|
|
|
pfd.fd = ConnectionNumber(display);
|
|
|
|
pfd.events = POLLIN;
|
|
|
|
if (timeout <= 0 || poll( &pfd, 1, timeout ) != 1)
|
|
|
|
{
|
2012-09-21 16:50:17 +02:00
|
|
|
FIXME( "window %p/%lx wait timed out\n", hwnd, window );
|
|
|
|
return;
|
2008-03-05 16:52:22 +01:00
|
|
|
}
|
2008-02-27 19:13:09 +01:00
|
|
|
}
|
|
|
|
}
|
2012-09-21 16:50:17 +02:00
|
|
|
release_win_data( data );
|
2008-02-27 19:13:09 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-09-18 11:20:07 +02:00
|
|
|
/*****************************************************************
|
|
|
|
* SetFocus (X11DRV.@)
|
|
|
|
*
|
|
|
|
* Set the X focus.
|
|
|
|
*/
|
|
|
|
void CDECL X11DRV_SetFocus( HWND hwnd )
|
|
|
|
{
|
|
|
|
struct x11drv_win_data *data;
|
|
|
|
|
2013-11-13 16:59:38 +01:00
|
|
|
HWND parent;
|
|
|
|
|
|
|
|
for (;;)
|
|
|
|
{
|
|
|
|
if (!(data = get_win_data( hwnd ))) return;
|
|
|
|
if (data->embedded) break;
|
|
|
|
parent = GetAncestor( hwnd, GA_PARENT );
|
|
|
|
if (!parent || parent == GetDesktopWindow()) break;
|
|
|
|
release_win_data( data );
|
|
|
|
hwnd = parent;
|
|
|
|
}
|
|
|
|
if (!data->managed || data->embedder) set_input_focus( data );
|
2012-09-18 11:24:55 +02:00
|
|
|
release_win_data( data );
|
2012-09-18 11:20:07 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2002-09-23 22:56:37 +02:00
|
|
|
static HWND find_drop_window( HWND hQueryWnd, LPPOINT lpPt )
|
|
|
|
{
|
|
|
|
RECT tempRect;
|
|
|
|
|
|
|
|
if (!IsWindowEnabled(hQueryWnd)) return 0;
|
|
|
|
|
|
|
|
GetWindowRect(hQueryWnd, &tempRect);
|
|
|
|
|
|
|
|
if(!PtInRect(&tempRect, *lpPt)) return 0;
|
|
|
|
|
|
|
|
if (!IsIconic( hQueryWnd ))
|
|
|
|
{
|
2005-03-24 21:41:27 +01:00
|
|
|
POINT pt = *lpPt;
|
|
|
|
ScreenToClient( hQueryWnd, &pt );
|
2002-09-23 22:56:37 +02:00
|
|
|
GetClientRect( hQueryWnd, &tempRect );
|
|
|
|
|
2005-03-24 21:41:27 +01:00
|
|
|
if (PtInRect( &tempRect, pt))
|
2002-09-23 22:56:37 +02:00
|
|
|
{
|
2005-03-24 21:41:27 +01:00
|
|
|
HWND ret = ChildWindowFromPointEx( hQueryWnd, pt, CWP_SKIPINVISIBLE|CWP_SKIPDISABLED );
|
|
|
|
if (ret && ret != hQueryWnd)
|
2002-09-23 22:56:37 +02:00
|
|
|
{
|
2005-03-24 21:41:27 +01:00
|
|
|
ret = find_drop_window( ret, lpPt );
|
|
|
|
if (ret) return ret;
|
2002-09-23 22:56:37 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if(!(GetWindowLongA( hQueryWnd, GWL_EXSTYLE ) & WS_EX_ACCEPTFILES)) return 0;
|
|
|
|
|
|
|
|
ScreenToClient(hQueryWnd, lpPt);
|
|
|
|
|
|
|
|
return hQueryWnd;
|
|
|
|
}
|
|
|
|
|
1998-12-07 10:13:40 +01:00
|
|
|
/**********************************************************************
|
|
|
|
* EVENT_DropFromOffix
|
|
|
|
*
|
2008-01-04 20:37:14 +01:00
|
|
|
* don't know if it still works (last Changelog is from 96/11/04)
|
1998-12-07 10:13:40 +01:00
|
|
|
*/
|
1999-04-15 17:22:23 +02:00
|
|
|
static void EVENT_DropFromOffiX( HWND hWnd, XClientMessageEvent *event )
|
1998-12-07 10:13:40 +01:00
|
|
|
{
|
2008-02-28 20:02:31 +01:00
|
|
|
struct x11drv_win_data *data;
|
2013-10-14 14:20:08 +02:00
|
|
|
POINT pt;
|
2002-09-23 22:56:37 +02:00
|
|
|
unsigned long data_length;
|
|
|
|
unsigned long aux_long;
|
|
|
|
unsigned char* p_data = NULL;
|
2005-11-23 14:30:41 +01:00
|
|
|
Atom atom_aux;
|
2012-09-18 11:37:33 +02:00
|
|
|
int x, y, cx, cy, dummy;
|
2005-01-17 20:17:47 +01:00
|
|
|
Window win, w_aux_root, w_aux_child;
|
2002-09-23 22:56:37 +02:00
|
|
|
|
2012-09-18 11:37:33 +02:00
|
|
|
if (!(data = get_win_data( hWnd ))) return;
|
|
|
|
cx = data->whole_rect.right - data->whole_rect.left;
|
|
|
|
cy = data->whole_rect.bottom - data->whole_rect.top;
|
|
|
|
win = data->whole_window;
|
|
|
|
release_win_data( data );
|
|
|
|
|
2005-01-17 20:17:47 +01:00
|
|
|
XQueryPointer( event->display, win, &w_aux_root, &w_aux_child,
|
2005-11-23 14:30:41 +01:00
|
|
|
&x, &y, &dummy, &dummy, (unsigned int*)&aux_long);
|
2013-10-14 14:20:08 +02:00
|
|
|
pt = root_to_virtual_screen( x, y );
|
2002-09-23 22:56:37 +02:00
|
|
|
|
|
|
|
/* find out drop point and drop window */
|
2013-10-14 14:20:08 +02:00
|
|
|
if (pt.x < 0 || pt.y < 0 || pt.x > cx || pt.y > cy)
|
2012-09-18 11:37:33 +02:00
|
|
|
{
|
2013-10-14 14:20:08 +02:00
|
|
|
if (!(GetWindowLongW( hWnd, GWL_EXSTYLE ) & WS_EX_ACCEPTFILES)) return;
|
|
|
|
pt.x = pt.y = 0;
|
2002-09-23 22:56:37 +02:00
|
|
|
}
|
|
|
|
else
|
1998-12-07 10:13:40 +01:00
|
|
|
{
|
2013-10-14 14:20:08 +02:00
|
|
|
if (!find_drop_window( hWnd, &pt )) return;
|
1998-12-07 10:13:40 +01:00
|
|
|
}
|
2001-10-16 23:58:58 +02:00
|
|
|
|
2003-11-21 22:48:36 +01:00
|
|
|
XGetWindowProperty( event->display, DefaultRootWindow(event->display),
|
|
|
|
x11drv_atom(DndSelection), 0, 65535, FALSE,
|
2005-11-23 14:30:41 +01:00
|
|
|
AnyPropertyType, &atom_aux, &dummy,
|
2003-11-21 22:48:36 +01:00
|
|
|
&data_length, &aux_long, &p_data);
|
2001-10-16 23:58:58 +02:00
|
|
|
|
|
|
|
if( !aux_long && p_data) /* don't bother if > 64K */
|
1998-12-07 10:13:40 +01:00
|
|
|
{
|
2005-11-23 14:30:41 +01:00
|
|
|
char *p = (char *)p_data;
|
2001-10-16 23:58:58 +02:00
|
|
|
char *p_drop;
|
1999-03-14 18:25:32 +01:00
|
|
|
|
2001-10-16 23:58:58 +02:00
|
|
|
aux_long = 0;
|
|
|
|
while( *p ) /* calculate buffer size */
|
|
|
|
{
|
2005-11-23 14:30:41 +01:00
|
|
|
INT len = GetShortPathNameA( p, NULL, 0 );
|
|
|
|
if (len) aux_long += len + 1;
|
2001-10-16 23:58:58 +02:00
|
|
|
p += strlen(p) + 1;
|
|
|
|
}
|
|
|
|
if( aux_long && aux_long < 65535 )
|
|
|
|
{
|
|
|
|
HDROP hDrop;
|
|
|
|
DROPFILES *lpDrop;
|
|
|
|
|
|
|
|
aux_long += sizeof(DROPFILES) + 1;
|
|
|
|
hDrop = GlobalAlloc( GMEM_SHARE, aux_long );
|
2008-12-01 02:09:52 +01:00
|
|
|
lpDrop = GlobalLock( hDrop );
|
2001-10-16 23:58:58 +02:00
|
|
|
|
|
|
|
if( lpDrop )
|
|
|
|
{
|
|
|
|
lpDrop->pFiles = sizeof(DROPFILES);
|
2013-10-14 14:20:08 +02:00
|
|
|
lpDrop->pt = pt;
|
2008-02-28 20:02:31 +01:00
|
|
|
lpDrop->fNC = FALSE;
|
2001-10-16 23:58:58 +02:00
|
|
|
lpDrop->fWide = FALSE;
|
|
|
|
p_drop = (char *)(lpDrop + 1);
|
2005-11-23 14:30:41 +01:00
|
|
|
p = (char *)p_data;
|
2001-10-16 23:58:58 +02:00
|
|
|
while(*p)
|
|
|
|
{
|
2005-11-23 14:30:41 +01:00
|
|
|
if (GetShortPathNameA( p, p_drop, aux_long - (p_drop - (char *)lpDrop) ))
|
2001-10-16 23:58:58 +02:00
|
|
|
p_drop += strlen( p_drop ) + 1;
|
|
|
|
p += strlen(p) + 1;
|
|
|
|
}
|
|
|
|
*p_drop = '\0';
|
|
|
|
PostMessageA( hWnd, WM_DROPFILES, (WPARAM)hDrop, 0L );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2003-11-21 22:48:36 +01:00
|
|
|
if( p_data ) XFree(p_data);
|
1998-12-07 10:13:40 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/**********************************************************************
|
|
|
|
* EVENT_DropURLs
|
|
|
|
*
|
2002-06-01 01:06:46 +02:00
|
|
|
* drop items are separated by \n
|
1998-12-07 10:13:40 +01:00
|
|
|
* each item is prefixed by its mime type
|
|
|
|
*
|
|
|
|
* event->data.l[3], event->data.l[4] contains drop x,y position
|
|
|
|
*/
|
1999-04-15 17:22:23 +02:00
|
|
|
static void EVENT_DropURLs( HWND hWnd, XClientMessageEvent *event )
|
1998-12-07 10:13:40 +01:00
|
|
|
{
|
2008-02-28 20:02:31 +01:00
|
|
|
struct x11drv_win_data *win_data;
|
1998-12-07 10:13:40 +01:00
|
|
|
unsigned long data_length;
|
|
|
|
unsigned long aux_long, drop_len = 0;
|
|
|
|
unsigned char *p_data = NULL; /* property data */
|
|
|
|
char *p_drop = NULL;
|
|
|
|
char *p, *next;
|
2000-09-26 01:56:41 +02:00
|
|
|
int x, y;
|
2013-10-14 14:20:08 +02:00
|
|
|
POINT pos;
|
2000-09-26 01:56:41 +02:00
|
|
|
DROPFILES *lpDrop;
|
|
|
|
HDROP hDrop;
|
1998-12-07 10:13:40 +01:00
|
|
|
union {
|
|
|
|
Atom atom_aux;
|
|
|
|
int i;
|
|
|
|
Window w_aux;
|
2005-08-16 18:02:45 +02:00
|
|
|
unsigned int u;
|
1998-12-07 10:13:40 +01:00
|
|
|
} u; /* unused */
|
|
|
|
|
2001-10-16 23:58:58 +02:00
|
|
|
if (!(GetWindowLongW( hWnd, GWL_EXSTYLE ) & WS_EX_ACCEPTFILES)) return;
|
1998-12-07 10:13:40 +01:00
|
|
|
|
2003-11-21 22:48:36 +01:00
|
|
|
XGetWindowProperty( event->display, DefaultRootWindow(event->display),
|
|
|
|
x11drv_atom(DndSelection), 0, 65535, FALSE,
|
|
|
|
AnyPropertyType, &u.atom_aux, &u.i,
|
|
|
|
&data_length, &aux_long, &p_data);
|
1998-12-07 10:13:40 +01:00
|
|
|
if (aux_long)
|
1999-12-08 04:56:23 +01:00
|
|
|
WARN("property too large, truncated!\n");
|
|
|
|
TRACE("urls=%s\n", p_data);
|
1998-12-07 10:13:40 +01:00
|
|
|
|
|
|
|
if( !aux_long && p_data) { /* don't bother if > 64K */
|
|
|
|
/* calculate length */
|
2005-08-16 18:02:45 +02:00
|
|
|
p = (char*) p_data;
|
1998-12-07 10:13:40 +01:00
|
|
|
next = strchr(p, '\n');
|
|
|
|
while (p) {
|
|
|
|
if (next) *next=0;
|
|
|
|
if (strncmp(p,"file:",5) == 0 ) {
|
1999-02-26 12:11:13 +01:00
|
|
|
INT len = GetShortPathNameA( p+5, NULL, 0 );
|
1998-12-07 10:13:40 +01:00
|
|
|
if (len) drop_len += len + 1;
|
|
|
|
}
|
2002-06-01 01:06:46 +02:00
|
|
|
if (next) {
|
|
|
|
*next = '\n';
|
1998-12-07 10:13:40 +01:00
|
|
|
p = next + 1;
|
|
|
|
next = strchr(p, '\n');
|
|
|
|
} else {
|
|
|
|
p = NULL;
|
|
|
|
}
|
|
|
|
}
|
2002-06-01 01:06:46 +02:00
|
|
|
|
1998-12-07 10:13:40 +01:00
|
|
|
if( drop_len && drop_len < 65535 ) {
|
2003-11-21 22:48:36 +01:00
|
|
|
XQueryPointer( event->display, root_window, &u.w_aux, &u.w_aux,
|
2005-08-16 18:02:45 +02:00
|
|
|
&x, &y, &u.i, &u.i, &u.u);
|
2013-10-14 14:20:08 +02:00
|
|
|
pos = root_to_virtual_screen( x, y );
|
1999-04-15 17:22:23 +02:00
|
|
|
|
2000-09-26 01:56:41 +02:00
|
|
|
drop_len += sizeof(DROPFILES) + 1;
|
2001-01-02 22:00:46 +01:00
|
|
|
hDrop = GlobalAlloc( GMEM_SHARE, drop_len );
|
2008-12-01 02:09:52 +01:00
|
|
|
lpDrop = GlobalLock( hDrop );
|
2000-09-26 01:56:41 +02:00
|
|
|
|
2012-09-18 11:37:33 +02:00
|
|
|
if( lpDrop && (win_data = get_win_data( hWnd )))
|
2008-02-28 20:02:31 +01:00
|
|
|
{
|
2000-09-26 01:56:41 +02:00
|
|
|
lpDrop->pFiles = sizeof(DROPFILES);
|
2013-10-14 14:20:08 +02:00
|
|
|
lpDrop->pt = pos;
|
2000-09-26 01:56:41 +02:00
|
|
|
lpDrop->fNC =
|
2013-10-14 14:20:08 +02:00
|
|
|
(pos.x < (win_data->client_rect.left - win_data->whole_rect.left) ||
|
|
|
|
pos.y < (win_data->client_rect.top - win_data->whole_rect.top) ||
|
|
|
|
pos.x > (win_data->client_rect.right - win_data->whole_rect.left) ||
|
|
|
|
pos.y > (win_data->client_rect.bottom - win_data->whole_rect.top) );
|
2000-09-26 01:56:41 +02:00
|
|
|
lpDrop->fWide = FALSE;
|
|
|
|
p_drop = (char*)(lpDrop + 1);
|
2012-09-18 11:37:33 +02:00
|
|
|
release_win_data( win_data );
|
1998-12-07 10:13:40 +01:00
|
|
|
}
|
2000-09-26 01:56:41 +02:00
|
|
|
|
1998-12-07 10:13:40 +01:00
|
|
|
/* create message content */
|
|
|
|
if (p_drop) {
|
2005-08-16 18:02:45 +02:00
|
|
|
p = (char*) p_data;
|
1998-12-07 10:13:40 +01:00
|
|
|
next = strchr(p, '\n');
|
|
|
|
while (p) {
|
|
|
|
if (next) *next=0;
|
|
|
|
if (strncmp(p,"file:",5) == 0 ) {
|
1999-02-26 12:11:13 +01:00
|
|
|
INT len = GetShortPathNameA( p+5, p_drop, 65535 );
|
1998-12-07 10:13:40 +01:00
|
|
|
if (len) {
|
1999-12-08 04:56:23 +01:00
|
|
|
TRACE("drop file %s as %s\n", p+5, p_drop);
|
1998-12-07 10:13:40 +01:00
|
|
|
p_drop += len+1;
|
|
|
|
} else {
|
2005-11-10 13:14:56 +01:00
|
|
|
WARN("can't convert file %s to dos name\n", p+5);
|
1998-12-07 10:13:40 +01:00
|
|
|
}
|
|
|
|
} else {
|
1999-12-08 04:56:23 +01:00
|
|
|
WARN("unknown mime type %s\n", p);
|
1998-12-07 10:13:40 +01:00
|
|
|
}
|
2002-06-01 01:06:46 +02:00
|
|
|
if (next) {
|
|
|
|
*next = '\n';
|
1998-12-07 10:13:40 +01:00
|
|
|
p = next + 1;
|
|
|
|
next = strchr(p, '\n');
|
|
|
|
} else {
|
|
|
|
p = NULL;
|
|
|
|
}
|
|
|
|
*p_drop = '\0';
|
|
|
|
}
|
|
|
|
|
2000-09-26 01:56:41 +02:00
|
|
|
GlobalUnlock(hDrop);
|
2001-01-02 22:00:46 +01:00
|
|
|
PostMessageA( hWnd, WM_DROPFILES, (WPARAM)hDrop, 0L );
|
1998-12-07 10:13:40 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2018-06-21 19:03:05 +02:00
|
|
|
if( p_data ) XFree(p_data);
|
1998-12-07 10:13:40 +01:00
|
|
|
}
|
|
|
|
|
2010-11-01 19:45:12 +01:00
|
|
|
|
|
|
|
/**********************************************************************
|
|
|
|
* handle_xembed_protocol
|
|
|
|
*/
|
|
|
|
static void handle_xembed_protocol( HWND hwnd, XClientMessageEvent *event )
|
|
|
|
{
|
|
|
|
switch (event->data.l[1])
|
|
|
|
{
|
|
|
|
case XEMBED_EMBEDDED_NOTIFY:
|
2013-10-26 18:34:32 +02:00
|
|
|
{
|
|
|
|
struct x11drv_win_data *data = get_win_data( hwnd );
|
|
|
|
if (!data) break;
|
|
|
|
|
|
|
|
TRACE( "win %p/%lx XEMBED_EMBEDDED_NOTIFY owner %lx\n", hwnd, event->window, event->data.l[3] );
|
|
|
|
data->embedder = event->data.l[3];
|
|
|
|
|
|
|
|
/* window has been marked as embedded before (e.g. systray) */
|
2014-01-23 20:19:41 +01:00
|
|
|
if (data->embedded || !data->embedder /* broken QX11EmbedContainer implementation */)
|
2013-10-26 18:34:32 +02:00
|
|
|
{
|
|
|
|
release_win_data( data );
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
make_window_embedded( data );
|
|
|
|
release_win_data( data );
|
|
|
|
reparent_notify( event->display, hwnd, event->data.l[3], 0, 0 );
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case XEMBED_WINDOW_DEACTIVATE:
|
|
|
|
TRACE( "win %p/%lx XEMBED_WINDOW_DEACTIVATE message\n", hwnd, event->window );
|
|
|
|
focus_out( event->display, GetAncestor( hwnd, GA_ROOT ) );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case XEMBED_FOCUS_OUT:
|
|
|
|
TRACE( "win %p/%lx XEMBED_FOCUS_OUT message\n", hwnd, event->window );
|
|
|
|
focus_out( event->display, GetAncestor( hwnd, GA_ROOT ) );
|
2010-11-01 19:45:12 +01:00
|
|
|
break;
|
2013-10-26 18:34:32 +02:00
|
|
|
|
|
|
|
case XEMBED_MODALITY_ON:
|
|
|
|
TRACE( "win %p/%lx XEMBED_MODALITY_ON message\n", hwnd, event->window );
|
|
|
|
EnableWindow( hwnd, FALSE );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case XEMBED_MODALITY_OFF:
|
|
|
|
TRACE( "win %p/%lx XEMBED_MODALITY_OFF message\n", hwnd, event->window );
|
|
|
|
EnableWindow( hwnd, TRUE );
|
|
|
|
break;
|
|
|
|
|
2010-11-01 19:45:12 +01:00
|
|
|
default:
|
|
|
|
TRACE( "win %p/%lx XEMBED message %lu(%lu)\n",
|
|
|
|
hwnd, event->window, event->data.l[1], event->data.l[2] );
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2005-03-01 12:52:02 +01:00
|
|
|
/**********************************************************************
|
|
|
|
* handle_dnd_protocol
|
|
|
|
*/
|
|
|
|
static void handle_dnd_protocol( HWND hwnd, XClientMessageEvent *event )
|
|
|
|
{
|
|
|
|
Window root, child;
|
|
|
|
int root_x, root_y, child_x, child_y;
|
|
|
|
unsigned int u;
|
|
|
|
|
|
|
|
/* query window (drag&drop event contains only drag window) */
|
|
|
|
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 (!hwnd) return;
|
|
|
|
if (event->data.l[0] == DndFile || event->data.l[0] == DndFiles)
|
|
|
|
EVENT_DropFromOffiX(hwnd, event);
|
|
|
|
else if (event->data.l[0] == DndURL)
|
|
|
|
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[] =
|
|
|
|
{
|
2010-11-01 19:57:12 +01:00
|
|
|
{ XATOM_MANAGER, handle_manager_message },
|
2005-03-01 12:52:02 +01:00
|
|
|
{ XATOM_WM_PROTOCOLS, handle_wm_protocols },
|
2010-11-01 19:45:12 +01:00
|
|
|
{ XATOM__XEMBED, handle_xembed_protocol },
|
2005-03-01 12:52:02 +01:00
|
|
|
{ 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 }
|
|
|
|
};
|
|
|
|
|
|
|
|
|
1998-12-07 10:13:40 +01:00
|
|
|
/**********************************************************************
|
2008-04-17 16:07:06 +02:00
|
|
|
* X11DRV_ClientMessage
|
1998-12-07 10:13:40 +01:00
|
|
|
*/
|
2016-08-23 15:13:26 +02:00
|
|
|
static BOOL X11DRV_ClientMessage( HWND hwnd, XEvent *xev )
|
1998-12-07 10:13:40 +01:00
|
|
|
{
|
2005-02-26 18:49:38 +01:00
|
|
|
XClientMessageEvent *event = &xev->xclient;
|
2005-03-01 12:52:02 +01:00
|
|
|
unsigned int i;
|
2005-02-26 18:49:38 +01:00
|
|
|
|
2016-08-23 15:13:26 +02:00
|
|
|
if (!hwnd) return FALSE;
|
2005-02-26 18:49:38 +01:00
|
|
|
|
2005-03-01 12:52:02 +01:00
|
|
|
if (event->format != 32)
|
2001-06-04 23:55:17 +02:00
|
|
|
{
|
2005-03-01 12:52:02 +01:00
|
|
|
WARN( "Don't know how to handle format %d\n", event->format );
|
2016-08-23 15:13:26 +02:00
|
|
|
return FALSE;
|
1999-04-18 11:21:01 +02:00
|
|
|
}
|
2005-03-01 12:52:02 +01:00
|
|
|
|
2018-09-19 21:01:10 +02:00
|
|
|
for (i = 0; i < ARRAY_SIZE( client_messages ); i++)
|
2003-11-20 23:09:51 +01:00
|
|
|
{
|
2005-03-01 12:52:02 +01:00
|
|
|
if (event->message_type == X11DRV_Atoms[client_messages[i].atom - FIRST_XATOM])
|
|
|
|
{
|
|
|
|
client_messages[i].handler( hwnd, event );
|
2016-08-23 15:13:26 +02:00
|
|
|
return TRUE;
|
2005-03-01 12:52:02 +01:00
|
|
|
}
|
1998-12-07 10:13:40 +01:00
|
|
|
}
|
2005-03-01 12:52:02 +01:00
|
|
|
TRACE( "no handler found for %ld\n", event->message_type );
|
2016-08-23 15:13:26 +02:00
|
|
|
return FALSE;
|
1998-12-07 10:13:40 +01:00
|
|
|
}
|