Fix hiding a maximized window On Windows (#2336)

This commit is contained in:
Amr Bashir 2022-07-23 14:23:58 +02:00 committed by GitHub
parent 1cd0e94c26
commit 08d025968e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 12 deletions

View file

@ -8,6 +8,7 @@ And please only add new entries to the top of this list, right below the `# Unre
# Unreleased # Unreleased
- On Windows, fix hiding a maximized window.
- On Android, `ndk-glue`'s `NativeWindow` lock is now held between `Event::Resumed` and `Event::Suspended`. - On Android, `ndk-glue`'s `NativeWindow` lock is now held between `Event::Resumed` and `Event::Suspended`.
- On Web, added `EventLoopExtWebSys` with a `spawn` method to start the event loop without throwing an exception. - On Web, added `EventLoopExtWebSys` with a `spawn` method to start the event loop without throwing an exception.
- Added `WindowEvent::Occluded(bool)`, currently implemented on macOS and X11. - Added `WindowEvent::Occluded(bool)`, currently implemented on macOS and X11.

View file

@ -106,7 +106,6 @@ bitflags! {
const EXCLUSIVE_FULLSCREEN_OR_MASK = WindowFlags::ALWAYS_ON_TOP.bits; const EXCLUSIVE_FULLSCREEN_OR_MASK = WindowFlags::ALWAYS_ON_TOP.bits;
const NO_DECORATIONS_AND_MASK = !WindowFlags::RESIZABLE.bits; const NO_DECORATIONS_AND_MASK = !WindowFlags::RESIZABLE.bits;
const INVISIBLE_AND_MASK = !WindowFlags::MAXIMIZED.bits;
} }
} }
@ -229,9 +228,6 @@ impl WindowFlags {
if self.contains(WindowFlags::MARKER_EXCLUSIVE_FULLSCREEN) { if self.contains(WindowFlags::MARKER_EXCLUSIVE_FULLSCREEN) {
self |= WindowFlags::EXCLUSIVE_FULLSCREEN_OR_MASK; self |= WindowFlags::EXCLUSIVE_FULLSCREEN_OR_MASK;
} }
if !self.contains(WindowFlags::VISIBLE) {
self &= WindowFlags::INVISIBLE_AND_MASK;
}
if !self.contains(WindowFlags::DECORATIONS) { if !self.contains(WindowFlags::DECORATIONS) {
self &= WindowFlags::NO_DECORATIONS_AND_MASK; self &= WindowFlags::NO_DECORATIONS_AND_MASK;
} }
@ -294,21 +290,17 @@ impl WindowFlags {
new = new.mask(); new = new.mask();
let diff = self ^ new; let diff = self ^ new;
if diff == WindowFlags::empty() { if diff == WindowFlags::empty() {
return; return;
} }
if diff.contains(WindowFlags::VISIBLE) { if new.contains(WindowFlags::VISIBLE) {
unsafe { unsafe {
ShowWindow( ShowWindow(window, SW_SHOW);
window,
match new.contains(WindowFlags::VISIBLE) {
true => SW_SHOW,
false => SW_HIDE,
},
);
} }
} }
if diff.contains(WindowFlags::ALWAYS_ON_TOP) { if diff.contains(WindowFlags::ALWAYS_ON_TOP) {
unsafe { unsafe {
SetWindowPos( SetWindowPos(
@ -352,6 +344,12 @@ impl WindowFlags {
} }
} }
if !new.contains(WindowFlags::VISIBLE) {
unsafe {
ShowWindow(window, SW_HIDE);
}
}
if diff != WindowFlags::empty() { if diff != WindowFlags::empty() {
let (style, style_ex) = new.to_window_styles(); let (style, style_ex) = new.to_window_styles();