aboutsummaryrefslogtreecommitdiff
path: root/src/window
diff options
context:
space:
mode:
authorIvan Molodetskikh <yalterz@gmail.com>2024-05-16 11:43:13 +0400
committerIvan Molodetskikh <yalterz@gmail.com>2024-05-16 12:27:09 +0400
commitcbfc682f9abc9b4c02ea3c0f63a4403d037f14a4 (patch)
tree8075783f9bdae04b3327e61ed613ebd8f4862896 /src/window
parentc64d9e5223a4a19fa718dc5a0b3e74dd6ee3b0e0 (diff)
downloadniri-cbfc682f9abc9b4c02ea3c0f63a4403d037f14a4.tar.gz
niri-cbfc682f9abc9b4c02ea3c0f63a4403d037f14a4.tar.bz2
niri-cbfc682f9abc9b4c02ea3c0f63a4403d037f14a4.zip
Implement at-startup window rule
Diffstat (limited to 'src/window')
-rw-r--r--src/window/mapped.rs12
-rw-r--r--src/window/mod.rs12
2 files changed, 18 insertions, 6 deletions
diff --git a/src/window/mapped.rs b/src/window/mapped.rs
index bdb62df8..4864d62e 100644
--- a/src/window/mapped.rs
+++ b/src/window/mapped.rs
@@ -120,10 +120,10 @@ impl Mapped {
}
/// Recomputes the resolved window rules and returns whether they changed.
- pub fn recompute_window_rules(&mut self, rules: &[WindowRule]) -> bool {
+ pub fn recompute_window_rules(&mut self, rules: &[WindowRule], is_at_startup: bool) -> bool {
self.need_to_recompute_rules = false;
- let new_rules = ResolvedWindowRules::compute(rules, WindowRef::Mapped(self));
+ let new_rules = ResolvedWindowRules::compute(rules, WindowRef::Mapped(self), is_at_startup);
if new_rules == self.rules {
return false;
}
@@ -132,12 +132,16 @@ impl Mapped {
true
}
- pub fn recompute_window_rules_if_needed(&mut self, rules: &[WindowRule]) -> bool {
+ pub fn recompute_window_rules_if_needed(
+ &mut self,
+ rules: &[WindowRule],
+ is_at_startup: bool,
+ ) -> bool {
if !self.need_to_recompute_rules {
return false;
}
- self.recompute_window_rules(rules)
+ self.recompute_window_rules(rules, is_at_startup)
}
pub fn is_focused(&self) -> bool {
diff --git a/src/window/mod.rs b/src/window/mod.rs
index 92b4f793..9bdbd887 100644
--- a/src/window/mod.rs
+++ b/src/window/mod.rs
@@ -135,7 +135,7 @@ impl ResolvedWindowRules {
}
}
- pub fn compute(rules: &[WindowRule], window: WindowRef) -> Self {
+ pub fn compute(rules: &[WindowRule], window: WindowRef, is_at_startup: bool) -> Self {
let _span = tracy_client::span!("ResolvedWindowRules::compute");
let mut resolved = ResolvedWindowRules::empty();
@@ -158,7 +158,15 @@ impl ResolvedWindowRules {
let mut open_on_workspace = None;
for rule in rules {
- let matches = |m| window_matches(window, &role, m);
+ let matches = |m: &Match| {
+ if let Some(at_startup) = m.at_startup {
+ if at_startup != is_at_startup {
+ return false;
+ }
+ }
+
+ window_matches(window, &role, m)
+ };
if !(rule.matches.is_empty() || rule.matches.iter().any(matches)) {
continue;