使用下面的链接查看函数void kGUISystemX :: Loop(void)
这是我在Linux上使用X Windows通过键盘和鼠标获取输入的主要循环.
这是一个片段:
if(XPending(m_display))
{
XNextEvent(m_display, &m_e);
switch(m_e.type)
{
case MotionNotify:
m_mousex=m_e.xmotion.x;
m_mousey=m_e.xmotion.y;
break;
case ButtonPress:
switch(m_e.xbutton.button)
{
case Button1:
m_mouseleft=true;
break;
case Button3:
m_mouseright=true;
break;
case Button4:/* middle mouse wheel moved */
m_mousewheel=1;
break;
case Button5:/* middle mouse wheel moved */
m_mousewheel=-1;
break;
}
break;
case ButtonRelease:
switch(m_e.xbutton.button)
{
case Button1:
m_mouseleft=false;
break;
case Button3:
m_mouseright=false;
break;
}
break;
case KeyPress:
{
XKeyEvent *ke;
int ks;
int key;
ke=&m_e.xkey;
kGUI::SetKeyShift((ke->state&ShiftMask)!=0);
kGUI::SetKeyControl((ke->state&ControlMask)!=0);
ks=XLookupKeysym(ke,(ke->state&ShiftMask)?1:0);
......