Repository navigation
refactor(clipboard): replace clipboard-rs with native macOS and Windows backends - #465
Merged
Merged
Conversation
This was referenced Nov 29, 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.
Summary
Replaces
clipboard-rsinwaterkit-clipboardwith native macOS and Windows implementations and removesclipboard-rsfrom the workspace dependency tree.platform/clipboard/src/sys/apple/macos.rs): DirectNSPasteboardimplementation throughobjc2/objc2-app-kit/objc2-foundation/objc2-uniform-type-identifiers/objc2-core-graphics. Maps custom MIME types to UTIs viaUTType::typeWithMIMEType, resolves file-reference URLs (file:///.file/id=...) viaNSURL::filePathURL, reads PNG/TIFF losslessly (falling back toNSImage/CGImagewith unpremultiplication to straight RGBA), and watches changes by pollingNSPasteboard.changeCount. Sharesfile_urlwith iOS (src/sys/apple/ios.rs).platform/clipboard/src/sys/windows/): Direct Win32 clipboard implementation through the workspacewindowscrate:CF_UNICODETEXT,CF_HTMLheader encode/decode with optional plain-text fallback,CF_HDROP(DROPFILES),PNG+CF_DIBV5/CF_DIB<-> straight-alpha RGBA8 conversion, registered MIME formats (RegisterClipboardFormatW), a hidden message-only window (HWND_MESSAGE) watcher usingAddClipboardFormatListener/WM_CLIPBOARDUPDATE, and delayed rendering (WM_RENDERFORMAT/WM_RENDERALLFORMATS/WM_DESTROYCLIPBOARD) forset_file_promise.clipboard-rsfromCargo.toml,platform/clipboard/Cargo.toml, andCargo.lock, scopestracingto the targets that use it, deletessys/desktop.rs, and updates platform notes inlib.rsandREADME.md.Fixes #462
Verification
cargo clippy -p waterkit-clipboard --all-targets --all-features -- -D warnings,cargo nextest run -p waterkit-clipboard --all-features(12 passed, includingdesktop_clipboard_round_tripcovering text/pbpaste, HTML, files, RGBA image, custom/large binary,set_file_promise, watcher, and clear), andcargo test --doc -p waterkit-clipboard --all-features.cargo clippy -p waterkit-clipboard --all-targets --all-features -- -D warnings,cargo test -p waterkit-clipboard --all-features(DIB/HTML unit tests,desktop_clipboard_round_tripincluding lazy delayed-renderedset_file_promiseandWM_CLIPBOARDUPDATEwatcher, plus directCF_DIBV5andCF_DIBclipboard decode), and doctests.cargo clippy -p waterkit-clipboard --all-targets --all-features -- -D warnings, 24 unit tests, doctests, and Xvfb integration tests (clipboard_round_trip,primary_selection_round_trip,display_gone).