rajat
rajat

Reputation: 3553

Stop interaction of mouse with the desktop in linux

i want to take input of co-ordinates from a mouse when left mouse button is pressed for some experiment , but it interacts with the stuff on the desktop and messes up things . Is there anyway to stop mouse from interacting with objects , like disable mouse click or something like that .

PS:I already have X11 connection to X server , i am using XQuerryPointer to get the co-ordinates, this application is windowless which outputs stuff on the terminal .

Upvotes: 0

Views: 191

Answers (1)

DThought
DThought

Reputation: 1314

I assume http://tronche.com/gui/x/xlib/input/XGrabPointer.html can do what you want. To receive the input coordinates I assume you already got an X11 connection to the X Server?

Ok, here is the code that works.

Display *dpy;
dpy = XOpenDisplay(NULL);
int g=XGrabPointer(dpy,DefaultRootWindow(dpy), true, ButtonPressMask |
                 ButtonReleaseMask |
                 PointerMotionMask |
                 FocusChangeMask |
                EnterWindowMask |
                  LeaveWindowMask,GrabModeAsync,GrabModeAsync, None, None, CurrentTime);

Upvotes: 1

Related Questions