fix(windows): keep a drag alive when the cursor leaves the view - #11
Merged
Y-PLONI merged 1 commit intoAug 27, 2026
Merged
Conversation
Y-PLONI
force-pushed
the
fix/windows-drag-cancelled-on-pointer-exit
branch
2 times, most recently
from
August 27, 2026 11:35
22a2ae1 to
25b534e
Compare
MouseRegion.onExit forwarded LEAVE unconditionally, including while a mouse button was still held. WebView2 turns that into WM_MOUSELEAVE and Chromium ends the gesture in flight, so dragging past the edge of the view -- how a selection is extended on every platform -- drops the selection the user is making. Flutter keeps routing those drag moves to this view until the button comes up, so the pointer has not actually gone anywhere as far as the gesture is concerned. Withhold the LEAVE while any button is down and deliver it on button-up or cancellation; swallow the matching ENTER when the cursor comes back first, so the native hover state stays paired. WebView2 has no mouse-cancel event. Translate Flutter cancellation to the matching button-up before delivering the deferred LEAVE, which clears the native button state. Leave arguments remain zero as required by WebView2 SendMouseInput.
Y-PLONI
force-pushed
the
fix/windows-drag-cancelled-on-pointer-exit
branch
from
August 27, 2026 11:35
25b534e to
2656a71
Compare
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.
The bug
On Windows, dragging the mouse out of the WebView while a button is held ends the gesture. This breaks text-selection extension, drag-and-drop, and mousemove-driven UI.
Root cause
MouseRegion.onExitfires when the cursor crosses the widget bounds, including mid-drag. Flutter continues routing the captured pointer sequence to theListener, but forwarding that exit as WebView2LEAVEmakes Chromium end the in-flight gesture.Fix
LEAVEwhile any mouse button is down, then send it after the final button-up or cancellation.The implementation deliberately leaves the WebView2
LEAVEarguments at zero, as required by itsSendMouseInputcontract.Tests
custom_platform_view_drag_test.dartcovers dragging out, forwarding out-of-bounds cursor positions, releasing/cancelling outside, re-entry during a drag, right-button drags, and ordinary hover behavior.Validation after rebasing onto current
master:flutter analyzeflutter test(44 tests)