Commit dba0f802 authored by David Rosca's avatar David Rosca

AppMenu: Don't call AboutToShow on LayoutUpdated

This workaround breaks applications that rely on aboutToShow/aboutToHide
signals, because it sends aboutToShow to all menus on startup without actually
the menu being opened.

BUG: 375053
FIXED-IN: 5.11.0

Differential Revision: https://phabricator.kde.org/D5705
parent 7bab7b63
......@@ -46,16 +46,11 @@ MenuImporter::MenuImporter(QObject* parent)
m_serviceWatcher->setConnection(QDBusConnection::sessionBus());
m_serviceWatcher->setWatchMode(QDBusServiceWatcher::WatchForUnregistration);
connect(m_serviceWatcher, &QDBusServiceWatcher::serviceUnregistered, this, &MenuImporter::slotServiceUnregistered);
QDBusConnection::sessionBus().connect(QString(), QString(), QStringLiteral("com.canonical.dbusmenu"), QStringLiteral("LayoutUpdated"),
this, SLOT(slotLayoutUpdated(uint,int)));
}
MenuImporter::~MenuImporter()
{
QDBusConnection::sessionBus().unregisterService(DBUS_SERVICE);
QDBusConnection::sessionBus().disconnect(QString(), QString(), QStringLiteral("com.canonical.dbusmenu"), QStringLiteral("LayoutUpdated"),
this, SLOT(slotLayoutUpdated(uint,int)));
}
bool MenuImporter::connectToBus()
......@@ -120,41 +115,3 @@ void MenuImporter::slotServiceUnregistered(const QString& service)
emit WindowUnregistered(id);
m_serviceWatcher->removeWatchedService(service);
}
void MenuImporter::slotLayoutUpdated(uint /*revision*/, int parentId)
{
// Fake unity-panel-service weird behavior of calling aboutToShow on
// startup. This is necessary for Firefox menubar to work correctly at
// startup.
// See: https://bugs.launchpad.net/plasma-idget-menubar/+bug/878165
if (parentId == 0) { //root menu
fakeUnityAboutToShow(message().service(), QDBusObjectPath(message().path()));
}
}
void MenuImporter::fakeUnityAboutToShow(const QString &service, const QDBusObjectPath &menuObjectPath)
{
QDBusMessage msg = QDBusMessage::createMethodCall(service, menuObjectPath.path(),
QStringLiteral("com.canonical.dbusmenu"),
QStringLiteral("GetLayout"));
msg.setArguments({0, 1, QStringList()});
QDBusPendingReply<uint, DBusMenuLayoutItem> reply = QDBusConnection::sessionBus().asyncCall(msg);
QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(reply, this);
QObject::connect(watcher, &QDBusPendingCallWatcher::finished, this, [=](QDBusPendingCallWatcher *watcher) {
QDBusPendingReply<uint, DBusMenuLayoutItem> reply = *watcher;
if (reply.isError()) {
qWarning() << "Call to GetLayout failed:" << reply.error().message();
} else {
const DBusMenuLayoutItem &root = reply.argumentAt<1>();
for (const auto &item : root.children) {
QDBusMessage msg = QDBusMessage::createMethodCall(service, menuObjectPath.path(), QStringLiteral("com.canonical.dbusmenu"), QStringLiteral("AboutToShow"));
msg.setArguments({item.id});
QDBusConnection::sessionBus().asyncCall(msg);
}
}
watcher->deleteLater();
});
}
......@@ -57,8 +57,6 @@ public:
QList<WId> ids() { return m_menuServices.keys(); }
void fakeUnityAboutToShow(const QString &service, const QDBusObjectPath &menuObjectPath);
Q_SIGNALS:
void WindowRegistered(WId id, const QString& service, const QDBusObjectPath&);
void WindowUnregistered(WId id);
......@@ -70,7 +68,6 @@ public Q_SLOTS:
private Q_SLOTS:
void slotServiceUnregistered(const QString& service);
void slotLayoutUpdated(uint revision, int parentId);
private:
QDBusServiceWatcher* m_serviceWatcher;
......
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