Why does XWarpPointer only work once?
When I run:
#include <stdio.h>
#include <X11/Xlib.h>
#include <X11/Xutil.h>
#include <X11/Xatom.h>
int main()
{
Display *dpy = XOpenDisplay(0);
while (1) {
Window root_window;
root_window = XRootWindow(dpy, 0);
XSelectInput(dpy, root_window, KeyReleaseMask);
XWarpPointer(dpy, None, root_window, 0, 0, 0, 0, 100, 100);
XSync(dpy, False);
}
}
The mouse should appear locked in a single position. But it only moves the mouse once and then lets me move it around while the loop is still runnning. What is causing the XWarpPointer to only run once? Is it some kind of X11 feature to protect the user from the application?
FYI, I am running RHEL 5.2 on VMWare Fusion on Mac OSX 10.6.
Update:
- When running the binary, components like a button or icon flicker, but the visual mouse cursor stays where I move it.
- After the one time XWarpPointer does work, when I move the mouse, the cursor jumps to near where it was before I warped it. It's as if there is a (last_x,last_y) that is not getting updated.
- When I change the pointer via OpenVMTools it seems to make the pointer stick to the desired location more, but the visual pointer does not change.
Thanks, Chenz
XFlushinstead ofXSyncworks too.