Write every clipboard type a program gives, each served its own bytes #27

Closed
opened 2026-10-16 15:11:20 -05:00 by jeff · 1 comment
Owner

Part of #23

A 5522 write arrives with every type the program wrote, but Session.clipboardWrite keeps only the first text type. If there is none, it replies ENOSYS. The Wayland data source offers only the text type names and serves its one buffer, whichever type is asked for, with a blocking write on the window thread. So kitten clipboard copying an image puts nothing on the clipboard.

What done looks like

  • A write keeps every Clipboard type it was given, each with its own bytes, within the existing 64 MiB total.
  • harrier's data source offers exactly those types. When text/plain (or another text type) is among them, it also offers the usual text aliases (text/plain;charset=utf-8, UTF8_STRING, TEXT, STRING).
  • Each send is served the bytes of the type it asked for, written a bounded chunk a turn without blocking, from the main loop's poll, in ClipboardTransfers (see #26), rather than a blocking write on the window thread.
  • OSC 52 writes are unchanged: text.
  • The primary selection stays text only. A write to it with no text type is refused as today.
  • Tests: the sway VM test writes a PNG with 5522 and gets the same bytes from wl-paste -t image/png. A write with both text and an image serves each its own.

Not here: replying "done" before the user has answered a write that asks first. That's its own issue.

Part of #23 A 5522 write arrives with every type the program wrote, but `Session.clipboardWrite` keeps only the first text type. If there is none, it replies ENOSYS. The Wayland data source offers only the text type names and serves its one buffer, whichever type is asked for, with a blocking write on the window thread. So `kitten clipboard` copying an image puts nothing on the clipboard. ## What done looks like - A write keeps every Clipboard type it was given, each with its own bytes, within the existing 64 MiB total. - harrier's data source offers exactly those types. When `text/plain` (or another text type) is among them, it also offers the usual text aliases (`text/plain;charset=utf-8`, `UTF8_STRING`, `TEXT`, `STRING`). - Each `send` is served the bytes of the type it asked for, written a bounded chunk a turn without blocking, from the main loop's poll, in `ClipboardTransfers` (see #26), rather than a blocking write on the window thread. - OSC 52 writes are unchanged: text. - The primary selection stays text only. A write to it with no text type is refused as today. - Tests: the sway VM test writes a PNG with 5522 and gets the same bytes from `wl-paste -t image/png`. A write with both text and an image serves each its own. Not here: replying "done" before the user has answered a write that asks first. That's its own issue.
jeff self-assigned this 2026-10-16 16:34:17 -05:00
Author
Owner

Done in 9a9ae8b. In the sway VM test, a program writes 1 MiB as image/png plus "hello" as text/plain with 5522. wl-paste -l then offers image/png text/plain;charset=utf-8 text/plain UTF8_STRING TEXT STRING, -t text/plain gives "hello", and -t image/png gives the image byte for byte. The platform keeps what it offers in a reference-counted Offered, and ClipboardTransfers writes each request without blocking. One test detail: the compositor accepts a selection only from a client that has had input, so the test presses a key before the program writes.

Done in 9a9ae8b. In the sway VM test, a program writes 1 MiB as `image/png` plus "hello" as `text/plain` with 5522. `wl-paste -l` then offers `image/png text/plain;charset=utf-8 text/plain UTF8_STRING TEXT STRING`, `-t text/plain` gives "hello", and `-t image/png` gives the image byte for byte. The platform keeps what it offers in a reference-counted `Offered`, and `ClipboardTransfers` writes each request without blocking. One test detail: the compositor accepts a selection only from a client that has had input, so the test presses a key before the program writes.
jeff closed this issue 2026-10-16 17:04:33 -05:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
jeff/harrier#27
No description provided.