XDefaultScreen

This commit is contained in:
Michael Zhang 2023-08-20 05:03:59 -05:00
parent 42afef8041
commit 97ceb1062d
Signed by: michael
GPG key ID: BDA47A31A3C8EE6B
3 changed files with 9 additions and 0 deletions

View file

@ -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<Screen> {
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<Window> {
let inner = unsafe { xlib::XRootWindow(self.inner, screen) };

View file

@ -8,6 +8,7 @@ mod drawable;
mod event;
mod image;
mod pixmap;
mod screen;
mod visual;
mod window;

1
src/xlib/screen.rs Normal file
View file

@ -0,0 +1 @@
pub struct Screen(pub(super) i32);