1

我想在 C++ 中检测鼠标右键按下。我在 Linux 操作系统中编程。

我尝试为我的项目使用 XGrabPointer(display, root_win, False,ButtonPressMask, GrabModeSync, GrabModeSync, root_win, None, CurrentTime)XWindowEvent(display, root_win, ButtonPressMask , &report)运行,但没有答案。

我的代码是:

Display* display = NULL;
display = XOpenDisplay(NULL);
Screen *screen; Window root_win;
XEvent report;
int screen_num;
int check;

screen_num = DefaultScreen(display);
screen = XScreenOfDisplay(display, screen_num);
root_win = RootWindow(display, XScreenNumberOfScreen(screen));
check = XGrabPointer(display, root_win, False,ButtonPressMask, GrabModeSync, GrabModeSync, root_win, None, CurrentTime);
XAllowEvents(display, SyncPointer, CurrentTime); XWindowEvent(display, root_win, ButtonPressMask , &report);  
4

1 回答 1

1

您最常使用 x11 库。它非常简单(http://www.wikihow.com/Configure-X11-in-Linux

于 2013-09-16T08:44:21.113 回答