其他分享
首页 > 其他分享> > 从Xlib转换为xcb

从Xlib转换为xcb

作者:互联网

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

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

也许有人可以为我指出文档或为我提供一个很小的示例以开始使用.

解决方法:

您基本上有2个选择:

选项1

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

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 Protocol Extension API.

选项2

您可以使用xcb_input_ * xcb-xinput扩展功能.根据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.

看看xinput.h header.

标签:xlib,xcb,c-3,linux,x11
来源: https://codeday.me/bug/20191118/2026365.html