Repository navigation
fix(window): restore the toggle when the maximized flag is lost on Windows - #2420
Conversation
…ndows With frame:false + thickFrame:false, Windows can drop the native maximized flag while the window keeps its work-area size, so isMaximized() reads false and every toggle-maximize click calls maximize() on a window that already fills the screen: the button goes dead (vastsa#1993). Decide the toggle through a shared plan: a non-maximized window whose bounds cover the work area of its display is pseudo-maximized and gets a maximize+unmaximize resync so the restore path has a real maximized state to come back from. Fullscreen windows stay on the existing exit-fullscreen-then-maximize interlock (vastsa#1655). fixes vastsa#1993
|
The The PR doesn't identify why the flag is lost and has no Windows runtime evidence that the window actually shrinks. It also changes behavior for an ordinary user-sized window that covers the work area (within the 8px tolerance): it can no longer be maximized. Please root-cause the flag loss, or restore to a real normal size (e.g. an explicit fallback |
|
Thanks for the review — the restore-bounds point is the key one and I agree: on the transparent Win10 path ( Revising the PR along the lines you and #1993 suggest: drop the resync entirely and, on the pseudo-maximized decision (now On verification: I don't have CI coverage for the flag-loss state, but I do have a Windows machine available and will report the manual test results (normal maximize/restore cycles, manually resized full-coverage windows, and the flag-loss recovery path) back on this PR. (Drafted via an AI assistant at my direction; I own the content.) |
… rect Review on PR vastsa#2420: on the transparent Win10 main window (window-background.ts), Electron records the current bounds as the restore bounds, so maximize()+unmaximize() returns the window to the same full-work-area rect and the resync could not revive the dead toggle. A work-area-filling window is also an ordinary user-resized window in some cases, and intercepting it needs a visible outcome. Restore via explicit setBounds instead: the main window goes back to its last persisted normal bounds (state.workPanelLastAppliedBounds) when they are a real windowed size for the current work area — in the flag-lost state Win32 reports the full rect as the normal position, so recorded bounds are validated and otherwise rejected — and plugin panel windows, which have no persisted bounds, get two thirds of the work area, centered.
|
Revised as promised in the earlier comment, pushed as b4bae22:
Unit tests cover the decision and the restore-rect selection including the polluted-bounds case (27 pass). Windows manual verification is next on my side — results will follow on this PR. (Drafted via an AI assistant at my direction; I own the content.) |
|
Thanks for the follow-up on #1993. The main-window fix looks reasonable, and macOS/Linux and the fullscreen interlock are unaffected. Two things before landing:
|
Review on PR vastsa#2420: only the main window sets thickFrame:false (bootstrap/window.ts), so plugin panels keep the default opaque frame and never lose the maximized flag; the transparent widget is maximizable:false and does not reach the toggle. Revert the plugin-panel-host.ts wiring to keep the flag-loss restore out of the panels, which would otherwise inherit the documented trade-off where a manually resized full-coverage panel shrinks instead of maximizing.
|
Both points addressed:
On the (Drafted via an AI assistant at my direction; I own the content.) |
|
Windows verification done, as requested. Environment: Windows 11, single display, run from source at b4bae22 + a1c9770 ( Results, all as expected:
No multi-display machine was available, so the display-switch variant of scenario 2 was exercised through scaling changes and sleep-wake only. (Drafted via an AI assistant at my direction; I own the content.) |
Summary / 概要
On Windows,
frame:false+thickFrame:falsewindows can lose the native maximized flag (IsZoomed = false) while the window still fills the work area, sotoggleMaximizekept callingmaximize()on an already-full window and the title-bar button went dead (#1993).The toggle now decides through a shared plan (window-maximize.ts):
isMaximized()→unmaximize()(unchanged)win32only → pseudo-maximized: explicitsetBoundsrestoremaximize()(unchanged)Per the review on this PR, the restore is an explicit rect rather than a
maximize()+unmaximize()resync: on the transparent Win10 main window Electron records the current bounds as the restore bounds, so the resync returned the window to the same full rect. The main window is restored to its last persisted normal bounds (state.workPanelLastAppliedBounds, already maintained bypersistNormalWindowState()) when they are a real windowed size for the current work area — in the flag-lost state Win32 reports the full rect as the normal position, so recorded bounds are validated (min size, not covering the work area, fully inside it) and otherwise rejected. Plugin panel windows, which have no persisted bounds, get two thirds of the work area, centered.The geometric fallback is Windows-only: elsewhere a work-area-filling window is an ordinary user-resized window and must keep the plain behavior. Fullscreen windows never take the fallback, preserving the exit-fullscreen-then-maximize interlock from #1655 (its regression contract in
window-fullscreen-maximize.test.mjsis updated to the decision shape and still asserts the interlock).A known trade-off, from the review: a manually resized window that happens to fill the work area is indistinguishable from the flag-loss state at toggle time (both have normal bounds == current bounds). The interception now always has a visible outcome — the window shrinks to the restored rect, and the next click maximizes normally — where the old code did nothing.
Requirement link / 需求关联
fixes #1993Validation / 验证
Task candidate:
fix/issue-1993-maximize-flag@ b4bae22, based onorigin/main@ 0ca8112 (merge-base verified).pnpm build:js— passpnpm --filter @pi-desktop/desktop typecheck— passpnpm lint— passnode --test test/window-maximize-toggle.test.mjs test/window-fullscreen-maximize.test.mjs— 27 pass, 0 fail (flag-loss geometry, win32 gating, restore-rect selection incl. flag-loss pollution of the persisted bounds, fullscreen interlock, missing work area; updated: [Bug] 双屏显示器,F11全屏后pi-desktop白屏 #1655 contract)apps/desktopnode --testsuite: 26 failures, all environmental in this workspace — 23× "Electron binary missing" (install ran with--ignore-scripts, which skips the Electron postinstall) and 3× host-app-dependent tests; the affected files are untouched by this branch. Task-candidate E2E on a real Windows host: pass — manually verified on Windows 11 (single display, run from source at this branch): normal maximize/restore cycles regress-clean; the flag-loss recovery shrinks the window back to a normal windowed size and the toggle keeps working; the manually-resized full-coverage trade-off behaves as documented; plugin panels unchanged. Details in the verification comment on this PR.Environment: macOS arm64, pnpm 12.8.1 (
--ignore-scripts).Rollback / 回滚
Revert the two commits;
window-maximize.tsis new and both call sites fall back to the previousisMaximized()-only toggle.(Drafted via an AI assistant at my direction; I own the content.)