From 5387a0f543eadd09caab210c053e843cc2008d33 Mon Sep 17 00:00:00 2001 From: Michael Zhang Date: Sun, 20 Aug 2023 05:07:29 -0500 Subject: [PATCH] screen --- src/xlib/display.rs | 8 ++++---- src/xlib/window.rs | 3 ++- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/xlib/display.rs b/src/xlib/display.rs index c3ce11f..b0f10cc 100644 --- a/src/xlib/display.rs +++ b/src/xlib/display.rs @@ -92,8 +92,8 @@ impl Display { } /// Gets the default visual - pub fn default_visual(&self, screen: i32) -> Visual { - let visual = unsafe { xlib::XDefaultVisual(self.inner, screen) }; + pub fn default_visual(&self, screen: &Screen) -> Visual { + let visual = unsafe { xlib::XDefaultVisual(self.inner, screen.0) }; Visual { inner: visual } } @@ -104,8 +104,8 @@ impl Display { } /// 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) }; + pub fn get_root_window(&self, screen: &Screen) -> Result { + let inner = unsafe { xlib::XRootWindow(self.inner, screen.0) }; if inner == 0 { return Err(Error::GetWindowError); } diff --git a/src/xlib/window.rs b/src/xlib/window.rs index 047d78b..2ae33fb 100644 --- a/src/xlib/window.rs +++ b/src/xlib/window.rs @@ -29,7 +29,8 @@ impl<'a> Window<'a> { Some(parent) => parent, None => display.get_default_root_window()?, }; - let visual = display.default_visual(0); + let screen = display.get_default_screen()?; + let visual = display.default_visual(&screen); let window = unsafe { xlib::XCreateWindow( display.as_raw(),