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
wilder-5.24
David Edmundson 4 years ago committed by Nate Graham
parent 63bea079c5
commit e55c2744cd
  1. 5
      applets/systemtray/statusnotifieritemjob.cpp

@ -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();
}

Loading…
Cancel
Save