aboutsummaryrefslogtreecommitdiff
path: root/src/layout/tile.rs
diff options
context:
space:
mode:
authorIvan Molodetskikh <yalterz@gmail.com>2025-11-24 15:10:14 +0300
committerIvan Molodetskikh <yalterz@gmail.com>2025-11-24 15:11:51 +0300
commit0920ea9f9fdf0b744e79e8dea57d5945ba74f312 (patch)
treed16345f47a3cc0cad34e10ab418713cae80b3115 /src/layout/tile.rs
parent79e41d7d88de44356b48400515076bf5593544e8 (diff)
downloadniri-0920ea9f9fdf0b744e79e8dea57d5945ba74f312.tar.gz
niri-0920ea9f9fdf0b744e79e8dea57d5945ba74f312.tar.bz2
niri-0920ea9f9fdf0b744e79e8dea57d5945ba74f312.zip
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.
Diffstat (limited to 'src/layout/tile.rs')
-rw-r--r--src/layout/tile.rs21
1 files changed, 16 insertions, 5 deletions
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<W: LayoutElement> Tile<W> {
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<W: LayoutElement> Tile<W> {
}
}
+ 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);