config: add auto-focus window rule
This commit is contained in:
parent
51e752992f
commit
b1ca98b488
12 changed files with 114 additions and 10 deletions
|
|
@ -1701,6 +1701,13 @@ impl ConfigClient {
|
|||
handler.cb = cb.clone();
|
||||
}
|
||||
|
||||
pub fn set_window_matcher_auto_focus(&self, matcher: WindowMatcher, auto_focus: bool) {
|
||||
self.send(&ClientMessage::SetWindowMatcherAutoFocus {
|
||||
matcher,
|
||||
auto_focus,
|
||||
});
|
||||
}
|
||||
|
||||
pub fn set_window_matcher_latch_handler(
|
||||
&self,
|
||||
matcher: WindowMatcher,
|
||||
|
|
|
|||
|
|
@ -698,6 +698,10 @@ pub enum ClientMessage<'a> {
|
|||
EnableWindowMatcherEvents {
|
||||
matcher: WindowMatcher,
|
||||
},
|
||||
SetWindowMatcherAutoFocus {
|
||||
matcher: WindowMatcher,
|
||||
auto_focus: bool,
|
||||
},
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Debug)]
|
||||
|
|
|
|||
|
|
@ -296,6 +296,16 @@ impl WindowCriterion<'_> {
|
|||
pub fn bind<F: FnMut(MatchedWindow) + 'static>(self, cb: F) {
|
||||
self.to_matcher().bind(cb);
|
||||
}
|
||||
|
||||
/// Sets whether newly mapped windows that match this criterion get the keyboard focus.
|
||||
///
|
||||
/// If a window matches any criterion for which this is false, the window will not be
|
||||
/// automatically focused.
|
||||
///
|
||||
/// This leaks the matcher.
|
||||
pub fn set_auto_focus(self, auto_focus: bool) {
|
||||
self.to_matcher().set_auto_focus(auto_focus);
|
||||
}
|
||||
}
|
||||
|
||||
impl WindowMatcher {
|
||||
|
|
@ -312,6 +322,14 @@ impl WindowMatcher {
|
|||
pub fn bind<F: FnMut(MatchedWindow) + 'static>(self, cb: F) {
|
||||
get!().set_window_matcher_handler(self, cb);
|
||||
}
|
||||
|
||||
/// Sets whether newly mapped windows that match this matcher get the keyboard focus.
|
||||
///
|
||||
/// If a window matches any matcher for which this is false, the window will not be
|
||||
/// automatically focused.
|
||||
pub fn set_auto_focus(self, auto_focus: bool) {
|
||||
get!().set_window_matcher_auto_focus(self, auto_focus);
|
||||
}
|
||||
}
|
||||
|
||||
impl MatchedWindow {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue