Hi Peter,

Here's another list of issues I've noticed over the past few weeks and
questions that have come up.

* The server crashes (Xext/xtest.c, line 386) when a virtual XTest is
detached due to a device grab and a client tries to send an event
through that device.  Similarly, removing a master device whose XTest
device is floated due to a grab will result in a crash.

* A related question is what the best way to detect virtual XTest
devices is.  I'm currently checking whether the device name ends in
"Xtst pointer", which seems slightly hackish, but should be fine as long
as the servers keeps using a predictable name for the device.

* I'm seeing random crashes when using the xi2 branch of easystroke that
I can't make any sense of (gdb backtrace attached).  I currently don't
know how to reproduce the issue, but I'll keep you posted as I find out
more.

* The super modifier (Mod4Mask) isn't reported any longer in state field
of core events and passive grabs containing this modifier in their
modifier mask don't work anymore.

* My tablet's valuators (which should be absolute) are reported as
having mode 3 (as opposed to XIModeAbsolute == 1 or XIModeRelative ==
0), which causes xinput to list them as relative devices.

* set_valuators (in dix/getevents.c) seems fishy to me, should this be
i instead of first_valuator + i?

* xinput will crash if remove-master is called with returnMode
AttachToMaster but no further argument.  I've attached two patches that
will return the pointer/keyboard back to the VCP/VCK in this case.  The
first patch assumes that the first pointer/keyboard master device is the
VCP/VCK, the second - slightly simpler - patch identifies VCP and VCK by
name -- I couldn't decide which one is better.

* Since people are likely to turn to xinput for example code, I've also
attached a patch replacing the custom BitIsOn/SetBit macros by the
standard XIMaskIsSet/XISetMask macros.

* xinput's test-xi2 reports incorrect event coordinates.  Patch attached

* Proximity events aren't reported as XI2 events at this points.  This
is not a big deal to me, I'm basically just making sure that you're
aware of this.

* Subpixel coordinates are not working for me.  Glancing through the
code, I think this is to be expected for devices like my tablet whose
device resolution is higher than the screen resolution, but it seems
that this should work for accelerated devices like my trackpoint.  Once
again, not really a big deal.

Thanks,
Tom
(gdb) bt
#0  0x0086b422 in __kernel_vsyscall ()
#1  0x002d46d0 in raise () from /lib/tls/i686/cmov/libc.so.6
#2  0x002d6098 in abort () from /lib/tls/i686/cmov/libc.so.6
#3  0x0031224d in ?? () from /lib/tls/i686/cmov/libc.so.6
#4  0x00318604 in ?? () from /lib/tls/i686/cmov/libc.so.6
#5  0x0031a5b6 in free () from /lib/tls/i686/cmov/libc.so.6
#6  0x080a7a61 in Xfree (ptr=0x0) at ../../os/utils.c:1159
#7  0x08129420 in ProcessOtherEvent (ev=0x944e298, device=0xbec2d38) at 
../../Xi/exevents.c:953
#8  0x08151ec8 in ProcessPointerEvent (ev=0x944e298, mouse=0xbec2d38) at 
../../xkb/xkbAccessX.c:732
#9  0x0809fb05 in mieqProcessDeviceEvent (dev=0xbec2d38, event=0x944e298, 
screen=0x0) at ../../mi/mieq.c:403
#10 0x081056b8 in ProcXTestFakeInput (client=<value optimized out>) at 
../../Xext/xtest.c:418
#11 0x0806cf87 in Dispatch () at ../../dix/dispatch.c:426
#12 0x080674b5 in main (argc=10, argv=0xbff73ac4, envp=0xbff73af0) at 
../../dix/main.c:283
(gdb) print ev->any.type == ET_Raw
$11 = 1
(gdb)
>From 0f46b8a25fba1001b47850763d5de92162bce367 Mon Sep 17 00:00:00 2001
From: Thomas Jaeger <[email protected]>
Date: Sun, 14 Jun 2009 13:58:39 -0400
Subject: [PATCH] reattach: Default to return to VCP/VCK when returnMode is AttachToMaster

Signed-off-by: Thomas Jaeger <[email protected]>
---
 src/hierarchy.c |   39 +++++++++++++++++++++++++++++++++++++--
 src/xinput.c    |    2 +-
 2 files changed, 38 insertions(+), 3 deletions(-)

diff --git a/src/hierarchy.c b/src/hierarchy.c
index cf0f783..18c6710 100644
--- a/src/hierarchy.c
+++ b/src/hierarchy.c
@@ -96,8 +96,43 @@ remove_master(Display* dpy, int argc, char** argv, char *name, char *desc)
 
     if (r.return_mode == XIAttachToMaster)
     {
-        r.return_pointer = atoi(argv[2]);
-        r.return_keyboard = atoi(argv[3]);
+	if (argc >= 3) {
+	    info = xi2_find_device_info(dpy, argv[2]);
+	    if (!info) {
+		fprintf(stderr, "unable to find device %s\n", argv[2]);
+		return EXIT_FAILURE;
+	    }
+
+	    r.return_pointer = info->deviceid;
+	} else {
+	    int i, ndevices;
+	    info = XIQueryDevice(dpy, XIAllDevices, &ndevices);
+	    for(i = 0; i < ndevices; i++)
+		if (info[i].use == XIMasterPointer) {
+		    r.return_pointer = info[i].deviceid;
+		    break;
+		}
+	    XIFreeDeviceInfo(info);
+	}
+
+	if (argc >= 4) {
+	    info = xi2_find_device_info(dpy, argv[3]);
+	    if (!info) {
+		fprintf(stderr, "unable to find device %s\n", argv[3]);
+		return EXIT_FAILURE;
+	    }
+
+	    r.return_keyboard = info->deviceid;
+	} else {
+	    int i, ndevices;
+	    info = XIQueryDevice(dpy, XIAllDevices, &ndevices);
+	    for(i = 0; i < ndevices; i++)
+		if (info[i].use == XIMasterKeyboard) {
+		    r.return_keyboard = info[i].deviceid;
+		    break;
+		}
+	    XIFreeDeviceInfo(info);
+	}
     }
 
     ret = XIChangeHierarchy(dpy, (XIAnyHierarchyChangeInfo*)&r, 1);
diff --git a/src/xinput.c b/src/xinput.c
index 007fe2c..7c47c3c 100644
--- a/src/xinput.c
+++ b/src/xinput.c
@@ -87,7 +87,7 @@ static entry drivers[] =
       create_master
     },
     { "remove-master",
-      "<id> [returnMode (dflt:Floating)] [returnPointer] [returnKeyboard]",
+      "<id> [returnMode (dflt:Floating, AttachToMaster)] [returnPointer] [returnKeyboard]",
       remove_master
     },
     { "reattach",
-- 
1.6.3.1

>From b9b12ba7877a014c8796051a66ce7927aa36ec4b Mon Sep 17 00:00:00 2001
From: Thomas Jaeger <[email protected]>
Date: Sun, 14 Jun 2009 13:58:39 -0400
Subject: [PATCH] reattach: Default to return to VCP/VCK when returnMode is AttachToMaster

Signed-off-by: Thomas Jaeger <[email protected]>
---
 src/hierarchy.c |   19 +++++++++++++++++--
 src/xinput.c    |    2 +-
 2 files changed, 18 insertions(+), 3 deletions(-)

diff --git a/src/hierarchy.c b/src/hierarchy.c
index cf0f783..c27d1f1 100644
--- a/src/hierarchy.c
+++ b/src/hierarchy.c
@@ -96,8 +96,23 @@ remove_master(Display* dpy, int argc, char** argv, char *name, char *desc)
 
     if (r.return_mode == XIAttachToMaster)
     {
-        r.return_pointer = atoi(argv[2]);
-        r.return_keyboard = atoi(argv[3]);
+	char *name;
+
+	name = argc >= 3 ? argv[2] : "Virtual core pointer";
+	info = xi2_find_device_info(dpy, name);
+	if (!info) {
+	    fprintf(stderr, "unable to find device %s\n", name);
+	    return EXIT_FAILURE;
+	}
+	r.return_pointer = info->deviceid;
+
+	name = argc >= 4 ? argv[3] : "Virtual core keyboard";
+	info = xi2_find_device_info(dpy, name);
+	if (!info) {
+	    fprintf(stderr, "unable to find device %s\n", name);
+	    return EXIT_FAILURE;
+	}
+	r.return_keyboard = info->deviceid;
     }
 
     ret = XIChangeHierarchy(dpy, (XIAnyHierarchyChangeInfo*)&r, 1);
diff --git a/src/xinput.c b/src/xinput.c
index 007fe2c..7c47c3c 100644
--- a/src/xinput.c
+++ b/src/xinput.c
@@ -87,7 +87,7 @@ static entry drivers[] =
       create_master
     },
     { "remove-master",
-      "<id> [returnMode (dflt:Floating)] [returnPointer] [returnKeyboard]",
+      "<id> [returnMode (dflt:Floating, AttachToMaster)] [returnPointer] [returnKeyboard]",
       remove_master
     },
     { "reattach",
-- 
1.6.3.1

>From 47a19c1d3a99e255d53c0b40b1bd733b649b56ba Mon Sep 17 00:00:00 2001
From: Thomas Jaeger <[email protected]>
Date: Mon, 15 Jun 2009 21:37:56 -0400
Subject: [PATCH 1/2] test-xi2: Use standard macros instead of BitIsOn/SetBit

Signed-off-by: Thomas Jaeger <[email protected]>
---
 src/test_xi2.c |   47 ++++++++++++++++++++++-------------------------
 1 files changed, 22 insertions(+), 25 deletions(-)

diff --git a/src/test_xi2.c b/src/test_xi2.c
index 8c6175f..32fa3f0 100644
--- a/src/test_xi2.c
+++ b/src/test_xi2.c
@@ -29,9 +29,6 @@
 extern void print_classes_xi2(Display*, XIAnyClassInfo **classes,
                               int num_classes);
 
-#define BitIsOn(ptr, bit) (((unsigned char *) (ptr))[(bit)>>3] & (1 << ((bit) & 7)))
-#define SetBit(ptr, bit)  (((unsigned char *) (ptr))[(bit)>>3] |= (1 << ((bit) & 7)))
-
 static Window create_win(Display *dpy)
 {
     Window win = XCreateSimpleWindow(dpy, DefaultRootWindow(dpy), 0, 0, 200,
@@ -59,7 +56,7 @@ static void print_deviceevent(XIDeviceEvent* event)
 
     printf("    buttons:");
     for (i = 0; i < event->buttons->mask_len * 8; i++)
-        if (BitIsOn(event->buttons->mask, i))
+        if (XIMaskIsSet(event->buttons->mask, i))
             printf(" %d", i);
     printf("\n");
 
@@ -73,7 +70,7 @@ static void print_deviceevent(XIDeviceEvent* event)
 
     val = event->valuators->values;
     for (i = 0; i < event->valuators->mask_len * 8; i++)
-        if (BitIsOn(event->valuators->mask, i))
+        if (XIMaskIsSet(event->valuators->mask, i))
             printf(" %.2f", *val++);
     printf("\n");
 
@@ -147,7 +144,7 @@ static void print_rawevent(XIRawEvent *event)
     val = event->valuators->values;
     raw_val = event->raw_values;
     for (i = 0; i < event->valuators->mask_len * 8; i++)
-        if (BitIsOn(event->valuators->mask, i))
+        if (XIMaskIsSet(event->valuators->mask, i))
             printf("         %2d: %.2f (%.2f)\n", i, *val++, *raw_val++);
     printf("\n");
 }
@@ -182,7 +179,7 @@ static void print_enterleave(XILeaveEvent* event)
                                  event->same_screen ? "[same screen]" : "");
     printf("    buttons:");
     for (i = 0; i < event->buttons->mask_len * 8; i++)
-        if (BitIsOn(event->buttons->mask, i))
+        if (XIMaskIsSet(event->buttons->mask, i))
             printf(" %d", i);
     printf("\n");
 
@@ -224,7 +221,7 @@ test_sync_grab(Display *display, Window win)
     mask.deviceid = XIAllDevices;
     mask.mask_len = 2;
     mask.mask = calloc(2, sizeof(char));
-    SetBit(mask.mask, XI_ButtonPress);
+    XISetMask(mask.mask, XI_ButtonPress);
 
     if ((rc = XIGrabDevice(display, 2,  win, CurrentTime, None, GrabModeSync,
                            GrabModeAsync, False, &mask)) != GrabSuccess)
@@ -277,18 +274,18 @@ test_xi2(Display	*display,
     mask.deviceid = XIAllDevices;
     mask.mask_len = 2;
     mask.mask = calloc(mask.mask_len, sizeof(char));
-    SetBit(mask.mask, XI_ButtonPress);
-    SetBit(mask.mask, XI_ButtonRelease);
-    SetBit(mask.mask, XI_KeyPress);
-    SetBit(mask.mask, XI_KeyRelease);
-    SetBit(mask.mask, XI_Motion);
-    SetBit(mask.mask, XI_DeviceChanged);
-    SetBit(mask.mask, XI_Enter);
-    SetBit(mask.mask, XI_Leave);
-    SetBit(mask.mask, XI_FocusIn);
-    SetBit(mask.mask, XI_FocusOut);
-    SetBit(mask.mask, XI_HierarchyChanged);
-    SetBit(mask.mask, XI_PropertyEvent);
+    XISetMask(mask.mask, XI_ButtonPress);
+    XISetMask(mask.mask, XI_ButtonRelease);
+    XISetMask(mask.mask, XI_KeyPress);
+    XISetMask(mask.mask, XI_KeyRelease);
+    XISetMask(mask.mask, XI_Motion);
+    XISetMask(mask.mask, XI_DeviceChanged);
+    XISetMask(mask.mask, XI_Enter);
+    XISetMask(mask.mask, XI_Leave);
+    XISetMask(mask.mask, XI_FocusIn);
+    XISetMask(mask.mask, XI_FocusOut);
+    XISetMask(mask.mask, XI_HierarchyChanged);
+    XISetMask(mask.mask, XI_PropertyEvent);
     XISelectEvents(display, win, &mask, 1);
     XSync(display, False);
 
@@ -298,10 +295,10 @@ test_xi2(Display	*display,
 
         mask.deviceid = 2;
         memset(mask.mask, 0, 2);
-        SetBit(mask.mask, XI_KeyPress);
-        SetBit(mask.mask, XI_KeyRelease);
-        SetBit(mask.mask, XI_ButtonPress);
-        SetBit(mask.mask, XI_Motion);
+        XISetMask(mask.mask, XI_KeyPress);
+        XISetMask(mask.mask, XI_KeyRelease);
+        XISetMask(mask.mask, XI_ButtonPress);
+        XISetMask(mask.mask, XI_Motion);
         XIGrabButton(display, 2, 1, win, None, GrabModeAsync, GrabModeAsync,
                 False, &mask, nmods, modifiers);
         XIGrabKeysym(display, 3, 0x71, win, GrabModeAsync, GrabModeAsync,
@@ -312,7 +309,7 @@ test_xi2(Display	*display,
 
     mask.deviceid = XIAllMasterDevices;
     memset(mask.mask, 0, 2);
-    SetBit(mask.mask, XI_RawEvent);
+    XISetMask(mask.mask, XI_RawEvent);
     XISelectEvents(display, DefaultRootWindow(display), &mask, 1);
 
     free(mask.mask);
-- 
1.6.3.1

>From 9d8d70b78dde06ab11ade7f9fcf0166d25d66707 Mon Sep 17 00:00:00 2001
From: Thomas Jaeger <[email protected]>
Date: Mon, 15 Jun 2009 21:45:32 -0400
Subject: [PATCH 2/2] test-xi2: Report correct event coordinates

Signed-off-by: Thomas Jaeger <[email protected]>
---
 src/test_xi2.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/src/test_xi2.c b/src/test_xi2.c
index 32fa3f0..b4f4dc1 100644
--- a/src/test_xi2.c
+++ b/src/test_xi2.c
@@ -52,7 +52,7 @@ static void print_deviceevent(XIDeviceEvent* event)
     printf("    detail: %d\n", event->detail);
 
     printf("    root: %.2f/%.2f\n", event->root_x, event->root_y);
-    printf("    event: %.2f/%.2f\n", event->event_x, event->event_x);
+    printf("    event: %.2f/%.2f\n", event->event_x, event->event_y);
 
     printf("    buttons:");
     for (i = 0; i < event->buttons->mask_len * 8; i++)
-- 
1.6.3.1

_______________________________________________
xorg-devel mailing list
[email protected]
http://lists.x.org/mailman/listinfo/xorg-devel

Reply via email to