简体   繁体   中英

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. Is there an XInput2 implementation in libxcb? If yes, where can I find the documentation.

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.

You basically have 2 options:

Option 1

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;
    }
}

Also take a look at the XCB Protocol Extension API .

Option 2

You can use the xcb_input_* xcb-xinput extension functions. 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.

Take a look at the xinput.h header .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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