config: add WM_CLASS window criteria
This commit is contained in:
parent
6d3d4dcabb
commit
faa0b27ef8
15 changed files with 159 additions and 10 deletions
|
|
@ -18,7 +18,9 @@ use {
|
|||
tlmm_just_mapped::TlmMatchJustMapped,
|
||||
tlmm_kind::TlmMatchKind,
|
||||
tlmm_seat_focus::TlmMatchSeatFocus,
|
||||
tlmm_string::{TlmMatchAppId, TlmMatchTag, TlmMatchTitle},
|
||||
tlmm_string::{
|
||||
TlmMatchAppId, TlmMatchClass, TlmMatchInstance, TlmMatchTag, TlmMatchTitle,
|
||||
},
|
||||
tlmm_urgent::TlmMatchUrgent,
|
||||
tlmm_visible::TlmMatchVisible,
|
||||
},
|
||||
|
|
@ -52,6 +54,7 @@ bitflags! {
|
|||
TL_CHANGED_FULLSCREEN = 1 << 8,
|
||||
TL_CHANGED_JUST_MAPPED = 1 << 9,
|
||||
TL_CHANGED_TAG = 1 << 10,
|
||||
TL_CHANGED_CLASS_INST = 1 << 11,
|
||||
}
|
||||
|
||||
type TlmFixedRootMatcher<T> = FixedRootMatcher<ToplevelData, T>;
|
||||
|
|
@ -80,6 +83,8 @@ pub struct RootMatchers {
|
|||
tag: TlmRootMatcherMap<TlmMatchTag>,
|
||||
app_id: TlmRootMatcherMap<TlmMatchAppId>,
|
||||
seat_foci: TlmRootMatcherMap<TlmMatchSeatFocus>,
|
||||
class: TlmRootMatcherMap<TlmMatchClass>,
|
||||
instance: TlmRootMatcherMap<TlmMatchInstance>,
|
||||
}
|
||||
|
||||
pub async fn handle_tl_changes(state: Rc<State>) {
|
||||
|
|
@ -208,6 +213,8 @@ impl TlMatcherManager {
|
|||
conditional!(TL_CHANGED_APP_ID, app_id);
|
||||
conditional!(TL_CHANGED_SEAT_FOCI, seat_foci);
|
||||
conditional!(TL_CHANGED_TAG, tag);
|
||||
conditional!(TL_CHANGED_CLASS_INST, class);
|
||||
conditional!(TL_CHANGED_CLASS_INST, instance);
|
||||
fixed_conditional!(TL_CHANGED_FLOATING, floating);
|
||||
fixed_conditional!(TL_CHANGED_VISIBLE, visible);
|
||||
fixed_conditional!(TL_CHANGED_URGENT, urgent);
|
||||
|
|
@ -281,6 +288,8 @@ impl TlMatcherManager {
|
|||
conditional!(TL_CHANGED_APP_ID, app_id);
|
||||
conditional!(TL_CHANGED_SEAT_FOCI, seat_foci);
|
||||
conditional!(TL_CHANGED_TAG, tag);
|
||||
conditional!(TL_CHANGED_CLASS_INST, class);
|
||||
conditional!(TL_CHANGED_CLASS_INST, instance);
|
||||
fixed_conditional!(TL_CHANGED_FLOATING, floating);
|
||||
fixed_conditional!(TL_CHANGED_VISIBLE, visible);
|
||||
fixed_conditional!(TL_CHANGED_URGENT, urgent);
|
||||
|
|
@ -338,6 +347,14 @@ impl TlMatcherManager {
|
|||
pub fn seat_focus(&self, seat: &WlSeatGlobal) -> Rc<TlmUpstreamNode> {
|
||||
self.root(TlmMatchSeatFocus::new(seat.id()))
|
||||
}
|
||||
|
||||
pub fn class(&self, string: CritLiteralOrRegex) -> Rc<TlmUpstreamNode> {
|
||||
self.root(TlmMatchClass::new(string))
|
||||
}
|
||||
|
||||
pub fn instance(&self, string: CritLiteralOrRegex) -> Rc<TlmUpstreamNode> {
|
||||
self.root(TlmMatchInstance::new(string))
|
||||
}
|
||||
}
|
||||
|
||||
impl CritTarget for ToplevelData {
|
||||
|
|
|
|||
|
|
@ -11,10 +11,14 @@ pub type TlmMatchString<T> = CritMatchString<ToplevelData, T>;
|
|||
pub type TlmMatchTitle = TlmMatchString<TitleAccess>;
|
||||
pub type TlmMatchAppId = TlmMatchString<AppIdAccess>;
|
||||
pub type TlmMatchTag = TlmMatchString<TagAccess>;
|
||||
pub type TlmMatchClass = TlmMatchString<ClassAccess>;
|
||||
pub type TlmMatchInstance = TlmMatchString<InstanceAccess>;
|
||||
|
||||
pub struct TitleAccess;
|
||||
pub struct AppIdAccess;
|
||||
pub struct TagAccess;
|
||||
pub struct ClassAccess;
|
||||
pub struct InstanceAccess;
|
||||
|
||||
impl StringAccess<ToplevelData> for TitleAccess {
|
||||
fn with_string(data: &ToplevelData, f: impl FnOnce(&str) -> bool) -> bool {
|
||||
|
|
@ -48,3 +52,29 @@ impl StringAccess<ToplevelData> for TagAccess {
|
|||
&roots.tag
|
||||
}
|
||||
}
|
||||
|
||||
impl StringAccess<ToplevelData> for ClassAccess {
|
||||
fn with_string(data: &ToplevelData, f: impl FnOnce(&str) -> bool) -> bool {
|
||||
if let ToplevelType::XWindow(data) = &data.kind {
|
||||
return f(&data.info.class.borrow().as_deref().unwrap_or_default());
|
||||
}
|
||||
false
|
||||
}
|
||||
|
||||
fn nodes(roots: &RootMatchers) -> &TlmRootMatcherMap<TlmMatchString<Self>> {
|
||||
&roots.class
|
||||
}
|
||||
}
|
||||
|
||||
impl StringAccess<ToplevelData> for InstanceAccess {
|
||||
fn with_string(data: &ToplevelData, f: impl FnOnce(&str) -> bool) -> bool {
|
||||
if let ToplevelType::XWindow(data) = &data.kind {
|
||||
return f(&data.info.instance.borrow().as_deref().unwrap_or_default());
|
||||
}
|
||||
false
|
||||
}
|
||||
|
||||
fn nodes(roots: &RootMatchers) -> &TlmRootMatcherMap<TlmMatchString<Self>> {
|
||||
&roots.instance
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue