Darken background color when the window is inactive
This commit is contained in:
parent
f32380416a
commit
3da5fac131
2 changed files with 15 additions and 6 deletions
16
src/deco.rs
16
src/deco.rs
|
|
@ -26,6 +26,7 @@ use crate::{
|
||||||
#[derive(Default, Debug, Clone, PartialEq)]
|
#[derive(Default, Debug, Clone, PartialEq)]
|
||||||
struct DecoParams {
|
struct DecoParams {
|
||||||
has_geometry: bool,
|
has_geometry: bool,
|
||||||
|
is_active: bool,
|
||||||
bounds: Bounds,
|
bounds: Bounds,
|
||||||
restricted_edges: Edges<bool>,
|
restricted_edges: Edges<bool>,
|
||||||
}
|
}
|
||||||
|
|
@ -208,6 +209,11 @@ impl Deco {
|
||||||
params.restricted_edges = edges;
|
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<()> {
|
pub fn handle_commit(&self) -> eyre::Result<()> {
|
||||||
self.draw()
|
self.draw()
|
||||||
}
|
}
|
||||||
|
|
@ -248,10 +254,12 @@ impl Deco {
|
||||||
let (buf, map) = pool.buffer(width, height)?;
|
let (buf, map) = pool.buffer(width, height)?;
|
||||||
let (pre, pix, post) = unsafe { map.align_to_mut::<u32>() };
|
let (pre, pix, post) = unsafe { map.align_to_mut::<u32>() };
|
||||||
assert!(pre.len() == 0 && post.len() == 0);
|
assert!(pre.len() == 0 && post.len() == 0);
|
||||||
let bg = crate::ARGS
|
let set_bg = crate::ARGS.get().unwrap().background;
|
||||||
.get()
|
let bg = (if params.is_active {
|
||||||
.unwrap()
|
set_bg
|
||||||
.background
|
} else {
|
||||||
|
set_bg.scale_chroma(0.6)
|
||||||
|
})
|
||||||
.premultiply()
|
.premultiply()
|
||||||
.to_rgba8();
|
.to_rgba8();
|
||||||
let bg_argb = u32::from_be_bytes([bg.a, bg.r, bg.g, bg.b]);
|
let bg_argb = u32::from_be_bytes([bg.a, bg.r, bg.g, bg.b]);
|
||||||
|
|
|
||||||
|
|
@ -293,6 +293,7 @@ impl XdgToplevelHandler for ClientXdgToplevel {
|
||||||
ToplevelState::Fullscreen => outer_state.push(XdgToplevelState::FULLSCREEN),
|
ToplevelState::Fullscreen => outer_state.push(XdgToplevelState::FULLSCREEN),
|
||||||
};
|
};
|
||||||
|
|
||||||
|
self.deco.set_active(activated);
|
||||||
self.deco.set_restricted_edges(restricted_edges);
|
self.deco.set_restricted_edges(restricted_edges);
|
||||||
let (width, height) = self.deco.transform_configure(width, height);
|
let (width, height) = self.deco.transform_configure(width, height);
|
||||||
let (_prefix, states, _suffix) = unsafe { outer_state.align_to::<u8>() };
|
let (_prefix, states, _suffix) = unsafe { outer_state.align_to::<u8>() };
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue