XWarpPointer seems doesn't work properly.
Peter Hutterer
peter.hutterer at who-t.net
Tue Jan 22 23:18:37 PST 2013
On Wed, Jan 23, 2013 at 12:46:48AM +0000, Asano, Yasushi wrote:
> Hello,
> I have a problem with XWarpPointer. It seems doesn't work properly.
> After startx, I don't move the mouse. and then I run a program which should move the mouse pointer around the screen (in absolute coordinates) as below WITHOUT moving the mouse cursor.
> (I use keyboard shortcut to run program.)
> However, visual mouse cursor jumped to a single position (x=0,y=0) on the screen and stay there permanently until the program is finished.
>
> The program seems work properly judging from message as below. but visual mouse cursor is locked to a same position (x=0, y=0) on the screen.
>
> XWarpPointer(): x= 0, y= 0
> XWarpPointer(): x= 100, y= 100
> XWarpPointer(): x= 200, y= 200
> XWarpPointer(): x= 300, y= 300
> XWarpPointer(): x= 400, y= 400
> XWarpPointer(): x= 500, y= 500
> XWarpPointer(): x= 600, y= 600
> XWarpPointer(): x= 700, y= 700
>
> If I move the mouse cursor before I run the program, XWarpPointer works. visual mouse cursor move correctly.
> What is causing the XWarpPointer to only run once? Is it some kind of X11 feature to protect the user from the application?
>
> I'm running into an issue on xorg-server 1.8.2 and libX11 1.3.1.
> However, I could see a same problem with xorg on Fedora17(xorg-server 1.12.0 and libX11 1.4.99).
> Could you please suggest me how can I solve this problem?
>
> Lastly, I found similar problem on website.
> http://stackoverflow.com/questions/5848909/why-does-xwarppointer-only-work-once-while-in-a-loop
> but It seems this issue has not yet been solved.
>
> Thank you for your time and assistance regarding this matter.
> ----------------------------------------------------------------------------------------------
> #include <stdio.h>
> #include <unistd.h>
> #include <X11/X.h>
> #include <X11/Xlib.h>
> #include <X11/Xutil.h>
>
> int main(int argc, char *argv[]){
> //Get system window
> Display *dpy;
> Window root_window;
> int x,y;
>
> dpy = XOpenDisplay(0);
> root_window = XRootWindow(dpy, 0);
> XSelectInput(dpy, root_window, KeyReleaseMask);
>
> for (x=0,y=0; y<768; x+=100,y+=100) {
> sleep(1);
> printf("XWarpPointer(): x=%5d, y=%5d\n", x, y);
> XWarpPointer(dpy, None, root_window, 0, 0, 0, 0, x, y);
> XFlush(dpy);
> //XSync(dpy, False); <-- no difference
XSync is good to force the server to process the request, otherwise multiple
XWarpPointer requests may be stuck in Xlib's output queue and never reach
the server. It does not, however, make a difference here as you're already
calling XFlush(). And passing true/false merely decides whether events
are discarded, but doesn't affect the server's processing.
having said this, it appears to work fine on current git and I tried 1.12.0
as well where this works and I can see the pointer moving across the screen.
fwiw, this isn't an issue of whether it runs once, if anything the pointer
update on the screen is incorrect. you can verify this by running xev, you
should see the events with the right coordinates even if the visible pointer
doesn't update. But then again, it seems to work just fine here.
Cheers,
Peter
More information about the xorg
mailing list