1
0
Fork 0
forked from wry/wry

config: add visibility window criteria

This commit is contained in:
Julian Orth 2025-05-01 18:35:29 +02:00
parent 8bb8b2a649
commit dcf57db3df
14 changed files with 50 additions and 3 deletions

View file

@ -111,6 +111,7 @@ pub enum WindowCriterionIpc {
Types(WindowType),
Client(ClientMatcher),
Floating,
Visible,
}
#[derive(Serialize, Deserialize, Clone, Debug, Hash, Eq, PartialEq)]

View file

@ -1658,6 +1658,7 @@ impl ConfigClient {
WindowCriterion::AppId(t) => string!(t, AppId, false),
WindowCriterion::AppIdRegex(t) => string!(t, AppId, true),
WindowCriterion::Floating => WindowCriterionIpc::Floating,
WindowCriterion::Visible => WindowCriterionIpc::Visible,
};
let res = self.send_with_response(&ClientMessage::CreateWindowMatcher { criterion });
get_response!(

View file

@ -246,6 +246,8 @@ pub enum WindowCriterion<'a> {
AppIdRegex(&'a str),
/// Matches if the window is floating.
Floating,
/// Matches if the window is visible.
Visible,
}
impl WindowCriterion<'_> {

View file

@ -1998,6 +1998,7 @@ impl ConfigProxyHandler {
mgr.client(&self.state, &self.get_client_matcher(*c)?.node)
}
WindowCriterionIpc::Floating => mgr.floating(),
WindowCriterionIpc::Visible => mgr.visible(),
};
let cached = Rc::new(CachedCriterion {
crit: criterion.clone(),

View file

@ -16,6 +16,7 @@ use {
tlmm_floating::TlmMatchFloating,
tlmm_kind::TlmMatchKind,
tlmm_string::{TlmMatchAppId, TlmMatchTitle},
tlmm_visible::TlmMatchVisible,
},
},
state::State,
@ -40,6 +41,7 @@ bitflags! {
TL_CHANGED_TITLE = 1 << 2,
TL_CHANGED_APP_ID = 1 << 3,
TL_CHANGED_FLOATING = 1 << 4,
TL_CHANGED_VISIBLE = 1 << 5,
}
type TlmFixedRootMatcher<T> = FixedRootMatcher<ToplevelData, T>;
@ -50,6 +52,7 @@ pub struct TlMatcherManager {
leaf_events: Rc<AsyncQueue<CritLeafEvent<ToplevelData>>>,
constant: TlmFixedRootMatcher<CritMatchConstant<ToplevelData>>,
floating: TlmFixedRootMatcher<TlmMatchFloating>,
visible: TlmFixedRootMatcher<TlmMatchVisible>,
matchers: Rc<RootMatchers>,
}
@ -101,6 +104,7 @@ impl TlMatcherManager {
Self {
constant: CritMatchConstant::create(&matchers, ids),
floating: bool!(TlmMatchFloating),
visible: bool!(TlmMatchVisible),
changes: Default::default(),
leaf_events: Default::default(),
ids: ids.clone(),
@ -168,6 +172,7 @@ impl TlMatcherManager {
conditional!(TL_CHANGED_TITLE, title);
conditional!(TL_CHANGED_APP_ID, app_id);
fixed_conditional!(TL_CHANGED_FLOATING, floating);
fixed_conditional!(TL_CHANGED_VISIBLE, visible);
false
}
@ -235,6 +240,7 @@ impl TlMatcherManager {
conditional!(TL_CHANGED_TITLE, title);
conditional!(TL_CHANGED_APP_ID, app_id);
fixed_conditional!(TL_CHANGED_FLOATING, floating);
fixed_conditional!(TL_CHANGED_VISIBLE, visible);
}
pub fn title(&self, string: CritLiteralOrRegex) -> Rc<TlmUpstreamNode> {
@ -256,6 +262,10 @@ impl TlMatcherManager {
pub fn client(&self, state: &Rc<State>, client: &Rc<ClmUpstreamNode>) -> Rc<TlmUpstreamNode> {
TlmMatchClient::new(state, client)
}
pub fn visible(&self) -> Rc<TlmUpstreamNode> {
self.visible[true].clone()
}
}
impl CritTarget for ToplevelData {

View file

@ -21,3 +21,4 @@ pub mod tlmm_client;
pub mod tlmm_floating;
pub mod tlmm_kind;
pub mod tlmm_string;
pub mod tlmm_visible;

View file

@ -0,0 +1,11 @@
use crate::{criteria::crit_graph::CritFixedRootCriterion, tree::ToplevelData};
pub struct TlmMatchVisible(pub bool);
fixed_root_criterion!(TlmMatchVisible, visible);
impl CritFixedRootCriterion<ToplevelData> for TlmMatchVisible {
fn matches(&self, data: &ToplevelData) -> bool {
data.visible.get()
}
}

View file

@ -5,7 +5,7 @@ use {
CritDestroyListener, CritMatcherId,
tlm::{
TL_CHANGED_APP_ID, TL_CHANGED_DESTROYED, TL_CHANGED_FLOATING, TL_CHANGED_NEW,
TL_CHANGED_TITLE, TlMatcherChange,
TL_CHANGED_TITLE, TL_CHANGED_VISIBLE, TlMatcherChange,
},
},
ifs::{
@ -631,7 +631,9 @@ impl ToplevelData {
}
pub fn set_visible(&self, node: &dyn Node, visible: bool) {
self.visible.set(visible);
if self.visible.replace(visible) != visible {
self.property_changed(TL_CHANGED_VISIBLE);
}
self.seat_state.set_visible(node, visible);
for sc in self.jay_screencasts.lock().values() {
sc.update_latch_listener();

View file

@ -260,6 +260,7 @@ pub struct WindowMatch {
pub app_id: Option<String>,
pub app_id_regex: Option<String>,
pub floating: Option<bool>,
pub visible: Option<bool>,
}
#[derive(Debug, Clone)]

View file

@ -56,7 +56,7 @@ impl Parser for WindowMatchParser<'_> {
title,
title_regex,
),
(app_id, app_id_regex, floating),
(app_id, app_id_regex, floating, visible),
) = ext.extract((
(
opt(str("name")),
@ -73,6 +73,7 @@ impl Parser for WindowMatchParser<'_> {
opt(str("app-id")),
opt(str("app-id-regex")),
opt(bol("floating")),
opt(bol("visible")),
),
))?;
let mut not = None;
@ -119,6 +120,7 @@ impl Parser for WindowMatchParser<'_> {
app_id: app_id.despan_into(),
app_id_regex: app_id_regex.despan_into(),
floating: floating.despan(),
visible: visible.despan(),
types,
client,
})

View file

@ -259,6 +259,7 @@ impl Rule for WindowRule {
value!(AppId, app_id);
value!(AppIdRegex, app_id_regex);
bool!(Floating, floating);
bool!(Visible, visible);
Some(())
}

View file

@ -1799,6 +1799,10 @@
"floating": {
"type": "boolean",
"description": "Matches if the window is/isn't floating."
},
"visible": {
"type": "boolean",
"description": "Matches if the window is/isn't visible."
}
},
"required": []

View file

@ -4040,6 +4040,12 @@ The table has the following fields:
The value of this field should be a boolean.
- `visible` (optional):
Matches if the window is/isn't visible.
The value of this field should be a boolean.
<a name="types-WindowMatchExactly"></a>
### `WindowMatchExactly`

View file

@ -3487,6 +3487,10 @@ WindowMatch:
kind: boolean
required: false
description: Matches if the window is/isn't floating.
visible:
kind: boolean
required: false
description: Matches if the window is/isn't visible.
WindowMatchExactly: