[PATCH XTS 2/2] xts5: fix XSetDeviceFocus-5

Peter Hutterer peter.hutterer at who-t.net
Wed Jan 4 21:02:26 PST 2012

t003() selects for key events on the root window. t005() takes over and then
complains when the focus correctly follows the pointer and an event is
delivered to the root window. If you don't expect events on the root window,
unselect them first.

Submitting a NULL mask to XSelectExtensionEvents doesn't work, so we need to
get the correct zero mask for our device. Take a known class and unset the last
8 bits since an XEventClass is defined as (deviceid << 8 | event type). But you
knew that, anyway.

We could also XCloseDisplay() at the end of each test but who knows what that
does to the other tests.

Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
 xts5/XI/XSetDeviceFocus.m |    4 ++++
 1 files changed, 4 insertions(+), 0 deletions(-)

diff --git a/xts5/XI/XSetDeviceFocus.m b/xts5/XI/XSetDeviceFocus.m
index be42090..ecaf305 100644
--- a/xts5/XI/XSetDeviceFocus.m
+++ b/xts5/XI/XSetDeviceFocus.m
@@ -430,6 +430,7 @@ XEvent	ev;
 int	n, sav_revert;
 int	dkp, dkr;
 XEventClass classes[2];
+XEventClass none_class;
 	if (noext(0))
@@ -446,6 +447,9 @@ XEventClass classes[2];
 	DeviceKeyRelease(device, dkr, classes[1]);
 	win = defwin(display);
 	XSelectExtensionEvent(display, win, classes, 2);
+	/* previous test selected for events on the root window */
+	none_class = classes[0] & ~0xFF;
+	XSelectExtensionEvent(display, DRW(display), &none_class, 1);
 	focus = FollowKeyboard;

More information about the xorg-devel mailing list