Skip to content

Fix text copy via mouse click on Wayland#50406

Merged
probably-neb merged 2 commits into
zed-industries:mainfrom
soundslocke:main
May 15, 2026
Merged

Fix text copy via mouse click on Wayland#50406
probably-neb merged 2 commits into
zed-industries:mainfrom
soundslocke:main

Conversation

@soundslocke

Copy link
Copy Markdown
Contributor

I've been working on a GPUI application which has a button for copying text. After starting the app in Wayland in Linux I noticed that when I click the button to copy text it does not work. After interacting with other buttons and/or copying text via keyboard shortcuts then my copy button works.

I thought I was handling something wrong, but then I noticed that Zed also exhibits this behavior: upon starting Zed if you highlight text and right-click and select "Copy" then nothing happens. After you interact with other UI elements and/or keyboard shortcuts then copy buttons seem to work fine.

This paper cut has been annoying me and with the help of Claude Code I arrived at this small fix. This solves the problem and this appears to be the way the serial should be handled for clipboard actions via button clicks in Wayland, as far as I've been able to learn. Here are a couple related Wayland documentation pages that I double checked:

  1. https://wayland.app/protocols/wayland#wl_data_device:request:set_selection
  2. https://wayland.freedesktop.org/docs/html/ch04.html#sect-Protocol-data-sharing-devices
  • Added a solid test coverage and/or screenshots from doing manual testing

  • Done a self-review taking into account security and performance aspects

    • None that I could find or think of
  • Aligned any UI changes with the UI checklist

    • I don't believe this is applicable...

Release Notes:

  • Improved first mouse-driven text copy action on Wayland

@cla-bot cla-bot Bot added the cla-signed The user has signed the Contributor License Agreement label Feb 28, 2026
@zed-community-bot zed-community-bot Bot added the first contribution the author's first pull request to Zed. NOTE: the label application is automated via github actions label Feb 28, 2026
@probably-neb

Copy link
Copy Markdown
Collaborator

hey sorry for the delay, once the merge conflicts are resolved I'd be happy to merge this

@soundslocke

Copy link
Copy Markdown
Contributor Author

It appears that #52053 came along several weeks later and duplicated this fix and then got merged a few days ago. It is a little more funky in my opinion, but not overly so.

The issue arises on in any Wayland environment, not just KDE Plasma as that PR alluded to. I also have nice screen recordings and had tied more documentation together. Alas.

I resolved the conflicts to orient around this code, which keeps the method docs and call sites simpler. But if you'd rather not merge because it's basically moot that's okay. 😞

@probably-neb

probably-neb commented Apr 15, 2026

Copy link
Copy Markdown
Collaborator

Sorry that me falling behind on my PR reviewing meant you weren't the one to fix this bug. It's still a nice API cleanup.

@probably-neb probably-neb enabled auto-merge (squash) April 15, 2026 07:14
@probably-neb probably-neb disabled auto-merge April 15, 2026 07:14
@probably-neb

Copy link
Copy Markdown
Collaborator

ugh, the CI is failing because we only fetch 350 commits from history to find the merge point. If you rebase on main I'd be happy to hit merge

@soundslocke

Copy link
Copy Markdown
Contributor Author

Hey @probably-neb, no problem, I just rebased with main. Thanks!

Also remove extraneous Wayland API reference.
@SomeoneToIgnore SomeoneToIgnore added platform:linux happens only on linux, not other OS platform:linux/wayland happens only on Linux Wayland labels May 3, 2026
@probably-neb probably-neb added this pull request to the merge queue May 15, 2026
Merged via the queue into zed-industries:main with commit 61e23fd May 15, 2026
47 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cla-signed The user has signed the Contributor License Agreement first contribution the author's first pull request to Zed. NOTE: the label application is automated via github actions platform:linux/wayland happens only on Linux Wayland platform:linux happens only on linux, not other OS

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants