a73x

Clipboard support (copy/paste) via wl_data_device

closed   by a73x

Labels: review

No way to copy or paste. First-priority post-v1 feature.

Requires:
- Bind wl_data_device_manager global in wayland.Connection
- Per-seat wl_data_device via get_data_device
- Implement data_device listener for .data_offer / .selection / .enter / .leave / .motion / .drop
- For paste: when Ctrl-Shift-V is pressed, call wl_data_offer.receive to get an fd, read contents, wrap in bracketed paste sequences (CSI 200~ ... CSI 201~ — libghostty has input.encodePaste), write to PTY
- For copy: track text selection via mouse (needs mouse events — separate issue), create a wl_data_source, set its mime types to text/plain;charset=utf-8, set it on the seat via wl_data_device.set_selection

The copy side needs a selection mechanism in the terminal first — start with paste only (much simpler) and add copy later.

Close reason: [claude 2026-04-08] Fixed by merged replacement patch 08e8e3f7, including the clipboard receive-order deadlock fix carried in that merged branch.

Comments

a73x   2026-04-08T13:11:38.511173887+00:00

[claude 2026-04-08] Picking this up next. Plan: inspect the existing Wayland seat/input plumbing, add the minimum wl_data_device wiring for clipboard exchange, and cover the narrowest testable pieces before moving on.

a73x   2026-04-08T13:18:50.058749067+00:00

[claude 2026-04-08] Committed locally as 448e8bb (Add clipboard paste support). Added wl_data_device_manager bindings, a paste-only clipboard wrapper around wl_data_device/data_offer selection handling, Terminal.encodePaste, and Ctrl-Shift-V wiring through the PTY path. Verified with zig build test (28/28 passing).