Add open-fullscreen window rule
Browse files at this commitab9d1aab4ed13027896a80200775e5679fca9539Parent: 506dcd94 changed files +20 -2
- niri-config/src/lib.rs +4 -0
- resources/default-config.kdl +5 -0
- src/handlers/xdg_shell.rs +8 -2
- src/window.rs +3 -0
niri-config/src/lib.rsmodified+4 -0
| @@ -585,6 +585,8 @@ pub struct WindowRule { | |||
| 585 | pub open_on_output: Option<String>, | 585 | pub open_on_output: Option<String>, |
| 586 | #[knuffel(child, unwrap(argument))] | 586 | #[knuffel(child, unwrap(argument))] |
| 587 | pub open_maximized: Option<bool>, | 587 | pub open_maximized: Option<bool>, |
| 588 | + #[knuffel(child, unwrap(argument))] | ||
| 589 | + pub open_fullscreen: Option<bool>, | ||
| 588 | } | 590 | } |
| 589 | 591 | ||
| 590 | #[derive(knuffel::Decode, Debug, Default, Clone)] | 592 | #[derive(knuffel::Decode, Debug, Default, Clone)] |
| @@ -1065,6 +1067,7 @@ mod tests { | |||
| 1065 | 1067 | ||
| 1066 | open-on-output "eDP-1" | 1068 | open-on-output "eDP-1" |
| 1067 | open-maximized true | 1069 | open-maximized true |
| 1070 | + open-fullscreen false | ||
| 1068 | } | 1071 | } |
| 1069 | 1072 | ||
| 1070 | binds { | 1073 | binds { |
| @@ -1225,6 +1228,7 @@ mod tests { | |||
| 1225 | }], | 1228 | }], |
| 1226 | open_on_output: Some("eDP-1".to_owned()), | 1229 | open_on_output: Some("eDP-1".to_owned()), |
| 1227 | open_maximized: Some(true), | 1230 | open_maximized: Some(true), |
| 1231 | + open_fullscreen: Some(false), | ||
| 1228 | ..Default::default() | 1232 | ..Default::default() |
| 1229 | }], | 1233 | }], |
| 1230 | binds: Binds(vec![ | 1234 | binds: Binds(vec![ |
resources/default-config.kdlmodified+5 -0
| @@ -308,6 +308,11 @@ animations { | |||
| 308 | 308 | ||
| 309 | // Make this window open as a maximized column. | 309 | // Make this window open as a maximized column. |
| 310 | open-maximized true | 310 | open-maximized true |
| 311 | + | ||
| 312 | + // Make this window open fullscreen. | ||
| 313 | + open-fullscreen true | ||
| 314 | + // You can also set this to false to prevent a window from opening fullscreen. | ||
| 315 | + // open-fullscreen false | ||
| 311 | } | 316 | } |
| 312 | 317 | ||
| 313 | // Here's a useful example. Work around WezTerm's initial configure bug | 318 | // Here's a useful example. Work around WezTerm's initial configure bug |
src/handlers/xdg_shell.rsmodified+8 -2
| @@ -93,6 +93,10 @@ pub fn resolve_window_rules( | |||
| 93 | if let Some(x) = rule.open_maximized { | 93 | if let Some(x) = rule.open_maximized { |
| 94 | resolved.open_maximized = Some(x); | 94 | resolved.open_maximized = Some(x); |
| 95 | } | 95 | } |
| 96 | + | ||
| 97 | + if let Some(x) = rule.open_fullscreen { | ||
| 98 | + resolved.open_fullscreen = Some(x); | ||
| 99 | + } | ||
| 96 | } | 100 | } |
| 97 | 101 | ||
| 98 | resolved.open_on_output = open_on_output.map(|x| x.to_owned()); | 102 | resolved.open_on_output = open_on_output.map(|x| x.to_owned()); |
| @@ -604,8 +608,10 @@ impl State { | |||
| 604 | .or_else(|| self.niri.layout.active_workspace()); | 608 | .or_else(|| self.niri.layout.active_workspace()); |
| 605 | 609 | ||
| 606 | if let Some(ws) = ws { | 610 | if let Some(ws) = ws { |
| 607 | - // Set a fullscreen state if requested. | 611 | + // Set a fullscreen state based on window request and window rule. |
| 608 | - if wants_fullscreen.is_some() { | 612 | + if (wants_fullscreen.is_some() && rules.open_fullscreen.is_none()) |
| 613 | + || rules.open_fullscreen == Some(true) | ||
| 614 | + { | ||
| 609 | toplevel.with_pending_state(|state| { | 615 | toplevel.with_pending_state(|state| { |
| 610 | state.states.set(xdg_toplevel::State::Fullscreen); | 616 | state.states.set(xdg_toplevel::State::Fullscreen); |
| 611 | }); | 617 | }); |
src/window.rsmodified+3 -0
| @@ -58,6 +58,9 @@ pub struct ResolvedWindowRules { | |||
| 58 | 58 | ||
| 59 | /// Whether the window should open full-width. | 59 | /// Whether the window should open full-width. |
| 60 | pub open_maximized: Option<bool>, | 60 | pub open_maximized: Option<bool>, |
| 61 | + | ||
| 62 | + /// Whether the window should open fullscreen. | ||
| 63 | + pub open_fullscreen: Option<bool>, | ||
| 61 | } | 64 | } |
| 62 | 65 | ||
| 63 | impl Unmapped { | 66 | impl Unmapped { |