Skip to content

Commit

Permalink
Only show window behaviour when it is visible (#126)
Browse files Browse the repository at this point in the history
winuser::ShowWindow will show the window and make set_visible(false) obsolete.
  • Loading branch information
Ngo Iok Ui (Wu Yu Wei) committed Jul 14, 2021
1 parent 6fcfa62 commit ff0903f
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 8 deletions.
5 changes: 5 additions & 0 deletions .changes/windows-hidden.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"tao": patch
---

Only show window behaviour when it is visible. winuser::ShowWindow will show the window and make with_visible(false) obsolete.
2 changes: 1 addition & 1 deletion examples/multiwindow.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ fn main() {
}
WindowEvent::KeyboardInput {
event: KeyEvent {
state: ElementState::Released,
state: ElementState::Pressed,
..
},
..
Expand Down
16 changes: 9 additions & 7 deletions src/platform_impl/windows/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -214,13 +214,15 @@ pub fn is_maximized(window: HWND) -> bool {

pub fn set_maximized(window: HWND, maximized: bool) {
unsafe {
winuser::ShowWindow(
window,
match maximized {
true => winuser::SW_MAXIMIZE,
false => winuser::SW_RESTORE,
},
);
if winuser::IsWindowVisible(window) != 0 {
winuser::ShowWindow(
window,
match maximized {
true => winuser::SW_MAXIMIZE,
false => winuser::SW_RESTORE,
},
);
}
}
}

Expand Down

0 comments on commit ff0903f

Please sign in to comment.