From 61c6753af4f93f3aac4cabb2789f0eb9dae4a3c5 Mon Sep 17 00:00:00 2001 From: Thayne McCombs Date: Wed, 17 Jul 2024 00:21:31 -0600 Subject: [PATCH] Handle resize if only one dimension is given. --- window/src/os/wayland/window.rs | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/window/src/os/wayland/window.rs b/window/src/os/wayland/window.rs index 57a88d1a274..b8d53250ed1 100644 --- a/window/src/os/wayland/window.rs +++ b/window/src/os/wayland/window.rs @@ -272,6 +272,7 @@ impl WaylandWindow { window: Some(window), window_frame, dimensions, + outer_size: (w, h), resize_increments: None, window_state: WindowState::default(), last_mouse_coords: Point::new(0, 0), @@ -493,6 +494,8 @@ pub struct WaylandWindowInner { window: Option, pub(super) window_frame: FallbackFrame, dimensions: Dimensions, + /// The size of the window, including decorations, according to the last configure event. + outer_size: (u32, u32), resize_increments: Option, window_state: WindowState, last_mouse_coords: Point, @@ -794,6 +797,7 @@ impl WaylandWindowInner { pixel_height: pixel_height.try_into().unwrap(), dpi, }; + self.outer_size = outer_size; // Only trigger a resize if the new dimensions are different; // this makes things more efficient and a little more smooth @@ -1228,8 +1232,17 @@ impl WindowHandler for WaylandState { .update_wm_capabilities(configure.capabilities); // TODO: should we resize if only one of width or height is specified? - if let (Some(w), Some(h)) = configure.new_size { - window_inner.update_size(w.get(), h.get(), qh); + match configure.new_size { + (Some(w), Some(h)) => window_inner.update_size(w.get(), h.get(), qh), + (Some(w), None) => { + let h = window_inner.outer_size.1; + window_inner.update_size(w.get(), h, qh) + } + (None, Some(h)) => { + let w = window_inner.outer_size.0; + window_inner.update_size(w, h.get(), qh) + } + _ => {} } if let Some(notify) = window_inner.pending_first_configure.take() {