Skip to content

Implement XDND: drag-and-drop support for Linux#20926

Draft
MrJul wants to merge 18 commits intoAvaloniaUI:masterfrom
MrJul:feature/xdnd
Draft

Implement XDND: drag-and-drop support for Linux#20926
MrJul wants to merge 18 commits intoAvaloniaUI:masterfrom
MrJul:feature/xdnd

Conversation

@MrJul
Copy link
Member

@MrJul MrJul commented Mar 17, 2026

What does the pull request do?

This PR implements XDND for Avalonia's X11 platform, allowing windows to act as drag sources and drop targets.
In short, drag-and-drop now works across processes on Linux.

How was the solution implemented (if it's not obvious)?

This PR supersedes #19232, which had several identified core problems: threading issues and re-implementations of existing algorithms already provided by the clipboard.

Instead, this PR tries to share most of its code with the clipboard implementation, since the underlying concepts are similar.

Key points:

  • Most of the clipboard logic has been moved to base Selection[...] classes, with Clipboard and DragDrop inheritors.
  • Threading is straightforward: no dispatcher calls, no arbitrary timers (except for timeouts), no non-awaited tasks.
  • Since drag-and-drop is synchronous, but X11 isn't, the SynchronousXEventWaiter type waits for specific matching events synchronously while reading from a selection, and puts back unused events onto the standard queue.
  • All atoms used by Avalonia are now interned on startup, even if they don't exist.

Draft

This PR works. However, there are two points remaining:

  • Touch/pen devices aren't properly captured. I focused on the mouse for the first draft because I didn't have a touchscreen readily available for testing. It's straightforward to add and will be implemented soon.
  • Hardening against sources misbehaving and not sending a XdndFinished message in time, effectively hanging the drop operation.

Fixed issues

@avaloniaui-bot
Copy link

You can test this PR using the following package version. 12.0.999-cibuild0063557-alpha. (feed url: https://nuget-feed-all.avaloniaui.net/v3/index.json) [PRBUILDID]

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Known][Waiting] Drag and Drop files doesn't work on Linux

2 participants