Preview an image in a clipboard confirmation #30

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

The Confirmation for Clipboard access names the Clipboard types and their sizes (#28), but an image is just image/png, 1.2 MiB. Showing the image itself would let the user see what a program is about to put on the clipboard.

  • The Confirmation draws only rectangles and text today. The renderer's Builder.image is private and takes a kitty Placement, so a preview needs a public way to draw an image of its own, with its own upload key.
  • PNG decoding is already available on both platforms through vt.sys.decode_png (wuffs on Linux, z2dimg on Windows).
  • Ghostty's gtk-kitty-clipboard branch previews images in its confirmation (ba50c6387, d6a4294f6), which is prior art.
  • A read is asked about before anything is read, so a preview applies to writes only, unless reading first becomes a decision of its own.
The Confirmation for Clipboard access names the Clipboard types and their sizes (#28), but an image is just `image/png, 1.2 MiB`. Showing the image itself would let the user see what a program is about to put on the clipboard. - The Confirmation draws only rectangles and text today. The renderer's `Builder.image` is private and takes a kitty `Placement`, so a preview needs a public way to draw an image of its own, with its own upload key. - PNG decoding is already available on both platforms through `vt.sys.decode_png` (wuffs on Linux, z2dimg on Windows). - Ghostty's `gtk-kitty-clipboard` branch previews images in its confirmation (ba50c6387, d6a4294f6), which is prior art. - A read is asked about before anything is read, so a preview applies to writes only, unless reading first becomes a decision of its own.
Author
Owner

Done in c171fde. The first PNG in a write is shown in its confirmation between the types and the text. It's fitted to the box at most 8 rows high, never scaled up, and drawn over a checkerboard. It's decoded once when the question is asked and shrunk to 512px on a side before upload; PNGs over 8192px on a side, or that don't decode, are only named. The sway VM test now writes a real PNG and checks the confirmation's screenshot for its magenta.

Done in c171fde. The first PNG in a write is shown in its confirmation between the types and the text. It's fitted to the box at most 8 rows high, never scaled up, and drawn over a checkerboard. It's decoded once when the question is asked and shrunk to 512px on a side before upload; PNGs over 8192px on a side, or that don't decode, are only named. The sway VM test now writes a real PNG and checks the confirmation's screenshot for its magenta.
jeff closed this issue 2026-10-16 22:42:20 -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.

Dependencies

No dependencies set

Reference
jeff/harrier#30
No description provided.