oxwm

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

Bug-Fix: Fixing the floating window to be centered by default

Commit
3a77c20e709d2321e83f65e7c2314a2b8a3671dc
Parent
4ccbef9
Author
xsoder <tadihailukebe@gmail.com>
Date
2025-10-17 17:29:32

Diff

diff --git a/src/window_manager.rs b/src/window_manager.rs
index beb16a1..7565947 100644
--- a/src/window_manager.rs
+++ b/src/window_manager.rs
@@ -322,11 +322,26 @@ impl WindowManager {
                 self.floating_windows.remove(&focused);
                 self.apply_layout()?;
             } else {
-                self.floating_windows.insert(focused);
+                let float_width = (self.screen.width_in_pixels / 2) as u32;
+                let float_height = (self.screen.height_in_pixels / 2) as u32;
+
+                let border_width = self.config.border_width;
+                
+                let center_width = ((self.screen.width_in_pixels - float_width as u16)/2) as i32;
+                let center_height = ((self.screen.height_in_pixels - float_height as u16)/2) as i32;
+
                 self.connection.configure_window(
                     focused,
-                    &ConfigureWindowAux::new().stack_mode(StackMode::ABOVE),
+                    &ConfigureWindowAux::new()
+                        .x(center_width)
+                        .y(center_height)
+                        .width(float_width)
+                        .height(float_height)
+                        .border_width(border_width)
+                        .stack_mode(StackMode::ABOVE),
                 )?;
+
+                self.floating_windows.insert(focused);
                 self.apply_layout()?;
                 self.connection.flush()?;
             }