tony / oxwm

Branch: 7572793
Switch branches/tags
master
tonybtw changed count to window_count 333c305 2025-09-26
47 lines · 1.4 KB Raw Blame History
1 use super::{Layout, WindowGeometry};
2 use x11rb::protocol::xproto::Window;
3
4 pub struct TilingLayout;
5
6 impl Layout for TilingLayout {
7 fn arrange(
8 &self,
9 windows: &[Window],
10 screen_width: u32,
11 screen_height: u32,
12 ) -> Vec<WindowGeometry> {
13 let window_count = windows.len();
14 if window_count == 0 {
15 return Vec::new();
16 }
17
18 if window_count == 1 {
19 vec![WindowGeometry {
20 x_coordinate: 0,
21 y_coordinate: 0,
22 width: screen_width,
23 height: screen_height,
24 }]
25 } else {
26 let master_width = screen_width / 2;
27 let mut geometries = vec![WindowGeometry {
28 x_coordinate: 0,
29 y_coordinate: 0,
30 width: master_width,
31 height: screen_height,
32 }];
33
34 let stack_height = screen_height / (window_count - 1) as u32;
35 for i in 1..window_count {
36 let y_offset = ((i - 1) as u32) * stack_height;
37 geometries.push(WindowGeometry {
38 x_coordinate: master_width as i32,
39 y_coordinate: y_offset as i32,
40 width: master_width,
41 height: stack_height,
42 });
43 }
44 return geometries;
45 }
46 }
47 }