【发布时间】:2012-02-20 07:06:58
【问题描述】:
在 XLib 中创建窗口时
- 我提供给
SetWindowAttributes.event_mask成员的掩码是什么? - 我必须将什么传递给
XCreateWindow()的第 11 个参数 - 我在主消息循环中寻找哪些事件(我在哪里使用
XNextEvent(lDisplay, &xEvent);? - 由于 X 的行为与 Microsoft 的 Win32 API 不同,我如何确定鼠标是在我的窗口上还是在我的“应用程序”中的窗口上而不是在桌面上?
我在寻找类似的帖子。如果已经有一个,请指出正确的方向。
更新
对于那些想要简单回答第 1-3 部分的人:
1.
xAttributes.event_mask = ExposureMask | KeyPressMask | ButtonPress |
StructureNotifyMask | ButtonReleaseMask |
KeyReleaseMask | EnterWindowMask | LeaveWindowMask |
PointerMotionMask | Button1MotionMask | VisibilityChangeMask |
ColormapChangeMask;
2.
unsigned long 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; }
【问题讨论】:
-
XLib 有很好的文档记录。你试过在网上搜索吗?例如XLib Programming Manual: Event Masks
标签: c linux x11 xlib mousemove