Skip to content

Conversation

@mergify
Copy link
Contributor

@mergify mergify bot commented Nov 27, 2025

GitHub Issue: closes #[issue_number]

PR Type:

  • 🐞 Bugfix

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.OnHostDragEnter now creates a DragUI instance for external drags (previously null)
  • CreateDragUIForExternalDrag - Creates DragUI with thumbnail content
    • Fast path: Uses OS-provided bitmap if available (DataFormats.Bitmap)
    • Fallback: Loads first image file from drag data
    • Supports: .png, .jpg, .jpeg, .gif, .bmp, .tiff, .ico
  • LoadImageFromFile - Loads images with 96px thumbnail size, validates file existence
  • ConvertBitmapSourceToUnoBitmapImage - Converts WPF BitmapSource to Uno BitmapImage via PNG encoding with 8KB pre-allocated buffer

Win32 Target Implementation

  • Win32DragDropExtension.DragEnter now creates a DragUI instance for external drags (previously null)
  • CreateDragUIForExternalDrag - Creates DragUI with thumbnail content from Win32 formats
    • Retrieves data directly from IDataObject with proper STGMEDIUM lifecycle management
    • Supports CF_DIB (Device Independent Bitmap) format
    • Supports CF_HDROP (file drop) format with image file detection
    • Properly releases STGMEDIUM resources using try-finally blocks
  • ExtractFilePathsFromHDrop - Extracts file paths from Win32 HDROP handle using DragQueryFile API
  • ConvertDibToUnoBitmapImage - Converts Win32 DIB format to Uno BitmapImage
  • LoadImageFromFile - Loads images from file system with validation
  • IsImageFile - Detects image files by extension

Error Handling (Both Targets)

  • Catches specific exceptions: IOException, UnauthorizedAccessException, NotSupportedException, UriFormatException
  • Graceful degradation: Returns DragUI without content on errors
  • Debug logging for troubleshooting

Resource Management (Win32)

  • STGMEDIUM properly acquired and released for each data format
  • Try-finally blocks ensure cleanup even if image conversion fails
  • Independent data retrieval eliminates dependency on indexed lists

PR Checklist ✅

  • 📝 Commits follow Conventional Commits specification
  • 🧪 Runtime/UI tests added (manual testing required - DragDrop_Files sample)
  • 📚 Docs updated (not applicable - internal fix)
  • 🖼️ Screenshot validation (requires manual testing)
  • ❗ Contains NO breaking changes

Other information ℹ️

Thumbnails show by default (CoreDragUIOverride.IsContentVisible = true). Applications can hide them via DragUIOverride in 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 mediumsToDispose aligned with formatEtcList, but mediumsToDispose only contains mediums for formats actually retrieved by ReadContentIntoPackage. This was fixed by retrieving data directly from the IDataObject when creating the DragUI.

  • Fixes unoplatform/kahua-private#372
Original prompt

This section details on the original issue you should resolve

<issue_title>When Dragging and Dropping an Image into Kahua, we no longer see the thumbnail around the cursor</issue_title>
<issue_description>### Current behavior 🐛

When dragging and dropping an image file into Kahua, we do not see the thumbnail for the image near the cursor

2025-10-29_11-32-38.mp4

Expected behavior 🎯

When dragging and dropping an image file into kahua, the thumbnail displays near the cursor prior to drop

2025-10-29_11-29-51.mp4

How to reproduce it (as minimally and precisely as possible) 🔬

Repro Steps:

  1. Log in as any user and open File Manager
  2. Drag an image from file explorer onto the log view

Workaround 🛠️

None

Renderer 🎨

  • Skia
  • Native

Affected platforms 📱💻🖥️

Desktop (Windows)

Uno.Sdk version (and other relevant versions) 📦

.59 devbits

IDE version 🧑‍💻

No response

Anything else we need to know? 💬

No response</issue_description>

Comments on the Issue (you are @copilot in this section)

@Jen-Uno @ChaseKopp6 Nov 1 or 7th?
  • Fixes unoplatform/kahua-private#372

💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.


This is an automatic backport of pull request #21759 done by [Mergify](https://mergify.com).

Copilot AI and others added 12 commits November 27, 2025 13:02
…xtension

Co-authored-by: MartinZikmund <[email protected]>
(cherry picked from commit 7e1dcee)
Co-authored-by: MartinZikmund <[email protected]>
(cherry picked from commit 2ead42b)
Co-authored-by: MartinZikmund <[email protected]>
(cherry picked from commit 827eaa6)
Co-authored-by: MartinZikmund <[email protected]>
(cherry picked from commit 7012547)
…pExtension

Co-authored-by: MartinZikmund <[email protected]>
(cherry picked from commit 1d79256)
…tion

Co-authored-by: MartinZikmund <[email protected]>
(cherry picked from commit c4699b5)
(cherry picked from commit 69a0cbf)
(cherry picked from commit 97378a2)
(cherry picked from commit 53abcc1)
@CLAassistant
Copy link

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you all sign our Contributor License Agreement before we can accept your contribution.
1 out of 2 committers have signed the CLA.

✅ MartinZikmund
❌ Copilot
You have signed the CLA already but the status is still pending? Let us recheck it.

@github-actions github-actions bot added area/skia ✏️ Categorizes an issue or PR as relevant to Skia platform/wpf 🪟 Categorizes an issue or PR as relevant to WPF labels Nov 27, 2025
@unodevops
Copy link
Contributor

🤖 Your Docs stage site is ready! Visit it here: https://unodocsprstaging.z13.web.core.windows.net/pr-21986/docs/index.html

@unodevops
Copy link
Contributor

🤖 Your WebAssembly Skia Sample App stage site is ready! Visit it here: https://unowasmprstaging.z20.web.core.windows.net/pr-21986/wasm-skia-net9/index.html

@unodevops
Copy link
Contributor

⚠️⚠️ The build 185375 has failed on Uno.UI - CI.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/skia ✏️ Categorizes an issue or PR as relevant to Skia platform/wpf 🪟 Categorizes an issue or PR as relevant to WPF

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants