Skip to content

Commit d1c7b3e

Browse files
jb0421claude
andcommitted
fix: use wl-copy for clipboard writes on native Wayland sessions
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>
1 parent dfc4d5d commit d1c7b3e

2 files changed

Lines changed: 14 additions & 1 deletion

File tree

changelog/unreleased/12534.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
Bugfix: Fix "Copy private link to clipboard" on native Wayland sessions
2+
3+
The "Copy private link to clipboard" action now correctly writes to the
4+
clipboard on native Wayland sessions. Previously the write was silently
5+
dropped by the Wayland compositor because the ownCloud daemon has no
6+
compositor surface.
7+
8+
https://github.com/owncloud/client/issues/12534

src/gui/socketapi/socketapi.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@
5454
#include <QBuffer>
5555

5656
#include <QClipboard>
57+
#include <QProcess>
5758

5859
#ifdef Q_OS_MAC
5960
#include <CoreFoundation/CoreFoundation.h>
@@ -672,7 +673,11 @@ void SocketApi::command_OPEN_PRIVATE_LINK_VERSIONS(const QString &localFile, Soc
672673

673674
void SocketApi::copyUrlToClipboard(const QUrl &link)
674675
{
675-
QApplication::clipboard()->setText(link.toString());
676+
if (!qgetenv("WAYLAND_DISPLAY").isEmpty()) {
677+
QProcess::startDetached(QStringLiteral("wl-copy"), {link.toString()});
678+
} else {
679+
QApplication::clipboard()->setText(link.toString());
680+
}
676681
}
677682

678683
void SocketApi::command_MAKE_AVAILABLE_LOCALLY(const QString &filesArg, SocketListener *)

0 commit comments

Comments
 (0)