Repository navigation
fix(screenshot): copy a saved screenshot as a file, not only image bytes - #3667
Conversation
dms screenshot put only image/png on the clipboard. Terminals can only paste text, so pasting a screenshot into a terminal app (e.g. a CLI that attaches images from a pasted path) did nothing, while a file copied through the server's clipboard.copyFile pastes its path. When the screenshot is saved to a file, copy it the same way: gnome-copied-files, text/uri-list, the path as text/plain, and the image bytes. The server is asked first so the copy lands in history; without it, the same offers are served locally. The offer list is shared with Manager.CopyFile through clipboard.FileOffers. copyMultiFork now waits for the child to take the selection, like copyForkCached, so a failed local copy is reported instead of lost. dms cl copy --download shares this path and now falls back to a local copy when the server is down or rejects the file. --no-file and PPM keep the image-only copy.
|
/claude review |
Claude reviewNo issues found. |
|
Thanks for the PR, small merge conflict to resolve and we should be good to go! |
Resolve the CopyFile conflict by keeping the shared FileOffers and moving upstream's percent-encoding of file URIs into it, so both the server and the CLI fallback offer encoded URIs.
|
/claude review |
Claude reviewNo issues found. |
Description
This PR makes
dms screenshotcopy a saved screenshot as a file, so it can be pasted into terminals.dms screenshotputs onlyimage/pngon the clipboard. Terminals can only paste text, so pasting a screenshot into a terminal app does nothing, for example into a CLI that attaches an image from a pasted path. A file copied through the server'sclipboard.copyFile(which plugins use) pastes its path there and still pastes the image into image-aware apps.clipboard.copyFile:x-special/gnome-copied-files,text/uri-list, the path astext/plain, and the image bytes. The server is asked first so the copy lands in history. Without a server, the CLI serves the same offers itselfclipboard.FileOffersbuilds the offer list for both, soManager.CopyFileand the CLI can't drift apart.Manager.CopyFile's offers, order and history entry are unchangedcopyMultiForkwaits for the child to take the selection, likecopyForkCached, so a failed local copy is reported instead of lost--no-fileand--format ppmkeep the image-only copy (there's no file to point to, and PPM isn't decodable as a clipboard image)No new strings.
A few things worth flagging:
clipboard.copyFile.dms cl copy --downloadsharescopyFileToClipboard, so when the server is down or rejects the file (overMaxEntrySize), it now copies locally instead of exiting with an error. That copy gets no history entry.MaxEntrySizeis 5 MiB, so large PNGs (4K, several monitors) take the local fallback. Their history behavior is the same as before.file://URIs aren't percent-encoded, so paths with spaces give invalid URIs.Manager.CopyFilealready does this; screenshots in such a directory now reach it too.Validation
TestFileOfferspins the full offer list in order, for an image and for non-image datago test ./...(everything exceptinternal/screenshot'sTestWaylandOutputBoundsScaled, which also fails onupstream/masteron this machine),make fmt,go veton the changed packages,GOOS=freebsd go build ./...,prek runon the changed files. Skipped theqml-testshook (needs niri) and thego-testhook (the screenshot test above)Type of change
Related issues
Screenshots / video
Checklist
I18n.tr()with translator context, reusing existing terms where possiblemake fmt, added/updated tests,make testpasses, andgo mod tidyis cleanmake lint-qmlwith no new warnings