从Xlib转换为xcb [英] Convert from Xlib to xcb

查看:89
本文介绍了从Xlib转换为xcb的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前正在将我的一个应用程序从Xlib移植到libxcb,并且在某些时候查找有关我使用的XInput2扩展的信息时遇到了一些麻烦.libxcb中是否有XInput2实现?如果是,我在哪里可以找到文档.

I am currently porting one of my applications from Xlib to libxcb and I am having a bit trouble finding informations on the XInput2 extension I use at some point. Is there an XInput2 implementation in libxcb? If yes, where can I find the documentation.

目前,我在使用以下功能方面遇到麻烦: XIQueryDevice XISelectEvents .这些主要是我使用的功能.

Currently I am having trouble for example with this functions: XIQueryDevice, XISelectEvents. These are mainly the functions I use.

也许有人可以为我指出文档,或者为我提供一个很小的例子来开始.

Maybe someone can point out the documentation for me or provide me a very small example to get started.

推荐答案

您基本上有2个选择:

调用常规的 XI * Xinput2函数,并在具有常规事件的事件循环中轮询它们.事件循环可能类似于以下内容:

Call the regular XI* Xinput2 functions and poll them in your event loop with a generic event. A event loop would probably look like similar to this:

xcb_generic_event_t *event;
while ((event = xcb_wait_for_event(connection))) {
    xcb_ge_generic_event_t *generic_event = (xcb_ge_generic_event_t*)event;
    if (generic_event->response_type == XCB_GE_GENERIC && generic_event->extension == xinput_ext_opcode && generic_event->event_type == XI_RawMotion) {
        // Handle motion
        continue;
    }
}

还请查看 XCB协议扩展API .

您可以使用 xcb_input _ * xcb-xinput扩展功能.根据官方文档:

You can use the xcb_input_* xcb-xinput extension functions. According to the official documentation:

当XCB将其API样式添加到组合中时,它遵循较新的样式,并为每个扩展创建了一个以"libxcb"为前缀的库--libxcb-composite,libxcb-render等.由于XCB可以生成API代码对于自动从扩展协议的XML描述进行扩展的扩展,只需将扩展描述添加到xcb-proto包中并进行重建,即可创建新的扩展API.

When XCB added its API style to the mix, it followed the newer style and created a "libxcb"-prefixed library for each extension---libxcb-composite, libxcb-render, etc. Since XCB can generates the API code for an extension automatically from an XML description of the extension protocol, new extension API's are created by simply adding the extension description to the xcb-proto package and rebuilding.

看看 xinput.h 标头

这篇关于从Xlib转换为xcb的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆