Skip to content

WaylandBackend: clipboard and primary selection support#1685

Merged
misyltoad merged 3 commits into
ValveSoftware:masterfrom
MithicSpirit:wayland-clipboard
Jan 23, 2025
Merged

WaylandBackend: clipboard and primary selection support#1685
misyltoad merged 3 commits into
ValveSoftware:masterfrom
MithicSpirit:wayland-clipboard

Conversation

@MithicSpirit
Copy link
Copy Markdown

@MithicSpirit MithicSpirit commented Dec 25, 2024

This forwards the internal clipboard and primary selection to the host. However,
this does not yet add support for accessing the host's clipboard/selection
internally.

The source for both the clipboard and primary selection are recreated every
time, rather than being reused when they are still valid. Although this doesn't
seem to be necessary, it does appear to be the norm. In particular, the only
difference in behavior I could notice between the two methods is that clipboard
managers are not aware of the new copy when it is reused (this is at least the
case with wl-paste --watch under Sway).

This also fixes an issue introduced in d75b122, which broke forwarding selections
to the host altogether, including under the (previously-working) SDL backend.

@MithicSpirit
Copy link
Copy Markdown
Author

It is of note that the primary selection support depends on the unstable primary-selection protocol. I don't care that much about that as compared to regular clipboard support, so I'm fine with dropping that part of the PR (the second commit) if preferred.

@misyltoad
Copy link
Copy Markdown
Collaborator

Oh! I didn't see this, thank you for doing this, I will look at merging it soon.

@MithicSpirit
Copy link
Copy Markdown
Author

MithicSpirit commented Jan 22, 2025

There seems to be a nontrivial merge conflict. While I think I figured out how to fix the conflict (just moving the SetSelection method to CWaylandConnector), I haven't been able to actually get it to work.

I believe that commit d75b122 is the issue (particularly the part where it commented out the call to SetSelection). Some basic testing on the SDL backend suggests copying to the host's clipboard is currently broken altogether.

@MithicSpirit
Copy link
Copy Markdown
Author

I think I was able to fix this issue with e737059, but I'm not sure if this is implemented quite correctly (particularly, I'm not sure if the current connector is the correct way to do it). Either way, I was able to rebase on top of that (https://github.com/MithicSpirit/gamescope/tree/wayland-clipboard-2), and it seems to be working properly now. I can edit this PR to use that branch instead if desired.

@kisak-valve
Copy link
Copy Markdown
Member

Hello @MithicSpirit, in general for any pull request, yes, you should update the branch you're proposing to be merged to be the best iteration you have. You should be able to force push the changes to your branch that this pull request is already pointing to and it'll show here.

Comment thread src/Backends/WaylandBackend.cpp
This forwards the internal clipboard to the host, but does not handle
the primary selection nor accessing the host's clipboard internally.

The source is recreated for every new copy, rather than being reused
when it is still valid. This doesn't seem to be necessary, but doing it
differently leads to clipboard managers not becoming aware of the reused
copies (under Sway, `wl-paste --watch` doesn't notice them), which at
least suggests that not reusing is more common.
This is an extension of the previous commit, also forwarding the primary
selection to the host. This does not add support for accessing the
host's primary selection internally.
@misyltoad misyltoad merged commit ef1e8db into ValveSoftware:master Jan 23, 2025
@MithicSpirit MithicSpirit deleted the wayland-clipboard branch January 23, 2025 15:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants