tony / oxwm

Bug-Fix: Fixing the floating window to be centered by default Browse files
xsoder committed 2025-10-17 parent 4ccbef9 commit 3a77c20e709d2321e83f65e7c2314a2b8a3671dc
Showing 1 changed file with 17 additions and 2 deletions. UnifiedSplit
+17 −2 src/window_manager.rs
@@ -322,11 +322,26 @@ impl WindowManager {
322 322 self.floating_windows.remove(&focused);
323 323 self.apply_layout()?;
324 324 } else {
325 - self.floating_windows.insert(focused);
325 + let float_width = (self.screen.width_in_pixels / 2) as u32;
326 + let float_height = (self.screen.height_in_pixels / 2) as u32;
327 +
328 + let border_width = self.config.border_width;
329 +
330 + let center_width = ((self.screen.width_in_pixels - float_width as u16)/2) as i32;
331 + let center_height = ((self.screen.height_in_pixels - float_height as u16)/2) as i32;
332 +
326 333 self.connection.configure_window(
327 334 focused,
328 - &ConfigureWindowAux::new().stack_mode(StackMode::ABOVE),
335 + &ConfigureWindowAux::new()
336 + .x(center_width)
337 + .y(center_height)
338 + .width(float_width)
339 + .height(float_height)
340 + .border_width(border_width)
341 + .stack_mode(StackMode::ABOVE),
329 342 )?;
343 +
344 + self.floating_windows.insert(focused);
330 345 self.apply_layout()?;
331 346 self.connection.flush()?;
332 347 }