| 1 | use super::{GapConfig, Layout, WindowGeometry}; |
| 2 | use x11rb::protocol::xproto::Window; |
| 3 | |
| 4 | pub struct MonocleLayout; |
| 5 | |
| 6 | impl Layout for MonocleLayout { |
| 7 | fn name(&self) -> &'static str { |
| 8 | super::LayoutType::Monocle.as_str() |
| 9 | } |
| 10 | |
| 11 | fn symbol(&self) -> &'static str { |
| 12 | "[M]" |
| 13 | } |
| 14 | |
| 15 | fn arrange( |
| 16 | &self, |
| 17 | windows: &[Window], |
| 18 | screen_width: u32, |
| 19 | screen_height: u32, |
| 20 | gaps: &GapConfig, |
| 21 | ) -> Vec<WindowGeometry> { |
| 22 | let window_count = windows.len(); |
| 23 | if window_count == 0 { |
| 24 | return Vec::new(); |
| 25 | } |
| 26 | |
| 27 | let x = gaps.outer_horizontal as i32; |
| 28 | let y = gaps.outer_vertical as i32; |
| 29 | let width = screen_width.saturating_sub(2 * gaps.outer_horizontal); |
| 30 | let height = screen_height.saturating_sub(2 * gaps.outer_vertical); |
| 31 | |
| 32 | let geometry = WindowGeometry { |
| 33 | x_coordinate: x, |
| 34 | y_coordinate: y, |
| 35 | width, |
| 36 | height, |
| 37 | }; |
| 38 | |
| 39 | vec![geometry; window_count] |
| 40 | } |
| 41 | } |