1
0
Fork 0
forked from wry/wry

clm: allow matching clients by id

This commit is contained in:
Julian Orth 2026-03-07 11:47:57 +01:00
parent acec4c7f09
commit c75b6ef66e
3 changed files with 29 additions and 0 deletions

View file

@ -7,6 +7,7 @@ use {
CritDestroyListener, CritLiteralOrRegex, CritMatcherId, CritMatcherIds, CritMgrExt,
CritUpstreamNode, FixedRootMatcher, RootMatcherMap,
clm::clm_matchers::{
clmm_id::ClmMatchId,
clmm_is_xwayland::ClmMatchIsXwayland,
clmm_pid::ClmMatchPid,
clmm_sandboxed::ClmMatchSandboxed,
@ -62,6 +63,7 @@ pub struct RootMatchers {
comm: ClmRootMatcherMap<ClmMatchComm>,
exe: ClmRootMatcherMap<ClmMatchExe>,
tag: ClmRootMatcherMap<ClmMatchTag>,
id: ClmRootMatcherMap<ClmMatchId>,
}
impl RootMatchers {
@ -74,6 +76,7 @@ impl RootMatchers {
self.comm.clear();
self.exe.clear();
self.tag.clear();
self.id.clear();
}
}
@ -184,6 +187,7 @@ impl ClMatcherManager {
unconditional!(comm);
unconditional!(exe);
unconditional!(tag);
unconditional!(id);
fixed!(sandboxed);
fixed!(is_xwayland);
self.constant[true].handle(data);
@ -229,6 +233,11 @@ impl ClMatcherManager {
pub fn tag(&self, string: CritLiteralOrRegex) -> Rc<ClmUpstreamNode> {
self.root(ClmMatchTag::new(string))
}
#[expect(dead_code)]
pub fn id(&self, id: ClientId) -> Rc<ClmUpstreamNode> {
self.root(ClmMatchId(id))
}
}
impl CritTarget for Rc<Client> {

View file

@ -17,6 +17,7 @@ macro_rules! fixed_root_criterion {
};
}
pub mod clmm_id;
pub mod clmm_is_xwayland;
pub mod clmm_pid;
pub mod clmm_sandboxed;

View file

@ -0,0 +1,19 @@
use {
crate::{
client::{Client, ClientId},
criteria::{RootMatcherMap, clm::RootMatchers, crit_graph::CritRootCriterion},
},
std::rc::Rc,
};
pub struct ClmMatchId(pub ClientId);
impl CritRootCriterion<Rc<Client>> for ClmMatchId {
fn matches(&self, data: &Rc<Client>) -> bool {
data.id == self.0
}
fn nodes(roots: &RootMatchers) -> Option<&RootMatcherMap<Rc<Client>, Self>> {
Some(&roots.id)
}
}