From a21234957c0e53c4b619cd215609aac9b80e3412 Mon Sep 17 00:00:00 2001 From: "U-ALDEBERAN\\Nate" Date: Mon, 3 Nov 2025 13:30:06 -0500 Subject: [PATCH] Changing `win32_set_window_redraw()` to only be functional when the window is visible According to Stack Overflow (https://stackoverflow.com/questions/9248553/wm-setredraw-and-losing-z-order-focus) the default handling of `WM_SETREDRAW` has some weird behaviors for windows that are not visible. This seems to be the case for Slint windows that are freshly created. This should fix https://github.com/slint-ui/slint/issues/9921 --- internal/backends/winit/muda.rs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/internal/backends/winit/muda.rs b/internal/backends/winit/muda.rs index 010a1fb8b83..babfeaf34bd 100644 --- a/internal/backends/winit/muda.rs +++ b/internal/backends/winit/muda.rs @@ -119,7 +119,10 @@ impl MudaAdapter { menubar: Option<&vtable::VRc>, muda_type: MudaType, ) { - win32_set_window_redraw(winit_window, false); + let must_set_window_redraw = cfg!(windows) && winit_window.is_visible() == Some(true); + if must_set_window_redraw { + win32_set_window_redraw(winit_window, false); + } // clear the menu while self.menu.remove_at(0).is_some() {} @@ -225,7 +228,9 @@ impl MudaAdapter { } } - win32_set_window_redraw(winit_window, true); + if must_set_window_redraw { + win32_set_window_redraw(winit_window, true); + } } pub fn invoke(&self, menubar: &vtable::VRc, entry_id: usize) {