Skip to content

wayland: adopt custom clipboard formats on the data-control backend (#17)#131

Merged
changkun merged 3 commits into
mainfrom
feat/custom-formats-wayland
Jun 6, 2026
Merged

wayland: adopt custom clipboard formats on the data-control backend (#17)#131
changkun merged 3 commits into
mainfrom
feat/custom-formats-wayland

Conversation

@changkun

@changkun changkun commented Jun 6, 2026

Copy link
Copy Markdown
Member

Backend PR of the custom clipboard formats design (spec). Builds on #128/#129/#130. Refs #17, #40.

Scope (Wayland data-control backend)

  • wlRead / wlWrite / wlWatch default case resolves a custom Format token to its MIME string and offers/requests it verbatim ([]string{mime}) — Wayland advertises selections by MIME type, so the registry maps 1:1.
  • Raw passthrough, no conversion. Built-in FmtText/FmtImage unchanged.

Tests

Both Linux backends (X11 and Wayland) now support custom formats, so the WAYLAND_DISPLAY skip is removed from clipboard_custom_linux_test.go. TestCustomFormatRoundTrip now runs on both the X11 ubuntu job and the headless-sway wayland_test job.

Verified locally via cross-compile + test-compile for linux/amd64.

changkun added 3 commits June 7, 2026 01:11
)

Wire the custom-format seam into the Wayland data-control backend:
wlRead/wlWrite/wlWatch resolve a custom Format token to its MIME string
and offer/request it verbatim ([]string{mime}), since Wayland advertises
selections by MIME type. Raw passthrough, no conversion. Built-ins
unchanged.

With both Linux backends (X11 and Wayland) now supporting custom formats,
drop the WAYLAND_DISPLAY skip so the headless-sway CI job exercises the
round-trip too.
On the Wayland data-control backend a freshly set selection is not
immediately visible to a new reader connection, so an immediate Read can
return nil. Poll Read for up to ~5s before asserting; backends that are
immediately consistent (darwin, X11, Windows) succeed on the first try
with no added delay.
…paste)

Under wlr/ext data-control, a client does not observe its own just-set
custom selection from a fresh reader connection (the built-in formats
happen to work same-process, but a single-MIME custom selection does
not, even after polling). The real use case is exchanging custom data
with other apps, so verify that directly:

- TestWaylandCustomWrite: wlWrite owns the selection; wl-paste --type
  reads the registered MIME back verbatim.
- TestWaylandCustomRead: wl-copy --type sets binary data; wlRead reads
  it back verbatim.

The same-process round-trip test skips under Wayland accordingly.
@changkun changkun merged commit dd6a906 into main Jun 6, 2026
7 checks passed
@changkun changkun deleted the feat/custom-formats-wayland branch June 6, 2026 23:30
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.

1 participant