windows: report OS file drops to the host - #7
Merged
Conversation
palmoni5
added a commit
to palmoni5/otzaria
that referenced
this pull request
Aug 13, 2026
גרירת \u200E.otzplugin\u200E אל חלונית התוספים או אל משגר הכלים מתקינה אותו, דרך אותו אירוע ואותו דיאלוג הרשאות שבורר הקבצים משתמש בהם. ב-Windows יש \u200EIDropTarget\u200E אחד לכל חלון והוא בבעלות הפורק של flutter_inappwebview, ולכן הגרירה מגיעה משם ולא מחבילת גרירה נפרדת — חבילה כזו הייתה גוזלת את הרישום ושוברת בשקט את ה-HTML5 drag בתוספים. הקליטה דולקת רק כשמותקן אזור קליטה, וה-Dart מחזיר ל-native החלטת accept/reject כדי שסמן הגרירה יופיע רק מעל אזור שבאמת יקלוט את הקובץ. תלוי ב-Otzaria/flutter_inappwebview#7; עד למיזוג ועדכון ה-ref הקוד רדום (הערוץ אינו קיים, והחריגה נתפסת).
In visual hosting the webview drop target owns the Flutter view's only IDropTarget, so a host that needs OS file drops cannot register its own alongside it - RegisterDragDrop would fail with DRAGDROP_S_ALREADYREGISTERED and silently disable HTML5 drag and drop inside webviews. Route file drags through the existing target instead. Registration is no longer tied to webview lifetime, and a host that opts in via the new filedrop channel receives enter/over/leave/drop with the dragged paths. Its setAccepted answer drives the drag cursor, so the effect is COPY only where the host would actually take the drop. Files still never reach WebView2: dropping one on browser UI bypasses every page-level and navigation guard.
palmoni5
force-pushed
the
feat/windows-file-drop
branch
from
August 13, 2026 11:59
9554913 to
5773ba0
Compare
palmoni5
changed the base branch from
fix/windows-creation-failure-and-null-view
to
master
August 13, 2026 11:59
Y-PLONI
added a commit
that referenced
this pull request
Aug 13, 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.
Why
In visual (composition) hosting,
WebViewDropTargetregisters the Flutter view's onlyIDropTarget. Windows permits one per HWND, so a host app that wants OS file drops cannot add its own: whichever registers first wins, and a general-purpose drop package registers at plugin-registration time — before any webview exists. The webview's ownRegisterDragDropthen fails withDRAGDROP_S_ALREADYREGISTEREDand HTML5 drag and drop inside plugin webviews silently breaks again (the regression #5237 this target was written to fix).What
Route file drags through the existing target instead of adding a second owner.
acquire/releaseIfUnused), so the target can exist for a host with no webview and is torn down when neither needs it.FileDropManager(channel…_filedrop):setEnabledopts in, andonFileDropreportsenter/over/leave/dropwith the dragged paths (CF_HDROP) and client coordinates.setAcceptedcarries the host's answer back and drives the drag cursor, so the effect isDROPEFFECT_COPYonly where the host would actually take the drop, and the plainDROPEFFECT_NONErefusal everywhere else. The answer is asynchronous and therefore lags by one drag event, which the continuousDragOverstream absorbs.Coordinates reuse the existing two-corner mapping, so they stay correct on RTL-mirrored windows (
WS_EX_LAYOUTRTL).Security
Unchanged: files still never reach WebView2.
reportFileDragcallsforwardLeave()before reporting, so a file dropped on browser UI (e.g. print preview) still cannot bypass page-level and navigation guards. With no host opted in, behaviour is byte-for-byte the previous flat refusal.Verification
COPYonly over the host's drop region and the X elsewhere; dropping a file delivers its path to the host; a non-matching file is refused everywhere.draggable+dragover/drop) still works — the non-file path is untouched apart from thecurrentDragHasFiles_early return, which isfalsefor such drags.