Skip to content

Wayland: implement drag and drop via wl_data_device#166

Open
DTW-Thalion wants to merge 1 commit into
gnustep:masterfrom
DTW-Thalion:feature/wayland-dnd
Open

Wayland: implement drag and drop via wl_data_device#166
DTW-Thalion wants to merge 1 commit into
gnustep:masterfrom
DTW-Thalion:feature/wayland-dnd

Conversation

@DTW-Thalion

@DTW-Thalion DTW-Thalion commented Jul 15, 2026

Copy link
Copy Markdown
Contributor

Closes #72.

The Wayland backend had no drag and drop support. -dragInfo fell through to the base GSDragView, whose client-driven tracking loop moves a drag window to follow the pointer and hit-tests other windows. That cannot work under Wayland, where the compositor owns the pointer during a drag and a client can neither see nor position other surfaces.

This adds a WaylandDragView (a GSDragView subclass) wired in as the server's -dragInfo, backed by wl_data_device. The source advertises the drag pasteboard through a wl_data_source and calls wl_data_device_start_drag, then runs a modal loop until the compositor concludes the drag. The destination turns the compositor's wl_data_device enter/motion/drop events into the GSAppKitDragging events that NSWindow dispatches to the target view, using the drag view as the NSDraggingInfo.

Depends on #165; without that fix the drag aborts as soon as the compositor takes the pointer.

Two limitations are left for follow-ups: no drag icon surface is attached yet, so the compositor shows no drag image, and a drop originating in another client is not yet read into an NSPasteboard. Same-process drags work.

The Wayland backend had no drag and drop support. Add WaylandDragView,
a GSDragView subclass wired in as the server -dragInfo. The source
side advertises the pasteboard through a wl_data_source and hands the
drag to the compositor with wl_data_device_start_drag; the destination
side turns the compositor wl_data_device enter/motion/drop events into
the GSAppKitDragging events that NSWindow dispatches to the target view.
@DTW-Thalion DTW-Thalion requested a review from fredkiefer as a code owner July 15, 2026 00:15
@DTW-Thalion

DTW-Thalion commented Jul 15, 2026

Copy link
Copy Markdown
Contributor Author

@fredkiefer, let this PR soak for a while. It's efffectively a new feature as it fills in functionality that was missing in Wayland to mirror what the x11 backend has to do drag and drop. I am not running on Wayland as a matter of course, so I tested it with a minimal Wayland setup and compositor. So this needs to be stress tested by those better setup than I. This was just an opportunity for me to try building it - so further testing required.

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

Labels

None yet

Development

Successfully merging this pull request may close these issues.

Drag/Drop icons fails on Wayland Backend

1 participant