diff options
| author | Ivan Molodetskikh <yalterz@gmail.com> | 2023-08-16 10:03:24 +0400 |
|---|---|---|
| committer | Ivan Molodetskikh <yalterz@gmail.com> | 2023-08-16 10:03:24 +0400 |
| commit | d4d2cefe50b13222a2eb45f59d4b80f8b8d4f634 (patch) | |
| tree | 384a1df113496549a681d073dbf42d960b54abc8 | |
| parent | c8a60c4513edbe588d982cfdc991c245166bb34a (diff) | |
| download | niri-d4d2cefe50b13222a2eb45f59d4b80f8b8d4f634.tar.gz niri-d4d2cefe50b13222a2eb45f59d4b80f8b8d4f634.tar.bz2 niri-d4d2cefe50b13222a2eb45f59d4b80f8b8d4f634.zip | |
Respect max window width
| -rw-r--r-- | src/layout.rs | 25 |
1 files changed, 24 insertions, 1 deletions
diff --git a/src/layout.rs b/src/layout.rs index eb0cfef6..8a090c07 100644 --- a/src/layout.rs +++ b/src/layout.rs @@ -68,6 +68,7 @@ pub trait LayoutElement: SpaceElement + PartialEq + Clone { fn request_size(&self, size: Size<i32, Logical>); fn request_fullscreen(&self, size: Size<i32, Logical>); fn min_size(&self) -> Size<i32, Logical>; + fn max_size(&self) -> Size<i32, Logical>; fn is_wl_surface(&self, wl_surface: &WlSurface) -> bool; fn send_frame<T, F>( &self, @@ -196,6 +197,13 @@ impl LayoutElement for Window { }) } + fn max_size(&self) -> Size<i32, Logical> { + with_states(self.toplevel().wl_surface(), |state| { + let curr = state.cached_state.current::<SurfaceCachedState>(); + curr.max_size + }) + } + fn is_wl_surface(&self, wl_surface: &WlSurface) -> bool { self.toplevel().wl_surface() == wl_surface } @@ -1739,9 +1747,24 @@ impl<W: LayoutElement> Column<W> { }) .max() .unwrap_or(1); + let max_width = self + .windows + .iter() + .filter_map(|win| { + let w = win.max_size().w; + if w == 0 { + None + } else { + Some(w) + } + }) + .min() + .unwrap_or(i32::MAX); + let max_width = max(max_width, min_width); + let width = self.width.resolve(view_size.w - PADDING) - PADDING; let height = (view_size.h - PADDING) / self.window_count() as i32 - PADDING; - let size = Size::from((max(width, min_width), max(height, 1))); + let size = Size::from((max(min(width, max_width), min_width), max(height, 1))); for win in &self.windows { win.request_size(size); |
