Repository navigation
Description
Requested native behavior
Copying a screenshot/image on Linux and pasting into a Mac application should use the desktop session's clipboard protocol. The user should not need a "Send screenshot" action, a helper/preload switch, a remote terminal, file-transfer permission or a reconnect. This follows the request to replace the workaround in #156 with native viewer support. Clipboard synchronization should respect the existing overall clipboard enable/disable behavior.
Current-main evidence and reproduction
Baseline: 1dad755823a53af2c3b4a3e9b7d93e51a7d85a1e.
- Copy a synthetic PNG to the Linux clipboard (image data, not its filename).
- Focus the native remote desktop and use the Mac application's Paste menu, or physical GUI/Win+V, to isolate this from the separate Ctrl-to-Command shortcut request.
- Expected: an image preview appears in an image-capable scratch document/composer without sending anything.
- Current code cannot transfer that image:
Window::poll_clipboardtestshas_clipboard_text()and callsSDL_GetClipboardText;ClipboardRequest, backend reads/writes andSyncStateuseString;clipboard_rich::Statenegotiates only CF_UNICODETEXT andpublic.utf8-plain-text. An image-only selection is skipped. This limitation is independently visible in the README's text-only clipboard description.
The original Mac image-paste failure was observed on 0.2.45 and the file/terminal workaround was accepted locally. A complete image-transfer test of this current commit has not been performed; the current-main finding above is the explicit text-only implementation, not a claim of a tested image protocol.
Proposed native implementation
- Local MIME data: represent clipboard content as typed data (at least text and PNG), and read image bytes through the focused desktop window's native clipboard integration. The current SDL2 clipboard API only exposes text. SDL3 offers
SDL_GetClipboardData("image/png", &size)/SDL_SetClipboardData; alternatively a platform backend would need to share the existing window/seat. SDL3 migration would be a separate dependency decision. Do not restore frequentwl-pastecalls on GNOME, which previously caused temporary-window/Dock churn ([Bug] v0.2.0 Linux 控制端在 GNOME Wayland 下连接远端后,Dock 图标持续跳动(剪贴板轮询创建临时窗口) #37); a separate GTK Wayland clipboard connection cannot simply be assumed to inherit SDL's focus. - Existing wire channel: extend the current format-list → data-request → confirmation/block exchange over
TEXT_DATA_CHANNEL(clipboard RPC request case 9 / response case 5). Keep the desktop connection alive. There is no reason to invoke the file or terminal tools to carry clipboard bytes. - Confirm the official Mac representation: macOS exposes PNG pasteboard data, but that alone does not prove the UU host's accepted format identifier/name or byte representation. With synthetic image data, capture only official format metadata and block/ack sizes, verify the host requests and accepts the image, then add a sanitized protocol fixture. Do not assume that a
public.pngoffer is already known to work; inspect TIFF/DIB conversion requirements if the official peer asks for those instead. - Binary bounds and lifecycle: add a separate image-size budget (keep the text limit), bounded blocks within the negotiated SCTP message size, request/transfer matching, timeout/cancellation on new ownership/disconnect, and no partial pasteboard replacement. Avoid echo loops. Only sizes/status are logged; no clipboard bytes or filenames.
- Paste ordering: ensure a newly copied image is offered/ready before forwarding the paste chord, so the Mac does not paste the previous clipboard content. Validate both selection changes and rapid Copy→Paste. The Mac service should populate its native pasteboard; Ctrl/Command mapping remains a separate input concern.
Validation needed for a mergeable implementation
- Text regression and image-only/mixed MIME selections; empty, invalid and oversized data.
- Multi-block images, missing/out-of-order/duplicate blocks, stale requests, cancellation and reconnect.
- GNOME Wayland/XWayland, native X11, and the existing niri backend behavior; no additional visible/toplevel polling windows.
- Real official Mac host: PNG paste in an image-capable scratch app, immediate Copy→Paste, focus changes and text↔image transitions. Verify remote-to-local separately before claiming bidirectional support.
Primary API references: SDL2 clipboard API, SDL3 arbitrary MIME clipboard data, SDL3 clipboard overview, Apple PNG pasteboard type.
This issue proposes built-in native support and records the remaining backend/protocol work. It does not present the old file/terminal bridge as native clipboard synchronization.
Activity
VallierDev commentedon Nov 3, 2026
Thanks for the precise pointers. Image clipboard needs the host/viewer clipboard format negotiation for images (format ids/names and payload encoding) to be established from the official clients first; today both directions are text-only, as you found. This is a larger change, so I've queued it for investigation rather than a quick patch.
🤖 Generated with Claude Code