Skip to content

fix: use wl-copy for clipboard writes on native Wayland sessions#12536

Open
jb0421 wants to merge 2 commits intoowncloud:6from
jb0421:fix/wayland-clipboard
Open

fix: use wl-copy for clipboard writes on native Wayland sessions#12536
jb0421 wants to merge 2 commits intoowncloud:6from
jb0421:fix/wayland-clipboard

Conversation

@jb0421
Copy link
Copy Markdown

@jb0421 jb0421 commented May 6, 2026

Summary

Fixes #12534

On native Wayland sessions, QApplication::clipboard()->setText() is silently
dropped by the compositor when the ownCloud daemon has no focused surface — which
is always the case when the command arrives via the socket from a file manager
shell integration.

This change detects a native Wayland session via WAYLAND_DISPLAY and delegates
the clipboard write to wl-copy(1), which uses the Wayland primary selection
protocol and does not require a compositor surface.

Changes

Testing

Tested manually on Ubuntu 24.04 LTS (GNOME Wayland, Nautilus 46.4) with a locally
built client:

  • Before: right-click → "Copy private link" → clipboard empty
  • After: right-click → "Copy private link" → URL correctly pasted

Notes

wl-copy is provided by the wl-clipboard package, which is available on all
major Linux distributions and is a common dependency for Wayland clipboard tools.
If wl-copy is not installed, QProcess::startDetached silently fails and the
clipboard write is lost — same behaviour as before this fix.

See also: owncloud/client-desktop-shell-integration-nautilus#11 (comment)

On Wayland the ownCloud daemon has no compositor surface and never
receives keyboard focus, so QClipboard::setText() is silently dropped
by the compositor when COPY_PRIVATE_LINK is handled.

Detect a native Wayland session via WAYLAND_DISPLAY and delegate the
clipboard write to wl-copy(1), which does not require a compositor
surface.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@CLAassistant
Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

@DeepDiver1975
Copy link
Copy Markdown
Member

Interesting approach indeed ..... requires wl-copy to be installed .... also needs to be ltested with the appimage - I guess we would need wl-copy to be packaged into the app image ...

@jb0421
Copy link
Copy Markdown
Author

jb0421 commented May 7, 2026

@DeepDiver1975 Should I create a new PR with wl-clipboard packaged into the AppImage, or do you as a Maintainer want to take over from here?

@DeepDiver1975
Copy link
Copy Markdown
Member

Should I create a new PR with wl-clipboard packaged into the AppImage

feel free to give it a shot - thank you

@jb0421 jb0421 force-pushed the fix/wayland-clipboard branch 2 times, most recently from 5d10c84 to 4e5e57e Compare May 7, 2026 19:07
On Wayland, look for wl-copy next to the application binary first
(covers self-contained builds like AppImage), then fall back to PATH.
Add BUNDLE_WL_COPY cmake option to install wl-copy alongside the client
binary during packaging.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@jb0421 jb0421 force-pushed the fix/wayland-clipboard branch from 4e5e57e to b99fc81 Compare May 7, 2026 19:22
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.

3 participants