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