1
0
Fork 0
forked from wry/wry

config: add workspace window criteria

This commit is contained in:
Julian Orth 2025-05-03 14:13:40 +02:00
parent 5ad6ca4dd3
commit 51e752992f
13 changed files with 88 additions and 3 deletions

View file

@ -20,7 +20,7 @@ use {
tlmm_seat_focus::TlmMatchSeatFocus,
tlmm_string::{
TlmMatchAppId, TlmMatchClass, TlmMatchInstance, TlmMatchRole, TlmMatchTag,
TlmMatchTitle,
TlmMatchTitle, TlmMatchWorkspace,
},
tlmm_urgent::TlmMatchUrgent,
tlmm_visible::TlmMatchVisible,
@ -57,6 +57,7 @@ bitflags! {
TL_CHANGED_TAG = 1 << 10,
TL_CHANGED_CLASS_INST = 1 << 11,
TL_CHANGED_ROLE = 1 << 12,
TL_CHANGED_WORKSPACE = 1 << 13,
}
type TlmFixedRootMatcher<T> = FixedRootMatcher<ToplevelData, T>;
@ -88,6 +89,7 @@ pub struct RootMatchers {
class: TlmRootMatcherMap<TlmMatchClass>,
instance: TlmRootMatcherMap<TlmMatchInstance>,
role: TlmRootMatcherMap<TlmMatchRole>,
workspace: TlmRootMatcherMap<TlmMatchWorkspace>,
}
pub async fn handle_tl_changes(state: Rc<State>) {
@ -219,6 +221,7 @@ impl TlMatcherManager {
conditional!(TL_CHANGED_CLASS_INST, class);
conditional!(TL_CHANGED_CLASS_INST, instance);
conditional!(TL_CHANGED_ROLE, role);
conditional!(TL_CHANGED_WORKSPACE, workspace);
fixed_conditional!(TL_CHANGED_FLOATING, floating);
fixed_conditional!(TL_CHANGED_VISIBLE, visible);
fixed_conditional!(TL_CHANGED_URGENT, urgent);
@ -295,6 +298,7 @@ impl TlMatcherManager {
conditional!(TL_CHANGED_CLASS_INST, class);
conditional!(TL_CHANGED_CLASS_INST, instance);
conditional!(TL_CHANGED_ROLE, role);
conditional!(TL_CHANGED_WORKSPACE, workspace);
fixed_conditional!(TL_CHANGED_FLOATING, floating);
fixed_conditional!(TL_CHANGED_VISIBLE, visible);
fixed_conditional!(TL_CHANGED_URGENT, urgent);
@ -364,6 +368,10 @@ impl TlMatcherManager {
pub fn role(&self, string: CritLiteralOrRegex) -> Rc<TlmUpstreamNode> {
self.root(TlmMatchRole::new(string))
}
pub fn workspace(&self, string: CritLiteralOrRegex) -> Rc<TlmUpstreamNode> {
self.root(TlmMatchWorkspace::new(string))
}
}
impl CritTarget for ToplevelData {

View file

@ -14,6 +14,7 @@ pub type TlmMatchTag = TlmMatchString<TagAccess>;
pub type TlmMatchClass = TlmMatchString<ClassAccess>;
pub type TlmMatchInstance = TlmMatchString<InstanceAccess>;
pub type TlmMatchRole = TlmMatchString<RoleAccess>;
pub type TlmMatchWorkspace = TlmMatchString<WorkspaceAccess>;
pub struct TitleAccess;
pub struct AppIdAccess;
@ -21,6 +22,7 @@ pub struct TagAccess;
pub struct ClassAccess;
pub struct InstanceAccess;
pub struct RoleAccess;
pub struct WorkspaceAccess;
impl StringAccess<ToplevelData> for TitleAccess {
fn with_string(data: &ToplevelData, f: impl FnOnce(&str) -> bool) -> bool {
@ -93,3 +95,16 @@ impl StringAccess<ToplevelData> for RoleAccess {
&roots.role
}
}
impl StringAccess<ToplevelData> for WorkspaceAccess {
fn with_string(data: &ToplevelData, f: impl FnOnce(&str) -> bool) -> bool {
if let Some(ws) = data.workspace.get() {
return f(&ws.name);
}
false
}
fn nodes(roots: &RootMatchers) -> &TlmRootMatcherMap<TlmMatchString<Self>> {
&roots.workspace
}
}