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