1
0
Fork 0
forked from wry/wry

config: add title window criteria

This commit is contained in:
Julian Orth 2025-05-01 18:22:33 +02:00
parent 2b5be7fbd9
commit 6ef7655dbd
14 changed files with 109 additions and 23 deletions

View file

@ -255,6 +255,8 @@ pub struct WindowMatch {
pub generic: GenericMatch<Self>,
pub types: Option<WindowType>,
pub client: Option<ClientMatch>,
pub title: Option<String>,
pub title_regex: Option<String>,
}
#[derive(Debug, Clone)]

View file

@ -44,16 +44,27 @@ impl Parser for WindowMatchParser<'_> {
table: &IndexMap<Spanned<String>, Spanned<Value>>,
) -> ParseResult<Self> {
let mut ext = Extractor::new(self.0, span, table);
let ((name, not_val, all_val, any_val, exactly_val, types_val, client_val),) = ext
.extract(((
opt(str("name")),
opt(val("not")),
opt(arr("all")),
opt(arr("any")),
opt(val("exactly")),
opt(val("types")),
opt(val("client")),
),))?;
let ((
name,
not_val,
all_val,
any_val,
exactly_val,
types_val,
client_val,
title,
title_regex,
),) = ext.extract(((
opt(str("name")),
opt(val("not")),
opt(arr("all")),
opt(arr("any")),
opt(val("exactly")),
opt(val("types")),
opt(val("client")),
opt(str("title")),
opt(str("title-regex")),
),))?;
let mut not = None;
if let Some(value) = not_val {
not = Some(Box::new(value.parse(&mut WindowMatchParser(self.0))?));
@ -93,6 +104,8 @@ impl Parser for WindowMatchParser<'_> {
any,
exactly,
},
title: title.despan_into(),
title_regex: title_regex.despan_into(),
types,
client,
})

View file

@ -224,7 +224,6 @@ impl Rule for WindowRule {
match_: &Self::Match,
) -> Option<()> {
let m = |c: WindowCriterion<'_>| MatcherTemp(c.to_matcher());
#[expect(unused_macros)]
macro_rules! value {
($ty:ident, $field:ident) => {
if let Some(value) = &match_.$field {
@ -256,6 +255,8 @@ impl Rule for WindowRule {
matcher.0,
))));
}
value!(Title, title);
value!(TitleRegex, title_regex);
Some(())
}