From 89eea64a4aa952ddb6a4612f61075f8ad622e1a9 Mon Sep 17 00:00:00 2001 From: Amr Bashir Date: Fri, 9 Dec 2022 20:33:11 +0200 Subject: [PATCH] Retain `WS_MAXIMZE` when unminmizing a maximized window (#2581) Co-authored-by: Markus Siglreithmaier --- CHANGELOG.md | 1 + examples/window_debug.rs | 1 + src/platform_impl/windows/event_loop.rs | 1 - src/platform_impl/windows/window_state.rs | 4 +++- 4 files changed, 5 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 43bbc932..7c02360d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,7 @@ And please only add new entries to the top of this list, right below the `# Unre # Unreleased +- On Windows, retain `WS_MAXIMIZE` window style when un-minimizing a maximized window. - On Windows, fix left mouse button release event not being sent after `Window::drag_window`. - On macOS, run most actions on the main thread, which is strictly more correct, but might make multithreaded applications block slightly more. - On macOS, fix panic when getting current monitor without any monitor attached. diff --git a/examples/window_debug.rs b/examples/window_debug.rs index 47a13017..01077a8b 100644 --- a/examples/window_debug.rs +++ b/examples/window_debug.rs @@ -51,6 +51,7 @@ fn main() { if minimized { minimized = !minimized; window.set_minimized(minimized); + window.focus_window(); } } VirtualKeyCode::V => { diff --git a/src/platform_impl/windows/event_loop.rs b/src/platform_impl/windows/event_loop.rs index 18213cf4..9eb5930c 100644 --- a/src/platform_impl/windows/event_loop.rs +++ b/src/platform_impl/windows/event_loop.rs @@ -1185,7 +1185,6 @@ unsafe fn public_window_callback_inner( w.set_window_flags_in_place(|f| f.set(WindowFlags::MAXIMIZED, maximized)); } } - userdata.send_event(event); 0 } diff --git a/src/platform_impl/windows/window_state.rs b/src/platform_impl/windows/window_state.rs index cf83ba00..60c0320a 100644 --- a/src/platform_impl/windows/window_state.rs +++ b/src/platform_impl/windows/window_state.rs @@ -299,7 +299,7 @@ impl WindowFlags { self = self.mask(); new = new.mask(); - let diff = self ^ new; + let mut diff = self ^ new; if diff == WindowFlags::empty() { return; @@ -357,6 +357,8 @@ impl WindowFlags { }, ); } + + diff.remove(WindowFlags::MINIMIZED); } if diff.contains(WindowFlags::CLOSABLE) || new.contains(WindowFlags::CLOSABLE) {