tony / oxwm

Added monitor knowledge to error modal. Browse files
tonybtw committed 2025-12-02 parent d974d56 commit df1e570f27e26a1e38aef37adb50b929baa20db1
Showing 2 changed files with 18 additions and 6 deletions. UnifiedSplit
+4 −2 src/overlay/error.rs
@@ -48,6 +48,8 @@ impl ErrorOverlay {
48 48 connection: &RustConnection,
49 49 font: &Font,
50 50 error_text: &str,
51 + monitor_x: i16,
52 + monitor_y: i16,
51 53 screen_width: u16,
52 54 screen_height: u16,
53 55 ) -> Result<(), X11Error> {
@@ -67,8 +69,8 @@ impl ErrorOverlay {
67 69 let line_height = font.height() + LINE_SPACING as u16;
68 70 let height = (self.lines.len() as u16 * line_height) + (PADDING as u16 * 2);
69 71
70 - let x = ((screen_width - width) / 2) as i16;
71 - let y = ((screen_height - height) / 2) as i16;
72 + let x = monitor_x + ((screen_width - width) / 2) as i16;
73 + let y = monitor_y + ((screen_height - height) / 2) as i16;
72 74
73 75 self.base.configure(connection, x, y, width, height)?;
74 76 self.base.show(connection)?;
+14 −4 src/window_manager.rs
@@ -329,13 +329,18 @@ impl WindowManager {
329 329 Press Mod+Shift+/ to see keybinds\n\
330 330 Press Mod+Shift+R to reload after fixing your config";
331 331
332 - let screen_width = self.screen.width_in_pixels;
333 - let screen_height = self.screen.height_in_pixels;
332 + let monitor = &self.monitors[self.selected_monitor];
333 + let monitor_x = monitor.screen_x as i16;
334 + let monitor_y = monitor.screen_y as i16;
335 + let screen_width = monitor.screen_width as u16;
336 + let screen_height = monitor.screen_height as u16;
334 337
335 338 if let Err(e) = self.overlay.show_error(
336 339 &self.connection,
337 340 &self.font,
338 341 message,
342 + monitor_x,
343 + monitor_y,
339 344 screen_width,
340 345 screen_height,
341 346 ) {
@@ -2961,12 +2966,17 @@ impl WindowManager {
2961 2966 Err(err) => {
2962 2967 eprintln!("Config reload error: {}", err);
2963 2968 self.error_message = Some(err.clone());
2964 - let screen_width = self.screen.width_in_pixels;
2965 - let screen_height = self.screen.height_in_pixels;
2969 + let monitor = &self.monitors[self.selected_monitor];
2970 + let monitor_x = monitor.screen_x as i16;
2971 + let monitor_y = monitor.screen_y as i16;
2972 + let screen_width = monitor.screen_width as u16;
2973 + let screen_height = monitor.screen_height as u16;
2966 2974 match self.overlay.show_error(
2967 2975 &self.connection,
2968 2976 &self.font,
2969 2977 &err,
2978 + monitor_x,
2979 + monitor_y,
2970 2980 screen_width,
2971 2981 screen_height,
2972 2982 ) {