config: add title window criteria
This commit is contained in:
parent
2b5be7fbd9
commit
6ef7655dbd
14 changed files with 109 additions and 23 deletions
|
|
@ -3,13 +3,15 @@ pub mod tlm_matchers;
|
|||
use {
|
||||
crate::{
|
||||
criteria::{
|
||||
CritDestroyListener, CritMatcherId, CritMatcherIds, CritMgrExt, CritUpstreamNode,
|
||||
FixedRootMatcher, RootMatcherMap,
|
||||
CritDestroyListener, CritLiteralOrRegex, CritMatcherId, CritMatcherIds, CritMgrExt,
|
||||
CritUpstreamNode, FixedRootMatcher, RootMatcherMap,
|
||||
clm::ClmUpstreamNode,
|
||||
crit_graph::{CritMgr, CritTarget, CritTargetOwner, WeakCritTargetOwner},
|
||||
crit_leaf::{CritLeafEvent, CritLeafMatcher},
|
||||
crit_matchers::critm_constant::CritMatchConstant,
|
||||
tlm::tlm_matchers::{tlmm_client::TlmMatchClient, tlmm_kind::TlmMatchKind},
|
||||
tlm::tlm_matchers::{
|
||||
tlmm_client::TlmMatchClient, tlmm_kind::TlmMatchKind, tlmm_string::TlmMatchTitle,
|
||||
},
|
||||
},
|
||||
state::State,
|
||||
tree::{NodeId, ToplevelData, ToplevelNode},
|
||||
|
|
@ -26,6 +28,7 @@ bitflags! {
|
|||
TlMatcherChange: u32;
|
||||
TL_CHANGED_DESTROYED = 1 << 0,
|
||||
TL_CHANGED_NEW = 1 << 1,
|
||||
TL_CHANGED_TITLE = 1 << 2,
|
||||
}
|
||||
|
||||
type TlmFixedRootMatcher<T> = FixedRootMatcher<ToplevelData, T>;
|
||||
|
|
@ -44,6 +47,7 @@ type TlmRootMatcherMap<T> = RootMatcherMap<ToplevelData, T>;
|
|||
pub struct RootMatchers {
|
||||
kinds: TlmRootMatcherMap<TlmMatchKind>,
|
||||
clients: CopyHashMap<CritMatcherId, Weak<TlmMatchClient>>,
|
||||
title: TlmRootMatcherMap<TlmMatchTitle>,
|
||||
}
|
||||
|
||||
pub async fn handle_tl_changes(state: Rc<State>) {
|
||||
|
|
@ -123,7 +127,6 @@ impl TlMatcherManager {
|
|||
}
|
||||
change |= TlMatcherChange::all();
|
||||
}
|
||||
#[expect(unused_macros)]
|
||||
macro_rules! conditional {
|
||||
($change:expr, $field:ident) => {
|
||||
if change.contains($change) && self.matchers.$field.is_not_empty() {
|
||||
|
|
@ -139,6 +142,7 @@ impl TlMatcherManager {
|
|||
}
|
||||
};
|
||||
}
|
||||
conditional!(TL_CHANGED_TITLE, title);
|
||||
false
|
||||
}
|
||||
|
||||
|
|
@ -188,7 +192,6 @@ impl TlMatcherManager {
|
|||
unconditional!(clients);
|
||||
self.constant[true].handle(data);
|
||||
}
|
||||
#[expect(unused_macros)]
|
||||
macro_rules! conditional {
|
||||
($change:expr, $field:ident) => {
|
||||
if changed.contains($change) {
|
||||
|
|
@ -206,6 +209,11 @@ impl TlMatcherManager {
|
|||
}
|
||||
};
|
||||
}
|
||||
conditional!(TL_CHANGED_TITLE, title);
|
||||
}
|
||||
|
||||
pub fn title(&self, string: CritLiteralOrRegex) -> Rc<TlmUpstreamNode> {
|
||||
self.root(TlmMatchTitle::new(string))
|
||||
}
|
||||
|
||||
pub fn kind(&self, kind: WindowType) -> Rc<TlmUpstreamNode> {
|
||||
|
|
|
|||
|
|
@ -20,3 +20,4 @@ macro_rules! fixed_root_criterion {
|
|||
|
||||
pub mod tlmm_client;
|
||||
pub mod tlmm_kind;
|
||||
pub mod tlmm_string;
|
||||
|
|
|
|||
23
src/criteria/tlm/tlm_matchers/tlmm_string.rs
Normal file
23
src/criteria/tlm/tlm_matchers/tlmm_string.rs
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
use crate::{
|
||||
criteria::{
|
||||
crit_matchers::critm_string::{CritMatchString, StringAccess},
|
||||
tlm::{RootMatchers, TlmRootMatcherMap},
|
||||
},
|
||||
tree::ToplevelData,
|
||||
};
|
||||
|
||||
pub type TlmMatchString<T> = CritMatchString<ToplevelData, T>;
|
||||
|
||||
pub type TlmMatchTitle = TlmMatchString<TitleAccess>;
|
||||
|
||||
pub struct TitleAccess;
|
||||
|
||||
impl StringAccess<ToplevelData> for TitleAccess {
|
||||
fn with_string(data: &ToplevelData, f: impl FnOnce(&str) -> bool) -> bool {
|
||||
f(&data.title.borrow())
|
||||
}
|
||||
|
||||
fn nodes(roots: &RootMatchers) -> &TlmRootMatcherMap<TlmMatchString<Self>> {
|
||||
&roots.title
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue