x11: Support XRandR versions older than 1.5 (#394)
* x11: Support XRandR versions older than 1.5 Fixes #392 Previously, initializing the member `xrandr` of `XConnection` resulted in a panic when symbols from XRandR version 1.5 were missing. There was already code to handle older versions of XRandR but it was never executed because of the panic. The member `XConnection.xrandr` now contains only functions that can safely be used with older versions. Additionally, this commit adds a new member to `XConnection` of type `Option<ffi::XRandr>` that only contains a value if version 1.5 functionality is present. * x11: Document the xrandr* members of XConnection
This commit is contained in:
parent
150d2706f9
commit
107a1e7332
2 changed files with 12 additions and 10 deletions
|
|
@ -10,7 +10,10 @@ use super::ffi;
|
|||
/// A connection to an X server.
|
||||
pub struct XConnection {
|
||||
pub xlib: ffi::Xlib,
|
||||
pub xrandr: ffi::Xrandr,
|
||||
/// Exposes XRandR functions from version < 1.5
|
||||
pub xrandr: ffi::Xrandr_2_2_0,
|
||||
/// Exposes XRandR functions from version = 1.5
|
||||
pub xrandr_1_5: Option<ffi::Xrandr>,
|
||||
pub xcursor: ffi::Xcursor,
|
||||
pub xinput2: ffi::XInput2,
|
||||
pub xlib_xcb: ffi::Xlib_xcb,
|
||||
|
|
@ -28,7 +31,8 @@ impl XConnection {
|
|||
// opening the libraries
|
||||
let xlib = try!(ffi::Xlib::open());
|
||||
let xcursor = try!(ffi::Xcursor::open());
|
||||
let xrandr = try!(ffi::Xrandr::open());
|
||||
let xrandr = try!(ffi::Xrandr_2_2_0::open());
|
||||
let xrandr_1_5 = ffi::Xrandr::open().ok();
|
||||
let xinput2 = try!(ffi::XInput2::open());
|
||||
let xlib_xcb = try!(ffi::Xlib_xcb::open());
|
||||
|
||||
|
|
@ -47,6 +51,7 @@ impl XConnection {
|
|||
Ok(XConnection {
|
||||
xlib: xlib,
|
||||
xrandr: xrandr,
|
||||
xrandr_1_5: xrandr_1_5,
|
||||
xcursor: xcursor,
|
||||
xinput2: xinput2,
|
||||
xlib_xcb: xlib_xcb,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue