Add workspace-shadow {} config to overview {}

This commit is contained in:
Ivan Molodetskikh
2025-05-01 09:36:10 +03:00
parent 3289324ce4
commit 446bc155ce
4 changed files with 103 additions and 26 deletions
+69
View File
@@ -754,6 +754,49 @@ pub struct ShadowOffset {
pub y: FloatOrInt<-65535, 65535>,
}
#[derive(knuffel::Decode, Debug, Clone, Copy, PartialEq)]
pub struct WorkspaceShadow {
#[knuffel(child)]
pub off: bool,
#[knuffel(child, default = Self::default().offset)]
pub offset: ShadowOffset,
#[knuffel(child, unwrap(argument), default = Self::default().softness)]
pub softness: FloatOrInt<0, 1024>,
#[knuffel(child, unwrap(argument), default = Self::default().spread)]
pub spread: FloatOrInt<-1024, 1024>,
#[knuffel(child, default = Self::default().color)]
pub color: Color,
}
impl Default for WorkspaceShadow {
fn default() -> Self {
Self {
off: false,
offset: ShadowOffset {
x: FloatOrInt(0.),
y: FloatOrInt(20.),
},
softness: FloatOrInt(120.),
spread: FloatOrInt(20.),
color: Color::from_rgba8_unpremul(0, 0, 0, 0x70),
}
}
}
impl From<WorkspaceShadow> for Shadow {
fn from(value: WorkspaceShadow) -> Self {
Self {
on: !value.off,
offset: value.offset,
softness: value.softness,
spread: value.spread,
draw_behind_window: false,
color: value.color,
inactive_color: None,
}
}
}
#[derive(knuffel::Decode, Debug, Clone, Copy, PartialEq)]
pub struct TabIndicator {
#[knuffel(child)]
@@ -1269,6 +1312,8 @@ pub struct Overview {
pub zoom: FloatOrInt<0, 1>,
#[knuffel(child, default = Self::default().backdrop_color)]
pub backdrop_color: Color,
#[knuffel(child, default)]
pub workspace_shadow: WorkspaceShadow,
}
impl Default for Overview {
@@ -1276,6 +1321,7 @@ impl Default for Overview {
Self {
zoom: FloatOrInt(0.5),
backdrop_color: DEFAULT_BACKDROP_COLOR,
workspace_shadow: WorkspaceShadow::default(),
}
}
}
@@ -4611,6 +4657,29 @@ mod tests {
b: 0.15,
a: 1.0,
},
workspace_shadow: WorkspaceShadow {
off: false,
offset: ShadowOffset {
x: FloatOrInt(
0.0,
),
y: FloatOrInt(
20.0,
),
},
softness: FloatOrInt(
120.0,
),
spread: FloatOrInt(
20.0,
),
color: Color {
r: 0.0,
g: 0.0,
b: 0.0,
a: 0.4392157,
},
},
},
environment: Environment(
[
+6 -26
View File
@@ -3,8 +3,7 @@ use std::rc::Rc;
use std::time::Duration;
use niri_config::{
CenterFocusedColumn, CornerRadius, FloatOrInt, OutputName, PresetSize,
Workspace as WorkspaceConfig,
CenterFocusedColumn, CornerRadius, OutputName, PresetSize, Workspace as WorkspaceConfig,
};
use niri_ipc::{ColumnDisplay, PositionChange, SizeChange};
use smithay::backend::renderer::gles::GlesRenderer;
@@ -236,17 +235,6 @@ impl<W: LayoutElement> Workspace<W> {
options.clone(),
);
let shadow_config = niri_config::Shadow {
on: true,
offset: niri_config::ShadowOffset {
x: FloatOrInt(0.),
y: FloatOrInt(20.),
},
softness: FloatOrInt(120.),
spread: FloatOrInt(20.),
..Default::default()
};
Self {
scrolling,
floating,
@@ -256,7 +244,7 @@ impl<W: LayoutElement> Workspace<W> {
transform: output.current_transform(),
view_size,
working_area,
shadow: Shadow::new(shadow_config),
shadow: Shadow::new(niri_config::Shadow::from(options.overview.workspace_shadow)),
output: Some(output),
clock,
base_options,
@@ -301,17 +289,6 @@ impl<W: LayoutElement> Workspace<W> {
options.clone(),
);
let shadow_config = niri_config::Shadow {
on: true,
offset: niri_config::ShadowOffset {
x: FloatOrInt(0.),
y: FloatOrInt(20.),
},
softness: FloatOrInt(120.),
spread: FloatOrInt(20.),
..Default::default()
};
Self {
scrolling,
floating,
@@ -322,7 +299,7 @@ impl<W: LayoutElement> Workspace<W> {
original_output,
view_size,
working_area,
shadow: Shadow::new(shadow_config),
shadow: Shadow::new(niri_config::Shadow::from(options.overview.workspace_shadow)),
clock,
base_options,
options,
@@ -403,6 +380,9 @@ impl<W: LayoutElement> Workspace<W> {
options.clone(),
);
let shadow_config = niri_config::Shadow::from(options.overview.workspace_shadow);
self.shadow.update_config(shadow_config);
self.base_options = base_options;
self.options = options;
}
+26
View File
@@ -26,6 +26,14 @@ cursor {
overview {
zoom 0.5
backdrop-color "#262626"
workspace-shadow {
// off
softness 120
spread 20
offset x=0 y=20
color "#00000070"
}
}
clipboard {
@@ -178,6 +186,24 @@ overview {
}
```
#### `workspace-shadow`
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.
Keep in mind that workspace shadows are configured for the full-screen workspace size, then zoomed out together with the workspace.
Practically, this means that you'll want bigger spread, offset, and softness compared to window shadows.
```kdl
// Disable workspace shadows in the overview.
overview {
workspace-shadow {
off
}
}
```
### `clipboard`
<sup>Since: 25.02</sup>
+2
View File
@@ -29,6 +29,8 @@ https://github.com/user-attachments/assets/b76d5349-aa20-4889-ab90-0a51554c789d
### Configuration
See the full documentation for the `overview {}` section [here](./Configuration:-Miscellaneous.md#overview).
You can set the zoom-out level like this:
```kdl