Skip to content

windows: adopt custom clipboard formats via RegisterClipboardFormat (#17)#132

Merged
changkun merged 1 commit into
mainfrom
feat/custom-formats-windows
Jun 6, 2026
Merged

windows: adopt custom clipboard formats via RegisterClipboardFormat (#17)#132
changkun merged 1 commit into
mainfrom
feat/custom-formats-windows

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#131. Refs #17, #40.

Scope (Windows backend)

  • read/write default case resolves a custom Format token to its MIME string, registers it via RegisterClipboardFormat, and stores/reads bytes verbatim through global memory — raw passthrough, no conversion.
  • New helpers: registerCustomFormat, readCustom (sized via GlobalSize), writeCustom.
  • Added the GlobalSize kernel32 proc.
  • Watch works for free (sequence-number poll + Read).
  • Built-in CF_UNICODETEXT/CF_DIBV5 paths unchanged — the previous default-to-text fallthrough is now an explicit FmtText case so custom tokens no longer fall through to text.

Tests

clipboard_custom_windows_test.go runs the shared customRoundTrip (raw bytes incl. NUL + non-UTF-8 through a registered format and ReadAs) on the windows-latest job.

Verified locally via cross-compile + test-compile for windows/amd64 and windows/386.

)

Wire the custom-format seam into the Windows backend: read/write's
default case resolves a custom Format token to its MIME string, registers
it as a clipboard format with RegisterClipboardFormat, and stores/reads
the bytes verbatim through global memory (raw passthrough, no
conversion). readCustom sizes the read with GlobalSize; writeCustom
mirrors the existing text/image write path. Watch works for free (polls
Read via the sequence number). Built-in CF_UNICODETEXT/CF_DIBV5 paths are
unchanged (the former default-to-text fallthrough is now explicit).

Adds GlobalSize to the kernel32 procs and a windows TestCustomFormatRoundTrip.
@changkun changkun merged commit 0996c7f into main Jun 6, 2026
7 checks passed
@changkun changkun deleted the feat/custom-formats-windows branch June 6, 2026 23:35
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