c/c++语言开发共享xlib – 打印事件名称

所以我有一个用xlib创建的标准窗口来处理事件:

while (keep_running){ XNextEvent (display, &event); printf("eventn"); } 

现在它似乎没有调用expose事件,所以我无法在窗口中绘制。 我可以通过print语句看到有些事件被解雇了,我想知道它们是什么事件。

所以基本上我的问题是,如何才能将事件名称打印出来?

我还在学习C,所以任何帮助都是适合的!

    所以我不完全同意他们的设计决定,但它可能是在30年前制作的,所以现在不是星期一早上四分卫的时候……

    这种类型是一个疯狂的联盟:

     typedef union _XEvent { int type; /* must not be changed */ XAnyEvent xany; XKeyEvent xkey; XButtonEvent xbutton; XMotionEvent xmotion; XCrossingEvent xcrossing; XFocusChangeEvent xfocus; XExposeEvent xexpose; XGraphicsExposeEvent xgraphicsexpose; XNoExposeEvent xnoexpose; XVisibilityEvent xvisibility; XCreateWindowEvent xcreatewindow; XDestroyWindowEvent xdestroywindow; XUnmapEvent xunmap; XMapEvent xmap; XMapRequestEvent xmaprequest; XReparentEvent xreparent; XConfigureEvent xconfigure; XGravityEvent xgravity; XResizeRequestEvent xresizerequest; XConfigureRequestEvent xconfigurerequest; XCirculateEvent xcirculate; XCirculateRequestEvent xcirculaterequest; XPropertyEvent xproperty; XSelectionClearEvent xselectionclear; XSelectionRequestEvent xselectionrequest; XSelectionEvent xselection; XColormapEvent xcolormap; XClientMessageEvent xclient; XMappingEvent xmapping; XErrorEvent xerror; XKeymapEvent xkeymap; long pad[24]; } Event; 

    因此,您必须首先使用该类型来确定正在使用的事件:

     if(event.type == KeyPress) { printf("keypressn"); // now you know the type you can use the specific fields from `XKeyEvent xkey`... } 

    或者您可以只记录类型

     printf("event type = (%d)n",event.type); 

    联合起作用,因为每个其他可能的元素也有类型作为第一个元素,所以它们都排在同一个地址上……

      以上就是c/c++开发分享xlib – 打印事件名称相关内容,想了解更多C/C++开发(异常处理)及C/C++游戏开发关注计算机技术网(www.ctvol.com)!)。

      本文来自网络收集,不代表计算机技术网立场,如涉及侵权请联系管理员删除。

      ctvol管理联系方式QQ:251552304

      本文章地址:https://www.ctvol.com/c-cdevelopment/519695.html

      (0)
      上一篇 2020年12月5日
      下一篇 2020年12月5日

      精彩推荐