How to fake a motion and press event ?

Wang Baisheng baisheng.wang.cn at gmail.com
Mon Nov 26 16:42:26 PST 2007


On Friday 23 November 2007 02:44:16 pm Glynn Clements wrote:
> 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.


Yes. 
But I have found the new strange clue that when I set the resolution to 
800x600, everything is ok, while I set the resolustion to 800x480, the motion 
event will be lost, how strange !

BRs,
Baisheng



More information about the xorg mailing list