在XLib中创建窗口时
-
我为
SetWindowAttributes.event_mask
会员提供的面具是什么? -
我需要传递给
XCreateWindow()
的第11个参数 -
我在主消息循环中寻找的事件是什么(我在哪里使用
XNextEvent(lDisplay, &xEvent);
? -
由于X的行为与Microsoft的Win32 API不同,如何确定鼠标是在我的窗口上还是在我的"Application"窗口而不是在桌面上?
我找了一个类似的帖子 . 如果那里已经有一个,请指出我正确的方向 .
Update
对于那些想要轻松回答第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;
}
2 回答
XLib有很好的记录 . 例如XLib Programming Manual: Event Masks
我认为前三个是有据可查的 .
要确定鼠标是否在窗口上,请收听Enter and Leave事件 .
xev
实用程序是了解X窗口系统中存在哪些事件以及何时发送它们的好方法 .