Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix hiding a maximized window On Windows #2336

Merged
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Expand Up @@ -8,6 +8,7 @@ And please only add new entries to the top of this list, right below the `# Unre

# Unreleased

- On Windows, fix hiding a maximized window.
- On X11, fix events for caps lock key not being sent
- Build docs on `docs.rs` for iOS and Android as well.
- **Breaking:** Removed the `WindowAttributes` struct, since all its functionality is accessible from `WindowBuilder`.
Expand Down
22 changes: 10 additions & 12 deletions src/platform_impl/windows/window_state.rs
Expand Up @@ -100,7 +100,6 @@ bitflags! {

const EXCLUSIVE_FULLSCREEN_OR_MASK = WindowFlags::ALWAYS_ON_TOP.bits;
const NO_DECORATIONS_AND_MASK = !WindowFlags::RESIZABLE.bits;
const INVISIBLE_AND_MASK = !WindowFlags::MAXIMIZED.bits;
}
}

Expand Down Expand Up @@ -200,9 +199,6 @@ impl WindowFlags {
if self.contains(WindowFlags::MARKER_EXCLUSIVE_FULLSCREEN) {
self |= WindowFlags::EXCLUSIVE_FULLSCREEN_OR_MASK;
}
if !self.contains(WindowFlags::VISIBLE) {
self &= WindowFlags::INVISIBLE_AND_MASK;
}
if !self.contains(WindowFlags::DECORATIONS) {
self &= WindowFlags::NO_DECORATIONS_AND_MASK;
}
Expand Down Expand Up @@ -265,21 +261,17 @@ impl WindowFlags {
new = new.mask();

let diff = self ^ new;

if diff == WindowFlags::empty() {
return;
}

if diff.contains(WindowFlags::VISIBLE) {
if new.contains(WindowFlags::VISIBLE) {
unsafe {
ShowWindow(
window,
match new.contains(WindowFlags::VISIBLE) {
true => SW_SHOW,
false => SW_HIDE,
},
);
ShowWindow(window, SW_SHOW);
}
}

if diff.contains(WindowFlags::ALWAYS_ON_TOP) {
unsafe {
SetWindowPos(
Expand Down Expand Up @@ -323,6 +315,12 @@ impl WindowFlags {
}
}

if !new.contains(WindowFlags::VISIBLE) {
unsafe {
ShowWindow(window, SW_HIDE);
}
}

if diff != WindowFlags::empty() {
let (style, style_ex) = new.to_window_styles();

Expand Down