config: add urgency window criteria
This commit is contained in:
parent
dcf57db3df
commit
eb172e9d8c
15 changed files with 56 additions and 5 deletions
|
|
@ -112,6 +112,7 @@ pub enum WindowCriterionIpc {
|
||||||
Client(ClientMatcher),
|
Client(ClientMatcher),
|
||||||
Floating,
|
Floating,
|
||||||
Visible,
|
Visible,
|
||||||
|
Urgent,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Serialize, Deserialize, Clone, Debug, Hash, Eq, PartialEq)]
|
#[derive(Serialize, Deserialize, Clone, Debug, Hash, Eq, PartialEq)]
|
||||||
|
|
|
||||||
|
|
@ -1659,6 +1659,7 @@ impl ConfigClient {
|
||||||
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,
|
WindowCriterion::Visible => WindowCriterionIpc::Visible,
|
||||||
|
WindowCriterion::Urgent => WindowCriterionIpc::Urgent,
|
||||||
};
|
};
|
||||||
let res = self.send_with_response(&ClientMessage::CreateWindowMatcher { criterion });
|
let res = self.send_with_response(&ClientMessage::CreateWindowMatcher { criterion });
|
||||||
get_response!(
|
get_response!(
|
||||||
|
|
|
||||||
|
|
@ -248,6 +248,8 @@ pub enum WindowCriterion<'a> {
|
||||||
Floating,
|
Floating,
|
||||||
/// Matches if the window is visible.
|
/// Matches if the window is visible.
|
||||||
Visible,
|
Visible,
|
||||||
|
/// Matches if the window has the urgency flag set.
|
||||||
|
Urgent,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl WindowCriterion<'_> {
|
impl WindowCriterion<'_> {
|
||||||
|
|
|
||||||
|
|
@ -1999,6 +1999,7 @@ impl ConfigProxyHandler {
|
||||||
}
|
}
|
||||||
WindowCriterionIpc::Floating => mgr.floating(),
|
WindowCriterionIpc::Floating => mgr.floating(),
|
||||||
WindowCriterionIpc::Visible => mgr.visible(),
|
WindowCriterionIpc::Visible => mgr.visible(),
|
||||||
|
WindowCriterionIpc::Urgent => mgr.urgent(),
|
||||||
};
|
};
|
||||||
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_urgent::TlmMatchUrgent,
|
||||||
tlmm_visible::TlmMatchVisible,
|
tlmm_visible::TlmMatchVisible,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
@ -42,6 +43,7 @@ bitflags! {
|
||||||
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,
|
TL_CHANGED_VISIBLE = 1 << 5,
|
||||||
|
TL_CHANGED_URGENT = 1 << 6,
|
||||||
}
|
}
|
||||||
|
|
||||||
type TlmFixedRootMatcher<T> = FixedRootMatcher<ToplevelData, T>;
|
type TlmFixedRootMatcher<T> = FixedRootMatcher<ToplevelData, T>;
|
||||||
|
|
@ -53,6 +55,7 @@ pub struct TlMatcherManager {
|
||||||
constant: TlmFixedRootMatcher<CritMatchConstant<ToplevelData>>,
|
constant: TlmFixedRootMatcher<CritMatchConstant<ToplevelData>>,
|
||||||
floating: TlmFixedRootMatcher<TlmMatchFloating>,
|
floating: TlmFixedRootMatcher<TlmMatchFloating>,
|
||||||
visible: TlmFixedRootMatcher<TlmMatchVisible>,
|
visible: TlmFixedRootMatcher<TlmMatchVisible>,
|
||||||
|
urgent: TlmFixedRootMatcher<TlmMatchUrgent>,
|
||||||
matchers: Rc<RootMatchers>,
|
matchers: Rc<RootMatchers>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -105,6 +108,7 @@ impl TlMatcherManager {
|
||||||
constant: CritMatchConstant::create(&matchers, ids),
|
constant: CritMatchConstant::create(&matchers, ids),
|
||||||
floating: bool!(TlmMatchFloating),
|
floating: bool!(TlmMatchFloating),
|
||||||
visible: bool!(TlmMatchVisible),
|
visible: bool!(TlmMatchVisible),
|
||||||
|
urgent: bool!(TlmMatchUrgent),
|
||||||
changes: Default::default(),
|
changes: Default::default(),
|
||||||
leaf_events: Default::default(),
|
leaf_events: Default::default(),
|
||||||
ids: ids.clone(),
|
ids: ids.clone(),
|
||||||
|
|
@ -173,6 +177,7 @@ impl TlMatcherManager {
|
||||||
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);
|
fixed_conditional!(TL_CHANGED_VISIBLE, visible);
|
||||||
|
fixed_conditional!(TL_CHANGED_URGENT, urgent);
|
||||||
false
|
false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -241,6 +246,7 @@ impl TlMatcherManager {
|
||||||
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);
|
fixed_conditional!(TL_CHANGED_VISIBLE, visible);
|
||||||
|
fixed_conditional!(TL_CHANGED_URGENT, urgent);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn title(&self, string: CritLiteralOrRegex) -> Rc<TlmUpstreamNode> {
|
pub fn title(&self, string: CritLiteralOrRegex) -> Rc<TlmUpstreamNode> {
|
||||||
|
|
@ -266,6 +272,10 @@ impl TlMatcherManager {
|
||||||
pub fn visible(&self) -> Rc<TlmUpstreamNode> {
|
pub fn visible(&self) -> Rc<TlmUpstreamNode> {
|
||||||
self.visible[true].clone()
|
self.visible[true].clone()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn urgent(&self) -> Rc<TlmUpstreamNode> {
|
||||||
|
self.urgent[true].clone()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl CritTarget for ToplevelData {
|
impl CritTarget for ToplevelData {
|
||||||
|
|
|
||||||
|
|
@ -21,4 +21,5 @@ 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_urgent;
|
||||||
pub mod tlmm_visible;
|
pub mod tlmm_visible;
|
||||||
|
|
|
||||||
11
src/criteria/tlm/tlm_matchers/tlmm_urgent.rs
Normal file
11
src/criteria/tlm/tlm_matchers/tlmm_urgent.rs
Normal file
|
|
@ -0,0 +1,11 @@
|
||||||
|
use crate::{criteria::crit_graph::CritFixedRootCriterion, tree::ToplevelData};
|
||||||
|
|
||||||
|
pub struct TlmMatchUrgent(pub bool);
|
||||||
|
|
||||||
|
fixed_root_criterion!(TlmMatchUrgent, urgent);
|
||||||
|
|
||||||
|
impl CritFixedRootCriterion<ToplevelData> for TlmMatchUrgent {
|
||||||
|
fn matches(&self, data: &ToplevelData) -> bool {
|
||||||
|
data.wants_attention.get()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -1152,7 +1152,7 @@ impl ContainerNode {
|
||||||
fn mod_attention_requests(&self, set: bool) {
|
fn mod_attention_requests(&self, set: bool) {
|
||||||
let propagate = self.attention_requests.adj(set);
|
let propagate = self.attention_requests.adj(set);
|
||||||
if set || propagate {
|
if set || propagate {
|
||||||
self.toplevel_data.wants_attention.set(set);
|
self.toplevel_data.set_wants_attention(set);
|
||||||
}
|
}
|
||||||
if propagate {
|
if propagate {
|
||||||
if let Some(parent) = self.toplevel_data.parent.get() {
|
if let Some(parent) = self.toplevel_data.parent.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, TL_CHANGED_VISIBLE, TlMatcherChange,
|
TL_CHANGED_TITLE, TL_CHANGED_URGENT, TL_CHANGED_VISIBLE, TlMatcherChange,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
ifs::{
|
ifs::{
|
||||||
|
|
@ -647,7 +647,7 @@ impl ToplevelData {
|
||||||
if !self.requested_attention.replace(false) {
|
if !self.requested_attention.replace(false) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
self.wants_attention.set(false);
|
self.set_wants_attention(false);
|
||||||
if let Some(parent) = self.parent.get() {
|
if let Some(parent) = self.parent.get() {
|
||||||
parent.cnode_child_attention_request_changed(node, false);
|
parent.cnode_child_attention_request_changed(node, false);
|
||||||
}
|
}
|
||||||
|
|
@ -660,12 +660,18 @@ impl ToplevelData {
|
||||||
if self.requested_attention.replace(true) {
|
if self.requested_attention.replace(true) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
self.wants_attention.set(true);
|
self.set_wants_attention(true);
|
||||||
if let Some(parent) = self.parent.get() {
|
if let Some(parent) = self.parent.get() {
|
||||||
parent.cnode_child_attention_request_changed(node, true);
|
parent.cnode_child_attention_request_changed(node, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn set_wants_attention(&self, value: bool) {
|
||||||
|
if self.wants_attention.replace(value) != value {
|
||||||
|
self.property_changed(TL_CHANGED_URGENT);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
pub fn output(&self) -> Rc<OutputNode> {
|
pub fn output(&self) -> Rc<OutputNode> {
|
||||||
match self.output_opt() {
|
match self.output_opt() {
|
||||||
None => self.state.dummy_output.get().unwrap(),
|
None => self.state.dummy_output.get().unwrap(),
|
||||||
|
|
|
||||||
|
|
@ -261,6 +261,7 @@ pub struct WindowMatch {
|
||||||
pub app_id_regex: Option<String>,
|
pub app_id_regex: Option<String>,
|
||||||
pub floating: Option<bool>,
|
pub floating: Option<bool>,
|
||||||
pub visible: Option<bool>,
|
pub visible: Option<bool>,
|
||||||
|
pub urgent: 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, visible),
|
(app_id, app_id_regex, floating, visible, urgent),
|
||||||
) = ext.extract((
|
) = ext.extract((
|
||||||
(
|
(
|
||||||
opt(str("name")),
|
opt(str("name")),
|
||||||
|
|
@ -74,6 +74,7 @@ impl Parser for WindowMatchParser<'_> {
|
||||||
opt(str("app-id-regex")),
|
opt(str("app-id-regex")),
|
||||||
opt(bol("floating")),
|
opt(bol("floating")),
|
||||||
opt(bol("visible")),
|
opt(bol("visible")),
|
||||||
|
opt(bol("urgent")),
|
||||||
),
|
),
|
||||||
))?;
|
))?;
|
||||||
let mut not = None;
|
let mut not = None;
|
||||||
|
|
@ -121,6 +122,7 @@ impl Parser for WindowMatchParser<'_> {
|
||||||
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(),
|
visible: visible.despan(),
|
||||||
|
urgent: urgent.despan(),
|
||||||
types,
|
types,
|
||||||
client,
|
client,
|
||||||
})
|
})
|
||||||
|
|
|
||||||
|
|
@ -260,6 +260,7 @@ impl Rule for WindowRule {
|
||||||
value!(AppIdRegex, app_id_regex);
|
value!(AppIdRegex, app_id_regex);
|
||||||
bool!(Floating, floating);
|
bool!(Floating, floating);
|
||||||
bool!(Visible, visible);
|
bool!(Visible, visible);
|
||||||
|
bool!(Urgent, urgent);
|
||||||
Some(())
|
Some(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1803,6 +1803,10 @@
|
||||||
"visible": {
|
"visible": {
|
||||||
"type": "boolean",
|
"type": "boolean",
|
||||||
"description": "Matches if the window is/isn't visible."
|
"description": "Matches if the window is/isn't visible."
|
||||||
|
},
|
||||||
|
"urgent": {
|
||||||
|
"type": "boolean",
|
||||||
|
"description": "Matches if the window has/hasn't the urgency flag set."
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"required": []
|
"required": []
|
||||||
|
|
|
||||||
|
|
@ -4046,6 +4046,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.
|
||||||
|
|
||||||
|
- `urgent` (optional):
|
||||||
|
|
||||||
|
Matches if the window has/hasn't the urgency flag set.
|
||||||
|
|
||||||
|
The value of this field should be a boolean.
|
||||||
|
|
||||||
|
|
||||||
<a name="types-WindowMatchExactly"></a>
|
<a name="types-WindowMatchExactly"></a>
|
||||||
### `WindowMatchExactly`
|
### `WindowMatchExactly`
|
||||||
|
|
|
||||||
|
|
@ -3491,6 +3491,10 @@ WindowMatch:
|
||||||
kind: boolean
|
kind: boolean
|
||||||
required: false
|
required: false
|
||||||
description: Matches if the window is/isn't visible.
|
description: Matches if the window is/isn't visible.
|
||||||
|
urgent:
|
||||||
|
kind: boolean
|
||||||
|
required: false
|
||||||
|
description: Matches if the window has/hasn't the urgency flag set.
|
||||||
|
|
||||||
|
|
||||||
WindowMatchExactly:
|
WindowMatchExactly:
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue