From 31e149d3d212073f5d40e12c595c7a3ca2b07a8c Mon Sep 17 00:00:00 2001 From: tsic404 Date: Wed, 10 Jan 2024 16:45:40 +0800 Subject: [PATCH] fix: dock get stucked when launching org.ayatana.bamf dbus will get into stucked, so only call it when it's ready log: only call org.ayatana.bamf when it's ready issue: https://github.com/linuxdeepin/developer-center/issues/6657 --- frame/taskmanager/windowidentify.cpp | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/frame/taskmanager/windowidentify.cpp b/frame/taskmanager/windowidentify.cpp index b9014b024..25c6e4ac4 100644 --- a/frame/taskmanager/windowidentify.cpp +++ b/frame/taskmanager/windowidentify.cpp @@ -13,7 +13,7 @@ #include #include -#include +#include #define XCB XCBUtils::instance() @@ -74,11 +74,28 @@ WindowIdentify::WindowIdentify(TaskManager *_taskmanager, QObject *parent) m_identifyWindowFuns << qMakePair(QString("FlatpakAppID"), &identifyWindowByFlatpakAppID); m_identifyWindowFuns << qMakePair(QString("CrxId"), &identifyWindowByCrxId); m_identifyWindowFuns << qMakePair(QString("Rule"), &identifyWindowByRule); - m_identifyWindowFuns << qMakePair(QString("Bamf"), &identifyWindowByBamf); m_identifyWindowFuns << qMakePair(QString("Pid"), &identifyWindowByPid); m_identifyWindowFuns << qMakePair(QString("Scratch"), &identifyWindowByScratch); m_identifyWindowFuns << qMakePair(QString("GtkAppId"), &identifyWindowByGtkAppId); m_identifyWindowFuns << qMakePair(QString("WmClass"), &identifyWindowByWmClass); + + // should remove bamf identify and turn to new AM + auto *dbusWatcher = new QDBusServiceWatcher(QStringLiteral("org.ayatana.bamf"), QDBusConnection::sessionBus(), + QDBusServiceWatcher::WatchForOwnerChange, this); + + auto ifc = QDBusConnection::sessionBus().interface(); + + if (ifc->isServiceRegistered(QStringLiteral("org.ayatana.bamf"))) { + m_identifyWindowFuns << qMakePair(QString("Bamf"), &identifyWindowByBamf); + } + + connect(dbusWatcher, &QDBusServiceWatcher::serviceRegistered, this, [this](){ + m_identifyWindowFuns << qMakePair(QString("Bamf"), &identifyWindowByBamf); + }); + + connect(dbusWatcher, &QDBusServiceWatcher::serviceUnregistered, this, [this](){ + m_identifyWindowFuns.removeAll(qMakePair(QString("Bamf"), &identifyWindowByBamf)); + }); } AppInfo *WindowIdentify::identifyWindow(WindowInfoBase *winInfo, QString &innerId)