WIP: Initiating and receiving drag and drop using winit API#11966
WIP: Initiating and receiving drag and drop using winit API#11966eira-fransham wants to merge 8 commits into
Conversation
| [features] | ||
|
|
||
| default = ["std", "backend-default", "renderer-femtovg", "renderer-software", "accessibility", "compat-1-2"] | ||
| # HACK |
There was a problem hiding this comment.
Why do we need this hack? accessibility should already be disabled in the winit/build.rs in that branch.
There was a problem hiding this comment.
So I checked and this isn't necessary on Linux, but it's required to build on macOS.
|
|
||
| portable-atomic = { version = "1", features = ["critical-section"] } | ||
| auto_enums = { version = "0.8.0", optional = true } | ||
| enumflags2 = "0.7" |
There was a problem hiding this comment.
Any reason to use this crate instead of bitflags which we already depends on in i-slint-core?
There was a problem hiding this comment.
Not really, it's just the bitset crate I reach for first since it's more ergonomic than bitflags. If we're already using bitflags then I'll switch to that.
| pub fn set_data_transfer_allowed_drop_effects( | ||
| transfer: &mut DataTransfer, | ||
| flags: BitFlags<DropEffect>, | ||
| ) { | ||
| transfer.allowed_effects = flags; | ||
| } | ||
|
|
||
| // ================= | ||
| // Free functions for internal use, so we don't need to re-export them from the main Slint library. | ||
| // ================= | ||
|
|
||
| /// Sets the set of allowed effects for a drag operation (see [`DropEffect`]). | ||
| pub fn data_transfer_allowed_drop_effects(transfer: &DataTransfer) -> BitFlags<DropEffect> { | ||
| transfer.allowed_effects | ||
| } |
There was a problem hiding this comment.
I don't find where this is used.
There was a problem hiding this comment.
It's not yet, because the winit PR doesn't yet expose reading the inbound valid drop effects. I'm still not totally sure what the best way to handle this is, I think it makes sense to put it on DataTransfer in Slint but I think in winit it should be ActiveEventLoop::valid_actions(&self, transfer_id: DataTransferId to mirror set_valid_actions(..) (that way an error can be returned if it's called with a selection transfer ID).
| self.flush_pending_mouse_move(); | ||
| } | ||
|
|
||
| if let Some(drop_event) = runtime_window.take_new_started_drag_event() { |
There was a problem hiding this comment.
I think it'd be better if there was some function call in WindowAdapter(Internal) to start a drag, this would be something that we could use later as a public API for backend to do.
There was a problem hiding this comment.
Sure, that makes sense
|
Now working on Wayland too. |
Built to use rust-windowing/winit#4571
Confirmed to work on Windows, macOS, Wayland and X11.
Showcase (macOS)
Showing off move, copy, and dragging to/from external applications.
2026-06-04.17-00-18.mov