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/layout/floating.rs | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) (limited to 'src/layout/floating.rs') diff --git a/src/layout/floating.rs b/src/layout/floating.rs index 08a74b37..a04c9b94 100644 --- a/src/layout/floating.rs +++ b/src/layout/floating.rs @@ -1102,9 +1102,14 @@ impl FloatingSpace { width.resolve_no_gaps(&self.options, self.working_area.size.w) } + pub fn resolve_height(&self, height: PresetSize) -> ResolvedSize { + resolve_preset_size(height, self.working_area.size.h) + } + pub fn new_window_size( &self, width: Option, + height: Option, rules: &ResolvedWindowRules, ) -> Size { let border = rules.border.resolve_against(self.options.border); @@ -1125,7 +1130,23 @@ impl FloatingSpace { 0 }; - Size::from((width, 0)) + let height = if let Some(height) = height { + let height = match self.resolve_height(height) { + ResolvedSize::Tile(mut size) => { + if !border.off { + size -= border.width.0 * 2.; + } + size + } + ResolvedSize::Window(size) => size, + }; + + max(1, height.floor() as i32) + } else { + 0 + }; + + Size::from((width, height)) } #[cfg(test)] -- cgit