Skip to content

Commit

Permalink
Fix window can't be hidden when maximized (#384)
Browse files Browse the repository at this point in the history
* Fix window can't be hidden when maximized

* remove `WindowFlags::MAXIMIZED` from diff if we are hiding

* Update src/platform_impl/windows/window_state.rs

Co-authored-by: Lucas Fernandes Nogueira <[email protected]>

* Revert "Update src/platform_impl/windows/window_state.rs"

This reverts commit a5083fd.

Co-authored-by: amrbashir <[email protected]>
Co-authored-by: Lucas Fernandes Nogueira <[email protected]>
  • Loading branch information
3 people authored Jun 15, 2022
1 parent 74b9608 commit cd9ad33
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .changes/flag.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"tao": patch
---

Fix window can't be hidden when maximized.
14 changes: 13 additions & 1 deletion src/platform_impl/windows/window_state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,19 @@ impl WindowFlags {
self = self.mask();
new = new.mask();

let diff = self ^ new;
let mut diff = self ^ new;

// when hiding a maximized window, `self` contains `WindowFlags::MAXIMIZED`
// but `new` won't have it as it is removed in `new.mask()` call by applying `WindowFlags::INVISIBLE_AND_MASK`
// so `diff` will contain `WindowFlags::MAXIMIZED` and that will cause the window to unmaximize, but
// since we are trying to hide the window, we need to apply `WindowFlags::INVISIBLE_AND_MASK` on `diff` too.
if diff.contains(WindowFlags::MAXIMIZED)
&& diff.contains(WindowFlags::VISIBLE)
&& !new.contains(WindowFlags::VISIBLE)
{
diff &= WindowFlags::INVISIBLE_AND_MASK;
}

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

0 comments on commit cd9ad33

Please sign in to comment.