X11鼠标移动事件 [英] X11 Mouse Movement Event
本文介绍了X11鼠标移动事件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在XLib中创建窗口时
When creating a Window in XLib
- 我为
SetWindowAttributes.event_mask
成员提供哪些遮罩? - 我要传递给
XCreateWindow()
的第11个参数什么? - 我在主消息循环中正在寻找什么事件(我在哪里使用
XNextEvent(lDisplay, &xEvent);
? - 由于X的行为不同于Microsoft的Win32 API,我如何确定鼠标是在我的窗口上还是在应用程序"中的窗口上而不是在桌面上?
- What are the masks I provide to the
SetWindowAttributes.event_mask
member? - What do I have to pass to the 11th paramater of
XCreateWindow()
- What are the Events I am looking for in the main message loop (Where I use
XNextEvent(lDisplay, &xEvent);
? - Since X behaves differently than Microsoft's Win32 API, how do I determine if the mouse is over my window or a window in my "Application" and not over the desktop?
我正在寻找类似的帖子.如果已经有一个,请指出正确的方向.
I have looked for a similar post. If there is already one out there please point me in the right direction.
更新
对于那些希望轻松回答第1-3部分的人:
For those who want the easy answer to parts 1-3:
1.
xAttributes.event_mask = ExposureMask | KeyPressMask | ButtonPress |
StructureNotifyMask | ButtonReleaseMask |
KeyReleaseMask | EnterWindowMask | LeaveWindowMask |
PointerMotionMask | Button1MotionMask | VisibilityChangeMask |
ColormapChangeMask;
2.
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编程手册:事件掩码
XLib is pretty well documented. For example XLib Programming Manual: Event Masks
这篇关于X11鼠标移动事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文