Skip to content

Commit 3044710

Browse files
committed
win32: avoid showing hidden windows when applying window state
1 parent c4afadb commit 3044710

2 files changed

Lines changed: 11 additions & 3 deletions

File tree

winit-win32/src/window_state.rs

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -344,7 +344,10 @@ impl WindowFlags {
344344
return;
345345
}
346346

347-
if new.contains(WindowFlags::VISIBLE) {
347+
if new.contains(WindowFlags::VISIBLE)
348+
&& !new.contains(WindowFlags::MAXIMIZED)
349+
&& !new.contains(WindowFlags::MINIMIZED)
350+
{
348351
let flag = if !self.contains(WindowFlags::MARKER_ACTIVATE) {
349352
self.set(WindowFlags::MARKER_ACTIVATE, true);
350353
SW_SHOWNOACTIVATE
@@ -379,7 +382,9 @@ impl WindowFlags {
379382
}
380383
}
381384

382-
if diff.contains(WindowFlags::MAXIMIZED) || new.contains(WindowFlags::MAXIMIZED) {
385+
if new.contains(WindowFlags::VISIBLE)
386+
&& (diff.contains(WindowFlags::MAXIMIZED) || new.contains(WindowFlags::MAXIMIZED))
387+
{
383388
unsafe {
384389
ShowWindow(window, match new.contains(WindowFlags::MAXIMIZED) {
385390
true => SW_MAXIMIZE,
@@ -389,7 +394,9 @@ impl WindowFlags {
389394
}
390395

391396
// Minimize operations should execute after maximize for proper window animations
392-
if diff.contains(WindowFlags::MINIMIZED) {
397+
if new.contains(WindowFlags::VISIBLE)
398+
&& (diff.contains(WindowFlags::MINIMIZED) || new.contains(WindowFlags::MINIMIZED))
399+
{
393400
unsafe {
394401
ShowWindow(window, match new.contains(WindowFlags::MINIMIZED) {
395402
true => SW_MINIMIZE,

winit/src/changelog/unreleased.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,3 +61,4 @@ changelog entry.
6161
- On Wayland, switch from using the `ahash` hashing algorithm to `foldhash`.
6262
- On macOS, fix borderless game presentation options not sticking after switching spaces.
6363
- On macOS, fix IME being locked on (regardless of requests to disable) after being enabled once.
64+
- On Windows, avoid briefly showing hidden windows when applying maximized or minimized state.

0 commit comments

Comments
 (0)