aboutsummaryrefslogtreecommitdiff
path: root/src/layout/mod.rs
diff options
context:
space:
mode:
authorIvan Molodetskikh <yalterz@gmail.com>2024-09-12 19:31:47 +0300
committerIvan Molodetskikh <yalterz@gmail.com>2024-09-12 19:31:47 +0300
commit43578e21b154345a8564a3eba55f4fe7aa7d3b3c (patch)
treece824c6457bed9e89918726ed359012a3ba4e7d1 /src/layout/mod.rs
parent55a798bd8b44465a354c1bd7723d4ece855c362c (diff)
downloadniri-43578e21b154345a8564a3eba55f4fe7aa7d3b3c.tar.gz
niri-43578e21b154345a8564a3eba55f4fe7aa7d3b3c.tar.bz2
niri-43578e21b154345a8564a3eba55f4fe7aa7d3b3c.zip
Always clamp non-auto window height with >1 windows in column
Diffstat (limited to 'src/layout/mod.rs')
-rw-r--r--src/layout/mod.rs39
1 files changed, 38 insertions, 1 deletions
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<Size<i32, Logical>>;
+
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<Size<i32, Logical>> {
+ 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<Value = f64> {
// Give equal weight to:
// - 0: the element is disabled