Commit ce7a98e9 authored by Akihiro Sagawa's avatar Akihiro Sagawa Committed by Alexandre Julliard

winex11: Return more reliable value from X11DRV_MsgWaitForMultipleObjects.

After processing several X events, X11DRV_MsgWaitForMultipleObjects always tells us that a new message is available. This is not true for some cases. For instance, when we call DestroyWindow, the X queues DestroyEvent. Then, X11DRV_MsgWaitForMultipleObjects handles the event only; none is posted or sent as hwnd for destroyed window is unavailable. However, the function states "new message is available" by returning count - 1 value. This is an issue for CoWaitForMultipleHandles because it expects a new message in the queue and consumes the message. Signed-off-by: 's avatarAkihiro Sagawa <sagawa.aki@gmail.com> Signed-off-by: 's avatarAlexandre Julliard <julliard@winehq.org>
parent 6f3b45d2
......@@ -3512,19 +3512,21 @@ END:
/***********************************************************************
* X11DRV_SelectionRequest
*/
void X11DRV_SelectionRequest( HWND hWnd, XEvent *event )
BOOL X11DRV_SelectionRequest( HWND hWnd, XEvent *event )
{
X11DRV_HandleSelectionRequest( hWnd, &event->xselectionrequest, FALSE );
return FALSE;
}
/***********************************************************************
* X11DRV_SelectionClear
*/
void X11DRV_SelectionClear( HWND hWnd, XEvent *xev )
BOOL X11DRV_SelectionClear( HWND hWnd, XEvent *xev )
{
XSelectionClearEvent *event = &xev->xselectionclear;
if (event->selection == XA_PRIMARY || event->selection == x11drv_atom(CLIPBOARD))
X11DRV_CLIPBOARD_ReleaseSelection( event->display, event->selection,
event->window, hWnd, event->time );
return FALSE;
}
......@@ -91,16 +91,16 @@ Bool (*pXGetEventData)( Display *display, XEvent /*XGenericEventCookie*/ *event
void (*pXFreeEventData)( Display *display, XEvent /*XGenericEventCookie*/ *event ) = NULL;
/* Event handlers */
static void X11DRV_FocusIn( HWND hwnd, XEvent *event );
static void X11DRV_FocusOut( HWND hwnd, XEvent *event );
static void X11DRV_Expose( HWND hwnd, XEvent *event );
static void X11DRV_MapNotify( HWND hwnd, XEvent *event );
static void X11DRV_UnmapNotify( HWND hwnd, XEvent *event );
static void X11DRV_ReparentNotify( HWND hwnd, XEvent *event );
static void X11DRV_ConfigureNotify( HWND hwnd, XEvent *event );
static void X11DRV_PropertyNotify( HWND hwnd, XEvent *event );
static void X11DRV_ClientMessage( HWND hwnd, XEvent *event );
static void X11DRV_GravityNotify( HWND hwnd, XEvent *event );
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 );
#define MAX_EVENT_HANDLERS 128
......@@ -374,16 +374,17 @@ static enum event_merge_action merge_events( XEvent *prev, XEvent *next )
/***********************************************************************
* call_event_handler
*/
static inline void call_event_handler( Display *display, XEvent *event )
static inline BOOL call_event_handler( Display *display, XEvent *event )
{
HWND hwnd;
XEvent *prev;
struct x11drv_thread_data *thread_data;
BOOL ret;
if (!handlers[event->type])
{
TRACE( "%s for win %lx, ignoring\n", dbgstr_event( event->type ), event->xany.window );
return; /* no handler, ignore it */
return FALSE; /* no handler, ignore it */
}
if (XFindContext( display, event->xany.window, winContext, (char **)&hwnd ) != 0)
......@@ -395,8 +396,9 @@ static inline void call_event_handler( Display *display, XEvent *event )
thread_data = x11drv_thread_data();
prev = thread_data->current_event;
thread_data->current_event = event;
handlers[event->type]( hwnd, event );
ret = handlers[event->type]( hwnd, event );
thread_data->current_event = prev;
return ret;
}
......@@ -407,6 +409,7 @@ static int process_events( Display *display, Bool (*filter)(Display*, XEvent*,XP
{
XEvent event, prev_event;
int count = 0;
BOOL queued = FALSE;
enum event_merge_action action = MERGE_DISCARD;
prev_event.type = 0;
......@@ -448,25 +451,25 @@ static int process_events( Display *display, Bool (*filter)(Display*, XEvent*,XP
switch( action )
{
case MERGE_HANDLE: /* handle prev, keep new */
call_event_handler( display, &prev_event );
queued |= call_event_handler( display, &prev_event );
/* fall through */
case MERGE_DISCARD: /* discard prev, keep new */
free_event_data( &prev_event );
prev_event = event;
break;
case MERGE_KEEP: /* handle new, keep prev for future merging */
call_event_handler( display, &event );
queued |= call_event_handler( display, &event );
/* fall through */
case MERGE_IGNORE: /* ignore new, keep prev for future merging */
free_event_data( &event );
break;
}
}
if (prev_event.type) call_event_handler( display, &prev_event );
if (prev_event.type) queued |= call_event_handler( display, &prev_event );
free_event_data( &prev_event );
XFlush( gdi_display );
if (count) TRACE( "processed %d events\n", count );
return count;
if (count) TRACE( "%s %d events\n", queued ? "processed" : "ignored", count );
return queued;
}
......@@ -749,23 +752,23 @@ static const char * const focus_details[] =
/**********************************************************************
* X11DRV_FocusIn
*/
static void X11DRV_FocusIn( HWND hwnd, XEvent *xev )
static BOOL X11DRV_FocusIn( HWND hwnd, XEvent *xev )
{
XFocusChangeEvent *event = &xev->xfocus;
XIC xic;
if (!hwnd) return;
if (!hwnd) return FALSE;
TRACE( "win %p xwin %lx detail=%s\n", hwnd, event->window, focus_details[event->detail] );
if (event->detail == NotifyPointer) return;
if (hwnd == GetDesktopWindow()) return;
if (event->detail == NotifyPointer) return FALSE;
if (hwnd == GetDesktopWindow()) return FALSE;
if ((xic = X11DRV_get_ic( hwnd ))) XSetICFocus( xic );
if (use_take_focus)
{
if (hwnd == GetForegroundWindow()) clip_fullscreen_window( hwnd, FALSE );
return;
return TRUE;
}
if (!can_activate_window(hwnd))
......@@ -777,6 +780,7 @@ static void X11DRV_FocusIn( HWND hwnd, XEvent *xev )
if (hwnd && can_activate_window(hwnd)) set_focus( event->display, hwnd, CurrentTime );
}
else SetForegroundWindow( hwnd );
return TRUE;
}
/**********************************************************************
......@@ -831,7 +835,7 @@ static void X11DRV_FocusIn( HWND hwnd, XEvent *xev )
*
* Note: only top-level windows get FocusOut events.
*/
static void X11DRV_FocusOut( HWND hwnd, XEvent *xev )
static BOOL X11DRV_FocusOut( HWND hwnd, XEvent *xev )
{
XFocusChangeEvent *event = &xev->xfocus;
......@@ -840,17 +844,18 @@ static void X11DRV_FocusOut( HWND hwnd, XEvent *xev )
if (event->detail == NotifyPointer)
{
if (!hwnd && event->window == x11drv_thread_data()->clip_window) reset_clipping_window();
return;
return TRUE;
}
if (!hwnd) return;
if (!hwnd) return FALSE;
focus_out( event->display, hwnd );
return TRUE;
}
/***********************************************************************
* X11DRV_Expose
*/
static void X11DRV_Expose( HWND hwnd, XEvent *xev )
static BOOL X11DRV_Expose( HWND hwnd, XEvent *xev )
{
XExposeEvent *event = &xev->xexpose;
RECT rect;
......@@ -869,7 +874,7 @@ static void X11DRV_Expose( HWND hwnd, XEvent *xev )
}
else pos = root_to_virtual_screen( event->x, event->y );
if (!(data = get_win_data( hwnd ))) return;
if (!(data = get_win_data( hwnd ))) return FALSE;
rect.left = pos.x;
rect.top = pos.y;
......@@ -914,22 +919,23 @@ static void X11DRV_Expose( HWND hwnd, XEvent *xev )
if (flags) RedrawWindow( hwnd, &rect, surface_region, flags );
if (surface_region) DeleteObject( surface_region );
return TRUE;
}
/**********************************************************************
* X11DRV_MapNotify
*/
static void X11DRV_MapNotify( HWND hwnd, XEvent *event )
static BOOL X11DRV_MapNotify( HWND hwnd, XEvent *event )
{
struct x11drv_win_data *data;
if (event->xany.window == x11drv_thread_data()->clip_window)
{
clipping_cursor = TRUE;
return;
return TRUE;
}
if (!(data = get_win_data( hwnd ))) return;
if (!(data = get_win_data( hwnd ))) return FALSE;
if (!data->managed && !data->embedded && data->mapped)
{
......@@ -938,16 +944,18 @@ static void X11DRV_MapNotify( HWND hwnd, XEvent *event )
set_input_focus( data );
}
release_win_data( data );
return TRUE;
}
/**********************************************************************
* X11DRV_UnmapNotify
*/
static void X11DRV_UnmapNotify( HWND hwnd, XEvent *event )
static BOOL X11DRV_UnmapNotify( HWND hwnd, XEvent *event )
{
if (event->xany.window == x11drv_thread_data()->clip_window)
clipping_cursor = FALSE;
return TRUE;
}
......@@ -986,17 +994,17 @@ static void reparent_notify( Display *display, HWND hwnd, Window xparent, int x,
/***********************************************************************
* X11DRV_ReparentNotify
*/
static void X11DRV_ReparentNotify( HWND hwnd, XEvent *xev )
static BOOL X11DRV_ReparentNotify( HWND hwnd, XEvent *xev )
{
XReparentEvent *event = &xev->xreparent;
struct x11drv_win_data *data;
if (!(data = get_win_data( hwnd ))) return;
if (!(data = get_win_data( hwnd ))) return FALSE;
if (!data->embedded)
{
release_win_data( data );
return;
return FALSE;
}
if (data->whole_window)
......@@ -1007,7 +1015,7 @@ static void X11DRV_ReparentNotify( HWND hwnd, XEvent *xev )
data->embedder = 0;
release_win_data( data );
SendMessageW( hwnd, WM_CLOSE, 0, 0 );
return;
return TRUE;
}
data->embedder = event->parent;
}
......@@ -1016,13 +1024,14 @@ static void X11DRV_ReparentNotify( HWND hwnd, XEvent *xev )
release_win_data( data );
reparent_notify( event->display, hwnd, event->parent, event->x, event->y );
return TRUE;
}
/***********************************************************************
* X11DRV_ConfigureNotify
*/
void X11DRV_ConfigureNotify( HWND hwnd, XEvent *xev )
static BOOL X11DRV_ConfigureNotify( HWND hwnd, XEvent *xev )
{
XConfigureEvent *event = &xev->xconfigure;
struct x11drv_win_data *data;
......@@ -1034,8 +1043,8 @@ void X11DRV_ConfigureNotify( HWND hwnd, XEvent *xev )
int cx, cy, x = event->x, y = event->y;
DWORD style;
if (!hwnd) return;
if (!(data = get_win_data( hwnd ))) return;
if (!hwnd) return FALSE;
if (!(data = get_win_data( hwnd ))) return FALSE;
if (!data->mapped || data->iconic) goto done;
if (data->whole_window && !data->managed) goto done;
/* ignore synthetic events on foreign windows */
......@@ -1114,7 +1123,7 @@ void X11DRV_ConfigureNotify( HWND hwnd, XEvent *xev )
TRACE( "win %p/%lx is maximized\n", data->hwnd, data->whole_window );
release_win_data( data );
SendMessageW( data->hwnd, WM_SYSCOMMAND, SC_MAXIMIZE, 0 );
return;
return TRUE;
}
}
else if (style & WS_MAXIMIZE)
......@@ -1122,7 +1131,7 @@ void X11DRV_ConfigureNotify( HWND hwnd, XEvent *xev )
TRACE( "window %p/%lx is no longer maximized\n", data->hwnd, data->whole_window );
release_win_data( data );
SendMessageW( data->hwnd, WM_SYSCOMMAND, SC_RESTORE, 0 );
return;
return TRUE;
}
}
......@@ -1130,29 +1139,30 @@ void X11DRV_ConfigureNotify( HWND hwnd, XEvent *xev )
{
release_win_data( data );
SetWindowPos( hwnd, 0, x, y, cx, cy, flags );
return;
return TRUE;
}
done:
release_win_data( data );
return FALSE;
}
/**********************************************************************
* X11DRV_GravityNotify
*/
static void X11DRV_GravityNotify( HWND hwnd, XEvent *xev )
static BOOL X11DRV_GravityNotify( HWND hwnd, XEvent *xev )
{
XGravityEvent *event = &xev->xgravity;
struct x11drv_win_data *data = get_win_data( hwnd );
RECT rect, window_rect;
if (!data) return;
if (!data) return FALSE;
if (data->whole_window) /* only handle this for foreign windows */
{
release_win_data( data );
return;
return FALSE;
}
rect.left = event->x;
......@@ -1171,6 +1181,7 @@ static void X11DRV_GravityNotify( HWND hwnd, XEvent *xev )
if (window_rect.left != rect.left || window_rect.top != rect.top)
SetWindowPos( hwnd, 0, rect.left, rect.top, 0, 0,
SWP_NOSIZE | SWP_NOZORDER | SWP_NOACTIVATE | SWP_NOCOPYBITS );
return TRUE;
}
......@@ -1286,12 +1297,13 @@ done:
/***********************************************************************
* X11DRV_PropertyNotify
*/
static void X11DRV_PropertyNotify( HWND hwnd, XEvent *xev )
static BOOL X11DRV_PropertyNotify( HWND hwnd, XEvent *xev )
{
XPropertyEvent *event = &xev->xproperty;
if (!hwnd) return;
if (!hwnd) return FALSE;
if (event->atom == x11drv_atom(WM_STATE)) handle_wm_state_notify( hwnd, event, TRUE );
return TRUE;
}
......@@ -1719,17 +1731,17 @@ static const struct client_message_handler client_messages[] =
/**********************************************************************
* X11DRV_ClientMessage
*/
static void X11DRV_ClientMessage( HWND hwnd, XEvent *xev )
static BOOL X11DRV_ClientMessage( HWND hwnd, XEvent *xev )
{
XClientMessageEvent *event = &xev->xclient;
unsigned int i;
if (!hwnd) return;
if (!hwnd) return FALSE;
if (event->format != 32)
{
WARN( "Don't know how to handle format %d\n", event->format );
return;
return FALSE;
}
for (i = 0; i < sizeof(client_messages)/sizeof(client_messages[0]); i++)
......@@ -1737,8 +1749,9 @@ static void X11DRV_ClientMessage( HWND hwnd, XEvent *xev )
if (event->message_type == X11DRV_Atoms[client_messages[i].atom - FIRST_XATOM])
{
client_messages[i].handler( hwnd, event );
return;
return TRUE;
}
}
TRACE( "no handler found for %ld\n", event->message_type );
return FALSE;
}
......@@ -1223,7 +1223,7 @@ static void update_key_state( BYTE *keystate, BYTE key, int down )
* from wine to another application and back.
* Toggle keys are handled in HandleEvent.
*/
void X11DRV_KeymapNotify( HWND hwnd, XEvent *event )
BOOL X11DRV_KeymapNotify( HWND hwnd, XEvent *event )
{
int i, j;
BYTE keystate[256];
......@@ -1235,7 +1235,7 @@ void X11DRV_KeymapNotify( HWND hwnd, XEvent *event )
} modifiers[6]; /* VK_LSHIFT through VK_RMENU are contiguous */
BOOL lwin_pressed = FALSE, rwin_pressed = FALSE;
if (!get_async_key_state( keystate )) return;
if (!get_async_key_state( keystate )) return FALSE;
memset(modifiers, 0, sizeof(modifiers));
......@@ -1302,7 +1302,7 @@ void X11DRV_KeymapNotify( HWND hwnd, XEvent *event )
}
LeaveCriticalSection( &kbd_section );
if (!changed) return;
if (!changed) return FALSE;
update_key_state( keystate, VK_CONTROL, (keystate[VK_LCONTROL] | keystate[VK_RCONTROL]) & 0x80 );
update_key_state( keystate, VK_MENU, (keystate[VK_LMENU] | keystate[VK_RMENU]) & 0x80 );
......@@ -1310,6 +1310,7 @@ void X11DRV_KeymapNotify( HWND hwnd, XEvent *event )
update_key_state( keystate, VK_LWIN, keystate[VK_LWIN] & 0x80 );
update_key_state( keystate, VK_RWIN, keystate[VK_RWIN] & 0x80 );
set_async_key_state( keystate );
return TRUE;
}
static void update_lock_state( HWND hwnd, WORD vkey, UINT state, DWORD time )
......@@ -1357,7 +1358,7 @@ static void update_lock_state( HWND hwnd, WORD vkey, UINT state, DWORD time )
*
* Handle a X key event
*/
void X11DRV_KeyEvent( HWND hwnd, XEvent *xev )
BOOL X11DRV_KeyEvent( HWND hwnd, XEvent *xev )
{
XKeyEvent *event = &xev->xkey;
char buf[24];
......@@ -1386,7 +1387,7 @@ void X11DRV_KeyEvent( HWND hwnd, XEvent *xev )
if (Str == NULL)
{
ERR_(key)("Failed to allocate memory!\n");
return;
return FALSE;
}
ascii_chars = XmbLookupString(xic, event, Str, ascii_chars, &keysym, &status);
}
......@@ -1401,7 +1402,7 @@ void X11DRV_KeyEvent( HWND hwnd, XEvent *xev )
X11DRV_XIMLookupChars( Str, ascii_chars );
if (buf != Str)
HeapFree(GetProcessHeap(), 0, Str);
return;
return TRUE;
}
EnterCriticalSection( &kbd_section );
......@@ -1441,7 +1442,7 @@ void X11DRV_KeyEvent( HWND hwnd, XEvent *xev )
LeaveCriticalSection( &kbd_section );
if (!vkey) return;
if (!vkey) return FALSE;
dwFlags = 0;
if ( event->type == KeyRelease ) dwFlags |= KEYEVENTF_KEYUP;
......@@ -1450,6 +1451,7 @@ void X11DRV_KeyEvent( HWND hwnd, XEvent *xev )
update_lock_state( hwnd, vkey, event->state, event_time );
X11DRV_send_keyboard_input( hwnd, vkey & 0xff, bScan, dwFlags, event_time );
return TRUE;
}
/**********************************************************************
......@@ -2008,7 +2010,7 @@ HKL CDECL X11DRV_ActivateKeyboardLayout(HKL hkl, UINT flags)
/***********************************************************************
* X11DRV_MappingNotify
*/
void X11DRV_MappingNotify( HWND dummy, XEvent *event )
BOOL X11DRV_MappingNotify( HWND dummy, XEvent *event )
{
HWND hwnd;
......@@ -2019,6 +2021,7 @@ void X11DRV_MappingNotify( HWND dummy, XEvent *event )
if (!hwnd) hwnd = GetActiveWindow();
PostMessageW(hwnd, WM_INPUTLANGCHANGEREQUEST,
0 /*FIXME*/, (LPARAM)X11DRV_GetKeyboardLayout(0));
return TRUE;
}
......
......@@ -1527,13 +1527,13 @@ void move_resize_window( HWND hwnd, int dir )
/***********************************************************************
* X11DRV_ButtonPress
*/
void X11DRV_ButtonPress( HWND hwnd, XEvent *xev )
BOOL X11DRV_ButtonPress( HWND hwnd, XEvent *xev )
{
XButtonEvent *event = &xev->xbutton;
int buttonNum = event->button - 1;
INPUT input;
if (buttonNum >= NB_BUTTONS) return;
if (buttonNum >= NB_BUTTONS) return FALSE;
TRACE( "hwnd %p/%lx button %u pos %d,%d\n", hwnd, event->window, buttonNum, event->x, event->y );
......@@ -1546,19 +1546,20 @@ void X11DRV_ButtonPress( HWND hwnd, XEvent *xev )
update_user_time( event->time );
send_mouse_input( hwnd, event->window, event->state, &input );
return TRUE;
}
/***********************************************************************
* X11DRV_ButtonRelease
*/
void X11DRV_ButtonRelease( HWND hwnd, XEvent *xev )
BOOL X11DRV_ButtonRelease( HWND hwnd, XEvent *xev )
{
XButtonEvent *event = &xev->xbutton;
int buttonNum = event->button - 1;
INPUT input;
if (buttonNum >= NB_BUTTONS || !button_up_flags[buttonNum]) return;
if (buttonNum >= NB_BUTTONS || !button_up_flags[buttonNum]) return FALSE;
TRACE( "hwnd %p/%lx button %u pos %d,%d\n", hwnd, event->window, buttonNum, event->x, event->y );
......@@ -1570,13 +1571,14 @@ void X11DRV_ButtonRelease( HWND hwnd, XEvent *xev )
input.u.mi.dwExtraInfo = 0;
send_mouse_input( hwnd, event->window, event->state, &input );
return TRUE;
}
/***********************************************************************
* X11DRV_MotionNotify
*/
void X11DRV_MotionNotify( HWND hwnd, XEvent *xev )
BOOL X11DRV_MotionNotify( HWND hwnd, XEvent *xev )
{
XMotionEvent *event = &xev->xmotion;
INPUT input;
......@@ -1594,24 +1596,25 @@ void X11DRV_MotionNotify( HWND hwnd, XEvent *xev )
if (!hwnd && is_old_motion_event( event->serial ))
{
TRACE( "pos %d,%d old serial %lu, ignoring\n", input.u.mi.dx, input.u.mi.dy, event->serial );
return;
return FALSE;
}
send_mouse_input( hwnd, event->window, event->state, &input );
return TRUE;
}
/***********************************************************************
* X11DRV_EnterNotify
*/
void X11DRV_EnterNotify( HWND hwnd, XEvent *xev )
BOOL X11DRV_EnterNotify( HWND hwnd, XEvent *xev )
{
XCrossingEvent *event = &xev->xcrossing;
INPUT input;
TRACE( "hwnd %p/%lx pos %d,%d detail %d\n", hwnd, event->window, event->x, event->y, event->detail );
if (event->detail == NotifyVirtual) return;
if (hwnd == x11drv_thread_data()->grab_hwnd) return;
if (event->detail == NotifyVirtual) return FALSE;
if (hwnd == x11drv_thread_data()->grab_hwnd) return FALSE;
/* simulate a mouse motion event */
input.u.mi.dx = event->x;
......@@ -1624,9 +1627,10 @@ void X11DRV_EnterNotify( HWND hwnd, XEvent *xev )
if (is_old_motion_event( event->serial ))
{
TRACE( "pos %d,%d old serial %lu, ignoring\n", input.u.mi.dx, input.u.mi.dy, event->serial );
return;
return FALSE;
}
send_mouse_input( hwnd, event->window, event->state, &input );
return TRUE;
}
#ifdef HAVE_X11_EXTENSIONS_XINPUT2_H
......@@ -1634,7 +1638,7 @@ void X11DRV_EnterNotify( HWND hwnd, XEvent *xev )
/***********************************************************************
* X11DRV_RawMotion
*/
static void X11DRV_RawMotion( XGenericEventCookie *xev )
static BOOL X11DRV_RawMotion( XGenericEventCookie *xev )
{
XIRawEvent *event = xev->data;
const double *values = event->valuators.values;
......@@ -1645,8 +1649,8 @@ static void X11DRV_RawMotion( XGenericEventCookie *xev )
struct x11drv_thread_data *thread_data = x11drv_thread_data();
XIDeviceInfo *devices = thread_data->xi2_devices;
if (!event->valuators.mask_len) return;
if (thread_data->xi2_state != xi_enabled) return;
if (!event->valuators.mask_len) return FALSE;
if (thread_data->xi2_state != xi_enabled) return FALSE;
input.u.mi.mouseData = 0;
input.u.mi.dwFlags = MOUSEEVENTF_MOVE;
......@@ -1691,13 +1695,14 @@ static void X11DRV_RawMotion( XGenericEventCookie *xev )
if (broken_rawevents && is_old_motion_event( xev->serial ))
{
TRACE( "pos %d,%d old serial %lu, ignoring\n", input.u.mi.dx, input.u.mi.dy, xev->serial );
return;
return FALSE;
}
TRACE( "pos %d,%d (event %f,%f)\n", input.u.mi.dx, input.u.mi.dy, dx, dy );
input.type = INPUT_MOUSE;
__wine_send_input( 0, &input );
return TRUE;
}
#endif /* HAVE_X11_EXTENSIONS_XINPUT2_H */
......@@ -1746,18 +1751,19 @@ void X11DRV_XInput2_Init(void)
/***********************************************************************
* X11DRV_GenericEvent
*/
void X11DRV_GenericEvent( HWND hwnd, XEvent *xev )
BOOL X11DRV_GenericEvent( HWND hwnd, XEvent *xev )
{
BOOL ret = FALSE;
#ifdef HAVE_X11_EXTENSIONS_XINPUT2_H
XGenericEventCookie *event = &xev->xcookie;
if (!event->data) return;
if (event->extension != xinput2_opcode) return;
if (!event->data) return FALSE;
if (event->extension != xinput2_opcode) return FALSE;
switch (event->evtype)
{
case XI_RawMotion:
X11DRV_RawMotion( event );
ret = X11DRV_RawMotion( event );
break;
default:
......@@ -1765,4 +1771,5 @@ void X11DRV_GenericEvent( HWND hwnd, XEvent *xev )
break;
}
#endif
return ret;
}
......@@ -1682,18 +1682,19 @@ void CDECL X11DRV_DestroyWindow( HWND hwnd )
/***********************************************************************
* X11DRV_DestroyNotify
*/
void X11DRV_DestroyNotify( HWND hwnd, XEvent *event )
BOOL X11DRV_DestroyNotify( HWND hwnd, XEvent *event )
{
struct x11drv_win_data *data;
BOOL embedded;
if (!(data = get_win_data( hwnd ))) return;
if (!(data = get_win_data( hwnd ))) return FALSE;
embedded = data->embedded;
if (!embedded) FIXME( "window %p/%lx destroyed from the outside\n", hwnd, data->whole_window );
destroy_whole_window( data, TRUE );
release_win_data( data );
if (embedded) SendMessageW( hwnd, WM_CLOSE, 0, 0 );
return TRUE;
}
......
......@@ -839,13 +839,13 @@ static int cursor_from_device(DWORD deviceid, LPWTI_CURSORS_INFO *cursorp)
return -1;
}
static void motion_event( HWND hwnd, XEvent *event )
static BOOL motion_event( HWND hwnd, XEvent *event )
{
XDeviceMotionEvent *motion = (XDeviceMotionEvent *)event;
LPWTI_CURSORS_INFO cursor;
int curnum = cursor_from_device(motion->deviceid, &cursor);
if (curnum < 0)
return;
return FALSE;
memset(&gMsgPacket,0,sizeof(WTPACKET));
......@@ -866,15 +866,16 @@ static void motion_event( HWND hwnd, XEvent *event )
gMsgPacket.pkNormalPressure = motion->axis_data[2];
gMsgPacket.pkButtons = get_button_state(curnum);
SendMessageW(hwndTabletDefault,WT_PACKET,gMsgPacket.pkSerialNumber,(LPARAM)hwnd);
return TRUE;
}
static void button_event( HWND hwnd, XEvent *event )
static BOOL button_event( HWND hwnd, XEvent *event )
{
XDeviceButtonEvent *button = (XDeviceButtonEvent *) event;
LPWTI_CURSORS_INFO cursor;
int curnum = cursor_from_device(button->deviceid, &cursor);
if (curnum < 0)
return;
return FALSE;
memset(&gMsgPacket,0,sizeof(WTPACKET));
......@@ -895,17 +896,19 @@ static void button_event( HWND hwnd, XEvent *event )
gMsgPacket.pkNormalPressure = button->axis_data[2];
gMsgPacket.pkButtons = get_button_state(curnum);
SendMessageW(hwndTabletDefault,WT_PACKET,gMsgPacket.pkSerialNumber,(LPARAM)hwnd);
return TRUE;
}
static void key_event( HWND hwnd, XEvent *event )
static BOOL key_event( HWND hwnd, XEvent *event )
{
if (event->type == key_press_type)
FIXME("Received tablet key press event\n");
else
FIXME("Received tablet key release event\n");
return FALSE;
}
static void proximity_event( HWND hwnd, XEvent *event )
static BOOL proximity_event( HWND hwnd, XEvent *event )
{
XProximityNotifyEvent *proximity = (XProximityNotifyEvent *) event;
LPWTI_CURSORS_INFO cursor;
......@@ -915,7 +918,7 @@ static void proximity_event( HWND hwnd, XEvent *event )
TRACE("hwnd=%p\n", hwnd);
if (curnum < 0)
return;
return FALSE;
memset(&gMsgPacket,0,sizeof(WTPACKET));
......@@ -944,6 +947,7 @@ static void proximity_event( HWND hwnd, XEvent *event )
proximity_info = MAKELPARAM((event->type == proximity_in_type),
(event->type == proximity_in_type) || (event->type == proximity_out_type));
SendMessageW(hwndTabletDefault, WT_PROXIMITY, (WPARAM)hwnd, proximity_info);
return TRUE;
}
/***********************************************************************
......
......@@ -495,21 +495,21 @@ extern Atom systray_atom DECLSPEC_HIDDEN;
/* X11 event driver */
typedef void (*x11drv_event_handler)( HWND hwnd, XEvent *event );
typedef BOOL (*x11drv_event_handler)( HWND hwnd, XEvent *event );
extern void X11DRV_register_event_handler( int type, x11drv_event_handler handler, const char *name ) DECLSPEC_HIDDEN;
extern void X11DRV_ButtonPress( HWND hwnd, XEvent *event ) DECLSPEC_HIDDEN;
extern void X11DRV_ButtonRelease( HWND hwnd, XEvent *event ) DECLSPEC_HIDDEN;
extern void X11DRV_MotionNotify( HWND hwnd, XEvent *event ) DECLSPEC_HIDDEN;
extern void X11DRV_EnterNotify( HWND hwnd, XEvent *event ) DECLSPEC_HIDDEN;
extern void X11DRV_KeyEvent( HWND hwnd, XEvent *event ) DECLSPEC_HIDDEN;
extern void X11DRV_KeymapNotify( HWND hwnd, XEvent *event ) DECLSPEC_HIDDEN;
extern void X11DRV_DestroyNotify( HWND hwnd, XEvent *event ) DECLSPEC_HIDDEN;
extern void X11DRV_SelectionRequest( HWND hWnd, XEvent *event ) DECLSPEC_HIDDEN;
extern void X11DRV_SelectionClear( HWND hWnd, XEvent *event ) DECLSPEC_HIDDEN;
extern void X11DRV_MappingNotify( HWND hWnd, XEvent *event ) DECLSPEC_HIDDEN;
extern void X11DRV_GenericEvent( HWND hwnd, XEvent *event ) DECLSPEC_HIDDEN;
extern BOOL X11DRV_ButtonPress( HWND hwnd, XEvent *event ) DECLSPEC_HIDDEN;
extern BOOL X11DRV_ButtonRelease( HWND hwnd, XEvent *event ) DECLSPEC_HIDDEN;
extern BOOL X11DRV_MotionNotify( HWND hwnd, XEvent *event ) DECLSPEC_HIDDEN;
extern BOOL X11DRV_EnterNotify( HWND hwnd, XEvent *event ) DECLSPEC_HIDDEN;
extern BOOL X11DRV_KeyEvent( HWND hwnd, XEvent *event ) DECLSPEC_HIDDEN;
extern BOOL X11DRV_KeymapNotify( HWND hwnd, XEvent *event ) DECLSPEC_HIDDEN;
extern BOOL X11DRV_DestroyNotify( HWND hwnd, XEvent *event ) DECLSPEC_HIDDEN;
extern BOOL X11DRV_SelectionRequest( HWND hWnd, XEvent *event ) DECLSPEC_HIDDEN;
extern BOOL X11DRV_SelectionClear( HWND hWnd, XEvent *event ) DECLSPEC_HIDDEN;
extern BOOL X11DRV_MappingNotify( HWND hWnd, XEvent *event ) DECLSPEC_HIDDEN;
extern BOOL X11DRV_GenericEvent( HWND hwnd, XEvent *event ) DECLSPEC_HIDDEN;
extern int xinput2_opcode DECLSPEC_HIDDEN;
extern Bool (*pXGetEventData)( Display *display, XEvent /*XGenericEventCookie*/ *event ) DECLSPEC_HIDDEN;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment