Repository navigation
feat(wayland): add zwp_primary_selection_v1 support and keyboard primary-selection writes (#1859) - #2640
Merged
Conversation
…ary-selection writes
Hona
force-pushed
the
feat/wayland-primary-selection
branch
from
November 27, 2026 15:22
6f6481e to
0aebebd
Compare
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
Implements native Wayland
zwp_primary_selection_v1primary-selection support (Part 2 of #1859) and extends Linux primary-selection writes to keyboard selections (Shift+Arrows,Ctrl+A) alongside pointer releases.zwp_primary_selection_v1backend (crates/rune/src/platform/wayland/primary_selection/):zwp_primary_selection_device_manager_v1(v1) once perwl_displayafter frame 1 (Host::run_on_readyand after an overlay's first frame); falls back to arboard'srune-primaryworker only when the compositor lacks the global (and keeps X11 unchanged).platform/wayland/serial.rs), shared bounded pipe reader promoted fromdrop/pipe.rsintoplatform/wayland/pipe.rs, and shared non-blocking bounded pipe writer (platform/wayland/pipe_write.rs).window::wayland_wakestrictly while our ownzwp_primary_selection_source_v1is owned (zero backgroundWaylandWatchthreads, zero idle wakeups on plain windows).machine.rs) handles Mutter'sselection(None)->selection(Some(new))replacement, Hyprland pointer-enter offers, zero-syscall self-paste fast path while owning the source, RFC 2045 case-insensitive MIME priority (text/plain;charset=utf-8>UTF8_STRING>text/plain>TEXT>STRINGwith Latin-1 decode),MAX_PENDING_OFFERS = 16eviction, latest-winsAttemptread cancellation (4 MiB / 2 s cap),MAX_CONCURRENT_WRITERS = 8(5 s timeout,Arc<[u8]>sharing), retired sources ignoring staleCancelled, and strict teardown beforewl_displaycloses.runtime/input/primary_selection.rs,keys.rs,caret_browse,select_all.rs):Shift+Arrows andCtrl+Ain editable/read-onlytext_input, caret browsing, and selectable text publish to primary selection coalesced once per frame, with secure fields still excluded and collapse/blur leaving primary selection intact.RuntimeCore::primary_selection_lost()clears the dedup hash when the active source receivesCancelled, so re-selecting identical text after another app overwrote primary selection publishes again.Verification
wasm32-unknown-unknown:cargo test -p rune --lib platform::wayland::(78 passed, including 8 newprimary_selection::machinetests and extendedserialtests)cargo test -p rune --lib runtime::input::primary_selection(8 passed, including keyboardShift+Arrow,Ctrl+A, coalescing,primary_selection_lost, secure fields, caret browsing, and selectable text)cargo test -p rune --lib wayland_wake(5 passed)cargo check -p rune --target wasm32-unknown-unknown(passed)scripts/file-size.sh(0 errors, 0 folder-shape violations)pipe(2)tests, opt-in headlessswayE2E test (sway_e2e_tests.rs), and live desktop Wayland compositors (GNOME/Mutter, Flatpak, KDE Plasma, Hyprland) — relying on Linux CI for Linux/Unix build + tests and asking the reporter to confirm on live compositors.Fixes #1859