Add is-urgent window rule matcher
Browse files at this commita2efaf2816f14ea437d88bc6b9253b1e347c4ceeParent: 58166914 changed files +26 -0
- niri-config/src/lib.rs +5 -0
- src/window/mapped.rs +1 -0
- src/window/mod.rs +6 -0
- wiki/Configuration:-Window-Rules.md +14 -0
niri-config/src/lib.rsmodified+5 -0
| @@ -1457,6 +1457,8 @@ pub struct Match { | ||
| 1457 | 1457 | #[knuffel(property)] |
| 1458 | 1458 | pub is_window_cast_target: Option<bool>, |
| 1459 | 1459 | #[knuffel(property)] |
| 1460 | + pub is_urgent: Option<bool>, | |
| 1461 | + #[knuffel(property)] | |
| 1460 | 1462 | pub at_startup: Option<bool>, |
| 1461 | 1463 | } |
| 1462 | 1464 | |
| @@ -4804,6 +4806,7 @@ mod tests { | ||
| 4804 | 4806 | is_active_in_column: None, |
| 4805 | 4807 | is_floating: None, |
| 4806 | 4808 | is_window_cast_target: None, |
| 4809 | + is_urgent: None, | |
| 4807 | 4810 | at_startup: None, |
| 4808 | 4811 | }, |
| 4809 | 4812 | ], |
| @@ -4822,6 +4825,7 @@ mod tests { | ||
| 4822 | 4825 | is_active_in_column: None, |
| 4823 | 4826 | is_floating: None, |
| 4824 | 4827 | is_window_cast_target: None, |
| 4828 | + is_urgent: None, | |
| 4825 | 4829 | at_startup: None, |
| 4826 | 4830 | }, |
| 4827 | 4831 | Match { |
| @@ -4836,6 +4840,7 @@ mod tests { | ||
| 4836 | 4840 | is_active_in_column: None, |
| 4837 | 4841 | is_floating: None, |
| 4838 | 4842 | is_window_cast_target: None, |
| 4843 | + is_urgent: None, | |
| 4839 | 4844 | at_startup: None, |
| 4840 | 4845 | }, |
| 4841 | 4846 | ], |
src/window/mapped.rsmodified+1 -0
| @@ -520,6 +520,7 @@ impl Mapped { | ||
| 520 | 520 | if self.is_focused && urgent { |
| 521 | 521 | return; |
| 522 | 522 | } |
| 523 | + | |
| 523 | 524 | let changed = self.is_urgent != urgent; |
| 524 | 525 | self.is_urgent = urgent; |
| 525 | 526 | self.need_to_recompute_rules |= changed; |
src/window/mod.rsmodified+6 -0
| @@ -440,6 +440,12 @@ fn window_matches(window: WindowRef, role: &XdgToplevelSurfaceRoleAttributes, m: | ||
| 440 | 440 | } |
| 441 | 441 | } |
| 442 | 442 | |
| 443 | + if let Some(is_urgent) = m.is_urgent { | |
| 444 | + if window.is_urgent() != is_urgent { | |
| 445 | + return false; | |
| 446 | + } | |
| 447 | + } | |
| 448 | + | |
| 443 | 449 | if let Some(is_active) = m.is_active { |
| 444 | 450 | // Our "is-active" definition corresponds to the window having a pending Activated state. |
| 445 | 451 | let pending_activated = server_pending |
wiki/Configuration:-Window-Rules.mdmodified+14 -0
| @@ -35,6 +35,7 @@ window-rule { | ||
| 35 | 35 | match is-active-in-column=true |
| 36 | 36 | match is-floating=true |
| 37 | 37 | match is-window-cast-target=true |
| 38 | + match is-urgent=true | |
| 38 | 39 | match at-startup=true |
| 39 | 40 | |
| 40 | 41 | // Properties that apply once upon window opening. |
| @@ -286,6 +287,19 @@ Example: | ||
| 286 | 287 | |
| 287 | 288 |  |
| 288 | 289 | |
| 290 | +#### `is-urgent` | |
| 291 | + | |
| 292 | +<sup>Since: next release</sup> | |
| 293 | + | |
| 294 | +Can be `true` or `false`. | |
| 295 | +Matches windows that request the user's attention. | |
| 296 | + | |
| 297 | +```kdl | |
| 298 | +window-rule { | |
| 299 | + match is-urgent=true | |
| 300 | +} | |
| 301 | +``` | |
| 302 | + | |
| 289 | 303 | #### `at-startup` |
| 290 | 304 | |
| 291 | 305 | <sup>Since: 0.1.6</sup> |