Repository navigation
Windows: a window closed maximized reopens without a white flash (winit#4587) - #674
Merged
echelon merged 2 commits intoOct 10, 2026
Merged
Conversation
…it#4587) eframe creates PdfCraft's window hidden, restores the saved state (app.ron, persist_window) and shows the window after the first frame is drawn. For a window closed maximized, winit 0.30.13 applies the maximized state with ShowWindow(SW_MAXIMIZE), which shows a hidden window: PdfCraft appeared unpainted (white), was hidden again, then shown with SW_SHOW and SW_MAXIMIZE once more. rust-windowing/winit#4586 also shows the window's focus state going wrong on this path. vendor/winit now skips the maximize while the window is hidden and shows a hidden window that is maximized with one SW_MAXIMIZE, as rust-windowing/winit#4587 (approved upstream) does on winit master. That is the later, focus-safe form of storytold#4575; storytold#4575's other change (re-sending SW_MINIMIZE on every flag change while minimized) is not taken. Transitions between two visible states make the same ShowWindow calls as before. A test fails if a re-vendored winit loses the patch. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This was referenced Oct 10, 2026
# Conflicts: # vendor/README.md
Member
|
Merged, thank you! One If you haven't already, come join us on Discord: https://discord.gg/artcraft |
This was referenced Oct 10, 2026
krichelj
pushed a commit
to krichelj/pdfcraft
that referenced
this pull request
Oct 11, 2026
…it#4587) (storytold#674) eframe creates PdfCraft's window hidden, restores the saved state (app.ron, persist_window) and shows the window after the first frame is drawn. For a window closed maximized, winit 0.30.13 applies the maximized state with ShowWindow(SW_MAXIMIZE), which shows a hidden window: PdfCraft appeared unpainted (white), was hidden again, then shown with SW_SHOW and SW_MAXIMIZE once more. rust-windowing/winit#4586 also shows the window's focus state going wrong on this path. vendor/winit now skips the maximize while the window is hidden and shows a hidden window that is maximized with one SW_MAXIMIZE, as rust-windowing/winit#4587 (approved upstream) does on winit master. That is the later, focus-safe form of storytold#4575; storytold#4575's other change (re-sending SW_MINIMIZE on every flag change while minimized) is not taken. Transitions between two visible states make the same ShowWindow calls as before. A test fails if a re-vendored winit loses the patch. Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> Co-authored-by: Brandon Thomas <echelon@gmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
On Windows, PdfCraft closed while maximized came back with a white, unpainted window before its first frame. eframe creates the window hidden, restores the saved maximized state (
app.ron,persist_window) and shows the window after the first frame is drawn. But winit applies "maximized" withShowWindow(SW_MAXIMIZE), which shows a hidden window. This keeps a hidden window hidden while its maximized state is set, and shows it maximized with a singleSW_MAXIMIZE.Port of rust-windowing/winit#4587 (reviewed head
9f8beaf502, approved upstream by kchibisov), which fixes winit#4586. It is the later, focus-safe form of winit#4575, whose author found the same startup flash in an eframe app with a saved maximized window (egui#7746).PdfCraft impact
Every Windows launch after closing PdfCraft maximized.
Root cause
vendor/winit/src/platform_impl/windows/window_state.rs,WindowFlags::apply_diff. Over the start-up sequence, the window is created hidden, then:set_maximized(true)while hidden callsShowWindow(SW_MAXIMIZE), which shows the unpainted window, thenShowWindow(SW_HIDE);set_visible(true)callsSW_SHOW, thenSW_MAXIMIZEagain.Winit#4586 also shows the window's focus state going wrong on this path.
Change
ShowWindow.SW_MAXIMIZE.ShowWindowcalls as before.Not included
SW_MINIMIZEon every flag change while the window is minimized, which can move activation to another window. eframe never minimizes a hidden window.Verification
apply_diff'sShowWindowcalls (old against new code, every combination of visible / maximized / minimized / activate before and after) confirms three things. Every visible-to-visible transition is unchanged (all 32 of them). A hidden target never getsSW_SHOW*,SW_MAXIMIZEorSW_RESTOREoutside the minimize path, which is unchanged. And hidden-to-visible-and-maximized is exactly oneSW_MAXIMIZE.apps/pdfcraft/tests/winit_windows_hidden_maximized.rsfails if a re-vendored winit loses the patch.Automated checks
aarch64-apple-darwin,x86_64-pc-windows-msvcandx86_64-unknown-linux-musl(cargo clippy --lib, lints capped to warnings): the warnings are the same as onmainfor all three (the one existingclippy::iter_kv_mapinlinux/x11/event_processor.rs).cargo check --locked -p winitinside the PdfCraft workspace, with PdfCraft's ownCargo.lock, on macOS and on the tree with all nine fixes merged: clean.main(fails);rustfmt --checkandclippy -D warningson it are clean.cargo test --workspaceand workspace clippy (the machine is short of disk space for a full build). CI runs them on Linux and Windows.Risk
Known edge case, as on winit master: a window that was maximized while visible, then hidden, then un-maximized while hidden, is shown maximized (no
SW_RESTOREwhile hidden). PdfCraft never hides its window after start-up.Revert and removal
This change is independent of the other winit PRs and can be reverted on its own. Drop it, together with the test and README item (4), once PdfCraft uses a winit release that includes rust-windowing/winit#4587 or an equivalent fix.
Merging alongside the other winit PRs
This is one of nine fixes to
vendor/winitsent together: #672 (Wayland IME after a capability change), #673 (Windows Korean IME caret), #674 (Windows maximized start-up), #675 (X11 input context focus), #676 (macOS IME commit state), #677 (macOS stale composition), and, building on #676, #678 (macOS emoji picker), #679 (macOS Korean double space), #680 (macOS first Korean key). Each adds one numbered item to the single winit row invendor/README.md, so they conflict with each other on that one line, and nowhere else (each test is in its own file). The item numbers (2)–(10) are fixed in advance: to resolve, keep every item in numeric order. All nine were merged locally in one tree (only that line conflicted); the combined vendored winit builds for macOS, Windows and Linux with the same clippy output asmain, and all nine tests pass on it.🤖 Generated with Claude Code