Repository navigation
Conversation
WindowCaption and VirtualWindowFrame registered a process-wide WindowManager listener even when given a window, so in a multi-window app every resize, focus or maximize event of any window made every caption and frame query its own window over FFI. Given a window, both widgets now listen to that window only. The subscription moves when the widget gets another window and is released on dispose. Without a window they keep the manager-wide listener that resolves the current window on each event. VirtualWindowFrame no longer calls setState from initState when the window starts maximized, unfocused or full screen; the initial state is assigned directly.
This was referenced Nov 10, 2026
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
WindowCaptionandVirtualWindowFrameregister a process-widenativeapi.WindowManagerlistener even when they are given awindow. In a multi-window app every resize, focus or maximize event of any window therefore makes every caption and frame query its own window over FFI. In addition,VirtualWindowFramecallssetStatefrominitStatewhen the window starts maximized, unfocused or full screen.Change
window, both widgets listen to that window only (Window.addListener).window, both widgets keep the current behavior: a manager-wide listener that resolves the current window on each event, so a window that is not current yet at startup is still picked up later.VirtualWindowFrameassigns its initial state directly ininitStateinstead of callingsetState.Tests
Extended
test/window_caption_test.dartwith a fake window that records its listeners: a caption and a frame react only to their own window, the subscription moves to a replacement window and is released on dispose, no re-subscription on rebuild with the same window, a caption without a window builds and disposes cleanly, and a frame whose window starts maximized raises no exception. The new tests fail against the previous widget code.dart format --set-exit-if-changed .,flutter analyze(package and example) andflutter test(package and example) pass locally (Flutter 3.47.7, Windows), and the full CI workflow passes on the identical commit in my fork.Related
Part of a set of independent PRs, each based on
mainand mergeable on its own: widgets #598, #599, #600 (this), #601; legacy bridge #602, #603, #604, #605, #606.Touches
window_caption.dartlike #601 (close fallback); the two merge cleanly in either order.