diff options
| author | Ivan Molodetskikh <yalterz@gmail.com> | 2024-12-30 08:48:05 +0300 |
|---|---|---|
| committer | Ivan Molodetskikh <yalterz@gmail.com> | 2024-12-30 20:12:37 +0300 |
| commit | 8409107a5bb04980ea196a5d7095d5c34f6b2e4e (patch) | |
| tree | 18a3fbcc3cab75a080f9f1d9c1ef2f06e55df237 /src/layout/scrolling.rs | |
| parent | 9089c3fb0224a7f8d425a02fa299f6a5ea607b17 (diff) | |
| download | niri-8409107a5bb04980ea196a5d7095d5c34f6b2e4e.tar.gz niri-8409107a5bb04980ea196a5d7095d5c34f6b2e4e.tar.bz2 niri-8409107a5bb04980ea196a5d7095d5c34f6b2e4e.zip | |
Implement default-window-height for scrolling windows
Diffstat (limited to 'src/layout/scrolling.rs')
| -rw-r--r-- | src/layout/scrolling.rs | 21 |
1 files changed, 19 insertions, 2 deletions
diff --git a/src/layout/scrolling.rs b/src/layout/scrolling.rs index 6fa6fbfc..10101cca 100644 --- a/src/layout/scrolling.rs +++ b/src/layout/scrolling.rs @@ -399,6 +399,7 @@ impl<W: LayoutElement> ScrollingSpace<W> { pub fn new_window_size( &self, width: Option<ColumnWidth>, + height: Option<PresetSize>, rules: &ResolvedWindowRules, ) -> Size<i32, Logical> { let border = rules.border.resolve_against(self.options.border); @@ -417,11 +418,27 @@ impl<W: LayoutElement> ScrollingSpace<W> { 0 }; - let mut height = self.working_area.size.h - self.options.gaps * 2.; + let mut full_height = self.working_area.size.h - self.options.gaps * 2.; if !border.off { - height -= border.width.0 * 2.; + full_height -= border.width.0 * 2.; } + let height = if let Some(height) = height { + let height = match resolve_preset_size(height, &self.options, self.working_area.size.h) + { + ResolvedSize::Tile(mut size) => { + if !border.off { + size -= border.width.0 * 2.; + } + size + } + ResolvedSize::Window(size) => size, + }; + f64::min(height, full_height) + } else { + full_height + }; + Size::from((width, max(height.floor() as i32, 1))) } |
