diff options
author | Matias Linares <matiaslina@openmailbox.org> | 2016-05-25 13:18:18 -0300 |
---|---|---|
committer | Matias Linares <matiaslina@openmailbox.org> | 2016-05-25 13:18:18 -0300 |
commit | da3fa00ccf4cde76d1d6489c6043d7e56d4f52c5 (patch) | |
tree | 49dbdb5ce9d0baed54ee41a64393b01b6953f2e6 /src/safe_x11/mod.rs | |
parent | 77e4450afef9fb5d1acb8f2b690bd5e228f61d8e (diff) | |
download | dotwm-da3fa00ccf4cde76d1d6489c6043d7e56d4f52c5.tar.gz |
Add a lazy_static connection to the X server
Diffstat (limited to 'src/safe_x11/mod.rs')
-rw-r--r-- | src/safe_x11/mod.rs | 25 |
1 files changed, 1 insertions, 24 deletions
diff --git a/src/safe_x11/mod.rs b/src/safe_x11/mod.rs index 03c54d8..3d08a4e 100644 --- a/src/safe_x11/mod.rs +++ b/src/safe_x11/mod.rs @@ -9,7 +9,6 @@ use x11::xlib::{ XDisplayWidth, XDisplayHeight, XDefaultScreen, XConnectionNumber, - Screen, Cursor, XDefaultRootWindow, XQueryTree, @@ -36,6 +35,7 @@ use std::fmt; use libc::c_int; pub mod window; +pub mod display; #[derive(Debug)] pub struct XSafeError<'a> { @@ -70,29 +70,6 @@ impl<'a> fmt::Display for XSafeError<'a> { } } -/// Open a display. If the string passed by parameter is `""`, it will open the -/// default display. -/// -/// # Failures -/// -/// This function can raise a NulError when the bytes yielded contains an internal -/// 0 byte. -/// -pub fn open_display(display: &str) -> Result<*mut Display, XSafeError> { - let d = if display == "" { - unsafe { xlib::XOpenDisplay(0x0 as *const i8) } - } else { - let cstr = try!(CString::new(display)); - unsafe { xlib::XOpenDisplay(cstr.as_ptr()) } - }; - - if d.is_null() { - Err(XSafeError::new("Cannot open display!")) - } else { - Ok(d) - } -} - pub fn close_display(display: *mut Display) { unsafe { xlib::XCloseDisplay(display); } } |