How to fake a motion and press event ?

Wang Baisheng at
Fri Nov 23 15:30:15 PST 2007

        I want to fake a x event, just as we select some text in the text 
entry using 
drag mouse, so I use the Xtst, the code is following:

        XTestFakeMotionEvent(xdpy, 0, 50, 100, CurrentTime);
        XTestFakeButtonEvent(xdpy, 1, True, CurrentTime);
        XTestFakeMotionEvent(xdpy, 0, 100, 2000, CurrentTime);
        XTestFakeButtonEvent(xdpy, 1, False, CurrentTime);
        XSync(xdpy, FALSE);

        But I have found the above fragment works on some computer, and on 
computer it dosn't work at all.

        I intercept the the gtk event loop and printf the event type. I have 
that in the computer not working, the gtk doesn't receive motion event at all 
and only receives press and release button event, while in the working 
computer, the gtk receives press, motion, release event.

        So if you have some experience, please give me some advice.

        Thank you!

More information about the xorg mailing list