windows: adopt custom clipboard formats via RegisterClipboardFormat (#17)#132
Merged
Conversation
) 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.
This was referenced Jun 6, 2026
Closed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Backend PR of the custom clipboard formats design (spec). Builds on #128–#131. Refs #17, #40.
Scope (Windows backend)
read/writedefaultcase resolves a customFormattoken to its MIME string, registers it viaRegisterClipboardFormat, and stores/reads bytes verbatim through global memory — raw passthrough, no conversion.registerCustomFormat,readCustom(sized viaGlobalSize),writeCustom.GlobalSizekernel32 proc.Watchworks for free (sequence-number poll +Read).CF_UNICODETEXT/CF_DIBV5paths unchanged — the previous default-to-text fallthrough is now an explicitFmtTextcase so custom tokens no longer fall through to text.Tests
clipboard_custom_windows_test.goruns the sharedcustomRoundTrip(raw bytes incl. NUL + non-UTF-8 through a registered format andReadAs) on thewindows-latestjob.Verified locally via cross-compile + test-compile for
windows/amd64andwindows/386.