Compare commits

...
2 changed files with 28 additions and 14 deletions
+10 -4
View File
@@ -1,14 +1,20 @@
# The root window hides instead of taking over another document
# The root window is never shown
The first window an app opens is the framework's root window, and the app ends when it closes. WordCraft
used to keep it open when the user closed it with other document windows open: it switched to another
window's document and that window disappeared, so the window the user closed stayed and a different one
vanished (#7752). We decided instead that the root window hides (storytold/craft-libs#584) and adopts
nothing, so the window the user closes is always the one that goes, and the app ends only when the last
document window closes or the user quits.
vanished (#7752). We decided instead that the window the user closes is always the one that goes, and
nothing adopts another document. The app ends only when the last document window closes or the user quits.
The root window is created hidden and never painted, on every platform. Every document window, the first
one included, is a child window, so closing a document window closes exactly that window. The mechanism comes
from the prototype in storytold/craft-libs#584; the framework docs (`docs/craft-framework.md` in
craft-libs) will carry it.
## Considered options
- **Root takes over another document** (the old behaviour): no framework change, but it is the reported bug,
and the moved window loses its position and size.
- **Root shows no document and stays visible**: leaves an empty window the user did not ask for.
- **Root hides when it is closed** (storytold/craft-libs#4218): cannot work on Wayland, where winit's
`set_visible` is a no-op, so the root never hides and its close button goes dead.
+18 -10
View File
@@ -1,34 +1,39 @@
# Implementation plan: closing document windows
For [the specification](../specs/multi-window-close.md) (#7822, part of #7671). Steps run in order; each is
For [the specification](../specs/multi-window-close.md) (#7822, part of #7671). Four steps run in order; each is
its own PR.
## 1. craft-libs prerequisites (base `next`)
## 1. storytold/egui patches
- **Hidden root window** (storytold/craft-libs#584, [ADR 0001](../adr/0001-hidden-root-window.md)): the root
OS window can close or hide while document windows stay open, and adopts nothing.
- 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](../adr/0001-hidden-root-window.md))
- The root is created hidden and every document window is a child; `adopt` is removed. Documented in
`docs/craft-framework.md`.
- **Test kit with any number of windows** (C5-8): `craft_ui_test_kit::windows::Windows` keeps 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.
## 2. Repin craft-libs in WordCraft
## 3. Repin craft-libs in WordCraft
Brings storytold/craft-libs#3290 (one modal stack across windows) and the two changes above. Stage 3 of
#7671 does this repin.
Brings storytold/craft-libs#3290 (one modal stack across windows) and the changes above. Stage 3 of #7671
does this repin.
## 3. WordCraft PR (Fixes #7822)
## 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`); closing the root window closes it through step 1's hidden root. Rewrite `closing_a_window_asks_first_and_the_root_adopts_another`. |
| 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, the root close acts on the active entry, not `root_key()`; the fallback layer keeps its close button (C5-1..3). |
| 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). |
@@ -36,3 +41,6 @@ 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.