🐛 use imageFlavor instead of javaFileListFlavor for single-image clipboard writes#4302
Merged
guiyanakuang merged 2 commits intoCrossPaste:mainfrom Apr 26, 2026
Conversation
…board writes For single images, place BufferedImage (imageFlavor) on the clipboard instead of file list references. On macOS, javaFileListFlavor produces public.file-url pasteboard entries that apps like WeChat read as text, resulting in file:/// paths being pasted instead of the actual image. Fall back to javaFileListFlavor only when the image cannot be read. Multi-image clipboard writes remain unchanged.
Member
|
Hi @Fldicoahkiin, thanks a lot for the PR and the careful diagnosis — #2729 is a real bug, and you've correctly identified that AWT translates javaFileListFlavor into public.file-url, which apps like WeChat and Notes prefer over the image flavor. Aiming for parity with native screenshot paste is a sensible direction. I pulled the branch locally to test and unfortunately found a regression we need to address before merging:
So we still need to keep |
keep map[DataFlavor.javaFileListFlavor.toPasteDataFlavor()] = fileList in the single-image branch
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
Fixes #2729
When pasting a single image from CrossPaste history (right-click copy or double-click quick paste), apps like WeChat and Notes on macOS receive a
file:///path instead of the actual image. This is becauseDesktopImageTypePlugin.buildTransferable()placesjavaFileListFlavor(file list) on the clipboard, which macOS translates topublic.file-urlpasteboard entries. Apps that prefer text/URL types over image types end up pasting the file path.This PR changes single-image clipboard writes to use
imageFlavor(BufferedImage) as the primary clipboard data, matching the behavior of native macOS screenshot paste (public.tiff). Falls back tojavaFileListFlavoronly when the image cannot be read. Multi-image clipboard writes remain unchanged.Changes
imageFlavor(BufferedImage) on the clipboard instead ofjavaFileListFlavorjavaFileListFlavorwhenimageHandler.readImage()returns null or throwsjavaFileListFlavor)Test plan