layout: Fix background color premultiplication
Browse files at this commita52df533c4694b5ed0a04140af60fd26146df911Parent: 5b771073 changed files +11 -9
niri-config/src/appearance.rsmodified+6 -0
| @@ -77,6 +77,12 @@ impl MulAssign<f32> for Color { | ||
| 77 | 77 | } |
| 78 | 78 | } |
| 79 | 79 | |
| 80 | +impl From<Color> for Color32F { | |
| 81 | + fn from(value: Color) -> Self { | |
| 82 | + Color32F::from(value.to_array_premul()) | |
| 83 | + } | |
| 84 | +} | |
| 85 | + | |
| 80 | 86 | #[derive(knuffel::Decode, Debug, Clone, Copy, PartialEq)] |
| 81 | 87 | pub struct Gradient { |
| 82 | 88 | #[knuffel(property, str)] |
src/layout/focus_ring.rsmodified+1 -1
| @@ -77,7 +77,7 @@ impl FocusRing { | ||
| 77 | 77 | }; |
| 78 | 78 | |
| 79 | 79 | for buf in &mut self.buffers { |
| 80 | - buf.set_color(color.to_array_premul()); | |
| 80 | + buf.set_color(color); | |
| 81 | 81 | } |
| 82 | 82 | |
| 83 | 83 | let radius = radius.fit_to(self.full_size.w as f32, self.full_size.h as f32); |
src/layout/workspace.rsmodified+4 -8
| @@ -252,8 +252,6 @@ impl<W: LayoutElement> Workspace<W> { | ||
| 252 | 252 | let shadow_config = |
| 253 | 253 | compute_workspace_shadow_config(options.overview.workspace_shadow, view_size); |
| 254 | 254 | |
| 255 | - let background_color = options.layout.background_color.to_array_unpremul(); | |
| 256 | - | |
| 257 | 255 | Self { |
| 258 | 256 | scrolling, |
| 259 | 257 | floating, |
| @@ -264,7 +262,7 @@ impl<W: LayoutElement> Workspace<W> { | ||
| 264 | 262 | view_size, |
| 265 | 263 | working_area, |
| 266 | 264 | shadow: Shadow::new(shadow_config), |
| 267 | - background_buffer: SolidColorBuffer::new(view_size, background_color), | |
| 265 | + background_buffer: SolidColorBuffer::new(view_size, options.layout.background_color), | |
| 268 | 266 | output: Some(output), |
| 269 | 267 | clock, |
| 270 | 268 | base_options, |
| @@ -318,8 +316,6 @@ impl<W: LayoutElement> Workspace<W> { | ||
| 318 | 316 | let shadow_config = |
| 319 | 317 | compute_workspace_shadow_config(options.overview.workspace_shadow, view_size); |
| 320 | 318 | |
| 321 | - let background_color = options.layout.background_color.to_array_unpremul(); | |
| 322 | - | |
| 323 | 319 | Self { |
| 324 | 320 | scrolling, |
| 325 | 321 | floating, |
| @@ -331,7 +327,7 @@ impl<W: LayoutElement> Workspace<W> { | ||
| 331 | 327 | view_size, |
| 332 | 328 | working_area, |
| 333 | 329 | shadow: Shadow::new(shadow_config), |
| 334 | - background_buffer: SolidColorBuffer::new(view_size, background_color), | |
| 330 | + background_buffer: SolidColorBuffer::new(view_size, options.layout.background_color), | |
| 335 | 331 | clock, |
| 336 | 332 | base_options, |
| 337 | 333 | options, |
| @@ -421,8 +417,8 @@ impl<W: LayoutElement> Workspace<W> { | ||
| 421 | 417 | compute_workspace_shadow_config(options.overview.workspace_shadow, self.view_size); |
| 422 | 418 | self.shadow.update_config(shadow_config); |
| 423 | 419 | |
| 424 | - let background_color = options.layout.background_color.to_array_unpremul(); | |
| 425 | - self.background_buffer.set_color(background_color); | |
| 420 | + self.background_buffer | |
| 421 | + .set_color(options.layout.background_color); | |
| 426 | 422 | |
| 427 | 423 | self.base_options = base_options; |
| 428 | 424 | self.options = options; |