Normalize workspace shadows to 1080 px tall screen, adjust defaults

Workspace gaps are dependent on screen size, so it makes sense to make shadows
depend on the screen size to, to avoid them filling more or less of the gap.
This commit is contained in:
Ivan Molodetskikh
2025-05-01 10:30:50 +03:00
parent 7b4cf094ef
commit 9d6037b94c
3 changed files with 41 additions and 13 deletions
+6 -6
View File
@@ -774,10 +774,10 @@ impl Default for WorkspaceShadow {
off: false, off: false,
offset: ShadowOffset { offset: ShadowOffset {
x: FloatOrInt(0.), x: FloatOrInt(0.),
y: FloatOrInt(20.), y: FloatOrInt(10.),
}, },
softness: FloatOrInt(120.), softness: FloatOrInt(80.),
spread: FloatOrInt(20.), spread: FloatOrInt(10.),
color: Color::from_rgba8_unpremul(0, 0, 0, 0x70), color: Color::from_rgba8_unpremul(0, 0, 0, 0x70),
} }
} }
@@ -4664,14 +4664,14 @@ mod tests {
0.0, 0.0,
), ),
y: FloatOrInt( y: FloatOrInt(
20.0, 10.0,
), ),
}, },
softness: FloatOrInt( softness: FloatOrInt(
120.0, 80.0,
), ),
spread: FloatOrInt( spread: FloatOrInt(
20.0, 10.0,
), ),
color: Color { color: Color {
r: 0.0, r: 0.0,
+31 -3
View File
@@ -235,6 +235,9 @@ impl<W: LayoutElement> Workspace<W> {
options.clone(), options.clone(),
); );
let shadow_config =
compute_workspace_shadow_config(options.overview.workspace_shadow, view_size);
Self { Self {
scrolling, scrolling,
floating, floating,
@@ -244,7 +247,7 @@ impl<W: LayoutElement> Workspace<W> {
transform: output.current_transform(), transform: output.current_transform(),
view_size, view_size,
working_area, working_area,
shadow: Shadow::new(niri_config::Shadow::from(options.overview.workspace_shadow)), shadow: Shadow::new(shadow_config),
output: Some(output), output: Some(output),
clock, clock,
base_options, base_options,
@@ -289,6 +292,9 @@ impl<W: LayoutElement> Workspace<W> {
options.clone(), options.clone(),
); );
let shadow_config =
compute_workspace_shadow_config(options.overview.workspace_shadow, view_size);
Self { Self {
scrolling, scrolling,
floating, floating,
@@ -299,7 +305,7 @@ impl<W: LayoutElement> Workspace<W> {
original_output, original_output,
view_size, view_size,
working_area, working_area,
shadow: Shadow::new(niri_config::Shadow::from(options.overview.workspace_shadow)), shadow: Shadow::new(shadow_config),
clock, clock,
base_options, base_options,
options, options,
@@ -380,7 +386,8 @@ impl<W: LayoutElement> Workspace<W> {
options.clone(), options.clone(),
); );
let shadow_config = niri_config::Shadow::from(options.overview.workspace_shadow); let shadow_config =
compute_workspace_shadow_config(options.overview.workspace_shadow, self.view_size);
self.shadow.update_config(shadow_config); self.shadow.update_config(shadow_config);
self.base_options = base_options; self.base_options = base_options;
@@ -522,6 +529,10 @@ impl<W: LayoutElement> Workspace<W> {
scale.fractional_scale(), scale.fractional_scale(),
self.options.clone(), self.options.clone(),
); );
let shadow_config =
compute_workspace_shadow_config(self.options.overview.workspace_shadow, size);
self.shadow.update_config(shadow_config);
} }
if scale_transform_changed { if scale_transform_changed {
@@ -1813,3 +1824,20 @@ impl<W: LayoutElement> Workspace<W> {
pub(super) fn compute_working_area(output: &Output) -> Rectangle<f64, Logical> { pub(super) fn compute_working_area(output: &Output) -> Rectangle<f64, Logical> {
layer_map_for_output(output).non_exclusive_zone().to_f64() layer_map_for_output(output).non_exclusive_zone().to_f64()
} }
fn compute_workspace_shadow_config(
config: niri_config::WorkspaceShadow,
view_size: Size<f64, Logical>,
) -> niri_config::Shadow {
// Gaps between workspaces are a multiple of the view height, so shadow settings should also be
// normalized to the view height to prevent them from overlapping on lower resolutions.
let norm = view_size.h / 1080.;
let mut config = niri_config::Shadow::from(config);
config.softness.0 *= norm;
config.spread.0 *= norm;
config.offset.x.0 *= norm;
config.offset.y.0 *= norm;
config
}
+4 -4
View File
@@ -29,9 +29,9 @@ overview {
workspace-shadow { workspace-shadow {
// off // off
softness 120 softness 80
spread 20 spread 10
offset x=0 y=20 offset x=0 y=10
color "#00000070" color "#00000070"
} }
} }
@@ -192,7 +192,7 @@ Control the shadow behind workspaces visible in the overview.
Settings here mirror the normal [`shadow` config in the layout section](./Configuration:-Layout.md#shadow), so check the documentation there. Settings here mirror the normal [`shadow` config in the layout section](./Configuration:-Layout.md#shadow), so check the documentation there.
Keep in mind that workspace shadows are configured for the full-screen workspace size, then zoomed out together with the workspace. Workspace shadows are configured for a workspace size normalized to 1080 pixels tall, then zoomed out together with the workspace.
Practically, this means that you'll want bigger spread, offset, and softness compared to window shadows. Practically, this means that you'll want bigger spread, offset, and softness compared to window shadows.
```kdl ```kdl