diff options
| author | Ivan Molodetskikh <yalterz@gmail.com> | 2024-02-23 14:24:39 +0400 |
|---|---|---|
| committer | Ivan Molodetskikh <yalterz@gmail.com> | 2024-02-23 14:24:39 +0400 |
| commit | 6a587245eb79a0e054c7283eb2a97d694482e834 (patch) | |
| tree | c0359757539c59f4cdfd1e0412c383788e67676c /src | |
| parent | 2317021a7c4a7296606533d38f1fdce96826f7dc (diff) | |
| download | niri-6a587245eb79a0e054c7283eb2a97d694482e834.tar.gz niri-6a587245eb79a0e054c7283eb2a97d694482e834.tar.bz2 niri-6a587245eb79a0e054c7283eb2a97d694482e834.zip | |
Add open-maximized window rule
Diffstat (limited to 'src')
| -rw-r--r-- | src/handlers/compositor.rs | 22 | ||||
| -rw-r--r-- | src/handlers/xdg_shell.rs | 14 | ||||
| -rw-r--r-- | src/window.rs | 6 |
3 files changed, 34 insertions, 8 deletions
diff --git a/src/handlers/compositor.rs b/src/handlers/compositor.rs index a8ef5e2c..2f842176 100644 --- a/src/handlers/compositor.rs +++ b/src/handlers/compositor.rs @@ -109,16 +109,22 @@ impl CompositorHandler for State { window.on_commit(); - let (width, output) = - if let InitialConfigureState::Configured { width, output, .. } = state { + let (width, is_full_width, output) = + if let InitialConfigureState::Configured { + width, + is_full_width, + output, + .. + } = state + { // Check that the output is still connected. let output = output.filter(|o| self.niri.layout.monitor_for_output(o).is_some()); - (width, output) + (width, is_full_width, output) } else { error!("window map must happen after initial configure"); - (None, None) + (None, false, None) }; let parent = window @@ -140,14 +146,16 @@ impl CompositorHandler for State { let output = if let Some(p) = parent { // Open dialogs immediately to the right of their parent window. - self.niri.layout.add_window_right_of(&p, win, width, false) + self.niri + .layout + .add_window_right_of(&p, win, width, is_full_width) } else if let Some(output) = &output { self.niri .layout - .add_window_on_output(output, win, width, false); + .add_window_on_output(output, win, width, is_full_width); Some(output) } else { - self.niri.layout.add_window(win, width, false) + self.niri.layout.add_window(win, width, is_full_width) }; if let Some(output) = output.cloned() { diff --git a/src/handlers/xdg_shell.rs b/src/handlers/xdg_shell.rs index 04d4cc50..7ad43db8 100644 --- a/src/handlers/xdg_shell.rs +++ b/src/handlers/xdg_shell.rs @@ -89,6 +89,10 @@ pub fn resolve_window_rules( if let Some(x) = rule.open_on_output.as_deref() { open_on_output = Some(x); } + + if let Some(x) = rule.open_maximized { + resolved.open_maximized = Some(x); + } } resolved.open_on_output = open_on_output.map(|x| x.to_owned()); @@ -503,6 +507,7 @@ impl State { let mon = mon.map(|(mon, _)| mon); let mut width = None; + let is_full_width = rules.open_maximized.unwrap_or(false); // Tell the surface the preferred size and bounds for its likely output. let ws = mon @@ -518,7 +523,13 @@ impl State { } width = ws.resolve_default_width(rules.default_width); - ws.configure_new_window(window, width); + + let configure_width = if is_full_width { + Some(ColumnWidth::Proportion(1.)) + } else { + width + }; + ws.configure_new_window(window, configure_width); } // If the user prefers no CSD, it's a reasonable assumption that they would prefer to get @@ -536,6 +547,7 @@ impl State { *state = InitialConfigureState::Configured { rules, width, + is_full_width, output, }; diff --git a/src/window.rs b/src/window.rs index 68d1e3a0..ce62d07b 100644 --- a/src/window.rs +++ b/src/window.rs @@ -29,6 +29,9 @@ pub enum InitialConfigureState { /// `None` means that the window will pick its own width. width: Option<ColumnWidth>, + /// Whether the window should open full-width. + is_full_width: bool, + /// Output to open this window on. /// /// This can be `None` in cases like: @@ -52,6 +55,9 @@ pub struct ResolvedWindowRules { /// Output to open this window on. pub open_on_output: Option<String>, + + /// Whether the window should open full-width. + pub open_maximized: Option<bool>, } impl Unmapped { |
