Skip to content

Commit

Permalink
fix #18, update changelog, bump version
Browse files Browse the repository at this point in the history
  • Loading branch information
hertg committed Jun 4, 2023
1 parent c852fcc commit b858e16
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 4 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
## :lady_beetle: Fixes

- Fix issue where column rotation was not properly applied if only the `main` **or** `stack` column was present
- Fix issue where more rects were returned than windows requested ([#18](https://github.com/leftwm/leftwm-layouts/issues/18))
2 changes: 1 addition & 1 deletion leftwm-layouts/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "leftwm-layouts"
version = "0.8.1"
version = "0.8.2"
edition = "2021"

license = "BSD-3-Clause"
Expand Down
31 changes: 29 additions & 2 deletions leftwm-layouts/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ fn main_stack(

let mut main_tiles = vec![];
if let Some(tile) = main_tile {
main_tiles.append(&mut geometry::split(&tile, main.count, main.split));
main_tiles.append(&mut geometry::split(&tile, usize::min(main.count, window_count), main.split));
geometry::rotate(&mut main_tiles, main.rotate, container);
geometry::flip(&mut main_tiles, main.flip, container);
}
Expand Down Expand Up @@ -184,7 +184,7 @@ mod tests {
use crate::{
apply,
geometry::{Rect, Split},
layouts::{Columns, SecondStack, Stack},
layouts::{Columns, SecondStack, Stack, Layouts},
Layout,
};

Expand Down Expand Up @@ -235,4 +235,31 @@ mod tests {
assert_eq!(Rect::new(2560, 1440, 640, 1440), rects[1]);
assert_eq!(Rect::new(4480, 1440, 640, 1440), rects[2]);
}

#[test]
fn should_never_return_more_rects_than_windows_for_any_layout() {
let container = Rect::new(0,0,40,20);
let mut layouts = Layouts::default().layouts;

// this specific layout does not exists in the defaults,
// but has lead to the issue tested here in the past when user-defined
layouts.push(Layout {
name: "MultiMain".to_string(),
columns: Columns {
main: Some(crate::layouts::Main {
count: 2,
..Default::default()
}),
..Default::default()
},
..Default::default()
});

for layout in layouts {
for i in 0usize..6 {
let rects = apply(&layout, i, &container);
assert!(rects.len() <= i, "got {}, expected <= {}, layout {}", rects.len(), i, &layout.name);
}
}
}
}

0 comments on commit b858e16

Please sign in to comment.