fix(desktop): restore maximized main window state on startup - #2435
Merged
wsp1911 merged 2 commits intoAug 24, 2026
Merged
Conversation
The tauri plugin window-state flow already persists the main window geometry, but a maximized undecorated window was saved as maximized:false together with its stretched frame stored as normal bounds. Every launch then restored that degenerate near-fullscreen normal window instead of the remembered geometry. Fix both sides on Windows: - After each explicit save, treat GetWindowPlacement as the authoritative maximized signal and flip the persisted flag when it disagrees. Geometry fields are never rewritten from the placement: rcNormalPosition is unreliable for maximized undecorated windows and previously blended the pre-restore centered origin with monitor-sized dimensions, which moved the restored window off-screen. - Skip maximizing during the hidden restore phase and re-assert the persisted maximized flag after the window becomes visible, because maximizing a hidden undecorated window is dropped on show. Save call sites now carry a reason for failure diagnostics.
wsp1911
force-pushed
the
fix/restore-maximized-window-state
branch
from
August 24, 2026 03:04
ec076a7 to
8854a45
Compare
A maximized frameless main window could be persisted with stretched normal bounds or lose its maximized flag during startup geometry repair. The correction path also replaced the state file by deleting the existing file first and assumed the plugin's default filename. Keep the persisted state reliable across startup and explicit save boundaries: - Separate full-state saves from geometry-only saves so startup size repair cannot overwrite maximized. - Defer maximized restoration only on Windows, where maximizing a hidden undecorated window is not reliable. - Resolve the state path through tauri-plugin-window-state's filename API. - Replace the state file atomically with ReplaceFileW and write-through semantics on Windows, and rename it atomically on other platforms. - Add regression coverage for replacement failures, preserved state, and platform-specific state flags. Validation: cargo check -p bitfun-desktop; cargo build -p bitfun-desktop; git diff --check. Refs: GCWing#2435
wsp1911
force-pushed
the
fix/restore-maximized-window-state
branch
from
August 24, 2026 03:33
db1247c to
9c7274f
Compare
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.
Problem
BitFun did not remember the main window geometry on startup: after quitting while maximized, the next launch reopened the near-fullscreen frameless window without the maximized state (or, in one revision, relocated off-screen). Windows only.
Root cause
Two layers conspired for undecorated main windows (
decorations(false)on Windows):tauri-plugin-window-stateasmaximized: falsewith its stretched maximized frame stored as normal bounds. Every launch faithfully restored that degenerate near-fullscreen normal window, so the perceived "fixed startup geometry" self-perpetuated.show(), and the window falls back to Windows' tracked normal-placement rect, which for a maximized undecorated window is not trustworthy (observed blending the pre-restore centered origin with monitor-sized dimensions).Fix
mainentry is corrected against the authoritativeGetWindowPlacementsignal: when the window is genuinely maximized the entry is markedmaximized: true. Geometry fields are deliberately never rewritten fromrcNormalPosition.Verification
src/apps/desktop/src/window_state_support.rscover flag-only correction, idempotency, non-maximized no-ops, legacy/partial entries, and file round-trips (invalid files are kept untouched).main_window_geometry_testsand the Web UI startup performance contract test still pass.