config: add visibility window criteria
This commit is contained in:
parent
8bb8b2a649
commit
dcf57db3df
14 changed files with 50 additions and 3 deletions
|
|
@ -111,6 +111,7 @@ pub enum WindowCriterionIpc {
|
||||||
Types(WindowType),
|
Types(WindowType),
|
||||||
Client(ClientMatcher),
|
Client(ClientMatcher),
|
||||||
Floating,
|
Floating,
|
||||||
|
Visible,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Serialize, Deserialize, Clone, Debug, Hash, Eq, PartialEq)]
|
#[derive(Serialize, Deserialize, Clone, Debug, Hash, Eq, PartialEq)]
|
||||||
|
|
|
||||||
|
|
@ -1658,6 +1658,7 @@ impl ConfigClient {
|
||||||
WindowCriterion::AppId(t) => string!(t, AppId, false),
|
WindowCriterion::AppId(t) => string!(t, AppId, false),
|
||||||
WindowCriterion::AppIdRegex(t) => string!(t, AppId, true),
|
WindowCriterion::AppIdRegex(t) => string!(t, AppId, true),
|
||||||
WindowCriterion::Floating => WindowCriterionIpc::Floating,
|
WindowCriterion::Floating => WindowCriterionIpc::Floating,
|
||||||
|
WindowCriterion::Visible => WindowCriterionIpc::Visible,
|
||||||
};
|
};
|
||||||
let res = self.send_with_response(&ClientMessage::CreateWindowMatcher { criterion });
|
let res = self.send_with_response(&ClientMessage::CreateWindowMatcher { criterion });
|
||||||
get_response!(
|
get_response!(
|
||||||
|
|
|
||||||
|
|
@ -246,6 +246,8 @@ pub enum WindowCriterion<'a> {
|
||||||
AppIdRegex(&'a str),
|
AppIdRegex(&'a str),
|
||||||
/// Matches if the window is floating.
|
/// Matches if the window is floating.
|
||||||
Floating,
|
Floating,
|
||||||
|
/// Matches if the window is visible.
|
||||||
|
Visible,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl WindowCriterion<'_> {
|
impl WindowCriterion<'_> {
|
||||||
|
|
|
||||||
|
|
@ -1998,6 +1998,7 @@ impl ConfigProxyHandler {
|
||||||
mgr.client(&self.state, &self.get_client_matcher(*c)?.node)
|
mgr.client(&self.state, &self.get_client_matcher(*c)?.node)
|
||||||
}
|
}
|
||||||
WindowCriterionIpc::Floating => mgr.floating(),
|
WindowCriterionIpc::Floating => mgr.floating(),
|
||||||
|
WindowCriterionIpc::Visible => mgr.visible(),
|
||||||
};
|
};
|
||||||
let cached = Rc::new(CachedCriterion {
|
let cached = Rc::new(CachedCriterion {
|
||||||
crit: criterion.clone(),
|
crit: criterion.clone(),
|
||||||
|
|
|
||||||
|
|
@ -16,6 +16,7 @@ use {
|
||||||
tlmm_floating::TlmMatchFloating,
|
tlmm_floating::TlmMatchFloating,
|
||||||
tlmm_kind::TlmMatchKind,
|
tlmm_kind::TlmMatchKind,
|
||||||
tlmm_string::{TlmMatchAppId, TlmMatchTitle},
|
tlmm_string::{TlmMatchAppId, TlmMatchTitle},
|
||||||
|
tlmm_visible::TlmMatchVisible,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
state::State,
|
state::State,
|
||||||
|
|
@ -40,6 +41,7 @@ bitflags! {
|
||||||
TL_CHANGED_TITLE = 1 << 2,
|
TL_CHANGED_TITLE = 1 << 2,
|
||||||
TL_CHANGED_APP_ID = 1 << 3,
|
TL_CHANGED_APP_ID = 1 << 3,
|
||||||
TL_CHANGED_FLOATING = 1 << 4,
|
TL_CHANGED_FLOATING = 1 << 4,
|
||||||
|
TL_CHANGED_VISIBLE = 1 << 5,
|
||||||
}
|
}
|
||||||
|
|
||||||
type TlmFixedRootMatcher<T> = FixedRootMatcher<ToplevelData, T>;
|
type TlmFixedRootMatcher<T> = FixedRootMatcher<ToplevelData, T>;
|
||||||
|
|
@ -50,6 +52,7 @@ pub struct TlMatcherManager {
|
||||||
leaf_events: Rc<AsyncQueue<CritLeafEvent<ToplevelData>>>,
|
leaf_events: Rc<AsyncQueue<CritLeafEvent<ToplevelData>>>,
|
||||||
constant: TlmFixedRootMatcher<CritMatchConstant<ToplevelData>>,
|
constant: TlmFixedRootMatcher<CritMatchConstant<ToplevelData>>,
|
||||||
floating: TlmFixedRootMatcher<TlmMatchFloating>,
|
floating: TlmFixedRootMatcher<TlmMatchFloating>,
|
||||||
|
visible: TlmFixedRootMatcher<TlmMatchVisible>,
|
||||||
matchers: Rc<RootMatchers>,
|
matchers: Rc<RootMatchers>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -101,6 +104,7 @@ impl TlMatcherManager {
|
||||||
Self {
|
Self {
|
||||||
constant: CritMatchConstant::create(&matchers, ids),
|
constant: CritMatchConstant::create(&matchers, ids),
|
||||||
floating: bool!(TlmMatchFloating),
|
floating: bool!(TlmMatchFloating),
|
||||||
|
visible: bool!(TlmMatchVisible),
|
||||||
changes: Default::default(),
|
changes: Default::default(),
|
||||||
leaf_events: Default::default(),
|
leaf_events: Default::default(),
|
||||||
ids: ids.clone(),
|
ids: ids.clone(),
|
||||||
|
|
@ -168,6 +172,7 @@ impl TlMatcherManager {
|
||||||
conditional!(TL_CHANGED_TITLE, title);
|
conditional!(TL_CHANGED_TITLE, title);
|
||||||
conditional!(TL_CHANGED_APP_ID, app_id);
|
conditional!(TL_CHANGED_APP_ID, app_id);
|
||||||
fixed_conditional!(TL_CHANGED_FLOATING, floating);
|
fixed_conditional!(TL_CHANGED_FLOATING, floating);
|
||||||
|
fixed_conditional!(TL_CHANGED_VISIBLE, visible);
|
||||||
false
|
false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -235,6 +240,7 @@ impl TlMatcherManager {
|
||||||
conditional!(TL_CHANGED_TITLE, title);
|
conditional!(TL_CHANGED_TITLE, title);
|
||||||
conditional!(TL_CHANGED_APP_ID, app_id);
|
conditional!(TL_CHANGED_APP_ID, app_id);
|
||||||
fixed_conditional!(TL_CHANGED_FLOATING, floating);
|
fixed_conditional!(TL_CHANGED_FLOATING, floating);
|
||||||
|
fixed_conditional!(TL_CHANGED_VISIBLE, visible);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn title(&self, string: CritLiteralOrRegex) -> Rc<TlmUpstreamNode> {
|
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> {
|
pub fn client(&self, state: &Rc<State>, client: &Rc<ClmUpstreamNode>) -> Rc<TlmUpstreamNode> {
|
||||||
TlmMatchClient::new(state, client)
|
TlmMatchClient::new(state, client)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn visible(&self) -> Rc<TlmUpstreamNode> {
|
||||||
|
self.visible[true].clone()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl CritTarget for ToplevelData {
|
impl CritTarget for ToplevelData {
|
||||||
|
|
|
||||||
|
|
@ -21,3 +21,4 @@ pub mod tlmm_client;
|
||||||
pub mod tlmm_floating;
|
pub mod tlmm_floating;
|
||||||
pub mod tlmm_kind;
|
pub mod tlmm_kind;
|
||||||
pub mod tlmm_string;
|
pub mod tlmm_string;
|
||||||
|
pub mod tlmm_visible;
|
||||||
|
|
|
||||||
11
src/criteria/tlm/tlm_matchers/tlmm_visible.rs
Normal file
11
src/criteria/tlm/tlm_matchers/tlmm_visible.rs
Normal 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()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -5,7 +5,7 @@ use {
|
||||||
CritDestroyListener, CritMatcherId,
|
CritDestroyListener, CritMatcherId,
|
||||||
tlm::{
|
tlm::{
|
||||||
TL_CHANGED_APP_ID, TL_CHANGED_DESTROYED, TL_CHANGED_FLOATING, TL_CHANGED_NEW,
|
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::{
|
ifs::{
|
||||||
|
|
@ -631,7 +631,9 @@ impl ToplevelData {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn set_visible(&self, node: &dyn Node, visible: bool) {
|
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);
|
self.seat_state.set_visible(node, visible);
|
||||||
for sc in self.jay_screencasts.lock().values() {
|
for sc in self.jay_screencasts.lock().values() {
|
||||||
sc.update_latch_listener();
|
sc.update_latch_listener();
|
||||||
|
|
|
||||||
|
|
@ -260,6 +260,7 @@ pub struct WindowMatch {
|
||||||
pub app_id: Option<String>,
|
pub app_id: Option<String>,
|
||||||
pub app_id_regex: Option<String>,
|
pub app_id_regex: Option<String>,
|
||||||
pub floating: Option<bool>,
|
pub floating: Option<bool>,
|
||||||
|
pub visible: Option<bool>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone)]
|
#[derive(Debug, Clone)]
|
||||||
|
|
|
||||||
|
|
@ -56,7 +56,7 @@ impl Parser for WindowMatchParser<'_> {
|
||||||
title,
|
title,
|
||||||
title_regex,
|
title_regex,
|
||||||
),
|
),
|
||||||
(app_id, app_id_regex, floating),
|
(app_id, app_id_regex, floating, visible),
|
||||||
) = ext.extract((
|
) = ext.extract((
|
||||||
(
|
(
|
||||||
opt(str("name")),
|
opt(str("name")),
|
||||||
|
|
@ -73,6 +73,7 @@ impl Parser for WindowMatchParser<'_> {
|
||||||
opt(str("app-id")),
|
opt(str("app-id")),
|
||||||
opt(str("app-id-regex")),
|
opt(str("app-id-regex")),
|
||||||
opt(bol("floating")),
|
opt(bol("floating")),
|
||||||
|
opt(bol("visible")),
|
||||||
),
|
),
|
||||||
))?;
|
))?;
|
||||||
let mut not = None;
|
let mut not = None;
|
||||||
|
|
@ -119,6 +120,7 @@ impl Parser for WindowMatchParser<'_> {
|
||||||
app_id: app_id.despan_into(),
|
app_id: app_id.despan_into(),
|
||||||
app_id_regex: app_id_regex.despan_into(),
|
app_id_regex: app_id_regex.despan_into(),
|
||||||
floating: floating.despan(),
|
floating: floating.despan(),
|
||||||
|
visible: visible.despan(),
|
||||||
types,
|
types,
|
||||||
client,
|
client,
|
||||||
})
|
})
|
||||||
|
|
|
||||||
|
|
@ -259,6 +259,7 @@ impl Rule for WindowRule {
|
||||||
value!(AppId, app_id);
|
value!(AppId, app_id);
|
||||||
value!(AppIdRegex, app_id_regex);
|
value!(AppIdRegex, app_id_regex);
|
||||||
bool!(Floating, floating);
|
bool!(Floating, floating);
|
||||||
|
bool!(Visible, visible);
|
||||||
Some(())
|
Some(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1799,6 +1799,10 @@
|
||||||
"floating": {
|
"floating": {
|
||||||
"type": "boolean",
|
"type": "boolean",
|
||||||
"description": "Matches if the window is/isn't floating."
|
"description": "Matches if the window is/isn't floating."
|
||||||
|
},
|
||||||
|
"visible": {
|
||||||
|
"type": "boolean",
|
||||||
|
"description": "Matches if the window is/isn't visible."
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"required": []
|
"required": []
|
||||||
|
|
|
||||||
|
|
@ -4040,6 +4040,12 @@ The table has the following fields:
|
||||||
|
|
||||||
The value of this field should be a boolean.
|
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>
|
<a name="types-WindowMatchExactly"></a>
|
||||||
### `WindowMatchExactly`
|
### `WindowMatchExactly`
|
||||||
|
|
|
||||||
|
|
@ -3487,6 +3487,10 @@ WindowMatch:
|
||||||
kind: boolean
|
kind: boolean
|
||||||
required: false
|
required: false
|
||||||
description: Matches if the window is/isn't floating.
|
description: Matches if the window is/isn't floating.
|
||||||
|
visible:
|
||||||
|
kind: boolean
|
||||||
|
required: false
|
||||||
|
description: Matches if the window is/isn't visible.
|
||||||
|
|
||||||
|
|
||||||
WindowMatchExactly:
|
WindowMatchExactly:
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue