From 6fba4c371e7868f8d581cf3d49d611cdbb590ad4 Mon Sep 17 00:00:00 2001 From: Ivan Molodetskikh Date: Fri, 27 Dec 2024 09:58:22 +0300 Subject: Implement default-window-height window rule Only works for floats that aren't initially fullscreen atm. --- src/window/mod.rs | 14 +++++++++++++- src/window/unmapped.rs | 6 ++++++ 2 files changed, 19 insertions(+), 1 deletion(-) (limited to 'src/window') diff --git a/src/window/mod.rs b/src/window/mod.rs index 0b0b5f1e..44d5359e 100644 --- a/src/window/mod.rs +++ b/src/window/mod.rs @@ -1,6 +1,6 @@ use std::cmp::{max, min}; -use niri_config::{BlockOutFrom, BorderRule, CornerRadius, Match, WindowRule}; +use niri_config::{BlockOutFrom, BorderRule, CornerRadius, Match, PresetSize, WindowRule}; use smithay::reexports::wayland_protocols::xdg::shell::server::xdg_toplevel; use smithay::utils::{Logical, Size}; use smithay::wayland::compositor::with_states; @@ -34,6 +34,13 @@ pub struct ResolvedWindowRules { /// - `Some(Some(width))`: set to a particular width. pub default_width: Option>, + /// Default height for this window. + /// + /// - `None`: unset (global default should be used). + /// - `Some(None)`: set to empty (window picks its own height). + /// - `Some(Some(width))`: set to a particular height. + pub default_height: Option>, + /// Output to open this window on. pub open_on_output: Option, @@ -114,6 +121,7 @@ impl ResolvedWindowRules { pub const fn empty() -> Self { Self { default_width: None, + default_height: None, open_on_output: None, open_on_workspace: None, open_maximized: None, @@ -192,6 +200,10 @@ impl ResolvedWindowRules { resolved.default_width = Some(x); } + if let Some(x) = rule.default_window_height { + resolved.default_height = Some(x.0); + } + if let Some(x) = rule.open_on_output.as_deref() { open_on_output = Some(x); } diff --git a/src/window/unmapped.rs b/src/window/unmapped.rs index 3ea0f1d8..18073a98 100644 --- a/src/window/unmapped.rs +++ b/src/window/unmapped.rs @@ -1,3 +1,4 @@ +use niri_config::PresetSize; use smithay::desktop::Window; use smithay::output::Output; use smithay::wayland::shell::xdg::ToplevelSurface; @@ -40,6 +41,11 @@ pub enum InitialConfigureState { /// `None` means that the window will pick its own width. floating_width: Option, + /// Resolved floating default height for this window. + /// + /// `None` means that the window will pick its own height. + floating_height: Option, + /// Whether the window should open full-width. is_full_width: bool, -- cgit