-
Notifications
You must be signed in to change notification settings - Fork 823
fix: Add DragUI support for external drag operations on Windows (Skia/WPF and Skia/Win32) #21759
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
…xtension Co-authored-by: MartinZikmund <[email protected]>
|
|
Co-authored-by: MartinZikmund <[email protected]>
Co-authored-by: MartinZikmund <[email protected]>
Co-authored-by: MartinZikmund <[email protected]>
Co-authored-by: MartinZikmund <[email protected]>
|
🤖 Your WebAssembly Skia Sample App stage site is ready! Visit it here: https://unowasmprstaging.z20.web.core.windows.net/pr-21759/wasm-skia-net9/index.html |
|
|
|
@copilot please implement this for Win32 target as well |
…pExtension Co-authored-by: MartinZikmund <[email protected]>
Implemented in commit efe66dc. The Win32 target now has the same DragUI support for external drag operations, including:
The implementation follows the same pattern as the WPF target but uses Win32 APIs to extract bitmap data from HGLOBAL handles. |
|
🤖 Your Docs stage site is ready! Visit it here: https://unodocsprstaging.z13.web.core.windows.net/pr-21759/docs/index.html |
|
🤖 Your WebAssembly Skia Sample App stage site is ready! Visit it here: https://unowasmprstaging.z20.web.core.windows.net/pr-21759/wasm-skia-net9/index.html |
|
@copilot It does not seem to work on Win32, CreateDragUIForExternalDrag |
…tion Co-authored-by: MartinZikmund <[email protected]>
Fixed in commit c705ac5. The issue was that The fix retrieves data directly from the IDataObject when creating DragUI, properly managing STGMEDIUM lifecycle with try-finally blocks for cleanup. This eliminates the dependency on the indexed medium list. |
|
🤖 Your Docs stage site is ready! Visit it here: https://unodocsprstaging.z13.web.core.windows.net/pr-21759/docs/index.html |
|
|
|
🤖 Your WebAssembly Skia Sample App stage site is ready! Visit it here: https://unowasmprstaging.z20.web.core.windows.net/pr-21759/wasm-skia-net9/index.html |
|
🤖 Your Docs stage site is ready! Visit it here: https://unodocsprstaging.z13.web.core.windows.net/pr-21759/docs/index.html |
|
🤖 Your WebAssembly Skia Sample App stage site is ready! Visit it here: https://unowasmprstaging.z20.web.core.windows.net/pr-21759/wasm-skia-net9/index.html |
|
|
|
@Mergifyio backport release/stable/6.4 |
🟠 Waiting for conditions to match
|
GitHub Issue: closes #[issue_number]
PR Type:
What is the current behavior? 🤔
Dragging image files from File Explorer into Uno Platform applications on Windows (Skia/WPF and Skia/Win32) shows no thumbnail near the cursor during the drag operation.
What is the new behavior? 🚀
External drag operations now display image thumbnails near the cursor on both Skia rendering backends. The implementation:
WPF Target Implementation
WpfDragDropExtension.OnHostDragEnternow creates aDragUIinstance for external drags (previously null)CreateDragUIForExternalDrag- Creates DragUI with thumbnail contentLoadImageFromFile- Loads images with 96px thumbnail size, validates file existenceConvertBitmapSourceToUnoBitmapImage- Converts WPF BitmapSource to Uno BitmapImage via PNG encoding with 8KB pre-allocated bufferWin32 Target Implementation
Win32DragDropExtension.DragEnternow creates aDragUIinstance for external drags (previously null)CreateDragUIForExternalDrag- Creates DragUI with thumbnail content from Win32 formatsExtractFilePathsFromHDrop- Extracts file paths from Win32 HDROP handle using DragQueryFile APIConvertDibToUnoBitmapImage- Converts Win32 DIB format to Uno BitmapImageLoadImageFromFile- Loads images from file system with validationIsImageFile- Detects image files by extensionError Handling (Both Targets)
IOException,UnauthorizedAccessException,NotSupportedException,UriFormatExceptionResource Management (Win32)
PR Checklist ✅
Other information ℹ️
Thumbnails show by default (
CoreDragUIOverride.IsContentVisible = true). Applications can hide them viaDragUIOverridein drag event handlers.This fix applies to both WPF and Win32 Skia rendering backends on Windows Desktop, ensuring consistent drag-and-drop visual feedback across both implementations.
Win32 Implementation Note: The initial implementation had an indexing bug where it assumed
mediumsToDisposealigned withformatEtcList, butmediumsToDisposeonly contains mediums for formats actually retrieved byReadContentIntoPackage. This was fixed by retrieving data directly from the IDataObject when creating the DragUI.Original prompt
💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.