Force clear clipboard on Wayland

* Fixes #4498
This commit is contained in:
Jonathan White 2024-04-24 07:40:23 -04:00
parent f812f0a1ac
commit 04fac249f9

View File

@ -21,6 +21,7 @@
#include <QApplication>
#include <QClipboard>
#include <QMimeData>
#include <QProcess>
#include <QTimer>
#include "core/Config.h"
@ -101,6 +102,12 @@ void Clipboard::clearCopiedText()
|| m_lastCopied == clipboard->text(QClipboard::Selection)) {
clipboard->clear(QClipboard::Clipboard);
clipboard->clear(QClipboard::Selection);
#ifdef Q_OS_UNIX
// Gnome Wayland doesn't let apps modify the clipboard when not in focus, so force clear
if (QProcessEnvironment::systemEnvironment().contains("WAYLAND_DISPLAY")) {
QProcess::startDetached("wl-copy", {"-c"});
}
#endif
}
m_lastCopied.clear();