rust-x-bindings / rust-xcb

Rust bindings and wrapper for XCB.
MIT License
161 stars 63 forks source link

Segfault polling for XInput RawMotionEvent #243

Closed jhgarner closed 4 months ago

jhgarner commented 10 months ago

Using the following code and xcb built with the xinput feature results in a segfault:

fn main() {
    let (main, _) = xcb::Connection::connect(Some(":0")).unwrap();
    loop {
        let event = main.register_for_special_xge::<xcb::xinput::RawMotionEvent>();
        main.poll_for_special_event(event).unwrap();
    }
}

Is there some other way to get RawMotionEvents from xcb?

rtbo commented 10 months ago

I confirm it also crashes for me

rtbo commented 10 months ago

After some digging, my API for special events appears to be incorrectly designed. Here is an online example of using the C API of special event. My API simply doesn't allow to do it and needs to be rewritten.

In regards to the XInput RawMotionEvent, I'm not sure if special event is the correct way to go though. I tried to adapt the xinput_stylus_event example, but I couldn't make it work in the same way for this kind of event. If you are aware of C code doing what you need, let me know it will be helpful.

rtbo commented 4 months ago

closed by #261.

register_for_special_xge is deprecated in favor of register_for_special_event.