问题
I am using X11
to get mouse position when the mouse button is pressed in a application which runs on terminal without any window.
Getting Mouse Position :
Display *dpy;
Window root, child;
int rootX, rootY, winX, winY;
unsigned int mask;
dpy = XOpenDisplay(NULL);
XQueryPointer(dpy,DefaultRootWindow(dpy),&root,&child,
&rootX,&rootY,&winX,&winY,&mask);
Now I want to use XGrabPointer()
to lock the mouse so that it does not interact with objects(windows , icons and docks ) present on desktop . here is the documentation of XGrabPointer , but I don't seem to understand how to use it and what arguments to pass .
回答1:
This is the correct format that seems to work for me .
int g=XGrabPointer(dpy,DefaultRootWindow(dpy), true, ButtonPressMask |
ButtonReleaseMask |
PointerMotionMask |
FocusChangeMask |
EnterWindowMask |
LeaveWindowMask,GrabModeAsync,GrabModeAsync, None, None, CurrentTime);
来源:https://stackoverflow.com/questions/12072886/locking-mouse-pointer-using-xgrabpointer-in-linux