@@ -1006,6 +1006,101 @@ where
10061006 }
10071007}
10081008
1009+ #[ derive( Debug , Clone , Copy , PartialEq ) ]
1010+ pub struct Blur {
1011+ pub off : bool ,
1012+ pub passes : u8 ,
1013+ pub offset : f64 ,
1014+ }
1015+
1016+ impl Default for Blur {
1017+ fn default ( ) -> Self {
1018+ Self {
1019+ off : false ,
1020+ // TODO: tune, reduce passes
1021+ passes : 3 ,
1022+ offset : 3. ,
1023+ }
1024+ }
1025+ }
1026+
1027+ #[ derive( knuffel:: Decode , Debug , Default , Clone , Copy , PartialEq ) ]
1028+ pub struct BlurPart {
1029+ #[ knuffel( child) ]
1030+ pub off : bool ,
1031+ #[ knuffel( child) ]
1032+ pub on : bool ,
1033+ #[ knuffel( child, unwrap( argument) ) ]
1034+ pub passes : Option < u8 > ,
1035+ #[ knuffel( child, unwrap( argument) ) ]
1036+ pub offset : Option < FloatOrInt < 0 , 100 > > ,
1037+ }
1038+
1039+ impl MergeWith < BlurPart > for Blur {
1040+ fn merge_with ( & mut self , part : & BlurPart ) {
1041+ self . off |= part. off ;
1042+ if part. on {
1043+ self . off = false ;
1044+ }
1045+
1046+ merge_clone ! ( ( self , part) , passes) ;
1047+ merge ! ( ( self , part) , offset) ;
1048+ }
1049+ }
1050+
1051+ #[ derive( knuffel:: Decode , Debug , Default , Clone , Copy , PartialEq ) ]
1052+ pub struct BlurRule {
1053+ #[ knuffel( child) ]
1054+ pub off : bool ,
1055+ #[ knuffel( child) ]
1056+ pub on : bool ,
1057+ }
1058+
1059+ #[ derive( knuffel:: Decode , Debug , Default , Clone , Copy , PartialEq ) ]
1060+ pub struct BackgroundEffectRule {
1061+ #[ knuffel( child, unwrap( argument) ) ]
1062+ pub xray : Option < bool > ,
1063+ #[ knuffel( child, default ) ]
1064+ pub blur : BlurRule ,
1065+ }
1066+
1067+ impl MergeWith < Self > for BackgroundEffectRule {
1068+ fn merge_with ( & mut self , part : & Self ) {
1069+ merge_clone_opt ! ( ( self , part) , xray) ;
1070+ merge_on_off ! ( ( self . blur, part. blur) ) ;
1071+ }
1072+ }
1073+
1074+ /// Resolved background effect rule.
1075+ #[ derive( Debug , Default , Clone , Copy , PartialEq ) ]
1076+ pub struct BackgroundEffect {
1077+ /// Whether to render with xray effect (see through).
1078+ pub xray : bool ,
1079+
1080+ /// Whether to blur the background.
1081+ ///
1082+ /// - `None`: blur when the window/layer requests it (e.g. through ext-background-effect
1083+ /// protocol)
1084+ /// - `Some(false)`: never blur
1085+ /// - `Some(true)`: always blur
1086+ pub blur : Option < bool > ,
1087+ }
1088+
1089+ impl MergeWith < BackgroundEffectRule > for BackgroundEffect {
1090+ fn merge_with ( & mut self , part : & BackgroundEffectRule ) {
1091+ if let Some ( x) = part. xray {
1092+ self . xray = x;
1093+ }
1094+
1095+ if part. blur . on {
1096+ self . blur = Some ( true ) ;
1097+ }
1098+ if part. blur . off {
1099+ self . blur = Some ( false ) ;
1100+ }
1101+ }
1102+ }
1103+
10091104#[ cfg( test) ]
10101105mod tests {
10111106 use insta:: { assert_debug_snapshot, assert_snapshot} ;
0 commit comments