diff options
Diffstat (limited to 'src/safe_x11/mod.rs')
-rw-r--r-- | src/safe_x11/mod.rs | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/src/safe_x11/mod.rs b/src/safe_x11/mod.rs index 0283966..9cd14fd 100644 --- a/src/safe_x11/mod.rs +++ b/src/safe_x11/mod.rs @@ -6,6 +6,8 @@ use x11::xlib; use x11::xlib::{ Display, + XDisplayWidth, XDisplayHeight, + XDefaultScreen, XConnectionNumber, Screen, Cursor, @@ -17,6 +19,8 @@ use x11::xlib::{ // Windows Window, + + Atom, XInternAtom, }; use x11::xlib::XKeyEvent; @@ -110,6 +114,12 @@ pub fn next_xevent(display: *mut Display) -> XEvent { } } +pub fn screen_size(display: *mut Display) -> (u32, u32) { + let screen = unsafe { XDefaultScreen(display) }; + let dw: u32 = unsafe { XDisplayWidth(display, screen) as u32 }; + let dh: u32 = unsafe { XDisplayHeight(display, screen) as u32 }; + (dw, dh) +} /// Grab pointer buttons. /// @@ -210,3 +220,10 @@ fn get_color<T: Into<Vec<u8>>>(display: *mut Display, color: T) -> u64{ pub fn lookup_keysym(ev: &mut XKeyEvent) -> xlib::KeySym { unsafe { xlib::XLookupKeysym(ev, 0) } } + +pub fn atom<T: Into<Vec<u8>>>(display: *mut Display, name: T) -> Atom { + unsafe { + let cstr = CString::new(name).unwrap(); + XInternAtom(display, cstr.as_ptr(), 0) + } +} |