Darken background color when the window is inactive

This commit is contained in:
Val Packett 2026-03-20 01:06:59 -03:00
parent f32380416a
commit 3da5fac131
2 changed files with 15 additions and 6 deletions

View file

@ -26,6 +26,7 @@ use crate::{
#[derive(Default, Debug, Clone, PartialEq)]
struct DecoParams {
has_geometry: bool,
is_active: bool,
bounds: Bounds,
restricted_edges: Edges<bool>,
}
@ -208,6 +209,11 @@ impl Deco {
params.restricted_edges = edges;
}
pub fn set_active(&self, is_active: bool) {
let mut params = self.next_params.borrow_mut();
params.is_active = is_active;
}
pub fn handle_commit(&self) -> eyre::Result<()> {
self.draw()
}
@ -248,12 +254,14 @@ impl Deco {
let (buf, map) = pool.buffer(width, height)?;
let (pre, pix, post) = unsafe { map.align_to_mut::<u32>() };
assert!(pre.len() == 0 && post.len() == 0);
let bg = crate::ARGS
.get()
.unwrap()
.background
.premultiply()
.to_rgba8();
let set_bg = crate::ARGS.get().unwrap().background;
let bg = (if params.is_active {
set_bg
} else {
set_bg.scale_chroma(0.6)
})
.premultiply()
.to_rgba8();
let bg_argb = u32::from_be_bytes([bg.a, bg.r, bg.g, bg.b]);
for y in 0..height {
for x in 0..width {

View file

@ -293,6 +293,7 @@ impl XdgToplevelHandler for ClientXdgToplevel {
ToplevelState::Fullscreen => outer_state.push(XdgToplevelState::FULLSCREEN),
};
self.deco.set_active(activated);
self.deco.set_restricted_edges(restricted_edges);
let (width, height) = self.deco.transform_configure(width, height);
let (_prefix, states, _suffix) = unsafe { outer_state.align_to::<u8>() };