From 8810a0146f6998d7a5b7a116cd0c526fed868015 Mon Sep 17 00:00:00 2001 From: Kirill Chibisov Date: Thu, 1 Feb 2024 00:11:31 +0400 Subject: [PATCH] On Wayland, fix min/max inner size setting The size is only applied on the next `wl_surface::commit` thus we must trigger the redraw. --- CHANGELOG.md | 1 + src/platform_impl/linux/wayland/window/mod.rs | 13 ++++++++++--- src/platform_impl/linux/wayland/window/state.rs | 8 ++++++-- 3 files changed, 17 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3465e9f1d0..a8a9bb5bd1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -18,6 +18,7 @@ Unreleased` header. - On X11, reload dpi on `_XSETTINGS_SETTINGS` update. - On X11, fix deadlock when adjusting DPI and resizing at the same time. - On Wayland, fix `Focused(false)` being send when other seats still have window focused. +- On Wayland, fix `Window::set_{min,max}_inner_size` not always applied. # 0.29.10 diff --git a/src/platform_impl/linux/wayland/window/mod.rs b/src/platform_impl/linux/wayland/window/mod.rs index 2ca949a7cf..d60f8de3c6 100644 --- a/src/platform_impl/linux/wayland/window/mod.rs +++ b/src/platform_impl/linux/wayland/window/mod.rs @@ -327,7 +327,9 @@ impl Window { self.window_state .lock() .unwrap() - .set_min_inner_size(min_size) + .set_min_inner_size(min_size); + // NOTE: Requires commit to be applied. + self.request_redraw(); } /// Set the maximum inner size for the window. @@ -338,7 +340,9 @@ impl Window { self.window_state .lock() .unwrap() - .set_max_inner_size(max_size) + .set_max_inner_size(max_size); + // NOTE: Requires commit to be applied. + self.request_redraw(); } #[inline] @@ -387,7 +391,10 @@ impl Window { #[inline] pub fn set_resizable(&self, resizable: bool) { - self.window_state.lock().unwrap().set_resizable(resizable); + if self.window_state.lock().unwrap().set_resizable(resizable) { + // NOTE: Requires commit to be applied. + self.request_redraw(); + } } #[inline] diff --git a/src/platform_impl/linux/wayland/window/state.rs b/src/platform_impl/linux/wayland/window/state.rs index 38310d050d..c4c1ce4739 100644 --- a/src/platform_impl/linux/wayland/window/state.rs +++ b/src/platform_impl/linux/wayland/window/state.rs @@ -498,10 +498,12 @@ impl WindowState { } /// Set the resizable state on the window. + /// + /// Returns `true` when the state was applied. #[inline] - pub fn set_resizable(&mut self, resizable: bool) { + pub fn set_resizable(&mut self, resizable: bool) -> bool { if self.resizable == resizable { - return; + return false; } self.resizable = resizable; @@ -517,6 +519,8 @@ impl WindowState { if let Some(frame) = self.frame.as_mut() { frame.set_resizable(resizable); } + + true } /// Whether the window is focused by any seat.