From 07080a0431d86d64efed6fa557c2a02cb9041e93 Mon Sep 17 00:00:00 2001 From: Andrew Davis Date: Wed, 11 Jun 2025 00:34:33 -0600 Subject: Clamp colors to valid values when parsing config The oklch color space often creates weird values when parsed by csscolorparser. clamping the output to values between 0 and 1 should fix inconsistent color handling on borders. --- niri-config/src/lib.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/niri-config/src/lib.rs b/niri-config/src/lib.rs index 67a621de..2d42e9f2 100644 --- a/niri-config/src/lib.rs +++ b/niri-config/src/lib.rs @@ -2677,7 +2677,10 @@ impl FromStr for Color { type Err = miette::Error; fn from_str(s: &str) -> Result { - let color = csscolorparser::parse(s).into_diagnostic()?.to_array(); + let color = csscolorparser::parse(s) + .into_diagnostic()? + .clamp() + .to_array(); Ok(Self::from_array_unpremul(color)) } } -- cgit