简体   繁体   English

从Xlib转换为xcb

[英]Convert from Xlib to xcb

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. 我目前正在将我的一个应用程序从Xlib移植到libxcb,我在查找我在某些时候使用的XInput2扩展上的信息时遇到了一些麻烦。 Is there an XInput2 implementation in libxcb? libxcb中是否有XInput2实现? If yes, where can I find the documentation. 如果是,我在哪里可以找到文档。

Currently I am having trouble for example with this functions: XIQueryDevice , XISelectEvents . 目前我遇到了这个函数的问题: XIQueryDeviceXISelectEvents 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. 也许有人可以为我指出文档,或者为我提供一个很小的例子来开始。

You basically have 2 options: 你基本上有两个选择:

Option 1 选项1

Call the regular XI* Xinput2 functions and poll them in your event loop with a generic event. 调用常规的XI* Xinput2函数,并在事件循环中使用泛型事件轮询它们。 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;
    }
}

Also take a look at the XCB Protocol Extension API . 另请参阅XCB协议扩展API

Option 2 选项2

You can use the xcb_input_* xcb-xinput extension functions. 您可以使用xcb_input_* xcb-xinput扩展函数。 According to the official documentation : 根据官方文件

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. 当XCB将其API样式添加到混合中时,它遵循较新的样式并为每个扩展创建了一个“libxcb” - 前缀库 - libxcb-composite,libxcb-render等。因为XCB可以为扩展生成API代码通过扩展协议的XML描述自动创建新扩展API,只需将扩展描述添加到xcb-proto包并重建即可。

Take a look at the xinput.h header . 看看xinput.h头文件

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM