From bc5d8e68170900caacd98b799bd80471a9284e52 Mon Sep 17 00:00:00 2001 From: Lukas Holecek Date: Wed, 17 Apr 2024 12:33:17 +0200 Subject: [PATCH] Linux: Fix storing previously synchronized clipboard Fixes #2630 --- src/app/clipboardmonitor.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/app/clipboardmonitor.cpp b/src/app/clipboardmonitor.cpp index ee6587fe8..0d9b6accb 100644 --- a/src/app/clipboardmonitor.cpp +++ b/src/app/clipboardmonitor.cpp @@ -22,6 +22,17 @@ namespace { bool hasSameData(const QVariantMap &data, const QVariantMap &lastData) { + // Detect change also in case the data is unchanged but previously copied + // by CopyQ and now externally. This solves storing a copied text which was + // previously synchronized from selection to clipboard via CopyQ. + if ( + !lastData.value(mimeOwner).toByteArray().isEmpty() + && data.value(mimeOwner).toByteArray().isEmpty() + ) + { + return false; + } + for (auto it = lastData.constBegin(); it != lastData.constEnd(); ++it) { const auto &format = it.key(); if ( !format.startsWith(COPYQ_MIME_PREFIX)