diff --git a/src/xlib/display.rs b/src/xlib/display.rs index 3e112ae..c3ce11f 100644 --- a/src/xlib/display.rs +++ b/src/xlib/display.rs @@ -10,6 +10,7 @@ use crate::ffi; use super::cursor::Cursor; use super::event::Event; +use super::screen::Screen; use super::visual::Visual; use super::window::Window; @@ -96,6 +97,12 @@ impl Display { Visual { inner: visual } } + /// Get the default screen using `XDefaultScreen` + pub fn get_default_screen(&self) -> Result { + let screen = unsafe { xlib::XDefaultScreen(self.inner) }; + Ok(Screen(screen)) + } + /// Returns the root window for the given screen. pub fn get_root_window(&self, screen: i32) -> Result { let inner = unsafe { xlib::XRootWindow(self.inner, screen) }; diff --git a/src/xlib/mod.rs b/src/xlib/mod.rs index 15ebc04..b6b1216 100644 --- a/src/xlib/mod.rs +++ b/src/xlib/mod.rs @@ -8,6 +8,7 @@ mod drawable; mod event; mod image; mod pixmap; +mod screen; mod visual; mod window; diff --git a/src/xlib/screen.rs b/src/xlib/screen.rs new file mode 100644 index 0000000..0ad7884 --- /dev/null +++ b/src/xlib/screen.rs @@ -0,0 +1 @@ +pub struct Screen(pub(super) i32);