Skip to content

WIP: Initiating and receiving drag and drop using winit API#11966

Open
eira-fransham wants to merge 8 commits into
slint-ui:feature/winit-0.31from
eira-fransham:eira/dnd
Open

WIP: Initiating and receiving drag and drop using winit API#11966
eira-fransham wants to merge 8 commits into
slint-ui:feature/winit-0.31from
eira-fransham:eira/dnd

Conversation

@eira-fransham

@eira-fransham eira-fransham commented Jun 4, 2026

Copy link
Copy Markdown
Contributor

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

@ogoffart ogoffart changed the base branch from master to feature/winit-0.31 June 4, 2026 14:05
Comment thread api/rs/slint/Cargo.toml Outdated
[features]

default = ["std", "backend-default", "renderer-femtovg", "renderer-software", "accessibility", "compat-1-2"]
# HACK

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we need this hack? accessibility should already be disabled in the winit/build.rs in that branch.

@eira-fransham eira-fransham Jun 8, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So I checked and this isn't necessary on Linux, but it's required to build on macOS.

Comment thread internal/core/Cargo.toml

portable-atomic = { version = "1", features = ["critical-section"] }
auto_enums = { version = "0.8.0", optional = true }
enumflags2 = "0.7"

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any reason to use this crate instead of bitflags which we already depends on in i-slint-core?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread internal/core/data_transfer.rs Outdated
Comment on lines +229 to +243
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
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't find where this is used.

@eira-fransham eira-fransham Jun 8, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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() {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, that makes sense

@eira-fransham

Copy link
Copy Markdown
Contributor Author

Now working on Wayland too.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants