fix: ignore client clipboard updates that echo our own copy - #31
Open
maryny4 wants to merge 1 commit into
Open
Conversation
When the server-side selection changes, hypr-rdp announces a format list to the RDP client. Client-side clipboard software (Windows clipboard history, clipboard managers) may rewrite the client clipboard in response, which comes back as a client format list; hypr-rdp then took the Wayland selection over with its own copy of the data, stealing selection ownership from the application the user had just copied from and routing every in-session paste through the RDP round trip — pastes inside the session became slow and unreliable until the client-side clipboard was touched manually. Compare incoming client data against the announced server-side cache (text normalized for CRLF, images byte-wise) and keep the owning application's selection when they match. Client-originated text is now also written with normalized line endings, so Wayland applications no longer paste CRLF. (cherry picked from commit eabd5f3)
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.
Problem
Copying inside the session, then pasting inside the session, is slow and unreliable — until the client-side clipboard is touched manually (opening Windows clipboard history, or copying something on the client).
Cause: when the server-side selection changes, hypr-rdp announces a format list to the RDP client. Client-side clipboard software (Windows clipboard history, clipboard managers) may rewrite the client clipboard in response, which arrives back as a client format list. hypr-rdp treated it as a fresh client copy: it fetched the data and took the Wayland selection over with its own copy — stealing selection ownership from the application the user had just copied from. Every in-session paste then went through the RDP round trip (and could dead-end in delayed rendering), instead of directly between the two Wayland applications.
Fix
Compare incoming client data against the announced server-side cache — text normalized for CRLF (Windows rewrites line endings), images byte-wise against the CF_DIB bytes we serve — and keep the owning application's selection when they match. Real client copies are unaffected.
Client-originated text is now also written to the Wayland selection with normalized line endings, so applications no longer paste stray CRLF.
Verification
Unit tests cover the text echo (CRLF-normalized), the image echo, and CRLF normalization of genuine client copies.
cargo fmt --check,clippy -- -D warnings,cargo test(both feature sets) pass. Verified live over multiple in-session copy/paste cycles with Windows clipboard history enabled: pastes are instant and no longer require touching the client clipboard.