Normalize workspace shadows to 1080 px tall screen, adjust defaults
Browse files at this commit9d6037b94c72deb0f5d928d3f68acc287d8baed2Parent: 7b4cf093 changed files +41 -13
- niri-config/src/lib.rs +6 -6
- src/layout/workspace.rs +31 -3
- wiki/Configuration:-Miscellaneous.md +4 -4
niri-config/src/lib.rsmodified+6 -6
| @@ -774,10 +774,10 @@ impl Default for WorkspaceShadow { | |||
| 774 | off: false, | 774 | off: false, |
| 775 | offset: ShadowOffset { | 775 | offset: ShadowOffset { |
| 776 | x: FloatOrInt(0.), | 776 | x: FloatOrInt(0.), |
| 777 | - y: FloatOrInt(20.), | 777 | + y: FloatOrInt(10.), |
| 778 | }, | 778 | }, |
| 779 | - softness: FloatOrInt(120.), | 779 | + softness: FloatOrInt(80.), |
| 780 | - spread: FloatOrInt(20.), | 780 | + spread: FloatOrInt(10.), |
| 781 | color: Color::from_rgba8_unpremul(0, 0, 0, 0x70), | 781 | color: Color::from_rgba8_unpremul(0, 0, 0, 0x70), |
| 782 | } | 782 | } |
| 783 | } | 783 | } |
| @@ -4664,14 +4664,14 @@ mod tests { | |||
| 4664 | 0.0, | 4664 | 0.0, |
| 4665 | ), | 4665 | ), |
| 4666 | y: FloatOrInt( | 4666 | y: FloatOrInt( |
| 4667 | - 20.0, | 4667 | + 10.0, |
| 4668 | ), | 4668 | ), |
| 4669 | }, | 4669 | }, |
| 4670 | softness: FloatOrInt( | 4670 | softness: FloatOrInt( |
| 4671 | - 120.0, | 4671 | + 80.0, |
| 4672 | ), | 4672 | ), |
| 4673 | spread: FloatOrInt( | 4673 | spread: FloatOrInt( |
| 4674 | - 20.0, | 4674 | + 10.0, |
| 4675 | ), | 4675 | ), |
| 4676 | color: Color { | 4676 | color: Color { |
| 4677 | r: 0.0, | 4677 | r: 0.0, |
src/layout/workspace.rsmodified+31 -3
| @@ -235,6 +235,9 @@ impl<W: LayoutElement> Workspace<W> { | |||
| 235 | options.clone(), | 235 | options.clone(), |
| 236 | ); | 236 | ); |
| 237 | 237 | ||
| 238 | + let shadow_config = | ||
| 239 | + compute_workspace_shadow_config(options.overview.workspace_shadow, view_size); | ||
| 240 | + | ||
| 238 | Self { | 241 | Self { |
| 239 | scrolling, | 242 | scrolling, |
| 240 | floating, | 243 | floating, |
| @@ -244,7 +247,7 @@ impl<W: LayoutElement> Workspace<W> { | |||
| 244 | transform: output.current_transform(), | 247 | transform: output.current_transform(), |
| 245 | view_size, | 248 | view_size, |
| 246 | working_area, | 249 | working_area, |
| 247 | - shadow: Shadow::new(niri_config::Shadow::from(options.overview.workspace_shadow)), | 250 | + shadow: Shadow::new(shadow_config), |
| 248 | output: Some(output), | 251 | output: Some(output), |
| 249 | clock, | 252 | clock, |
| 250 | base_options, | 253 | base_options, |
| @@ -289,6 +292,9 @@ impl<W: LayoutElement> Workspace<W> { | |||
| 289 | options.clone(), | 292 | options.clone(), |
| 290 | ); | 293 | ); |
| 291 | 294 | ||
| 295 | + let shadow_config = | ||
| 296 | + compute_workspace_shadow_config(options.overview.workspace_shadow, view_size); | ||
| 297 | + | ||
| 292 | Self { | 298 | Self { |
| 293 | scrolling, | 299 | scrolling, |
| 294 | floating, | 300 | floating, |
| @@ -299,7 +305,7 @@ impl<W: LayoutElement> Workspace<W> { | |||
| 299 | original_output, | 305 | original_output, |
| 300 | view_size, | 306 | view_size, |
| 301 | working_area, | 307 | working_area, |
| 302 | - shadow: Shadow::new(niri_config::Shadow::from(options.overview.workspace_shadow)), | 308 | + shadow: Shadow::new(shadow_config), |
| 303 | clock, | 309 | clock, |
| 304 | base_options, | 310 | base_options, |
| 305 | options, | 311 | options, |
| @@ -380,7 +386,8 @@ impl<W: LayoutElement> Workspace<W> { | |||
| 380 | options.clone(), | 386 | options.clone(), |
| 381 | ); | 387 | ); |
| 382 | 388 | ||
| 383 | - let shadow_config = niri_config::Shadow::from(options.overview.workspace_shadow); | 389 | + let shadow_config = |
| 390 | + compute_workspace_shadow_config(options.overview.workspace_shadow, self.view_size); | ||
| 384 | self.shadow.update_config(shadow_config); | 391 | self.shadow.update_config(shadow_config); |
| 385 | 392 | ||
| 386 | self.base_options = base_options; | 393 | self.base_options = base_options; |
| @@ -522,6 +529,10 @@ impl<W: LayoutElement> Workspace<W> { | |||
| 522 | scale.fractional_scale(), | 529 | scale.fractional_scale(), |
| 523 | self.options.clone(), | 530 | self.options.clone(), |
| 524 | ); | 531 | ); |
| 532 | + | ||
| 533 | + let shadow_config = | ||
| 534 | + compute_workspace_shadow_config(self.options.overview.workspace_shadow, size); | ||
| 535 | + self.shadow.update_config(shadow_config); | ||
| 525 | } | 536 | } |
| 526 | 537 | ||
| 527 | if scale_transform_changed { | 538 | if scale_transform_changed { |
| @@ -1813,3 +1824,20 @@ impl<W: LayoutElement> Workspace<W> { | |||
| 1813 | pub(super) fn compute_working_area(output: &Output) -> Rectangle<f64, Logical> { | 1824 | pub(super) fn compute_working_area(output: &Output) -> Rectangle<f64, Logical> { |
| 1814 | layer_map_for_output(output).non_exclusive_zone().to_f64() | 1825 | layer_map_for_output(output).non_exclusive_zone().to_f64() |
| 1815 | } | 1826 | } |
| 1827 | + | ||
| 1828 | +fn compute_workspace_shadow_config( | ||
| 1829 | + config: niri_config::WorkspaceShadow, | ||
| 1830 | + view_size: Size<f64, Logical>, | ||
| 1831 | +) -> niri_config::Shadow { | ||
| 1832 | + // Gaps between workspaces are a multiple of the view height, so shadow settings should also be | ||
| 1833 | + // normalized to the view height to prevent them from overlapping on lower resolutions. | ||
| 1834 | + let norm = view_size.h / 1080.; | ||
| 1835 | + | ||
| 1836 | + let mut config = niri_config::Shadow::from(config); | ||
| 1837 | + config.softness.0 *= norm; | ||
| 1838 | + config.spread.0 *= norm; | ||
| 1839 | + config.offset.x.0 *= norm; | ||
| 1840 | + config.offset.y.0 *= norm; | ||
| 1841 | + | ||
| 1842 | + config | ||
| 1843 | +} | ||
wiki/Configuration:-Miscellaneous.mdmodified+4 -4
| @@ -29,9 +29,9 @@ overview { | |||
| 29 | 29 | ||
| 30 | workspace-shadow { | 30 | workspace-shadow { |
| 31 | // off | 31 | // off |
| 32 | - softness 120 | 32 | + softness 80 |
| 33 | - spread 20 | 33 | + spread 10 |
| 34 | - offset x=0 y=20 | 34 | + offset x=0 y=10 |
| 35 | color "#00000070" | 35 | color "#00000070" |
| 36 | } | 36 | } |
| 37 | } | 37 | } |
| @@ -192,7 +192,7 @@ Control the shadow behind workspaces visible in the overview. | |||
| 192 | 192 | ||
| 193 | Settings here mirror the normal [`shadow` config in the layout section](./Configuration:-Layout.md#shadow), so check the documentation there. | 193 | Settings here mirror the normal [`shadow` config in the layout section](./Configuration:-Layout.md#shadow), so check the documentation there. |
| 194 | 194 | ||
| 195 | -Keep in mind that workspace shadows are configured for the full-screen workspace size, then zoomed out together with the workspace. | 195 | +Workspace shadows are configured for a workspace size normalized to 1080 pixels tall, then zoomed out together with the workspace. |
| 196 | Practically, this means that you'll want bigger spread, offset, and softness compared to window shadows. | 196 | Practically, this means that you'll want bigger spread, offset, and softness compared to window shadows. |
| 197 | 197 | ||
| 198 | ```kdl | 198 | ```kdl |