How to fake a motion and press event ?

Glynn Clements glynn at gclements.plus.com
Fri Nov 23 11:44:16 PST 2007


Wang Baisheng wrote:

>         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 
> others 
> computer it dosn't work at all.
> 
>         I intercept the the gtk event loop and printf the event type. I have 
> found 
> 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.

Have both applications selected motion events on the window? The X
server only reports events which are selected by the window's event
mask.

-- 
Glynn Clements <glynn at gclements.plus.com>



More information about the xorg mailing list