在Linux中使用xGrabPointer锁定鼠标指针 [英] Locking mouse pointer using xGrabPointer in Linux

查看:786
本文介绍了在Linux中使用xGrabPointer锁定鼠标指针的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用X11来获取在没有任何窗口的终端上运行的应用程序中按下鼠标按钮时的鼠标位置.

I am using X11 to get mouse position when the mouse button is pressed in a application which runs on terminal without any window.

获取鼠标位置:

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);

现在,我想使用XGrabPointer()锁定鼠标,以使其不与桌面上存在的对象(窗口,图标和底座)交互. 此处是XGrabPointer的文档,但我似乎不太明白如何使用它,传递什么参数.

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 .

推荐答案

这是似乎对我有用的正确格式.

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);

这篇关于在Linux中使用xGrabPointer锁定鼠标指针的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆