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;
}
......@@ -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