Skip to content

Commit

Permalink
fix(windows): apply maximize state before minimize (#334)
Browse files Browse the repository at this point in the history
  • Loading branch information
amrbashir committed Mar 1, 2022
1 parent 19d7887 commit 11dac10
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 8 deletions.
5 changes: 5 additions & 0 deletions .changes/windows-maximize-minimize.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"tao": "patch"
---

On Windows, apply maximize state before minimize. Fixes `Window::set_minimized` not working when the window is maximized.
15 changes: 7 additions & 8 deletions src/platform_impl/windows/window_state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,6 @@ impl WindowFlags {
style |= WS_THICKFRAME | WS_MAXIMIZEBOX;
}
if self.contains(WindowFlags::DECORATIONS) {
style |= WS_BORDER;
style_ex |= WS_EX_WINDOWEDGE;
}
if self.contains(WindowFlags::VISIBLE) {
Expand Down Expand Up @@ -276,25 +275,25 @@ impl WindowFlags {
}
}

// Minimize operations should execute after maximize for proper window animations
if diff.contains(WindowFlags::MINIMIZED) {
if diff.contains(WindowFlags::MAXIMIZED) || new.contains(WindowFlags::MAXIMIZED) {
unsafe {
ShowWindow(
window,
match new.contains(WindowFlags::MINIMIZED) {
true => SW_MINIMIZE,
match new.contains(WindowFlags::MAXIMIZED) {
true => SW_MAXIMIZE,
false => SW_RESTORE,
},
);
}
}

if diff.contains(WindowFlags::MAXIMIZED) || new.contains(WindowFlags::MAXIMIZED) {
// Minimize operations should execute after maximize for proper window animations
if diff.contains(WindowFlags::MINIMIZED) {
unsafe {
ShowWindow(
window,
match new.contains(WindowFlags::MAXIMIZED) {
true => SW_MAXIMIZE,
match new.contains(WindowFlags::MINIMIZED) {
true => SW_MINIMIZE,
false => SW_RESTORE,
},
);
Expand Down

0 comments on commit 11dac10

Please sign in to comment.