diff --git a/greeter/greeterapp.cpp b/greeter/greeterapp.cpp --- a/greeter/greeterapp.cpp +++ b/greeter/greeterapp.cpp @@ -53,6 +53,7 @@ #include #include #include +#include #include #include @@ -401,8 +402,18 @@ showProperty.write(true); // random state update, actually rather required on init only QMetaObject::invokeMethod(this, "getFocus", Qt::QueuedConnection); - QGuiApplication::clipboard()->clear(); - QGuiApplication::clipboard()->clear(QClipboard::Selection); + + auto mime1 = new QMimeData; + //this mime is chosen for two reasons. + //1) we need some non-empty non-text mimeData to replace the clipboard so we don't leak real data to a user pasting into the text field + //2) this specific hint means that klipper won't save this + mime1->setData(QStringLiteral("x-kde-passwordManagerHint"), QByteArrayLiteral("secret")); + //ownership is transferred + QGuiApplication::clipboard()->setMimeData(mime1, QClipboard::Clipboard); + + auto mime2 = new QMimeData; + mime2->setData(QStringLiteral("x-kde-passwordManagerHint"), QByteArrayLiteral("secret")); + QGuiApplication::clipboard()->setMimeData(mime2, QClipboard::Selection); } void UnlockApp::getFocus()