From 3a63d58d9e2cbf63deb6a2a6cdbba13815bd5c31 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20M=C3=BCllner?= Date: Thu, 9 Jul 2015 17:39:05 +0200 Subject: [PATCH] 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 35dd1e644dbc238. [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 --- src/x11/events.c | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/src/x11/events.c b/src/x11/events.c index f70838b12..11f5159d5 100644 --- a/src/x11/events.c +++ b/src/x11/events.c @@ -691,7 +691,8 @@ meta_spew_event_print (MetaDisplay *display, static gboolean handle_window_focus_event (MetaDisplay *display, MetaWindow *window, - XIEnterEvent *event) + XIEnterEvent *event, + unsigned long serial) { MetaWindow *focus_window; #ifdef WITH_VERBOSE_MODE @@ -726,7 +727,7 @@ handle_window_focus_event (MetaDisplay *display, event->event, window_type, meta_event_mode_to_string (event->mode), meta_event_detail_to_string (event->mode), - event->serial); + serial); #endif /* FIXME our pointer tracking is broken; see how @@ -770,7 +771,7 @@ handle_window_focus_event (MetaDisplay *display, if (event->evtype == XI_FocusIn) { display->server_focus_window = event->event; - display->server_focus_serial = event->serial; + display->server_focus_serial = serial; focus_window = window; } else if (event->evtype == XI_FocusOut) @@ -784,7 +785,7 @@ handle_window_focus_event (MetaDisplay *display, } display->server_focus_window = None; - display->server_focus_serial = event->serial; + display->server_focus_serial = serial; focus_window = NULL; } else @@ -829,8 +830,9 @@ crossing_serial_is_ignored (MetaDisplay *display, } static gboolean -handle_input_xevent (MetaDisplay *display, - XIEvent *input_event) +handle_input_xevent (MetaDisplay *display, + XIEvent *input_event, + unsigned long serial) { XIEnterEvent *enter_event = (XIEnterEvent *) input_event; 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 * 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 != XINotifyUngrab && enter_event->detail != XINotifyInferior && @@ -892,7 +894,7 @@ handle_input_xevent (MetaDisplay *display, break; case XI_FocusIn: 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) { if (enter_event->evtype == XI_FocusIn && @@ -1736,7 +1738,7 @@ meta_display_handle_xevent (MetaDisplay *display, } #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; goto out;