oxwm

https://git.tonybtw.com/oxwm.git git://git.tonybtw.com/oxwm.git

Added monitor knowledge to error modal.

Commit
df1e570f27e26a1e38aef37adb50b929baa20db1
Parent
d974d56
Author
tonybtw <tonybtw@tonybtw.com>
Date
2025-12-02 08:33:56

Diff

diff --git a/src/overlay/error.rs b/src/overlay/error.rs
index 2d1f98e..d953d9c 100644
--- a/src/overlay/error.rs
+++ b/src/overlay/error.rs
@@ -48,6 +48,8 @@ impl ErrorOverlay {
         connection: &RustConnection,
         font: &Font,
         error_text: &str,
+        monitor_x: i16,
+        monitor_y: i16,
         screen_width: u16,
         screen_height: u16,
     ) -> Result<(), X11Error> {
@@ -67,8 +69,8 @@ impl ErrorOverlay {
         let line_height = font.height() + LINE_SPACING as u16;
         let height = (self.lines.len() as u16 * line_height) + (PADDING as u16 * 2);
 
-        let x = ((screen_width - width) / 2) as i16;
-        let y = ((screen_height - height) / 2) as i16;
+        let x = monitor_x + ((screen_width - width) / 2) as i16;
+        let y = monitor_y + ((screen_height - height) / 2) as i16;
 
         self.base.configure(connection, x, y, width, height)?;
         self.base.show(connection)?;
diff --git a/src/window_manager.rs b/src/window_manager.rs
index 6ebf110..34792f2 100644
--- a/src/window_manager.rs
+++ b/src/window_manager.rs
@@ -329,13 +329,18 @@ impl WindowManager {
                        Press Mod+Shift+/ to see keybinds\n\
                        Press Mod+Shift+R to reload after fixing your config";
 
-        let screen_width = self.screen.width_in_pixels;
-        let screen_height = self.screen.height_in_pixels;
+        let monitor = &self.monitors[self.selected_monitor];
+        let monitor_x = monitor.screen_x as i16;
+        let monitor_y = monitor.screen_y as i16;
+        let screen_width = monitor.screen_width as u16;
+        let screen_height = monitor.screen_height as u16;
 
         if let Err(e) = self.overlay.show_error(
             &self.connection,
             &self.font,
             message,
+            monitor_x,
+            monitor_y,
             screen_width,
             screen_height,
         ) {
@@ -2961,12 +2966,17 @@ impl WindowManager {
                                 Err(err) => {
                                     eprintln!("Config reload error: {}", err);
                                     self.error_message = Some(err.clone());
-                                    let screen_width = self.screen.width_in_pixels;
-                                    let screen_height = self.screen.height_in_pixels;
+                                    let monitor = &self.monitors[self.selected_monitor];
+                                    let monitor_x = monitor.screen_x as i16;
+                                    let monitor_y = monitor.screen_y as i16;
+                                    let screen_width = monitor.screen_width as u16;
+                                    let screen_height = monitor.screen_height as u16;
                                     match self.overlay.show_error(
                                         &self.connection,
                                         &self.font,
                                         &err,
+                                        monitor_x,
+                                        monitor_y,
                                         screen_width,
                                         screen_height,
                                     ) {