Add backdrop-color setting to overview {}

This commit is contained in:
Ivan Molodetskikh
2025-04-28 07:53:03 +03:00
parent db09727b18
commit fd389af6d8
4 changed files with 45 additions and 24 deletions
+13 -9
View File
@@ -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(
[
+12 -7
View File
@@ -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.;
+12
View File
@@ -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>
+8 -8
View File
@@ -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"
}
```