X11鼠标移动事件

Mat*_*gan 5 c linux x11 xlib mousemove

在XLib中创建窗口时

  1. 我为SetWindowAttributes.event_mask会员提供的口罩是什么?
  2. 我有什么要传递给第11个参赛者 XCreateWindow()
  3. 我在主消息循环中寻找的事件是什么(我在哪里使用XNextEvent(lDisplay, &xEvent);
  4. 由于X的行为与Microsoft的Win32 API不同,如何确定鼠标是在我的"应用程序"中的窗口还是窗口上,而不是在桌面上?

我找了一个类似的帖子.如果那里已经有一个,请指出我正确的方向.


更新

对于那些想要轻松回答第1-3部分的人:

1.

xAttributes.event_mask =  ExposureMask | KeyPressMask | ButtonPress |
                          StructureNotifyMask | ButtonReleaseMask |
                          KeyReleaseMask | EnterWindowMask | LeaveWindowMask |
                          PointerMotionMask | Button1MotionMask | VisibilityChangeMask |
                          ColormapChangeMask;
Run Code Online (Sandbox Code Playgroud)

2.

unsigned long valuemask = CWEventMask | CWBackPixel | CWBorderPixel | CWCursor;


  1.                 switch (xEvent.type)
                    {
                    case MapNotify:
                        break;
                    case Expose:
                        // If this is not the last expose event break
                        if (xEvent.xexpose.count != 0)
                            break;
                        else
                            break;
                    case ConfigureNotify:
                        break;
                    case VisibilityNotify:
                        break;
                    case DestroyNotify:
                        break;
                    case ButtonPress:
                    case ButtonRelease:
                    case EnterNotify:
                    case MotionNotify:
                    case LeaveNotify:
                        if(_mouseHandler)
                            _mouseHandler->HandleInput(lDisplay, &xEvent);
                        break;
                    case KeyPress:
                    case KeyRelease:
                        if(_keyboardHandler)
                            _keyboardHandler->HandleInput(lDisplay, &xEvent);
                        break;
                    default:
                        if(_keyboardHandler)
                            _keyboardHandler->HandleInput(lDisplay, &xEvent);
                        break;
                    }
    
    Run Code Online (Sandbox Code Playgroud)

Jim*_*son 4

XLib 有很好的文档记录。例如XLib 编程手册:事件掩码