Remember the main window size between runs - #8
Open
raman78 wants to merge 3 commits into
Open
Conversation
The window opened at a fixed 1280x720 every time. Its inner size and maximized state are now kept in the settings file and handed to the viewport builder on the next launch. The size is read from the egui viewport rect rather than ViewportInfo::inner_rect, because the latter is None on Wayland, where a client is not told where its window is. It is scaled by the zoom factor to the logical pixels the viewport builder expects, so that a "ui scale" other than 1 does not shrink the window a little on every launch. Writing is deferred until the size has stayed put for two seconds, so dragging a window edge does not rewrite the settings file every frame. The position is deliberately not persisted: Wayland has no way for a client to read or set its own window position, so restoring it would work on some platforms and silently do nothing on others. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
The contents trailed behind the window while a window edge was dragged, because a repaint was only requested when something else asked for one. Size changes are already tracked here for persistence, so they also tell us the window is being resized: while they keep arriving, ask for a repaint every frame, and once they stop, only ask for the single frame that writes the settled size. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
At the old minimum of 480x270 the toolbar wraps into several rows and the tabs below it have almost no room left, so the window can be dragged into a state where it cannot be used. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This was referenced Jul 26, 2026
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.
What & why
The main window opens at a fixed 1280x720 on every launch, however it was left. This stores its size and maximized state in the settings file and hands them to the viewport builder on the next start.
This was originally part of #6; that PR has been narrowed down to the overlay itself.
What is in it
Settingsgains awindowsection (size,maximized). It is#[serde(default)], so settings files written by earlier versions keep loading — covered by a test.Appand written once it has been stable for two seconds, so dragging a window edge does not rewrite the settings file every frame.on_exitflushes a change that has not settled yet.Two details worth flagging
The size is read from
ctx.viewport_rect(), not fromViewportInfo::inner_rect.inner_rectis built fromwindow.inner_position(), which returnsErron Wayland, so the whole rect isNonethere and nothing would ever be recorded. The viewport rect comes from the surface size and behaves the same on both backends.It is scaled by
ctx.zoom_factor(). The viewport rect is in egui points whilewith_inner_sizetakes logical pixels, and the two differ by exactly the zoom factor that the "ui scale" setting drives. Without that scaling, a ui scale of 1.5 would shrink the window a little on every launch.Why the position is not stored
Wayland gives a client no way to read or set its own top-level position: winit returns
Err(NotSupportedError)fromouter_position(), andset_outer_position()is an empty function there. Persisting it would restore the window on X11, Windows and macOS and silently do nothing on Wayland. Size and maximized state are the part that behaves identically everywhere, so that is all this stores — there is nocfganywhere in the change.eframe already clamps the requested size to the largest monitor, so a size carried over from a larger screen still comes up usable.
Testing
Verified on KDE/Wayland: the size and maximized state survive a restart, including when the process is killed without a clean exit, which the deferred write covers. Not tested on X11, Windows or macOS.
Overlap with #6
Both this PR and #6 change the same lines of
src/app/mod.rsandsrc/main.rs— #6 removes the window-geometry code that used to sit there, this one adds its own version in the same place — so whichever of the two you merge first, the other will report a conflict.Nothing for you to resolve: merge either one in any order and I will rebase the other branch and push, which updates its PR automatically. The two changes are independent in substance; only the text overlaps.