connect default
This commit is contained in:
parent
5387a0f543
commit
8fecd2b64a
2 changed files with 9 additions and 1 deletions
|
@ -31,6 +31,9 @@ pub enum Error {
|
||||||
#[error("nul error: {0}")]
|
#[error("nul error: {0}")]
|
||||||
Nul(#[from] std::ffi::NulError),
|
Nul(#[from] std::ffi::NulError),
|
||||||
|
|
||||||
|
#[error("env var error: {0}")]
|
||||||
|
Var(#[from] std::env::VarError),
|
||||||
|
|
||||||
#[error("error")]
|
#[error("error")]
|
||||||
Error,
|
Error,
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
use std::ffi::CString;
|
use std::ffi::CString;
|
||||||
use std::mem::MaybeUninit;
|
use std::mem::MaybeUninit;
|
||||||
use std::os::raw::c_char;
|
use std::os::raw::c_char;
|
||||||
use std::ptr;
|
use std::{ptr, env};
|
||||||
|
|
||||||
use x11::xlib;
|
use x11::xlib;
|
||||||
|
|
||||||
|
@ -43,6 +43,11 @@ impl Display {
|
||||||
Ok(Display { inner })
|
Ok(Display { inner })
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn connect_default() -> Result<Display> {
|
||||||
|
let env = env::var("DISPLAY")?;
|
||||||
|
Self::connect(env)
|
||||||
|
}
|
||||||
|
|
||||||
/// Create a Display for an existing connection
|
/// Create a Display for an existing connection
|
||||||
pub fn from_handle(handle: u64) -> Self {
|
pub fn from_handle(handle: u64) -> Self {
|
||||||
Display {
|
Display {
|
||||||
|
|
Loading…
Reference in a new issue