Using the latest xserver from server-1.6 branch, when
XTestFakeRelativeMotionEvent is called with a delay parameter !=
CurrentTime, the client may crash under certain circumstances.  I've
also seen problems with the same symptons on earlier X servers, but I've
never been able to reproduce them.  The replies the server sends seem to
violate some assumptions that libx11/libxcb make, but I'm not familiar
with wire protocol, so I'm not quite sure what it is.  The problem
manifests itself in (at least) three forms:
(1) XNextEvent crashes because _XReadEvents leaves behind an empty queue
(2) _XReply raises an I/O error because there is no reply
(3) process_responses: Assertion `((int) (((dpy->last_request_read)) -
((dpy->request))) <= 0)' failed.

Here's the program that I can use to reproduce the problem.  When the
left mouse button is pressed, it freezes Button1 event processing until
the mouse is released (the freeze doesn't apply to the XInput release
event) and then replays the events.  The XTestFakeRelativeMotionEvent
call is necessary for other clients to be made aware of the current
pointer position, it would be nice if this call wasn't needed, see
http://lists.freedesktop.org/archives/xorg/2009-January/042039.html
The source needs to be manually edited to reflect the device being used.
 The program doesn't demonstrate the problem equally well on all
devices: my track point and my USB mouse exhibit the problem every
single time, my stylus only about every 10th time.

Any pointers how to further debug the issue are appreciated.

Thanks,
Tom
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <X11/extensions/XInput.h>
#include <X11/extensions/XTest.h>

#include <X11/Xutil.h>

Display *dpy;
Window root;

int press, release;

XDevice *dev;
XEventClass events[3];
int all_events_n;

void handle() {
	XEvent ev;
	XNextEvent(dpy, &ev);
	if (ev.type != release)
		return;
	static int i = 1;
	printf("Release %d\n", i++);
	XAllowEvents(dpy, ReplayPointer, CurrentTime);
	XTestFakeRelativeMotionEvent(dpy, 0, 0, 20);
}

void init_xi() {
	int n;
	XDeviceInfo *devs = XListInputDevices(dpy, &n);
	if (!devs)
		exit(EXIT_FAILURE);
	for (int i = 0; i < n; i++) {
//		if (strcmp(devs[i].name, "stylus"))
//		if (strcmp(devs[i].name, "TPPS/2 IBM TrackPoint"))
		if (strcmp(devs[i].name, "Microsoft Microsoft 3-Button Mouse with IntelliEye(TM)"))
			continue;
		dev = XOpenDevice(dpy, devs[i].id);
		break;
	}
	if (!dev)
		exit(EXIT_FAILURE);
	XFreeDeviceList(devs);

	int dummy;
	DeviceButtonPress(dev, press, events[0]);
	DeviceButtonRelease(dev, release, events[1]);
	DeviceMotionNotify(dev, dummy, events[2]);
	all_events_n = 3;
}

int main(int argc, char **argv) {
	dpy = XOpenDisplay(NULL);
	if (!dpy)
		exit(EXIT_FAILURE);
	root = DefaultRootWindow(dpy);

	init_xi();
	XGrabDevice(dpy, dev, root, False, all_events_n, events, GrabModeAsync, GrabModeAsync, CurrentTime);
	XGrabButton(dpy, 1, 0, root, False, ButtonPressMask, GrabModeSync, GrabModeAsync, None, None);
	while (true)
		handle();
}
_______________________________________________
xorg mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/xorg

Reply via email to