feat(session): persist and restore window size, maximized, and fullscreen state#64
Draft
roramirez wants to merge 1 commit into
Draft
feat(session): persist and restore window size, maximized, and fullscreen state#64roramirez wants to merge 1 commit into
roramirez wants to merge 1 commit into
Conversation
…reen state Capture the window's geometry (maximized / fullscreen flags and the last inner size) into the saved session and reapply it on the next restore, so a scope (or the default session) reopens the way it was left. - add `SavedWindowState` and an optional `window_state` field to `SavedSession` (`#[serde(default, skip_serializing_if)]` keeps old session files loading) - capture geometry from the live window in `build_saved_session` - load the session once in `resumed()` and set fullscreen / maximized / inner size on the `WindowAttributes` before the window is mapped - tests for the round-trip, backward-compat, and the no-window path
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
mmterm always reopened at the fixed
config.window.width/height, discardinghowever the window was actually left. This teaches session persistence to
remember the window geometry — maximized, fullscreen, or the last resized inner
size — and reapply it when the session is restored, for both the default
session and named
--scopesessions.Changes
src/session/mod.rs— newSavedWindowState { maximized, fullscreen, width, height }and an optional
window_statefield onSavedSession. Uses#[serde(default, skip_serializing_if = "Option::is_none")](same pattern astheme) so existing session files without the key still load cleanly.src/restore.rs—build_saved_sessioncaptures the live window'sis_maximized(),fullscreen(), andinner_size(); yieldsNonewhen thereis no window.
src/winit_handler.rs—resumed()loads the session once up front andapplies fullscreen / maximized / inner size to the
WindowAttributesbeforethe window is mapped (avoids a visible post-map resize); the same loaded value
seeds tab restore (no second
load_from). Precedence: fullscreen > maximized > size.None), skip-when-none,save/load fullscreen round-trip, and a headless
build_saved_sessionno-window case.Added.How to test
cargo run -- --scope demo, then maximize the window (orAlt+Enterforfullscreen) and/or resize it.
Ctrl+Q→s.cargo run -- --scope demo— the window reopens maximized /fullscreen / at the saved size.
session.tomllackingwindow_statestill loads without error.cargo test window_statecovers the serialization matrix.