From 43578e21b154345a8564a3eba55f4fe7aa7d3b3c Mon Sep 17 00:00:00 2001 From: Ivan Molodetskikh Date: Thu, 12 Sep 2024 19:31:47 +0300 Subject: Always clamp non-auto window height with >1 windows in column --- src/layout/mod.rs | 39 ++++++++++++++++++++++++++++++++++++++- 1 file changed, 38 insertions(+), 1 deletion(-) (limited to 'src/layout/mod.rs') diff --git a/src/layout/mod.rs b/src/layout/mod.rs index 9d69e0ff..470b4262 100644 --- a/src/layout/mod.rs +++ b/src/layout/mod.rs @@ -189,6 +189,9 @@ pub trait LayoutElement { /// This *will* switch immediately after a [`LayoutElement::request_fullscreen()`] call. fn is_pending_fullscreen(&self) -> bool; + /// Size previously requested through [`LayoutElement::request_size()`]. + fn requested_size(&self) -> Option>; + fn rules(&self) -> &ResolvedWindowRules; /// Runs periodic clean-up tasks. @@ -2777,7 +2780,7 @@ mod tests { } fn communicate(&self) -> bool { - if let Some(size) = self.0.requested_size.take() { + if let Some(size) = self.0.requested_size.get() { assert!(size.w >= 0); assert!(size.h >= 0); @@ -2887,6 +2890,10 @@ mod tests { self.0.pending_fullscreen.get() } + fn requested_size(&self) -> Option> { + self.0.requested_size.get() + } + fn refresh(&self) {} fn rules(&self) -> &ResolvedWindowRules { @@ -4696,6 +4703,36 @@ mod tests { check_ops(&ops); } + #[test] + fn fixed_height_takes_max_non_auto_into_account() { + let ops = [ + Op::AddOutput(1), + Op::AddWindow { + id: 0, + bbox: Rectangle::from_loc_and_size((0, 0), (100, 200)), + min_max_size: Default::default(), + }, + Op::SetWindowHeight { id: Some(0), change: SizeChange::SetFixed(704) }, + Op::AddWindow { + id: 1, + bbox: Rectangle::from_loc_and_size((0, 0), (100, 200)), + min_max_size: Default::default(), + }, + Op::ConsumeOrExpelWindowLeft, + ]; + + let options = Options { + border: niri_config::Border { + off: false, + width: niri_config::FloatOrInt(4.), + ..Default::default() + }, + gaps: 0., + ..Default::default() + }; + check_ops_with_options(options, &ops); + } + fn arbitrary_spacing() -> impl Strategy { // Give equal weight to: // - 0: the element is disabled -- cgit