Skip to content

Window: remember the window's size and position between launches - #829

Open
pravdomil wants to merge 1 commit into
storytold:mainfrom
pravdomil:claude/window-position-size-persist-99f0d6
Open

pravdomil wants to merge 1 commit into
storytold:mainfrom
pravdomil:claude/window-position-size-persist-99f0d6

Conversation

@pravdomil

Copy link
Copy Markdown

Problem

The app window opened at a fixed 1680 × 1020, wherever the system put it, on every launch. Nothing saved its geometry.

Fix

  • New apps/effectcraft/src/window.rs (ported from VectorCraft's window module, same conventions): the window's size, position and maximized state are saved to window.json in the config directory, when they change (at most once a second, so a session that ends badly still has them) and on exit.
  • The next launch restores them, moved onto a monitor that is still connected; a window bigger than its screen opens maximized.
  • The first launch fits the window to its screen (maximized where the default size leaves no room for a Dock or taskbar).
  • A window restored maximized keeps the size it returns to (its first frames report the maximized size as an ordinary one).
  • Agent-driven runs (--control) restore the saved window but don't overwrite it.
  • A damaged or oversized window.json is ignored.
  • winit (already in the build through eframe) becomes a dependency on every platform, not just macOS; serde is added to the app crate.

Testing

  • 6 new unit tests in window.rs (placement, monitor changes, damaged values, tracking, save/load round trip, maximized restore): pass.
  • Manually on macOS with a scratch EFFECTCRAFT_CONFIG_DIR: a seeded geometry (normal and maximized) is restored and tracked back unchanged; a first launch writes the fitted geometry.
  • cargo fmt --check and cargo clippy --workspace --all-targets --release -- -D warnings pass. The rest of cargo xtask ci (full workspace tests, layers, assets, wasm) was not run to completion locally.
  • Not tested on Windows or Linux.

🤖 Generated with Claude Code

The window opened at a fixed 1680 × 1020 wherever the system put it. Its size, position
and maximized state are now saved to window.json in the config directory (when they change,
and on exit) and restored on the next launch, moved onto a monitor that is still connected.
The first launch fits the window to its screen. Agent-driven runs (--control) restore the
saved window but don't overwrite it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

This branch has not been deployed

No deployments
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