1
0
Fork 0
forked from wry/wry

config: add toplevel-tag window criteria

This commit is contained in:
Julian Orth 2025-05-01 17:31:42 +02:00
parent 5f1268cada
commit 6d3d4dcabb
15 changed files with 106 additions and 8 deletions

View file

@ -3,16 +3,18 @@ use crate::{
crit_matchers::critm_string::{CritMatchString, StringAccess},
tlm::{RootMatchers, TlmRootMatcherMap},
},
tree::ToplevelData,
tree::{ToplevelData, ToplevelType},
};
pub type TlmMatchString<T> = CritMatchString<ToplevelData, T>;
pub type TlmMatchTitle = TlmMatchString<TitleAccess>;
pub type TlmMatchAppId = TlmMatchString<AppIdAccess>;
pub type TlmMatchTag = TlmMatchString<TagAccess>;
pub struct TitleAccess;
pub struct AppIdAccess;
pub struct TagAccess;
impl StringAccess<ToplevelData> for TitleAccess {
fn with_string(data: &ToplevelData, f: impl FnOnce(&str) -> bool) -> bool {
@ -33,3 +35,16 @@ impl StringAccess<ToplevelData> for AppIdAccess {
&roots.app_id
}
}
impl StringAccess<ToplevelData> for TagAccess {
fn with_string(data: &ToplevelData, f: impl FnOnce(&str) -> bool) -> bool {
if let ToplevelType::XdgToplevel(data) = &data.kind {
return f(&data.tag.borrow());
}
false
}
fn nodes(roots: &RootMatchers) -> &TlmRootMatcherMap<TlmMatchString<Self>> {
&roots.tag
}
}