Skip to content

fix(window): drop a re-homed window from the previous tile's display - #149

Merged
PapyElGringo merged 3 commits into
mainfrom
fix/reroute-drop-displayed
Oct 15, 2026
Merged

PapyElGringo merged 3 commits into
mainfrom
fix/reroute-drop-displayed

Conversation

@PapyElGringo

@PapyElGringo PapyElGringo commented Oct 15, 2026 •

Copy link
Copy Markdown
Contributor

Problem

The video on #128 shows the same native surface owned by two shell windows at once: Kitty gets a fresh PersistentWindow, then the same window is attached to the Chrome tile as a dialog. The surface is visible on both and input reaches it from either. Closing the dialog leaves the persistent tile blank.

The screenshot of that blank is a Flutter error screen:

ProviderException: Tried to use a provider that is in error state.
A provider threw: Exception: MetaWindowState 0bc6c41b-... not yet initialized
#0  MetaWindowState.build (meta_window_state.dart:28)
...
#14 WindowWidget.build (window/widget/window.dart:61)

Cause

onMetaWindowMapped first matches the window normally (a new tile), and when the client's activatedBy/parent/modal hint arrives within the settle window _maybeRerouteAsDialog moves it into a dialog. That move detached the window with removeMetaWindow(id, shouldNotify: false), which closes the subscription and clears metaWindowWindowMap but skips _recomputeDisplayedMetaWindow(). So the tile kept its metaWindowId pointing at a window it no longer owned:

  • while the dialog lived, the tile rendered the same surface too (the double display / shared input in the video);
  • when the dialog closed and MetaWindowState was destroyed, the tile built WindowWidget(metaWindowId: <destroyed>), which watches metaWindowStateProvider and threw MetaWindowState <id> not yet initialized — the red blank.

shouldNotify was only ever meant to suppress the settle timer (so the re-homed window is not re-dispatched), not the display bookkeeping.

Fix

1. Drop the window from the previous tile's displayed set (window_provider.mixin.dart). removeMetaWindow(..., shouldNotify: false) now recomputes the displayed window too; shouldNotify still controls only the settle timer. The window is displayed by exactly one shell window.

2. Dispose the stray intermediate tile. The tile the matcher created for the window (a fresh PersistentWindow that only ever showed that window) was left behind as an empty placeholder. Matcher-created tiles are tagged (markAutoCreatedForMatching) and detachForReroute disposes them when the re-routed window leaves them empty. A tile the user created, or one that still owns another window, is left alone.

Once the xdg-foreign importer relations land (#146) these cross-process dialogs will route straight to a dialog with no intermediate tile; this keeps the fallback clean until then.

Spec updated: re-routing detaches from the previous tile's displayed set and disposes a matcher-created, now-empty tile.

Verification

  • dart format --set-exit-if-changed clean · flutter analyze clean (no new issues).
  • flutter test green (483).
  • flutter build linux --debug succeeds.

Refs #128.

Veshell release bot added 3 commits October 15, 2026 09:05
When a late parent/modal/activatedBy hint re-routes an already-matched window
into a dialog, the manager detaches it from the tile that owned it with
`removeMetaWindow(id, shouldNotify: false)`. That path closes the subscription
and clears the window map but skips `_recomputeDisplayedMetaWindow`, so the
tile keeps its `metaWindowId` pointing at the window it no longer owns.

Two consequences, both in the reporter's video:
- the surface is rendered twice (once by the stale tile, once by the dialog),
  and input reaches the same native surface from both;
- once the dialog closes and the MetaWindowState is destroyed, the tile builds
  `WindowWidget(metaWindowId)` against the destroyed provider and throws
  `MetaWindowState <id> not yet initialized` — the red blank tile.

Recompute the displayed window on the silent removal too; `shouldNotify` still
controls only the settle timer.
When a late relation re-routes a window into a dialog, the tile the matcher
created for it (a fresh PersistentWindow that only ever showed that window)
was left behind as an empty placeholder. Tag matcher-created tiles and, when
the re-routed window leaves one empty, dispose it instead of stranding it.
A tile the user created, or one that still owns another window, is untouched.

Once xdg-foreign importer relations land (#146) these windows will route
straight to a dialog with no intermediate tile; this keeps the fallback clean
until then.
The first commit made every `removeMetaWindow(shouldNotify: false)` recompute
the displayed window. Its other callers (redistribution moves, turning a
leftover into a dialog, extracting a dialog to a tile) already reconcile the
display, so widening the shared method risked touching paths unrelated to the
reroute — including the manual-close path via `onMetaWindowRemoved`.

Move the reconciliation into `detachForReroute` so only the reroute changes;
`removeMetaWindow` is back to its original form and the normal close,
redistribution and extraction paths are byte-for-byte unchanged.
@PapyElGringo
PapyElGringo merged commit 1575212 into main Oct 15, 2026
2 checks passed
@PapyElGringo
PapyElGringo deleted the fix/reroute-drop-displayed branch October 15, 2026 07:35
@PapyElGringo PapyElGringo mentioned this pull request Oct 16, 2026
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