Implement xray background effect

This commit is contained in:
Ivan Molodetskikh
2026-04-14 07:33:50 +00:00
parent 7f9c7d1415
commit fee8719299
34 changed files with 1485 additions and 82 deletions
+23
View File
@@ -1006,6 +1006,29 @@ where
}
}
#[derive(knuffel::Decode, Debug, Default, Clone, Copy, PartialEq)]
pub struct BackgroundEffectRule {
#[knuffel(child, unwrap(argument))]
pub xray: Option<bool>,
}
/// Resolved background effect rule.
#[derive(Debug, Default, Clone, Copy, PartialEq)]
pub struct BackgroundEffect {
/// Whether to render with xray effect (see through).
///
/// - `None`: xray if any background effect is active
/// - `Some(false)`: no xray
/// - `Some(true)`: xray even if no other background effect is active
pub xray: Option<bool>,
}
impl MergeWith<BackgroundEffectRule> for BackgroundEffect {
fn merge_with(&mut self, part: &BackgroundEffectRule) {
merge_clone_opt!((self, part), xray);
}
}
#[cfg(test)]
mod tests {
use insta::{assert_debug_snapshot, assert_snapshot};
+3 -1
View File
@@ -1,4 +1,4 @@
use crate::appearance::{BlockOutFrom, CornerRadius, ShadowRule};
use crate::appearance::{BackgroundEffectRule, BlockOutFrom, CornerRadius, ShadowRule};
use crate::utils::RegexEq;
#[derive(knuffel::Decode, Debug, Default, Clone, PartialEq)]
@@ -20,6 +20,8 @@ pub struct LayerRule {
pub place_within_backdrop: Option<bool>,
#[knuffel(child, unwrap(argument))]
pub baba_is_float: Option<bool>,
#[knuffel(child, default)]
pub background_effect: BackgroundEffectRule,
}
#[derive(knuffel::Decode, Debug, Default, Clone, PartialEq)]
+6
View File
@@ -1845,6 +1845,9 @@ mod tests {
),
scroll_factor: None,
tiled_state: None,
background_effect: BackgroundEffectRule {
xray: None,
},
},
],
layer_rules: [
@@ -1880,6 +1883,9 @@ mod tests {
geometry_corner_radius: None,
place_within_backdrop: None,
baba_is_float: None,
background_effect: BackgroundEffectRule {
xray: None,
},
},
],
binds: Binds(
+5 -1
View File
@@ -1,6 +1,8 @@
use niri_ipc::ColumnDisplay;
use crate::appearance::{BlockOutFrom, BorderRule, CornerRadius, ShadowRule, TabIndicatorRule};
use crate::appearance::{
BackgroundEffectRule, BlockOutFrom, BorderRule, CornerRadius, ShadowRule, TabIndicatorRule,
};
use crate::layout::DefaultPresetSize;
use crate::utils::RegexEq;
use crate::FloatOrInt;
@@ -72,6 +74,8 @@ pub struct WindowRule {
pub scroll_factor: Option<FloatOrInt<0, 100>>,
#[knuffel(child, unwrap(argument))]
pub tiled_state: Option<bool>,
#[knuffel(child, default)]
pub background_effect: BackgroundEffectRule,
}
#[derive(knuffel::Decode, Debug, Default, Clone, PartialEq)]