config: add WM_WINDOW_ROLE window criteria
This commit is contained in:
parent
faa0b27ef8
commit
5ad6ca4dd3
14 changed files with 81 additions and 6 deletions
|
|
@ -19,7 +19,8 @@ use {
|
|||
tlmm_kind::TlmMatchKind,
|
||||
tlmm_seat_focus::TlmMatchSeatFocus,
|
||||
tlmm_string::{
|
||||
TlmMatchAppId, TlmMatchClass, TlmMatchInstance, TlmMatchTag, TlmMatchTitle,
|
||||
TlmMatchAppId, TlmMatchClass, TlmMatchInstance, TlmMatchRole, TlmMatchTag,
|
||||
TlmMatchTitle,
|
||||
},
|
||||
tlmm_urgent::TlmMatchUrgent,
|
||||
tlmm_visible::TlmMatchVisible,
|
||||
|
|
@ -55,6 +56,7 @@ bitflags! {
|
|||
TL_CHANGED_JUST_MAPPED = 1 << 9,
|
||||
TL_CHANGED_TAG = 1 << 10,
|
||||
TL_CHANGED_CLASS_INST = 1 << 11,
|
||||
TL_CHANGED_ROLE = 1 << 12,
|
||||
}
|
||||
|
||||
type TlmFixedRootMatcher<T> = FixedRootMatcher<ToplevelData, T>;
|
||||
|
|
@ -85,6 +87,7 @@ pub struct RootMatchers {
|
|||
seat_foci: TlmRootMatcherMap<TlmMatchSeatFocus>,
|
||||
class: TlmRootMatcherMap<TlmMatchClass>,
|
||||
instance: TlmRootMatcherMap<TlmMatchInstance>,
|
||||
role: TlmRootMatcherMap<TlmMatchRole>,
|
||||
}
|
||||
|
||||
pub async fn handle_tl_changes(state: Rc<State>) {
|
||||
|
|
@ -215,6 +218,7 @@ impl TlMatcherManager {
|
|||
conditional!(TL_CHANGED_TAG, tag);
|
||||
conditional!(TL_CHANGED_CLASS_INST, class);
|
||||
conditional!(TL_CHANGED_CLASS_INST, instance);
|
||||
conditional!(TL_CHANGED_ROLE, role);
|
||||
fixed_conditional!(TL_CHANGED_FLOATING, floating);
|
||||
fixed_conditional!(TL_CHANGED_VISIBLE, visible);
|
||||
fixed_conditional!(TL_CHANGED_URGENT, urgent);
|
||||
|
|
@ -290,6 +294,7 @@ impl TlMatcherManager {
|
|||
conditional!(TL_CHANGED_TAG, tag);
|
||||
conditional!(TL_CHANGED_CLASS_INST, class);
|
||||
conditional!(TL_CHANGED_CLASS_INST, instance);
|
||||
conditional!(TL_CHANGED_ROLE, role);
|
||||
fixed_conditional!(TL_CHANGED_FLOATING, floating);
|
||||
fixed_conditional!(TL_CHANGED_VISIBLE, visible);
|
||||
fixed_conditional!(TL_CHANGED_URGENT, urgent);
|
||||
|
|
@ -355,6 +360,10 @@ impl TlMatcherManager {
|
|||
pub fn instance(&self, string: CritLiteralOrRegex) -> Rc<TlmUpstreamNode> {
|
||||
self.root(TlmMatchInstance::new(string))
|
||||
}
|
||||
|
||||
pub fn role(&self, string: CritLiteralOrRegex) -> Rc<TlmUpstreamNode> {
|
||||
self.root(TlmMatchRole::new(string))
|
||||
}
|
||||
}
|
||||
|
||||
impl CritTarget for ToplevelData {
|
||||
|
|
|
|||
|
|
@ -13,12 +13,14 @@ pub type TlmMatchAppId = TlmMatchString<AppIdAccess>;
|
|||
pub type TlmMatchTag = TlmMatchString<TagAccess>;
|
||||
pub type TlmMatchClass = TlmMatchString<ClassAccess>;
|
||||
pub type TlmMatchInstance = TlmMatchString<InstanceAccess>;
|
||||
pub type TlmMatchRole = TlmMatchString<RoleAccess>;
|
||||
|
||||
pub struct TitleAccess;
|
||||
pub struct AppIdAccess;
|
||||
pub struct TagAccess;
|
||||
pub struct ClassAccess;
|
||||
pub struct InstanceAccess;
|
||||
pub struct RoleAccess;
|
||||
|
||||
impl StringAccess<ToplevelData> for TitleAccess {
|
||||
fn with_string(data: &ToplevelData, f: impl FnOnce(&str) -> bool) -> bool {
|
||||
|
|
@ -78,3 +80,16 @@ impl StringAccess<ToplevelData> for InstanceAccess {
|
|||
&roots.instance
|
||||
}
|
||||
}
|
||||
|
||||
impl StringAccess<ToplevelData> for RoleAccess {
|
||||
fn with_string(data: &ToplevelData, f: impl FnOnce(&str) -> bool) -> bool {
|
||||
if let ToplevelType::XWindow(data) = &data.kind {
|
||||
return f(&data.info.role.borrow().as_deref().unwrap_or_default());
|
||||
}
|
||||
false
|
||||
}
|
||||
|
||||
fn nodes(roots: &RootMatchers) -> &TlmRootMatcherMap<TlmMatchString<Self>> {
|
||||
&roots.role
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue