AltF02 / x11-rs

Rust bindings for X11 libraries
https://docs.rs/x11
MIT License
204 stars 66 forks source link

XRRScreenResources not giving more than one #115

Closed ShayBox closed 2 years ago

ShayBox commented 4 years ago

https://doc.servo.org/x11/xrandr/struct.XRRScreenResources.html crtcs, outputs, and modes are supposed to be multiple, it's only one with this lib, XRRScreenResources is just one example, there's others.

Jokler commented 4 years ago

Those are pointers to the first of multiple, the n* variables tell you how many elements there are. I haven't tested this code but you should be able to do something like this:

let scr_res: XRRScreenResources = todo!();
let crtcs = unsafe { std::slice::from_raw_parts_mut(scr_res.crtcs, scr_res.ncrtcs as usize) };

https://doc.rust-lang.org/std/slice/fn.from_raw_parts.html https://doc.rust-lang.org/std/slice/fn.from_raw_parts_mut.html