1
0
Fork 0
forked from wry/wry

config: add client window criteria

This commit is contained in:
Julian Orth 2025-05-02 23:46:11 +02:00
parent 59f8acdfde
commit 2b5be7fbd9
19 changed files with 205 additions and 14 deletions

View file

@ -109,6 +109,7 @@ pub enum WindowCriterionIpc {
regex: bool,
},
Types(WindowType),
Client(ClientMatcher),
}
#[derive(Serialize, Deserialize, Clone, Debug, Hash, Eq, PartialEq)]

View file

@ -1638,6 +1638,7 @@ impl ConfigClient {
destroy_matcher,
)
};
let _destroy_client_matcher;
let criterion = match criterion {
WindowCriterion::Matcher(m) => return generic(GenericCriterion::Matcher(m)),
WindowCriterion::Not(c) => return generic(GenericCriterion::Not(c)),
@ -1645,6 +1646,13 @@ impl ConfigClient {
WindowCriterion::Any(c) => return generic(GenericCriterion::Any(c)),
WindowCriterion::Exactly(n, c) => return generic(GenericCriterion::Exactly(n, c)),
WindowCriterion::Types(t) => WindowCriterionIpc::Types(t),
WindowCriterion::Client(c) => {
let (matcher, original) = self.create_client_matcher_(*c, true);
if original {
_destroy_client_matcher = on_drop(move || matcher.destroy());
}
WindowCriterionIpc::Client(matcher)
}
};
let res = self.send_with_response(&ClientMessage::CreateWindowMatcher { criterion });
get_response!(

View file

@ -1,7 +1,10 @@
//! Tools for inspecting and manipulating windows.
use {
crate::{Axis, Direction, Workspace, client::Client},
crate::{
Axis, Direction, Workspace,
client::{Client, ClientCriterion},
},
serde::{Deserialize, Serialize},
std::ops::Deref,
};
@ -231,6 +234,8 @@ pub enum WindowCriterion<'a> {
Any(&'a [WindowCriterion<'a>]),
/// Matches if an exact number of the contained criteria match.
Exactly(usize, &'a [WindowCriterion<'a>]),
/// Matches if the window's client matches the client criterion.
Client(&'a ClientCriterion<'a>),
}
impl WindowCriterion<'_> {