events: Don't use XIEvent serial numbers

XInput2 uses the raw sequence number for XIEvent serials[0], which only
matches the serial number in XEvents up to 16 bits[1]. So in order to
be able to make reliable comparisons with serials from other events or
calls to XNextRequest(), always use the field from the original XEvent
rather than the XIEvent serial (at least until we can get libXi fixed).

This (partially) reverts commit 35dd1e644d.

[0] http://cgit.freedesktop.org/xorg/lib/libXi/commit?id=5d43d4914dcabb6d
[1] http://cgit.freedesktop.org/xorg/lib/libX11/tree/src/XlibInt.c#n265

https://bugzilla.gnome.org/show_bug.cgi?id=756649
This commit is contained in:
Florian Müllner 2015-07-09 17:39:05 +02:00
parent a95ae4d178
commit 3a63d58d9e

View File

@ -691,7 +691,8 @@ meta_spew_event_print (MetaDisplay *display,
static gboolean static gboolean
handle_window_focus_event (MetaDisplay *display, handle_window_focus_event (MetaDisplay *display,
MetaWindow *window, MetaWindow *window,
XIEnterEvent *event) XIEnterEvent *event,
unsigned long serial)
{ {
MetaWindow *focus_window; MetaWindow *focus_window;
#ifdef WITH_VERBOSE_MODE #ifdef WITH_VERBOSE_MODE
@ -726,7 +727,7 @@ handle_window_focus_event (MetaDisplay *display,
event->event, window_type, event->event, window_type,
meta_event_mode_to_string (event->mode), meta_event_mode_to_string (event->mode),
meta_event_detail_to_string (event->mode), meta_event_detail_to_string (event->mode),
event->serial); serial);
#endif #endif
/* FIXME our pointer tracking is broken; see how /* FIXME our pointer tracking is broken; see how
@ -770,7 +771,7 @@ handle_window_focus_event (MetaDisplay *display,
if (event->evtype == XI_FocusIn) if (event->evtype == XI_FocusIn)
{ {
display->server_focus_window = event->event; display->server_focus_window = event->event;
display->server_focus_serial = event->serial; display->server_focus_serial = serial;
focus_window = window; focus_window = window;
} }
else if (event->evtype == XI_FocusOut) else if (event->evtype == XI_FocusOut)
@ -784,7 +785,7 @@ handle_window_focus_event (MetaDisplay *display,
} }
display->server_focus_window = None; display->server_focus_window = None;
display->server_focus_serial = event->serial; display->server_focus_serial = serial;
focus_window = NULL; focus_window = NULL;
} }
else else
@ -829,8 +830,9 @@ crossing_serial_is_ignored (MetaDisplay *display,
} }
static gboolean static gboolean
handle_input_xevent (MetaDisplay *display, handle_input_xevent (MetaDisplay *display,
XIEvent *input_event) XIEvent *input_event,
unsigned long serial)
{ {
XIEnterEvent *enter_event = (XIEnterEvent *) input_event; XIEnterEvent *enter_event = (XIEnterEvent *) input_event;
Window modified; Window modified;
@ -867,7 +869,7 @@ handle_input_xevent (MetaDisplay *display,
/* Check if we've entered a window; do this even if window->has_focus to /* Check if we've entered a window; do this even if window->has_focus to
* avoid races. * avoid races.
*/ */
if (window && !crossing_serial_is_ignored (display, input_event->serial) && if (window && !crossing_serial_is_ignored (display, serial) &&
enter_event->mode != XINotifyGrab && enter_event->mode != XINotifyGrab &&
enter_event->mode != XINotifyUngrab && enter_event->mode != XINotifyUngrab &&
enter_event->detail != XINotifyInferior && enter_event->detail != XINotifyInferior &&
@ -892,7 +894,7 @@ handle_input_xevent (MetaDisplay *display,
break; break;
case XI_FocusIn: case XI_FocusIn:
case XI_FocusOut: case XI_FocusOut:
if (handle_window_focus_event (display, window, enter_event) && if (handle_window_focus_event (display, window, enter_event, serial) &&
enter_event->event == enter_event->root) enter_event->event == enter_event->root)
{ {
if (enter_event->evtype == XI_FocusIn && if (enter_event->evtype == XI_FocusIn &&
@ -1736,7 +1738,7 @@ meta_display_handle_xevent (MetaDisplay *display,
} }
#endif /* HAVE_XI23 */ #endif /* HAVE_XI23 */
if (handle_input_xevent (display, input_event)) if (handle_input_xevent (display, input_event, event->xany.serial))
{ {
bypass_gtk = bypass_compositor = TRUE; bypass_gtk = bypass_compositor = TRUE;
goto out; goto out;