Skip to content

feat(session): persist and restore window size, maximized, and fullscreen state#64

Draft
roramirez wants to merge 1 commit into
mainfrom
feat/persist-window-state
Draft

feat(session): persist and restore window size, maximized, and fullscreen state#64
roramirez wants to merge 1 commit into
mainfrom
feat/persist-window-state

Conversation

@roramirez

Copy link
Copy Markdown
Owner

Summary

mmterm always reopened at the fixed config.window.width/height, discarding
however 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 --scope sessions.

Changes

  • src/session/mod.rs — new SavedWindowState { maximized, fullscreen, width, height }
    and an optional window_state field on SavedSession. Uses
    #[serde(default, skip_serializing_if = "Option::is_none")] (same pattern as
    theme) so existing session files without the key still load cleanly.
  • src/restore.rsbuild_saved_session captures the live window's
    is_maximized(), fullscreen(), and inner_size(); yields None when there
    is no window.
  • src/winit_handler.rsresumed() loads the session once up front and
    applies fullscreen / maximized / inner size to the WindowAttributes before
    the window is mapped (avoids a visible post-map resize); the same loaded value
    seeds tab restore (no second load_from). Precedence: fullscreen > maximized > size.
  • Tests — TOML round-trip, backward-compat (missing key → None), skip-when-none,
    save/load fullscreen round-trip, and a headless build_saved_session no-window case.
  • CHANGELOG — entry under Added.

How to test

  1. cargo run -- --scope demo, then maximize the window (or Alt+Enter for
    fullscreen) and/or resize it.
  2. Quit and save the session: Ctrl+Qs.
  3. Relaunch cargo run -- --scope demo — the window reopens maximized /
    fullscreen / at the saved size.
  4. An older session.toml lacking window_state still loads without error.
  5. cargo test window_state covers the serialization matrix.

…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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant