mirror of
https://github.com/storytold/wordcraft.git
synced 2026-12-02 10:47:02 -06:00
3.0 KiB
3.0 KiB
Implementation plan: closing document windows
For the specification (#7822, part of #7671). Four steps run in order; each is its own PR.
1. storytold/egui patches
- eframe never paints a viewport built with
visible == Some(false)(wgpu); it still runs that viewport's ui. - egui-winit skips the XDG activation token for a hidden root.
2. craft-libs PR (storytold/craft-libs#584, ADR 0001)
- The root is created hidden and every document window is a child;
adoptis removed. Documented indocs/craft-framework.md. - Test kit with any number of windows (C5-8):
craft_ui_test_kit::windows::Windowskeeps focus and close events per child, so three-window tests can target one child. - Not in scope: the cursor on non-root windows (C5-5,
cursor::image_target) gets its own issue.
3. Repin craft-libs in WordCraft
Brings storytold/craft-libs#3290 (one modal stack across windows) and the changes above. Stage 3 of #7671 does this repin.
4. WordCraft PR (Fixes #7822)
Code is in crates/ui-egui/src/ unless noted.
| Spec rule | Change |
|---|---|
| 1 | Drop the root taking over another document (settle_windows in windows.rs); the first document window is a child like the rest, so no root window is left to close. Rewrite closing_a_window_asks_first_and_the_root_adopts_another. |
| 2 | other_window_on_document filters windows by document (C5-6). |
| 3, 9 | app::Closing records the window that owns the prompt. Pumping, cancelling and closing the prompt use that window's dialog host, not the active one. |
| 4, 9 | run and close_decision check closing first: a close while one is running raises the prompt and returns, never calls begin_closing again. |
| 9 | Clearing closing.prompt in sync_document and apply_close_answer either continues the close or ends it, so no Hold is left with no prompt. apply_close_answer matches the guard's document, not the active one. |
| 5 | Cancelling Save As during a close cancels the close or quit (continue_after_save). |
| 7 | On one-document-at-a-time hosts, a close acts on the active entry, not root_key() (on the web that is the root window's close; on a full-screen or Wayland-maximized document window, that window's); the fallback layer keeps its close button (C5-1..3). |
| 8 | file.close takes save; close_refused names both options. ui.closeWindow takes window and defaults to active_viewport() (control/handler.rs). Update docs/control-protocol.md and docs/mcp.md. |
| — | queue_for_window repaints the target window (C5-7). |
Tests: the table in the specification, in windows/tests.rs and documents.rs.
Checks: cargo fmt --all --check, cargo clippy -p wordcraft-ui-egui --all-targets -- -D warnings,
cargo test -p wordcraft-ui-egui, cargo xtask layers, cargo xtask wasm.
Real-window checks before step 4 merges: KDE Wayland; Windows; GNOME (requested on craft-libs#584); macOS through CI plus a confirmation request in the PR. The release waits for this on all platforms.