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/tile.rs | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) (limited to 'src/layout/tile.rs') diff --git a/src/layout/tile.rs b/src/layout/tile.rs index bc39db6d..beaa981f 100644 --- a/src/layout/tile.rs +++ b/src/layout/tile.rs @@ -29,7 +29,9 @@ use crate::render_helpers::snapshot::RenderSnapshot; use crate::render_helpers::solid_color::{SolidColorBuffer, SolidColorRenderElement}; use crate::render_helpers::RenderTarget; use crate::utils::transaction::Transaction; -use crate::utils::{baba_is_float_offset, round_logical_in_physical}; +use crate::utils::{ + baba_is_float_offset, round_logical_in_physical, round_logical_in_physical_max1, +}; /// Toplevel window with decorations. #[derive(Debug)] @@ -228,16 +230,20 @@ impl Tile { self.scale = scale; self.options = options; + let round_max1 = |logical| round_logical_in_physical_max1(self.scale, logical); + let rules = self.window.rules(); - let border_config = self.options.layout.border.merged_with(&rules.border); + let mut border_config = self.options.layout.border.merged_with(&rules.border); + border_config.width = round_max1(border_config.width); self.border.update_config(border_config.into()); - let focus_ring_config = self + let mut focus_ring_config = self .options .layout .focus_ring .merged_with(&rules.focus_ring); + focus_ring_config.width = round_max1(focus_ring_config.width); self.focus_ring.update_config(focus_ring_config); let shadow_config = self.options.layout.shadow.merged_with(&rules.shadow); @@ -373,14 +379,19 @@ impl Tile { } } + let round_max1 = |logical| round_logical_in_physical_max1(self.scale, logical); + let rules = self.window.rules(); - let border_config = self.options.layout.border.merged_with(&rules.border); + let mut border_config = self.options.layout.border.merged_with(&rules.border); + border_config.width = round_max1(border_config.width); self.border.update_config(border_config.into()); - let focus_ring_config = self + + let mut focus_ring_config = self .options .layout .focus_ring .merged_with(&rules.focus_ring); + focus_ring_config.width = round_max1(focus_ring_config.width); self.focus_ring.update_config(focus_ring_config); let shadow_config = self.options.layout.shadow.merged_with(&rules.shadow); -- cgit