From d1c7b3e28673b324bab904183502f0945b76c8b3 Mon Sep 17 00:00:00 2001 From: Jaap Braasch Date: Tue, 5 May 2026 16:03:07 +0200 Subject: [PATCH 1/2] 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 --- changelog/unreleased/12534.md | 8 ++++++++ src/gui/socketapi/socketapi.cpp | 7 ++++++- 2 files changed, 14 insertions(+), 1 deletion(-) create mode 100644 changelog/unreleased/12534.md diff --git a/changelog/unreleased/12534.md b/changelog/unreleased/12534.md new file mode 100644 index 00000000000..e57ec99d596 --- /dev/null +++ b/changelog/unreleased/12534.md @@ -0,0 +1,8 @@ +Bugfix: Fix "Copy private link to clipboard" on native Wayland sessions + +The "Copy private link to clipboard" action now correctly writes to the +clipboard on native Wayland sessions. Previously the write was silently +dropped by the Wayland compositor because the ownCloud daemon has no +compositor surface. + +https://github.com/owncloud/client/issues/12534 diff --git a/src/gui/socketapi/socketapi.cpp b/src/gui/socketapi/socketapi.cpp index 23b888b62d3..1d1b8940740 100644 --- a/src/gui/socketapi/socketapi.cpp +++ b/src/gui/socketapi/socketapi.cpp @@ -54,6 +54,7 @@ #include #include +#include #ifdef Q_OS_MAC #include @@ -672,7 +673,11 @@ void SocketApi::command_OPEN_PRIVATE_LINK_VERSIONS(const QString &localFile, Soc void SocketApi::copyUrlToClipboard(const QUrl &link) { - QApplication::clipboard()->setText(link.toString()); + if (!qgetenv("WAYLAND_DISPLAY").isEmpty()) { + QProcess::startDetached(QStringLiteral("wl-copy"), {link.toString()}); + } else { + QApplication::clipboard()->setText(link.toString()); + } } void SocketApi::command_MAKE_AVAILABLE_LOCALLY(const QString &filesArg, SocketListener *) From b99fc81a31dce7df95cf0dd220c615a4950fb807 Mon Sep 17 00:00:00 2001 From: Jaap Braasch Date: Thu, 7 May 2026 21:07:24 +0200 Subject: [PATCH 2/2] feat: prefer bundled wl-copy and add BUNDLE_WL_COPY cmake option 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 --- src/gui/CMakeLists.txt | 6 ++++++ src/gui/socketapi/socketapi.cpp | 7 ++++++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/src/gui/CMakeLists.txt b/src/gui/CMakeLists.txt index a51e69a6193..273950295dc 100644 --- a/src/gui/CMakeLists.txt +++ b/src/gui/CMakeLists.txt @@ -230,4 +230,10 @@ if(UNIX AND NOT APPLE) if(SharedMimeInfo_FOUND) update_xdg_mimetypes( ${KDE_INSTALL_DATADIR}/mime/packages ) endif(SharedMimeInfo_FOUND) + + option(BUNDLE_WL_COPY "Bundle wl-copy for self-contained builds such as AppImage" OFF) + if(BUNDLE_WL_COPY) + find_program(WL_COPY_EXECUTABLE wl-copy REQUIRED) + install(PROGRAMS ${WL_COPY_EXECUTABLE} DESTINATION ${KDE_INSTALL_BINDIR}) + endif() endif() diff --git a/src/gui/socketapi/socketapi.cpp b/src/gui/socketapi/socketapi.cpp index 1d1b8940740..ad06142adc9 100644 --- a/src/gui/socketapi/socketapi.cpp +++ b/src/gui/socketapi/socketapi.cpp @@ -38,6 +38,7 @@ #include #include #include +#include #include #include #include @@ -674,7 +675,11 @@ void SocketApi::command_OPEN_PRIVATE_LINK_VERSIONS(const QString &localFile, Soc void SocketApi::copyUrlToClipboard(const QUrl &link) { if (!qgetenv("WAYLAND_DISPLAY").isEmpty()) { - QProcess::startDetached(QStringLiteral("wl-copy"), {link.toString()}); + QString wlCopy = QApplication::applicationDirPath() + QStringLiteral("/wl-copy"); + if (!QFileInfo::exists(wlCopy)) { + wlCopy = QStringLiteral("wl-copy"); + } + QProcess::startDetached(wlCopy, {link.toString()}); } else { QApplication::clipboard()->setText(link.toString()); }