创建XLib中的窗口时,
这段代码定义了一个无符号长整型变量valuemask,并将它赋值为CWEventMask、CWBackPixel、CWBorderPixel和CWCursor的按位或操作结果。
- 我需要提供什么掩码来设置
SetWindowAttributes.event_mask
成员? - 我需要传递什么参数到
XCreateWindow()
的第11个参数? - 在主消息循环中,我正在寻找哪些事件(我在其中使用
XNextEvent(lDisplay, &xEvent);
?) - 由于X与微软的Win32 API行为不同,如何确定鼠标是否在我的窗口或我的“应用程序”中的窗口上,而不是在桌面上?
我已经搜索了类似的帖子。如果已经有一个,请指引我正确的方向。
更新
对于那些想要简单回答前三个问题的人:
1.
xAttributes.event_mask = ExposureMask | KeyPressMask | ButtonPress |
StructureNotifyMask | ButtonReleaseMask |
KeyReleaseMask | EnterWindowMask | LeaveWindowMask |
PointerMotionMask | Button1MotionMask | VisibilityChangeMask |
ColormapChangeMask;
2.
unsigned long valuemask = CWEventMask | CWBackPixel | CWBorderPixel | CWCursor;
这段代码定义了一个无符号长整型变量valuemask,并将它赋值为CWEventMask、CWBackPixel、CWBorderPixel和CWCursor的按位或操作结果。
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; }