Skip to content

Commit 42a1f80

Browse files
committed
winit-win32: Fix Window focus after showing hidden maximized window
1 parent c4afadb commit 42a1f80

2 files changed

Lines changed: 14 additions & 7 deletions

File tree

winit-win32/src/window_state.rs

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -345,12 +345,15 @@ impl WindowFlags {
345345
}
346346

347347
if new.contains(WindowFlags::VISIBLE) {
348-
let flag = if !self.contains(WindowFlags::MARKER_ACTIVATE) {
349-
self.set(WindowFlags::MARKER_ACTIVATE, true);
350-
SW_SHOWNOACTIVATE
351-
} else {
352-
SW_SHOW
353-
};
348+
let flag =
349+
if new.contains(WindowFlags::MAXIMIZED) && diff.contains(WindowFlags::VISIBLE) {
350+
SW_MAXIMIZE
351+
} else if !self.contains(WindowFlags::MARKER_ACTIVATE) {
352+
self.set(WindowFlags::MARKER_ACTIVATE, true);
353+
SW_SHOWNOACTIVATE
354+
} else {
355+
SW_SHOW
356+
};
354357
unsafe {
355358
ShowWindow(window, flag);
356359
}
@@ -379,7 +382,10 @@ impl WindowFlags {
379382
}
380383
}
381384

382-
if diff.contains(WindowFlags::MAXIMIZED) || new.contains(WindowFlags::MAXIMIZED) {
385+
if (diff.contains(WindowFlags::MAXIMIZED) || new.contains(WindowFlags::MAXIMIZED))
386+
&& new.contains(WindowFlags::VISIBLE)
387+
&& !diff.contains(WindowFlags::VISIBLE)
388+
{
383389
unsafe {
384390
ShowWindow(window, match new.contains(WindowFlags::MAXIMIZED) {
385391
true => SW_MAXIMIZE,

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, fix missing focus events after showing a hidden maximized window.

0 commit comments

Comments
 (0)