Repository navigation
feat: clipboard sync on X11 sessions and through XWayland - #337
Merged
Merged
Conversation
Clipboard sync needed a Wayland data-control protocol, so it was off on X11 desktops (XFCE, GNOME on Xorg, issue zackb#65) and on GNOME Wayland, whose Mutter offers neither wlr nor ext data-control. Add an X11 ClipboardManager backend: XFixes reports CLIPBOARD ownership changes without polling, reads use selection conversions (TARGETS first, INCR for large payloads), and writes take ownership and serve TARGETS/TIMESTAMP/text/PNG requests, with INCR for payloads that do not fit one request. WaylandContext uses it when there is no Wayland compositor, and as a fallback when the compositor has no data-control manager: XWayland bridges the Wayland clipboard to X11, so GNOME's own selection is still seen. Wayland data-control stays the first choice. The backend is optional at build time (TETHER_X11) and needs libx11 and libxfixes. Tested with helper unit tests plus live tests against a throwaway X server (TETHER_TEST_X11_DISPLAY, skipped when unset): text and PNG paste, STRING Latin-1, a 3 MB INCR transfer, and desktop copies reported once with no echo of our own selection. Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
Owner
|
Thanks, this is nicely done. I think this is the best way tether could support X11. I pushed one small commit on top so X11 is not a hard dependency for tether, which I'm not willing to do. BUT, I checked that gtk3 already pulls them in and it builds and runs correctly on all the different permutations of system configurations (Wayland only, X11+Wayland, etc). I made the link \PRIVATE to core. x11>=1.7 is required so older libX11 disables the X11 backend instead of breaking the build. Also had claude fix the translations. Thanks for the contribution! |
Closed
Contributor
Author
|
Thank you for your time and merging this request. Happy to contribute! |
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.
Refs #65 (Wayland requirement).
What
An X11
ClipboardManagerbackend, so clipboard sync works without a Wayland data-control protocol:zwlr_data_control_manager_v1norext_data_control_manager_v1, so sync was unavailable. XWayland bridges the Wayland clipboard to X11, so the same backend sees (and sets) GNOME's selection.Wayland data-control stays the first choice; X11 is used when there is no compositor, or when the compositor has no data-control manager.
How
TARGETSfirst, thenpick_clipboard_mime;INCRfor large payloads;STRINGconverted from Latin-1.CLIPBOARD, serveTARGETS,TIMESTAMP, UTF-8/text types,STRING(Latin-1),image/png;INCRwhen a payload exceeds one request.copy()is not reported back as a desktop change (no echo to the phone).TETHER_X11, on by default whenx11andxfixesare found); package dependencies updated.Testing
TETHER_TEST_X11_DISPLAY=:Nwith Xvfb/Xephyr; skipped when unset): UTF-8/Latin-1/PNG paste, a 3 MBINCRtransfer, desktop copies reported once.Notes for review
WaylandContext::setup();setup_x11()is also reached frominit()when there is no compositor.docs/PROTOCOL.mdwording alone; README requirements and build deps are updated.🤖 Generated with Claude Code