我想在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);