aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIvan Molodetskikh <yalterz@gmail.com>2025-05-01 09:36:10 +0300
committerIvan Molodetskikh <yalterz@gmail.com>2025-05-01 09:45:38 +0300
commit446bc155ce15103c347c1a4f654c71a88d9991fa (patch)
tree63ec298768577b1ed14ff4dfc1e729bcd43d9aaf
parent3289324ce412f882566c99d53732078bf888ad56 (diff)
downloadniri-446bc155ce15103c347c1a4f654c71a88d9991fa.tar.gz
niri-446bc155ce15103c347c1a4f654c71a88d9991fa.tar.bz2
niri-446bc155ce15103c347c1a4f654c71a88d9991fa.zip
Add workspace-shadow {} config to overview {}
-rw-r--r--niri-config/src/lib.rs69
-rw-r--r--src/layout/workspace.rs32
-rw-r--r--wiki/Configuration:-Miscellaneous.md26
-rw-r--r--wiki/Overview.md2
4 files changed, 103 insertions, 26 deletions
diff --git a/niri-config/src/lib.rs b/niri-config/src/lib.rs
index 263ab7a7..8bb069c6 100644
--- a/niri-config/src/lib.rs
+++ b/niri-config/src/lib.rs
@@ -755,6 +755,49 @@ pub struct ShadowOffset {
}
#[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)]
pub off: bool,
@@ -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(
[
diff --git a/src/layout/workspace.rs b/src/layout/workspace.rs
index 58a2d40f..fe9ce585 100644
--- a/src/layout/workspace.rs
+++ b/src/layout/workspace.rs
@@ -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;
}
diff --git a/wiki/Configuration:-Miscellaneous.md b/wiki/Configuration:-Miscellaneous.md
index 5f4a8e7c..ee78cebd 100644
--- a/wiki/Configuration:-Miscellaneous.md
+++ b/wiki/Configuration:-Miscellaneous.md
@@ -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>
diff --git a/wiki/Overview.md b/wiki/Overview.md
index 57629c2e..c907eb67 100644
--- a/wiki/Overview.md
+++ b/wiki/Overview.md
@@ -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