aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIvan Molodetskikh <yalterz@gmail.com>2025-04-28 07:53:03 +0300
committerIvan Molodetskikh <yalterz@gmail.com>2025-04-28 09:14:43 +0300
commitfd389af6d8c905b8af3d0896a109a301bf404658 (patch)
tree78069fa7b9ca5615518276bb8304c7a5054c7082
parentdb09727b183d34675f645b499e8153c822260bfa (diff)
downloadniri-fd389af6d8c905b8af3d0896a109a301bf404658.tar.gz
niri-fd389af6d8c905b8af3d0896a109a301bf404658.tar.bz2
niri-fd389af6d8c905b8af3d0896a109a301bf404658.zip
Add backdrop-color setting to overview {}
-rw-r--r--niri-config/src/lib.rs22
-rw-r--r--src/niri.rs19
-rw-r--r--wiki/Configuration:-Miscellaneous.md12
-rw-r--r--wiki/Overview.md16
4 files changed, 45 insertions, 24 deletions
diff --git a/niri-config/src/lib.rs b/niri-config/src/lib.rs
index 3fef17b1..e77ff558 100644
--- a/niri-config/src/lib.rs
+++ b/niri-config/src/lib.rs
@@ -447,8 +447,8 @@ pub struct Output {
pub focus_at_startup: bool,
#[knuffel(child, default = DEFAULT_BACKGROUND_COLOR)]
pub background_color: Color,
- #[knuffel(child, default = DEFAULT_BACKDROP_COLOR)]
- pub backdrop_color: Color,
+ #[knuffel(child)]
+ pub backdrop_color: Option<Color>,
}
impl Output {
@@ -477,7 +477,7 @@ impl Default for Output {
mode: None,
variable_refresh_rate: None,
background_color: DEFAULT_BACKGROUND_COLOR,
- backdrop_color: DEFAULT_BACKDROP_COLOR,
+ backdrop_color: None,
}
}
}
@@ -1264,12 +1264,15 @@ pub struct HotCorners {
pub struct Overview {
#[knuffel(child, unwrap(argument), default = Self::default().zoom)]
pub zoom: FloatOrInt<0, 1>,
+ #[knuffel(child, default = Self::default().backdrop_color)]
+ pub backdrop_color: Color,
}
impl Default for Overview {
fn default() -> Self {
Self {
zoom: FloatOrInt(0.5),
+ backdrop_color: DEFAULT_BACKDROP_COLOR,
}
}
}
@@ -4225,12 +4228,7 @@ mod tests {
b: 0.4,
a: 1.0,
},
- backdrop_color: Color {
- r: 0.15,
- g: 0.15,
- b: 0.15,
- a: 1.0,
- },
+ backdrop_color: None,
},
],
),
@@ -4603,6 +4601,12 @@ mod tests {
zoom: FloatOrInt(
0.5,
),
+ backdrop_color: Color {
+ r: 0.15,
+ g: 0.15,
+ b: 0.15,
+ a: 1.0,
+ },
},
environment: Environment(
[
diff --git a/src/niri.rs b/src/niri.rs
index 292618cc..de3ec082 100644
--- a/src/niri.rs
+++ b/src/niri.rs
@@ -15,7 +15,7 @@ use anyhow::{bail, ensure, Context};
use calloop::futures::Scheduler;
use niri_config::{
Config, FloatOrInt, Key, Modifiers, OutputName, PreviewRender, TrackLayout,
- WarpMouseToFocusMode, WorkspaceReference, DEFAULT_BACKDROP_COLOR, DEFAULT_BACKGROUND_COLOR,
+ WarpMouseToFocusMode, WorkspaceReference, DEFAULT_BACKGROUND_COLOR,
};
use smithay::backend::allocator::Fourcc;
use smithay::backend::input::Keycode;
@@ -1394,6 +1394,11 @@ impl State {
output_config_changed = true;
}
+ // FIXME: move backdrop rendering into layout::Monitor, then this will become unnecessary.
+ if config.overview.backdrop_color != old_config.overview.backdrop_color {
+ output_config_changed = true;
+ }
+
*old_config = config;
if let Some(outputs) = preserved_output_config {
@@ -1471,8 +1476,8 @@ impl State {
for output in self.niri.global_space.outputs() {
let name = output.user_data().get::<OutputName>().unwrap();
- let config = self.niri.config.borrow_mut();
- let config = config.outputs.find(name);
+ let full_config = self.niri.config.borrow_mut();
+ let config = full_config.outputs.find(name);
let scale = config
.and_then(|c| c.scale)
@@ -1513,8 +1518,8 @@ impl State {
let background_color = Color32F::from(background_color);
let mut backdrop_color = config
- .map(|c| c.backdrop_color)
- .unwrap_or(DEFAULT_BACKDROP_COLOR)
+ .and_then(|c| c.backdrop_color)
+ .unwrap_or(full_config.overview.backdrop_color)
.to_array_unpremul();
backdrop_color[3] = 1.;
let backdrop_color = Color32F::from(backdrop_color);
@@ -2701,8 +2706,8 @@ impl Niri {
background_color[3] = 1.;
let mut backdrop_color = c
- .map(|c| c.backdrop_color)
- .unwrap_or(DEFAULT_BACKDROP_COLOR)
+ .and_then(|c| c.backdrop_color)
+ .unwrap_or(config.overview.backdrop_color)
.to_array_unpremul();
backdrop_color[3] = 1.;
diff --git a/wiki/Configuration:-Miscellaneous.md b/wiki/Configuration:-Miscellaneous.md
index 1d5bf0f8..be957721 100644
--- a/wiki/Configuration:-Miscellaneous.md
+++ b/wiki/Configuration:-Miscellaneous.md
@@ -25,6 +25,7 @@ cursor {
overview {
zoom 0.5
+ backdrop-color "#262626"
}
clipboard {
@@ -161,6 +162,17 @@ overview {
}
```
+`backdrop-color` sets the backdrop color behind workspaces in the overview.
+The backdrop is also visible between workspaces when switching.
+
+The alpha channel for this color will be ignored.
+
+```kdl
+overview {
+ backdrop-color "#262626"
+}
+```
+
### `clipboard`
<sup>Since: 25.02</sup>
diff --git a/wiki/Overview.md b/wiki/Overview.md
index 6ea27b3b..99da885c 100644
--- a/wiki/Overview.md
+++ b/wiki/Overview.md
@@ -38,6 +38,14 @@ overview {
}
```
+To change the color behind the workspaces, use the `backdrop-color` setting:
+
+```kdl
+overview {
+ backdrop-color "#777777"
+}
+```
+
You can also disable the hot corner:
```kdl
@@ -48,11 +56,3 @@ gestures {
}
}
```
-
-To change the color behind the workspaces, use the `backdrop-color` output setting:
-
-```kdl
-output "HDMI-A-1" {
- backdrop-color "#777777"
-}
-```