From 97ceb1062d98df23aabc1b58495b0a7b7a37c71c Mon Sep 17 00:00:00 2001 From: Michael Zhang Date: Sun, 20 Aug 2023 05:03:59 -0500 Subject: [PATCH] XDefaultScreen --- src/xlib/display.rs | 7 +++++++ src/xlib/mod.rs | 1 + src/xlib/screen.rs | 1 + 3 files changed, 9 insertions(+) create mode 100644 src/xlib/screen.rs 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);