Repository navigation
fix(window): drop a re-homed window from the previous tile's display - #149
Merged
Merged
Conversation
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.
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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:
Cause
onMetaWindowMappedfirst matches the window normally (a new tile), and when the client'sactivatedBy/parent/modal hint arrives within the settle window_maybeRerouteAsDialogmoves it into a dialog. That move detached the window withremoveMetaWindow(id, shouldNotify: false), which closes the subscription and clearsmetaWindowWindowMapbut skips_recomputeDisplayedMetaWindow(). So the tile kept itsmetaWindowIdpointing at a window it no longer owned:MetaWindowStatewas destroyed, the tile builtWindowWidget(metaWindowId: <destroyed>), which watchesmetaWindowStateProviderand threwMetaWindowState <id> not yet initialized— the red blank.shouldNotifywas 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;shouldNotifystill 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
PersistentWindowthat only ever showed that window) was left behind as an empty placeholder. Matcher-created tiles are tagged (markAutoCreatedForMatching) anddetachForReroutedisposes 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-foreignimporter 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-changedclean ·flutter analyzeclean (no new issues).flutter testgreen (483).flutter build linux --debugsucceeds.Refs #128.