Fix cached data not updating on config change
Browse files at this commit032589446a4bb0ae856cfa035feeb3113d50ca8fParent: 9ae98e02 changed files +25 -2
- src/layout/mod.rs +21 -0
- src/layout/workspace.rs +4 -2
src/layout/mod.rsmodified+21 -0
| @@ -3912,6 +3912,27 @@ mod tests { | ||
| 3912 | 3912 | assert_eq!(workspaces.len(), 2); |
| 3913 | 3913 | } |
| 3914 | 3914 | |
| 3915 | + #[test] | |
| 3916 | + fn config_change_updates_cached_sizes() { | |
| 3917 | + let mut config = Config::default(); | |
| 3918 | + config.layout.border.off = false; | |
| 3919 | + config.layout.border.width = 2; | |
| 3920 | + | |
| 3921 | + let mut layout = Layout::new(&config); | |
| 3922 | + | |
| 3923 | + Op::AddWindow { | |
| 3924 | + id: 1, | |
| 3925 | + bbox: Rectangle::from_loc_and_size((0, 0), (1280, 200)), | |
| 3926 | + min_max_size: Default::default(), | |
| 3927 | + } | |
| 3928 | + .apply(&mut layout); | |
| 3929 | + | |
| 3930 | + config.layout.border.width = 4; | |
| 3931 | + layout.update_config(&config); | |
| 3932 | + | |
| 3933 | + layout.verify_invariants(); | |
| 3934 | + } | |
| 3935 | + | |
| 3915 | 3936 | fn arbitrary_spacing() -> impl Strategy<Value = u16> { |
| 3916 | 3937 | // Give equal weight to: |
| 3917 | 3938 | // - 0: the element is disabled |
src/layout/workspace.rsmodified+4 -2
| @@ -457,8 +457,9 @@ impl<W: LayoutElement> Workspace<W> { | ||
| 457 | 457 | } |
| 458 | 458 | |
| 459 | 459 | pub fn update_config(&mut self, options: Rc<Options>) { |
| 460 | - for column in &mut self.columns { | |
| 460 | + for (column, data) in zip(&mut self.columns, &mut self.data) { | |
| 461 | 461 | column.update_config(options.clone()); |
| 462 | + data.update(column); | |
| 462 | 463 | } |
| 463 | 464 | |
| 464 | 465 | self.options = options; |
| @@ -2741,8 +2742,9 @@ impl<W: LayoutElement> Column<W> { | ||
| 2741 | 2742 | update_sizes = true; |
| 2742 | 2743 | } |
| 2743 | 2744 | |
| 2744 | - for tile in &mut self.tiles { | |
| 2745 | + for (tile, data) in zip(&mut self.tiles, &mut self.data) { | |
| 2745 | 2746 | tile.update_config(options.clone()); |
| 2747 | + data.update(tile); | |
| 2746 | 2748 | } |
| 2747 | 2749 | |
| 2748 | 2750 | self.options = options; |