wayland: keep the clipboard alive when its surface is destroyed#360
Open
MohamedAklamaash wants to merge 1 commit into
Open
wayland: keep the clipboard alive when its surface is destroyed#360MohamedAklamaash wants to merge 1 commit into
MohamedAklamaash wants to merge 1 commit into
Conversation
Author
|
@Drakulix Can you take a look at this? |
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.
When a layer-shell surface, popup, or subsurface is destroyed, the wayland event loop resets the clipboard with
*clipboard = Clipboard::unconnected(). That drops thewindow_clipboard::Clipboardand the smithay-clipboard worker serving whatever was just copied. So any app that copies to the clipboard and then closes the surface it copied from loses the offer immediately.COSMIC's screenshot portal is the clearest case. It owns a single overlay surface, and copying to the clipboard destroys that overlay in the same batch as the copy, so the
image/pngoffer dies a moment after it's set and nothing can paste the screenshot. See pop-os/xdg-desktop-portal-cosmic#295.The reset isn't needed.
window_clipboardonly wants the wayland display handle, not the surface, and smithay-clipboard runs its own connection to serve the selection. The display outlives every surface, so a copied selection should survive the surface going away. The regular window-close path inlib.rsalready does the right thing by rebinding to another window instead of dropping; only the layer/popup/subsurface destroy paths did the unconditional reset. This removes those three.Before, copying a screenshot to the clipboard:
After: