Skip to content

win32: avoid showing hidden windows when applying window state#4575

Open
YelovSK wants to merge 1 commit into
rust-windowing:masterfrom
YelovSK:fix-hidden-window-maximize
Open

win32: avoid showing hidden windows when applying window state#4575
YelovSK wants to merge 1 commit into
rust-windowing:masterfrom
YelovSK:fix-hidden-window-maximize

Conversation

@YelovSK
Copy link
Copy Markdown

@YelovSK YelovSK commented May 22, 2026

On Windows, ShowWindow(SW_MAXIMIZE) and ShowWindow(SW_MINIMIZE) can make a hidden window visible.

This currently causes a problem when a window is configured while hidden. For example, eframe creates its window hidden, applies the persisted maximized state, renders the first frame, and only then shows the window. But when winit applies the maximized state, it calls ShowWindow(SW_MAXIMIZE) even though the target state is still hidden. The window can briefly appear before the first frame is rendered, causing a white flash.

This change avoids calling the show/maximize/minimize ShowWindow commands while the target window state is hidden. If the window is supposed to become visible and maximized/minimized, that state is applied when it is shown.

It also avoids doing a normal SW_SHOW first when the target state is maximized or minimized, so the window is shown directly in the intended state.

Tested with:

  • cargo +nightly fmt
  • cargo check -p winit-win32

Also tested downstream in an eframe app on Windows, where this fixes the startup flash when reopening a persisted maximized window. An example of the flicker/flash is shown in this egui issue - emilk/egui#7746.

  • Tested on all platforms changed
  • Added an entry to the changelog module if knowledge of this change could be valuable to users
  • Updated documentation to reflect any user-facing changes, including notes of platform-specific behavior
  • Created or updated an example program if it would help users understand this functionality

joe-loach added a commit to joe-loach/winit that referenced this pull request Jun 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant