如何检测鼠标右键按?

时间:2013-05-09 06:14:30

标签: c++ linux mouse

我想在c ++中检测鼠标右键。我在Linux OS中编程。

我尝试将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);  

1 个答案:

答案 0 :(得分:1)

你最常用的是x11 library.it非常简单 (http://www.wikihow.com/Configure-X11-in-Linux