Skip to content

Commit

Permalink
Force clear clipboard on Wayland
Browse files Browse the repository at this point in the history
* Fixes #4498
  • Loading branch information
droidmonkey committed Apr 29, 2024
1 parent f812f0a commit 04fac24
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/gui/Clipboard.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
#include <QApplication>
#include <QClipboard>
#include <QMimeData>
#include <QProcess>
#include <QTimer>

#include "core/Config.h"
Expand Down Expand Up @@ -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();
Expand Down

0 comments on commit 04fac24

Please sign in to comment.