1

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 .

Arun
  • 3,406
  • 4
  • 30
  • 55
rajat
  • 3,415
  • 15
  • 56
  • 90

1 Answers1

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);
rajat
  • 3,415
  • 15
  • 56
  • 90