diff --git a/.changes/flag.md b/.changes/flag.md new file mode 100644 index 000000000..5e2d0823b --- /dev/null +++ b/.changes/flag.md @@ -0,0 +1,5 @@ +--- +"tao": patch +--- + +Fix window can't be hidden when maximized. \ No newline at end of file diff --git a/src/platform_impl/windows/window_state.rs b/src/platform_impl/windows/window_state.rs index 8111a24b9..bb7fb8588 100644 --- a/src/platform_impl/windows/window_state.rs +++ b/src/platform_impl/windows/window_state.rs @@ -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; }