Restore the window size/position reliably and stop auto-starting fullscreen#34000
Open
hayaksi1 wants to merge 1 commit into
Open
Restore the window size/position reliably and stop auto-starting fullscreen#34000hayaksi1 wants to merge 1 commit into
hayaksi1 wants to merge 1 commit into
Conversation
…screen The desktop window did not reliably restore its previous size and position, and could relaunch into fullscreen even when the user had left it windowed (element-hq#32228, element-hq#32360). That was handled by the unmaintained electron-window-state package, which persists to its own JSON file and re-applies a stored fullscreen rectangle on launch. Replace it with an in-repo WindowStateManager that persists size/position/maximized state durably through the existing electron-store-backed Store, clamps restored bounds to the displays currently connected (so a window stranded on a now-disconnected monitor falls back to defaults), and deliberately never restores fullscreen. Geometry is flushed on close and before exit — including the macOS hide-on-close path where `closed` never fires — and high-frequency resize/move events are debounced. Drops the electron-window-state dependency.
t3chguy
reviewed
Jun 29, 2026
| mainWindowState.manage(global.mainWindow); | ||
|
|
||
| // Now the window exists, restore the maximized state and start tracking changes. Fullscreen | ||
| // is deliberately not restored so the app never auto-starts fullscreen (#32360). |
Member
There was a problem hiding this comment.
I'm not sure about this change, I always use Element full screen on my mac so having to re-maximise it on every restart/update would not be ideal
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
The desktop window did not reliably restore its previous size and position, and could relaunch
into fullscreen even when the user had left it windowed (#32228, #32360). This was handled by
the unmaintained
electron-window-statepackage, which persists to its own JSON file and re-appliesa stored fullscreen rectangle on launch.
Fix
Replace
electron-window-statewith an in-repoWindowStateManager:electron-store-backedStore(atomic, alongside the rest of the app's state) instead of a separate JSON file.now-disconnected monitor falls back to sensible defaults instead of opening off-screen.
app never auto-starts fullscreen (Riot always starts in full screen #32360).
closeand beforeapp.exit()— including the macOS hide-on-close path whereclosednever fires — and debounces high-frequencyresize/moveevents.This drops the
electron-window-statedependency.Tests
window-state.test.ts(Vitest, 43 passing) covers bounds persistence, restore + display clamping(including disconnected-monitor fallback), the maximized round-trip, the no-fullscreen rule, and the
debounce/flush behaviour.
Fixes #32228
Fixes #32360
Notes: Reliably restores the desktop window's size/position/maximized state (clamped to connected displays) and no longer auto-starts fullscreen, replacing the unmaintained electron-window-state package.
Checklist
public/exportedsymbols have accurate TSDoc documentation.