Use the most recent serial of kinds KeyPress or MousePress when copying#52053
Merged
kubkon merged 2 commits intozed-industries:mainfrom Mar 25, 2026
Merged
Use the most recent serial of kinds KeyPress or MousePress when copying#52053kubkon merged 2 commits intozed-industries:mainfrom
kubkon merged 2 commits intozed-industries:mainfrom
Conversation
This comment was marked as outdated.
This comment was marked as outdated.
3 tasks
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.
Context
Wayland's
write_to_clipboardandwrite_to_primaryexclusively useSerialKind::KeyPressas theserial. When Wayland users try to copy using the mouse without having pressed a key on the keyboard,state.serial_tracker.get(SerialKind::KeyPress)could return0, causing users to experience failed writes to the clipboard or primary with no visibility of what failed or why.I have added a
latest_of(...)helper incrates/gpui_linux/src/linux/wayland/serial.rswhich returns the most recent tracked serial of theSerialKinds provided. Incrates/gpui_linux/src/linux/wayland/client.rs, I call this new helper soserialis assigned the latest tracked serial of kindKeyPressorMousePress.I, personally, only reproduced the bug on KDE Plasma (Wayland). All the reports with confirmed desktop environments have been KDE Plasma, though it may also affect other desktop environments. I have tested this fix on KDE Plasma and Niri.
Old context for reference
WIP This change fixed mouse copying on KDE Plasma but broke it on others. I will review the new logs I gathered with actual values for `serial` using `SerialKind::KeyPress` and `SerialKind::MousePress`. Once I have, I will update the approach.Original Context
Wayland'swrite_to_clipboardandwrite_to_primaryuseSerialKind::KeyPress, exclusively. When Wayland users tried to copy using the mouse without having pressed a key on the keyboard,state.serial_tracker.get(SerialKind::KeyPress)could return0, causing users to experience failed writes to the clipboard or primary with no visibility of what failed or why.This PR adds a fallback toSerialKind::MousePresswhenstate.serial_tracker.get(SerialKind::KeyPress)returns0for bothwrite_to_clipboardandwrite_to_primary. In my testing on KDE Plasma, this fixes the bug when users copy with the mouse from the context menu and when users use the middle mouse click for primary copy/pasting. I, personally, only reproduced the bug on KDE Plasma (Wayland). All the reports with confirmed desktop environments have been KDE Plasma, though it may also affect other desktop environments.What I have manually tested
Still need help
How to Review
May need to be on KDE Plasma (see note in context section)
cargo runwrite_to_primaryand observe content is pasted correctlyRecording of fix on KDE Plasma
https://github.com/user-attachments/assets/479a7167-d19d-4d4e-a53a-b67c29d49b9fRecording of fix on Niri
https://github.com/user-attachments/assets/dbb2e2ea-d886-4ea2-955b-13b0e797974bSelf-Review Checklist
Release Notes: