diff options
| author | Ivan Molodetskikh <yalterz@gmail.com> | 2025-05-01 10:30:50 +0300 |
|---|---|---|
| committer | Ivan Molodetskikh <yalterz@gmail.com> | 2025-05-01 10:33:53 +0300 |
| commit | 9d6037b94c72deb0f5d928d3f68acc287d8baed2 (patch) | |
| tree | 8380b2330170ba08a554be0292ba6617a07fe3bd /src | |
| parent | 7b4cf094ef6c45ca92eaca4b0d42ef0a7c77e7e3 (diff) | |
| download | niri-9d6037b94c72deb0f5d928d3f68acc287d8baed2.tar.gz niri-9d6037b94c72deb0f5d928d3f68acc287d8baed2.tar.bz2 niri-9d6037b94c72deb0f5d928d3f68acc287d8baed2.zip | |
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.
Diffstat (limited to 'src')
| -rw-r--r-- | src/layout/workspace.rs | 34 |
1 files changed, 31 insertions, 3 deletions
diff --git a/src/layout/workspace.rs b/src/layout/workspace.rs index fe9ce585..6ae045f7 100644 --- a/src/layout/workspace.rs +++ b/src/layout/workspace.rs @@ -235,6 +235,9 @@ impl<W: LayoutElement> Workspace<W> { options.clone(), ); + let shadow_config = + compute_workspace_shadow_config(options.overview.workspace_shadow, view_size); + Self { scrolling, floating, @@ -244,7 +247,7 @@ impl<W: LayoutElement> Workspace<W> { transform: output.current_transform(), view_size, working_area, - shadow: Shadow::new(niri_config::Shadow::from(options.overview.workspace_shadow)), + shadow: Shadow::new(shadow_config), output: Some(output), clock, base_options, @@ -289,6 +292,9 @@ impl<W: LayoutElement> Workspace<W> { options.clone(), ); + let shadow_config = + compute_workspace_shadow_config(options.overview.workspace_shadow, view_size); + Self { scrolling, floating, @@ -299,7 +305,7 @@ impl<W: LayoutElement> Workspace<W> { original_output, view_size, working_area, - shadow: Shadow::new(niri_config::Shadow::from(options.overview.workspace_shadow)), + shadow: Shadow::new(shadow_config), clock, base_options, options, @@ -380,7 +386,8 @@ impl<W: LayoutElement> Workspace<W> { 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.base_options = base_options; @@ -522,6 +529,10 @@ impl<W: LayoutElement> Workspace<W> { scale.fractional_scale(), 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 { @@ -1813,3 +1824,20 @@ impl<W: LayoutElement> Workspace<W> { pub(super) fn compute_working_area(output: &Output) -> Rectangle<f64, Logical> { 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 +} |
