config: add auto-focus window rule
This commit is contained in:
parent
51e752992f
commit
b1ca98b488
12 changed files with 114 additions and 10 deletions
|
|
@ -248,6 +248,7 @@ pub struct WindowRule {
|
|||
pub match_: WindowMatch,
|
||||
pub action: Option<Action>,
|
||||
pub latch: Option<Action>,
|
||||
pub auto_focus: Option<bool>,
|
||||
}
|
||||
|
||||
#[derive(Default, Debug, Clone)]
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ use {
|
|||
config::{
|
||||
WindowMatch, WindowRule,
|
||||
context::Context,
|
||||
extractor::{Extractor, ExtractorError, opt, str, val},
|
||||
extractor::{Extractor, ExtractorError, bol, opt, recover, str, val},
|
||||
parser::{DataType, ParseResult, Parser, UnexpectedDataType},
|
||||
parsers::{
|
||||
action::{ActionParser, ActionParserError},
|
||||
|
|
@ -47,11 +47,12 @@ impl Parser for WindowRuleParser<'_> {
|
|||
table: &IndexMap<Spanned<String>, Spanned<Value>>,
|
||||
) -> ParseResult<Self> {
|
||||
let mut ext = Extractor::new(self.0, span, table);
|
||||
let (name, match_val, action_val, latch_val) = ext.extract((
|
||||
let (name, match_val, action_val, latch_val, auto_focus) = ext.extract((
|
||||
opt(str("name")),
|
||||
opt(val("match")),
|
||||
opt(val("action")),
|
||||
opt(val("latch")),
|
||||
recover(opt(bol("auto-focus"))),
|
||||
))?;
|
||||
let mut action = None;
|
||||
if let Some(value) = action_val {
|
||||
|
|
@ -78,6 +79,7 @@ impl Parser for WindowRuleParser<'_> {
|
|||
match_,
|
||||
action,
|
||||
latch,
|
||||
auto_focus: auto_focus.despan(),
|
||||
})
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -333,6 +333,9 @@ impl Rule for WindowRule {
|
|||
});
|
||||
}
|
||||
}
|
||||
if let Some(auto_focus) = self.auto_focus {
|
||||
matcher.set_auto_focus(auto_focus);
|
||||
}
|
||||
}
|
||||
|
||||
fn gen_matcher(m: Self::Matcher) -> Self::Criterion<'static> {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue