From 37d23e43e93f7b4df7d6226bd8386e696009fdd8 Mon Sep 17 00:00:00 2001 From: Osspial Date: Sat, 28 Dec 2019 22:15:47 -0500 Subject: [PATCH] Fix Window::set_visible not setting internal flags correctly --- CHANGELOG.md | 1 + src/platform_impl/windows/window.rs | 15 +++++++-------- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index cf323212e3..92a8dfa2c5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -16,6 +16,7 @@ - `RedrawEventsCleared` is issued after each set of `RedrawRequested` events. - Implement synthetic window focus key events on Windows. - **Breaking**: Change `ModifiersState` to a `bitflags` struct. +- On Windows, fix `Window::set_visible` not setting internal flags correctly. This resulted in some weird behavior. # 0.20.0 Alpha 5 (2019-12-09) diff --git a/src/platform_impl/windows/window.rs b/src/platform_impl/windows/window.rs index 08e884d4a1..d99f86457b 100644 --- a/src/platform_impl/windows/window.rs +++ b/src/platform_impl/windows/window.rs @@ -127,14 +127,13 @@ impl Window { #[inline] pub fn set_visible(&self, visible: bool) { - match visible { - true => unsafe { - winuser::ShowWindow(self.window.0, winuser::SW_SHOW); - }, - false => unsafe { - winuser::ShowWindow(self.window.0, winuser::SW_HIDE); - }, - } + let window_state = Arc::clone(&self.window_state); + let window = self.window.clone(); + self.thread_executor.execute_in_thread(move || { + WindowState::set_window_flags(window_state.lock(), window.0, |f| { + f.set(WindowFlags::VISIBLE, visible) + }); + }); } #[inline]