config: add floating window criteria
This commit is contained in:
parent
da64166e82
commit
8bb8b2a649
14 changed files with 78 additions and 14 deletions
|
|
@ -1997,6 +1997,7 @@ impl ConfigProxyHandler {
|
|||
self.state.cl_matcher_manager.rematch_all(&self.state);
|
||||
mgr.client(&self.state, &self.get_client_matcher(*c)?.node)
|
||||
}
|
||||
WindowCriterionIpc::Floating => mgr.floating(),
|
||||
};
|
||||
let cached = Rc::new(CachedCriterion {
|
||||
crit: criterion.clone(),
|
||||
|
|
|
|||
|
|
@ -6,11 +6,14 @@ use {
|
|||
CritDestroyListener, CritLiteralOrRegex, CritMatcherId, CritMatcherIds, CritMgrExt,
|
||||
CritUpstreamNode, FixedRootMatcher, RootMatcherMap,
|
||||
clm::ClmUpstreamNode,
|
||||
crit_graph::{CritMgr, CritTarget, CritTargetOwner, WeakCritTargetOwner},
|
||||
crit_graph::{
|
||||
CritMgr, CritRoot, CritRootFixed, CritTarget, CritTargetOwner, WeakCritTargetOwner,
|
||||
},
|
||||
crit_leaf::{CritLeafEvent, CritLeafMatcher},
|
||||
crit_matchers::critm_constant::CritMatchConstant,
|
||||
tlm::tlm_matchers::{
|
||||
tlmm_client::TlmMatchClient,
|
||||
tlmm_floating::TlmMatchFloating,
|
||||
tlmm_kind::TlmMatchKind,
|
||||
tlmm_string::{TlmMatchAppId, TlmMatchTitle},
|
||||
},
|
||||
|
|
@ -23,7 +26,11 @@ use {
|
|||
},
|
||||
},
|
||||
jay_config::window::WindowType,
|
||||
std::rc::{Rc, Weak},
|
||||
linearize::static_map,
|
||||
std::{
|
||||
marker::PhantomData,
|
||||
rc::{Rc, Weak},
|
||||
},
|
||||
};
|
||||
|
||||
bitflags! {
|
||||
|
|
@ -32,6 +39,7 @@ bitflags! {
|
|||
TL_CHANGED_NEW = 1 << 1,
|
||||
TL_CHANGED_TITLE = 1 << 2,
|
||||
TL_CHANGED_APP_ID = 1 << 3,
|
||||
TL_CHANGED_FLOATING = 1 << 4,
|
||||
}
|
||||
|
||||
type TlmFixedRootMatcher<T> = FixedRootMatcher<ToplevelData, T>;
|
||||
|
|
@ -41,6 +49,7 @@ pub struct TlMatcherManager {
|
|||
changes: AsyncQueue<Rc<dyn ToplevelNode>>,
|
||||
leaf_events: Rc<AsyncQueue<CritLeafEvent<ToplevelData>>>,
|
||||
constant: TlmFixedRootMatcher<CritMatchConstant<ToplevelData>>,
|
||||
floating: TlmFixedRootMatcher<TlmMatchFloating>,
|
||||
matchers: Rc<RootMatchers>,
|
||||
}
|
||||
|
||||
|
|
@ -78,8 +87,20 @@ pub type TlmLeafMatcher = CritLeafMatcher<ToplevelData>;
|
|||
impl TlMatcherManager {
|
||||
pub fn new(ids: &Rc<CritMatcherIds>) -> Self {
|
||||
let matchers = Rc::new(RootMatchers::default());
|
||||
macro_rules! bool {
|
||||
($name:ident) => {{
|
||||
static_map! {
|
||||
v => CritRoot::new(
|
||||
&matchers,
|
||||
ids.next(),
|
||||
CritRootFixed($name(v), PhantomData),
|
||||
)
|
||||
}
|
||||
}};
|
||||
}
|
||||
Self {
|
||||
constant: CritMatchConstant::create(&matchers, ids),
|
||||
floating: bool!(TlmMatchFloating),
|
||||
changes: Default::default(),
|
||||
leaf_events: Default::default(),
|
||||
ids: ids.clone(),
|
||||
|
|
@ -108,7 +129,6 @@ impl TlMatcherManager {
|
|||
if change.contains(TL_CHANGED_DESTROYED) && data.destroyed.is_not_empty() {
|
||||
return true;
|
||||
}
|
||||
#[expect(unused_macros)]
|
||||
macro_rules! fixed {
|
||||
($name:ident) => {
|
||||
if self.$name[false].has_downstream() || self.$name[true].has_downstream() {
|
||||
|
|
@ -138,7 +158,6 @@ impl TlMatcherManager {
|
|||
}
|
||||
};
|
||||
}
|
||||
#[expect(unused_macros)]
|
||||
macro_rules! fixed_conditional {
|
||||
($change:expr, $field:ident) => {
|
||||
if change.contains($change) {
|
||||
|
|
@ -148,6 +167,7 @@ impl TlMatcherManager {
|
|||
}
|
||||
conditional!(TL_CHANGED_TITLE, title);
|
||||
conditional!(TL_CHANGED_APP_ID, app_id);
|
||||
fixed_conditional!(TL_CHANGED_FLOATING, floating);
|
||||
false
|
||||
}
|
||||
|
||||
|
|
@ -177,7 +197,6 @@ impl TlMatcherManager {
|
|||
.filter_map(|m| m.upgrade())
|
||||
};
|
||||
}
|
||||
#[expect(unused_macros)]
|
||||
macro_rules! fixed {
|
||||
($name:ident) => {
|
||||
self.$name[false].handle(data);
|
||||
|
|
@ -206,7 +225,6 @@ impl TlMatcherManager {
|
|||
}
|
||||
};
|
||||
}
|
||||
#[expect(unused_macros)]
|
||||
macro_rules! fixed_conditional {
|
||||
($change:expr, $field:ident) => {
|
||||
if changed.contains($change) {
|
||||
|
|
@ -216,6 +234,7 @@ impl TlMatcherManager {
|
|||
}
|
||||
conditional!(TL_CHANGED_TITLE, title);
|
||||
conditional!(TL_CHANGED_APP_ID, app_id);
|
||||
fixed_conditional!(TL_CHANGED_FLOATING, floating);
|
||||
}
|
||||
|
||||
pub fn title(&self, string: CritLiteralOrRegex) -> Rc<TlmUpstreamNode> {
|
||||
|
|
@ -226,6 +245,10 @@ impl TlMatcherManager {
|
|||
self.root(TlmMatchAppId::new(string))
|
||||
}
|
||||
|
||||
pub fn floating(&self) -> Rc<TlmUpstreamNode> {
|
||||
self.floating[true].clone()
|
||||
}
|
||||
|
||||
pub fn kind(&self, kind: WindowType) -> Rc<TlmUpstreamNode> {
|
||||
self.root(TlmMatchKind::new(kind))
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,3 @@
|
|||
#[expect(unused_macros)]
|
||||
macro_rules! fixed_root_criterion {
|
||||
($ty:ty, $field:ident) => {
|
||||
impl crate::criteria::crit_graph::CritFixedRootCriterionBase<crate::tree::ToplevelData>
|
||||
|
|
@ -19,5 +18,6 @@ macro_rules! fixed_root_criterion {
|
|||
}
|
||||
|
||||
pub mod tlmm_client;
|
||||
pub mod tlmm_floating;
|
||||
pub mod tlmm_kind;
|
||||
pub mod tlmm_string;
|
||||
|
|
|
|||
11
src/criteria/tlm/tlm_matchers/tlmm_floating.rs
Normal file
11
src/criteria/tlm/tlm_matchers/tlmm_floating.rs
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
use crate::{criteria::crit_graph::CritFixedRootCriterion, tree::ToplevelData};
|
||||
|
||||
pub struct TlmMatchFloating(pub bool);
|
||||
|
||||
fixed_root_criterion!(TlmMatchFloating, floating);
|
||||
|
||||
impl CritFixedRootCriterion<ToplevelData> for TlmMatchFloating {
|
||||
fn matches(&self, data: &ToplevelData) -> bool {
|
||||
data.is_floating.get()
|
||||
}
|
||||
}
|
||||
|
|
@ -4,8 +4,8 @@ use {
|
|||
criteria::{
|
||||
CritDestroyListener, CritMatcherId,
|
||||
tlm::{
|
||||
TL_CHANGED_APP_ID, TL_CHANGED_DESTROYED, TL_CHANGED_NEW, TL_CHANGED_TITLE,
|
||||
TlMatcherChange,
|
||||
TL_CHANGED_APP_ID, TL_CHANGED_DESTROYED, TL_CHANGED_FLOATING, TL_CHANGED_NEW,
|
||||
TL_CHANGED_TITLE, TlMatcherChange,
|
||||
},
|
||||
},
|
||||
ifs::{
|
||||
|
|
@ -104,7 +104,12 @@ impl<T: ToplevelNodeBase> ToplevelNode for T {
|
|||
if parent_was_none {
|
||||
data.property_changed(TL_CHANGED_NEW);
|
||||
}
|
||||
data.is_floating.set(parent.node_is_float());
|
||||
let was_floating = data.is_floating.get();
|
||||
let is_floating = parent.node_is_float();
|
||||
if was_floating != is_floating {
|
||||
data.property_changed(TL_CHANGED_FLOATING);
|
||||
}
|
||||
data.is_floating.set(is_floating);
|
||||
self.tl_set_workspace(&parent.cnode_workspace());
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue