From 0920ea9f9fdf0b744e79e8dea57d5945ba74f312 Mon Sep 17 00:00:00 2001 From: Ivan Molodetskikh Date: Mon, 24 Nov 2025 15:10:14 +0300 Subject: layout: Round focus ring/border width to physical at the right place Before this, focus ring/border width was incorrectly rounded only for layout config, which does not take into account window rules overrides. This means that setting width in window rules prevented correct rounding altogether. Tests didn't check this because window rules weren't tested. This commit also adds basic window rules random generation, making the tests catch this problem too. --- src/layout/tests.rs | 32 ++++++++++++++++++++++++++------ 1 file changed, 26 insertions(+), 6 deletions(-) (limited to 'src/layout/tests.rs') diff --git a/src/layout/tests.rs b/src/layout/tests.rs index 17a8a30e..e022475a 100644 --- a/src/layout/tests.rs +++ b/src/layout/tests.rs @@ -40,12 +40,13 @@ struct TestWindowInner { is_pending_windowed_fullscreen: Cell, animate_next_configure: Cell, animation_snapshot: RefCell>, + rules: ResolvedWindowRules, } #[derive(Debug, Clone)] struct TestWindow(Rc); -#[derive(Debug, Clone, Copy, Arbitrary)] +#[derive(Debug, Clone, Arbitrary)] struct TestWindowParams { #[proptest(strategy = "1..=5usize")] id: usize, @@ -56,6 +57,8 @@ struct TestWindowParams { bbox: Rectangle, #[proptest(strategy = "arbitrary_min_max_size()")] min_max_size: (Size, Size), + #[proptest(strategy = "prop::option::of(arbitrary_rules())")] + rules: Option, } impl TestWindowParams { @@ -66,6 +69,7 @@ impl TestWindowParams { is_floating: false, bbox: Rectangle::from_size(Size::from((100, 200))), min_max_size: Default::default(), + rules: None, } } } @@ -88,6 +92,7 @@ impl TestWindow { is_pending_windowed_fullscreen: Cell::new(false), animate_next_configure: Cell::new(false), animation_snapshot: RefCell::new(None), + rules: params.rules.unwrap_or(ResolvedWindowRules::empty()), })) } @@ -262,8 +267,7 @@ impl LayoutElement for TestWindow { fn refresh(&self) {} fn rules(&self) -> &ResolvedWindowRules { - static EMPTY: ResolvedWindowRules = ResolvedWindowRules::empty(); - &EMPTY + &self.0.rules } fn take_animation_snapshot(&mut self) -> Option { @@ -345,6 +349,19 @@ fn arbitrary_min_max_size() -> impl Strategy, Size ResolvedWindowRules { + ResolvedWindowRules { + focus_ring, + border, + ..ResolvedWindowRules::empty() + } + } +} + fn arbitrary_view_offset_gesture_delta() -> impl Strategy { prop_oneof![(-10f64..10f64), (-50000f64..50000f64),] } @@ -891,6 +908,7 @@ impl Op { } } + let is_floating = params.is_floating; let win = TestWindow::new(params); layout.add_window( win, @@ -898,7 +916,7 @@ impl Op { None, None, false, - params.is_floating, + is_floating, ActivateWindow::default(), ); } @@ -959,6 +977,7 @@ impl Op { } } + let is_floating = params.is_floating; let win = TestWindow::new(params); layout.add_window( win, @@ -966,7 +985,7 @@ impl Op { None, None, false, - params.is_floating, + is_floating, ActivateWindow::default(), ); } @@ -1032,6 +1051,7 @@ impl Op { } } + let is_floating = params.is_floating; let win = TestWindow::new(params); layout.add_window( win, @@ -1039,7 +1059,7 @@ impl Op { None, None, false, - params.is_floating, + is_floating, ActivateWindow::default(), ); } -- cgit