| 1 | use super::{GapConfig, Layout, WindowGeometry}; |
| 2 | use x11rb::protocol::xproto::Window; |
| 3 | |
| 4 | pub struct NormieLayout; |
| 5 | |
| 6 | impl Layout for NormieLayout { |
| 7 | fn name(&self) -> &'static str { |
| 8 | super::NORMIE |
| 9 | } |
| 10 | |
| 11 | fn arrange( |
| 12 | &self, |
| 13 | windows: &[Window], |
| 14 | screen_width: u32, |
| 15 | screen_height: u32, |
| 16 | _gaps: &GapConfig, |
| 17 | ) -> Vec<WindowGeometry> { |
| 18 | // Floating layout: all windows open centered with a reasonable default size |
| 19 | // This mimics dwm's NULL layout behavior where windows float freely |
| 20 | const DEFAULT_WIDTH_RATIO: f32 = 0.6; |
| 21 | const DEFAULT_HEIGHT_RATIO: f32 = 0.6; |
| 22 | |
| 23 | windows |
| 24 | .iter() |
| 25 | .map(|_| { |
| 26 | // Calculate default window dimensions (60% of screen) |
| 27 | let width = ((screen_width as f32) * DEFAULT_WIDTH_RATIO) as u32; |
| 28 | let height = ((screen_height as f32) * DEFAULT_HEIGHT_RATIO) as u32; |
| 29 | |
| 30 | // Center the window on the screen |
| 31 | let x = ((screen_width - width) / 2) as i32; |
| 32 | let y = ((screen_height - height) / 2) as i32; |
| 33 | |
| 34 | WindowGeometry { |
| 35 | x_coordinate: x, |
| 36 | y_coordinate: y, |
| 37 | width, |
| 38 | height, |
| 39 | } |
| 40 | }) |
| 41 | .collect() |
| 42 | } |
| 43 | } |