From 92019b42860c3c7e779e1c966124c0e36dbaad1f Mon Sep 17 00:00:00 2001 From: Victoria Brekenfeld Date: Fri, 7 Jul 2023 18:23:34 +0200 Subject: [PATCH] shell: Enforce some minimum resize sizes --- src/shell/layout/floating/grabs/resize.rs | 4 ++-- src/shell/layout/floating/mod.rs | 16 +++++++++++++++- src/shell/layout/tiling/mod.rs | 7 ++++++- 3 files changed, 23 insertions(+), 4 deletions(-) diff --git a/src/shell/layout/floating/grabs/resize.rs b/src/shell/layout/floating/grabs/resize.rs index fec6dd75..a1c75262 100644 --- a/src/shell/layout/floating/grabs/resize.rs +++ b/src/shell/layout/floating/grabs/resize.rs @@ -86,8 +86,8 @@ impl PointerGrab for ResizeSurfaceGrab { let (min_size, max_size) = (self.window.min_size(), self.window.max_size()); - let min_width = min_size.map(|s| s.w).unwrap_or(1); - let min_height = min_size.map(|s| s.h).unwrap_or(1); + let min_width = min_size.map(|s| s.w).unwrap_or(360); + let min_height = min_size.map(|s| s.h).unwrap_or(240); let max_width = max_size.map(|s| s.w).unwrap_or(i32::max_value()); let max_height = max_size.map(|s| s.h).unwrap_or(i32::max_value()); diff --git a/src/shell/layout/floating/mod.rs b/src/shell/layout/floating/mod.rs index 48caab09..273331f3 100644 --- a/src/shell/layout/floating/mod.rs +++ b/src/shell/layout/floating/mod.rs @@ -305,6 +305,14 @@ impl FloatingLayout { Some(other) => Some(other.merge(output_geo)), }) else { return true }; + let (min_size, max_size) = (mapped.min_size(), mapped.max_size()); + let min_width = min_size.map(|s| s.w).unwrap_or(360); + let min_height = min_size.map(|s| s.h).unwrap_or(240); + let max_width = max_size.map(|s| s.w).unwrap_or(i32::max_value()); + let max_height = max_size.map(|s| s.h).unwrap_or(i32::max_value()); + + geo.size.w = min_width.max(geo.size.w).min(max_width); + geo.size.h = min_height.max(geo.size.h).min(max_height); geo = geo.intersection(bounding_box).unwrap(); *mapped.resize_state.lock().unwrap() = Some(ResizeState::Resizing(ResizeData { @@ -314,7 +322,13 @@ impl FloatingLayout { })); mapped.set_resizing(true); - mapped.set_geometry(geo); + mapped.set_geometry(Rectangle::from_loc_and_size( + match mapped.active_window() { + CosmicSurface::X11(s) => s.geometry().loc, + _ => (0, 0).into(), + }, + geo.size, + )); mapped.configure(); true diff --git a/src/shell/layout/tiling/mod.rs b/src/shell/layout/tiling/mod.rs index 4aa73ac5..f9d95a13 100644 --- a/src/shell/layout/tiling/mod.rs +++ b/src/shell/layout/tiling/mod.rs @@ -1536,7 +1536,12 @@ impl TilingLayout { }; let old_size = sizes[shrink_idx]; - sizes[shrink_idx] = (old_size - amount).max(10); + sizes[shrink_idx] = + (old_size - amount).max(if orientation == Orientation::Vertical { + 360 + } else { + 240 + }); let diff = old_size - sizes[shrink_idx]; sizes[grow_idx] += diff; }