Repository navigation
Conversation
Winit binds a wl_data_device for each seat and accepts drags that offer text/uri-list with the copy action. The list is read without blocking as soon as the drag enters a window, so the window receives HoveredFile for each local file while the drag is over it, HoveredFileCancelled when it leaves, and DroppedFile for each file once it is dropped. The actions are set only on enter: setting them again on motion restarts the negotiation and can turn a quick drop into a leave. Only file URIs naming this machine become paths.
Hyprland (0.56.2) sends the selection and drags only to the first wl_data_device a client binds for a seat (dataDeviceForClient in src/protocols/core/DataDevice.cpp). Winit binds one for file drops, so a toolkit clipboard such as smithay-clipboard, which binds a second device on the same connection, never receives the selection and paste fails everywhere. A client should keep one data device per seat, so winit now offers the clipboard on its own device instead. platform::wayland::Clipboard reads and writes text on the seat that last gave the application input. It is found from the event loop with ActiveEventLoopExtWayland::clipboard, or from a wl_display pointer with Clipboard::for_display, for toolkits that only receive the display handle. Keyboard enter, key and button events record the serial that setting the selection needs. Reading another client's selection receives it through a pipe without dispatching the event loop and gives up after two seconds of silence. Our own selection carries a private marker type and is returned directly, so pasting it never waits on the thread that would have to send it. The compositor asks for our text through the data source, and a short-lived thread writes it.
17aa519 to
7a962fd
Compare
|
Fixed the typos failure: a test string contained |
Remove before merging, once a winit 0.30 release has winit::platform::wayland::Clipboard.
|
A test report from an app that needs this: FilmCraft, a video editor on eframe, on Hyprland 0.56.2 (aarch64). On winit 0.30.13, a file dragged from a GTK source onto FilmCraft imports nothing: FilmCraft gets enter, motion and leave but never a drop, because Hyprland sends drags and the selection only to the first data device a client creates. With this PR (7a962fd) pinned in, a drop imported the file 2 of 2 times, and text copy, text paste and file paste through the system clipboard all still worked, 2 of 2. The two FilmCraft PRs that work around it without this (storytold/filmcraft#1115, which adds its own data device, and storytold/filmcraft#634, which moves to XWayland) both broke text copy and paste in the same test. Thanks for doing this. |
The winit fork receives drag and drop on Wayland (rust-windowing/winit#4729), so the window no longer turns drops off there and the setup view offers dragging a folder on every desktop. Co-Authored-By: Claude Opus 5.5 <[email protected]>
winit 0.30.13 reports dropped files only on X11, so on a Wayland session a workbook dragged from Files showed a "no" cursor. Rather than running through XWayland, pin winit to rust-windowing/winit#4729 (the 0.30 backport of Wayland file drops, which also moves the clipboard onto winit's own data device). egui's clipboard would otherwise bind a second data device through smithay-clipboard, and Hyprland serves the selection only to a client's first one, so paste would break there. patches/egui-winit is the published egui-winit 0.36.2 with emilk/egui#8657 ported (it was written against egui main), so egui reads and writes text through winit's clipboard when the display belongs to a winit event loop. Licence files from egui 0.36.2 are included. Both patches go away once winit and egui release these changes. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01JxSbmEZZDKrHjsmEDM34SY
winit 0.30.13 reports dropped files only on X11, so on a Wayland session a drawing dragged from Files showed a "no" cursor unless CADCRAFT_X11=1 ran the app through XWayland. Pin winit to rust-windowing/winit#4729 (the 0.30 backport of Wayland file drops, which also moves the clipboard onto winit's own data device). egui's clipboard would otherwise bind a second data device through smithay-clipboard, and Hyprland serves the selection only to a client's first one, so paste would break there. patches/egui-winit is the published egui-winit 0.36.2 with emilk/egui#8657 ported, so egui reads and writes text through winit's clipboard when the display belongs to a winit event loop. Licence files from egui 0.36.2 are included. Both patches go away once winit and egui release these changes. Ported from GridCraft (storytold/gridcraft#2222). Co-Authored-By: Claude Opus 5.5 <[email protected]>
* #523: files dropped on the window are attached on Wayland too Notes the winit fork's second patch (rust-windowing/winit#4729) beside the pin; the rev is bumped once the fork is pushed. Human-reviewed, AI-assisted, nobody's mailbox harmed. * #523: winit from the fork with Wayland file drops Human-reviewed, AI-assisted, nobody's mailbox harmed.
…board when available Port of emilk#8657 (draft) to 0.36.2, the companion of W15 (rust-windowing/winit#4729): winit now binds a wl_data_device per seat for file drops, and a second device from smithay-clipboard loses the selection on compositors that serve only the first device per client (Hyprland). With winit's clipboard available, smithay-clipboard is not started. Only the clipboard.rs change is taken; the PR's temporary [patch] of egui's own winit is not. On 0.37, `Clipboard::new` stays `unsafe`. While winit's clipboard is in use, the PRIMARY selection goes through arboard: W15 offers only the regular selection.
…board when available Port of emilk#8657 (draft) to 0.36.2, the companion of W15 (rust-windowing/winit#4729): winit now binds a wl_data_device per seat for file drops, and a second device from smithay-clipboard loses the selection on compositors that serve only the first device per client (Hyprland). With winit's clipboard available, smithay-clipboard is not started. Only the clipboard.rs change is taken; the PR's temporary [patch] of egui's own winit is not.
winit 0.30.13 reported dropped files only on X11. The egui 0.37 migration (storytold#2543) pins storytold/winit, whose patch W15 reports file drops through a per-seat Wayland data device (rust-windowing/winit#4729), so files dragged from the file manager open on native Wayland too. The XWayland default is no longer needed. It also costs a startup crash: winit's X11 backend loads libxkbcommon-x11, which the Linux packages don't depend on. Where it's missing (a Fedora toolbox, minimal installs), GridCraft panics before the window opens: "Library libxkbcommon-x11.so could not be loaded." Checked on GNOME (Wayland, Fedora 44) with a build of main plus other proposed changes, run with GRIDCRAFT_WAYLAND=1 (the path this revert makes the default): an .xlsx and a .csv dragged from Files each open as a workbook, and the app starts without libxkbcommon-x11 installed. This reverts commit 6f0e43c. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Rvu8dWh26U2fsLQMSBQfH8
The game workspace pinned winit to an unreleased backport in a personal fork (crmne/winit) for native Wayland file drops. Every player build would then depend on a repository outside winit's own, which the project doesn't take. The drop import itself works wherever winit already delivers DroppedFile (Windows, macOS, X11, XWayland); native Wayland follows once a winit 0.30 release carries rust-windowing/winit#4729. Co-Authored-By: Claude Opus 5.5 <[email protected]>
* Linux: run on native Wayland again by default (revert #165) winit 0.30.13 reported dropped files only on X11. The egui 0.37 migration (#2543) pins storytold/winit, whose patch W15 reports file drops through a per-seat Wayland data device (rust-windowing/winit#4729), so files dragged from the file manager open on native Wayland too. The XWayland default is no longer needed. It also costs a startup crash: winit's X11 backend loads libxkbcommon-x11, which the Linux packages don't depend on. Where it's missing (a Fedora toolbox, minimal installs), GridCraft panics before the window opens: "Library libxkbcommon-x11.so could not be loaded." Checked on GNOME (Wayland, Fedora 44) with a build of main plus other proposed changes, run with GRIDCRAFT_WAYLAND=1 (the path this revert makes the default): an .xlsx and a .csv dragged from Files each open as a workbook, and the app starts without libxkbcommon-x11 installed. This reverts commit 6f0e43c. Claude-Session: https://claude.ai/code/session_01Rvu8dWh26U2fsLQMSBQfH8
Bind a wl_data_device per seat and accept text/uri-list drops, emitting HoveredFile/DroppedFile. Add start_drag_files() to begin an outgoing drag with an optional preview image, advertised as Copy. Backport of the approach in emilk/egui#8805 and rust-windowing#4729 for the 0.30 line.
winit 0.30 reports no file drops on Wayland, so files dragged in from a file manager never reach the Files tab or the Import dialog. Apply the source changes of rust-windowing/winit#4729 (commits a4d60d8 and 7a962fd on v0.30.x) to the v0.30.13 tree. A drag offering text/uri-list is accepted with the copy action, and the window then gets HoveredFile, HoveredFileCancelled and DroppedFile. The PR's second commit adds platform::wayland::Clipboard, which the next commit uses. The PR's Cargo.toml change, which adds percent-encoding to the wayland feature, is made by hand. The PR was still open on 2026-11-28. Drop this copy once a winit 0.30.x release includes it.
For the 0.30 maintenance branch, where eframe/egui and many other applications still are. On master, file drops landed with #4571 and the clipboard is being added on the same data device in #4658, so this is 0.30 only.
Problem
winit 0.30 reports no file drops on Wayland (#1881). Adding them means binding a
wl_data_deviceper seat, and that alone breaks paste in many apps on Hyprland: toolkits such as egui get their clipboard from smithay-clipboard, which binds a second data device on the same connection, and Hyprland (0.56.2) sends the selection and drags only to the first data device a client creates (dataDeviceForClient). Whichever device comes second loses either paste or drops. wlroots sends the selection to every device of a client, so sway is not affected.Fix
Two commits:
wl_data_deviceper seat and accepts drags offeringtext/uri-listwith the copy action. The list is read without blocking as soon as the drag enters a window, so the window getsHoveredFilefor each local file,HoveredFileCancelledwhen the drag leaves, andDroppedFilefor each file on drop. Actions are set only on enter: setting them again on motion restarts the negotiation and can turn a quick drop into a leave. OnlyfileURIs for this machine become paths; the parser has unit tests.platform::wayland::Clipboard, obtained withActiveEventLoopExtWayland::clipboard(), or withClipboard::for_display()from thewl_displaypointer of a display handle for toolkits that only get the handle. It hasload_text()andstore_text()and works on the seat that last gave the app input (keyboard enter, key and button serials are recorded forset_selection).Text only; images and the primary selection are out of scope.
Testing
cargo +nightly fmt --check;cargo testandcargo clippy --all-targetswith default features and with--no-default-features --features=wayland,wayland-dlopen; X11-only build;cargo doc; build with 1.70.0 (MSRV). Clippy reports only existing lints inxkb/compose.rsandx11/event_processor.rs, none in the changed files.In an egui app (with the companion egui change below) on headless compositors:
With the file drops but smithay-clipboard still binding its own device, the same Hyprland setup reproduces the bug: smithay-clipboard sees an empty selection and paste fails. Paste keeps working after drops in the same session with this change.
CI on v0.30.x currently fails before compiling:
cargo update -p syn --precise 2.0.114is ambiguous now that syn 3 exists (see #4692).Downstream report: crmne/spotifast#614. The egui-winit side, which uses this clipboard instead of starting smithay-clipboard when the display belongs to a winit event loop, is emilk/egui#8657.
changelogmodule if knowledge of this change could be valuable to users