Commit e55c2744 authored by David Edmundson's avatar David Edmundson Committed by Nate Graham
Browse files

Disconnect watcher for xdgActivationTokenArrived

XdgActivationTokens are loaded async. To acheive a job like pattern we
were comparing serials in our slot when one was created.

On wayland this isn't ideal because we're slowly building up an
increasibly long list of lambdas being run, but they'll all no-op.

On X11 because lastInputSerial is always 0 we run the slot multiple
times for every system tray item each time an item is clicked or an
application is launched.

For xembedsniproxy this is especially problematic problematic as we will
trigger synthesised input events in our slot.

BUG: 444385
parent 63bea079
......@@ -7,6 +7,7 @@
#include "statusnotifieritemjob.h"
#include <KWindowSystem>
#include <QSharedPointer>
StatusNotifierItemJob::StatusNotifierItemJob(StatusNotifierItemSource *source, const QString &operation, QMap<QString, QVariant> &parameters, QObject *parent)
: ServiceJob(source->objectName(), operation, parameters, parent)
......@@ -30,8 +31,10 @@ void StatusNotifierItemJob::start()
QWindow *window = nullptr;
const quint32 launchedSerial = KWindowSystem::lastInputSerial(window);
connect(KWindowSystem::self(), &KWindowSystem::xdgActivationTokenArrived, this, [this, launchedSerial](quint32 serial, const QString &token) {
auto conn = QSharedPointer<QMetaObject::Connection>::create();
*conn = connect(KWindowSystem::self(), &KWindowSystem::xdgActivationTokenArrived, this, [this, launchedSerial, conn](quint32 serial, const QString &token) {
if (serial == launchedSerial) {
disconnect(*conn);
m_source->provideXdgActivationToken(token);
performJob();
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment