From 2d1d7daf8293194203e64bf121a3ef23b3d50e04 Mon Sep 17 00:00:00 2001 From: Ivailo Monev Date: Sun, 3 Sep 2023 00:46:58 +0300 Subject: [PATCH] kio: drop fake startup notification support silent_arg was used to fake startup notification for non-compliant applications, that shall not be the case anymore - when applications do not claim startup notification support or it is simply disabled for specific use case (as is done by ark for its service actions) then there shall be no startup notification, silent or otherwise Signed-off-by: Ivailo Monev --- kinit/klauncher_adaptor.cpp | 4 +- kio/kio/krun.cpp | 76 +++++++++++++++---------------------- kio/kio/krun.h | 4 +- 3 files changed, 34 insertions(+), 50 deletions(-) diff --git a/kinit/klauncher_adaptor.cpp b/kinit/klauncher_adaptor.cpp index ecdb21d3..7b57ba04 100644 --- a/kinit/klauncher_adaptor.cpp +++ b/kinit/klauncher_adaptor.cpp @@ -74,9 +74,8 @@ void KLauncherProcess::setupStartup(const QByteArray &startup_id, const QString const KService::Ptr kservice, const qint64 timeout) { Q_ASSERT(m_kstartupinfoid.none() == true); - bool startupsilent = false; QByteArray startupwmclass; - if (KRun::checkStartupNotify(kservice.data(), &startupsilent, &startupwmclass)) { + if (KRun::checkStartupNotify(kservice.data(), &startupwmclass)) { m_kstartupinfoid.initId(!isASNValid(startup_id) ? KStartupInfo::createNewStartupId() : startup_id); kDebug() << "setting up ASN for" << kservice->entryPath() << m_kstartupinfoid.id(); m_kstartupinfodata.setHostname(); @@ -84,7 +83,6 @@ void KLauncherProcess::setupStartup(const QByteArray &startup_id, const QString m_kstartupinfodata.setDescription(i18n("Launching %1", kservice->name())); m_kstartupinfodata.setIcon(kservice->icon()); m_kstartupinfodata.setApplicationId(kservice->entryPath()); - m_kstartupinfodata.setSilent(startupsilent ? KStartupInfoData::Yes : KStartupInfoData::No); m_kstartupinfodata.setWMClass(startupwmclass); QProcessEnvironment processenv = QProcess::processEnvironment(); processenv.insert(QString::fromLatin1("DESKTOP_STARTUP_ID"), m_kstartupinfoid.id()); diff --git a/kio/kio/krun.cpp b/kio/kio/krun.cpp index 5adc08d4..da6f534e 100644 --- a/kio/kio/krun.cpp +++ b/kio/kio/krun.cpp @@ -533,11 +533,10 @@ static bool runCommandInternal(KProcess* proc, const KService* service, const QS } QString bin = KRun::binaryName(executable, true); -#ifdef Q_WS_X11 // Startup notification doesn't work with QT/E, service isn't needed without Startup notification - bool silent; +#ifdef Q_WS_X11 QByteArray wmclass; KStartupInfoId id; - bool startup_notify = (asn != "0" && KRun::checkStartupNotify(service, &silent, &wmclass)); + bool startup_notify = (asn != "0" && KRun::checkStartupNotify(service, &wmclass)); if (startup_notify) { id.initId(asn); id.setupStartupEnv(); @@ -558,9 +557,6 @@ static bool runCommandInternal(KProcess* proc, const KService* service, const QS if (!wmclass.isEmpty()) { data.setWMClass(wmclass); } - if (silent) { - data.setSilent(KStartupInfoData::Yes); - } data.setDesktop(KWindowSystem::currentDesktop()); if(service && !service->entryPath().isEmpty()) data.setApplicationId(service->entryPath()); @@ -582,59 +578,49 @@ static bool runCommandInternal(KProcess* proc, const KService* service, const QS } // This code is also used in klauncher. -bool KRun::checkStartupNotify(const KService* service, bool* silent_arg, QByteArray* wmclass_arg) +bool KRun::checkStartupNotify(const KService *service, QByteArray *wmclass_arg) { if (!service || service->entryPath().isEmpty()) { - // non-compliant app or service action + // non-compliant app or service action - // TODO: for service actions (and other KService's crafted from the name, exec and icon) - // get the ASN property from the "Desktop Entry" group in the .desktop file somehow - return false; + // TODO: for service actions (and other KService's crafted from the name, exec and icon) + // get the ASN property from the "Desktop Entry" group in the .desktop file somehow + return false; } - bool silent = false; - QByteArray wmclass; - if (service->property("StartupNotify").isValid()) { - silent = !service->property("StartupNotify").toBool(); - wmclass = service->property("StartupWMClass").toString().toLatin1(); + if (service->property("StartupNotify").toBool() != true) { + // nope + return false; + } - // NOTE: this is using spec properties but probably not for the purpose the properties were - // ment for - if (service->property("SingleMainWindow").toBool()) { - const QStringList implements = service->property("Implements").toStringList(); - if (!implements.isEmpty()) { - // TODO: where is the interface supposed to be registered? - QDBusConnectionInterface* dbusconnectioninterface = QDBusConnection::sessionBus().interface(); - if (dbusconnectioninterface) { - QDBusReply implementedreply; - foreach (const QString &implemented, implements) { - implementedreply = dbusconnectioninterface->isServiceRegistered(implemented); - if (implementedreply.isValid() && implementedreply.value() == true) { - kDebug(7010) << "implemented interface" << implemented << ", disabling startup notification"; - return false; - } + QByteArray wmclass = service->property("StartupWMClass").toString().toLatin1(); + + // NOTE: this is using spec properties but probably not for the purpose the properties were + // ment for + if (service->property("SingleMainWindow").toBool()) { + const QStringList implements = service->property("Implements").toStringList(); + if (!implements.isEmpty()) { + // TODO: where is the interface supposed to be registered? + QDBusConnectionInterface* dbusconnectioninterface = QDBusConnection::sessionBus().interface(); + if (dbusconnectioninterface) { + QDBusReply implementedreply; + foreach (const QString &implemented, implements) { + implementedreply = dbusconnectioninterface->isServiceRegistered(implemented); + if (implementedreply.isValid() && implementedreply.value() == true) { + kDebug(7010) << "implemented interface" << implemented << ", disabling startup notification"; + return false; } - } else { - kDebug(7010) << "null D-Bus connection interface"; } + } else { + kDebug(7010) << "null D-Bus connection interface"; } } - } else { - // non-compliant app - if (service->isApplication()) { - // doesn't have .desktop entries needed, start as non-compliant - silent = true; - wmclass = "0"; - } else { - return false; // no startup notification at all - } - } - if (silent_arg != NULL) { - *silent_arg = silent; } + if (wmclass_arg != NULL) { *wmclass_arg = wmclass; } + return true; } diff --git a/kio/kio/krun.h b/kio/kio/krun.h index d6e946e0..ba7497e2 100644 --- a/kio/kio/krun.h +++ b/kio/kio/krun.h @@ -327,12 +327,12 @@ public: * @endcode * to the mimetype's desktop file. */ - static bool isExecutableFile(const KUrl& url, const QString &mimetype); + static bool isExecutableFile(const KUrl &url, const QString &mimetype); /** * @internal */ - static bool checkStartupNotify(const KService* service, bool* silent_arg, QByteArray* wmclass_arg); + static bool checkStartupNotify(const KService *service, QByteArray *wmclass_arg); Q_SIGNALS: /**