File 0031-Hide-menu-if-the-menu-disappears-off-DBus.patch of Package plasma5-workspace
From 727f407a18d6dbe34f90decedc0eea5811a0c1a9 Mon Sep 17 00:00:00 2001
From: David Edmundson <kde@davidedmundson.co.uk>
Date: Tue, 17 Jan 2017 19:36:35 +0000
Subject: [PATCH 31/44] Hide menu if the menu disappears off DBus
Summary:
This can happen without a focus change if focus is changed to a window
that doesn't claim the menu, for example the desktop.
It could also happen if an application does something weird, like
release
its service name.
BUG: 374995
Test Plan:
Ran "sleep 10; killall kate"
Then selected kate then the desktop
Kate remained showing for 10 seconds then closed
Reviewers: #plasma
Subscribers: plasma-devel
Tags: #plasma
Differential Revision: https://phabricator.kde.org/D4177
---
applets/appmenu/plugin/appmenumodel.cpp | 15 ++++++++++++++-
1 file changed, 14 insertions(+), 1 deletion(-)
diff --git a/applets/appmenu/plugin/appmenumodel.cpp b/applets/appmenu/plugin/appmenumodel.cpp
index aa0b1e4d..62f6e80d 100644
--- a/applets/appmenu/plugin/appmenumodel.cpp
+++ b/applets/appmenu/plugin/appmenumodel.cpp
@@ -32,6 +32,9 @@
#include <QAction>
#include <QMenu>
+#include <QDebug>
+#include <QDBusConnection>
+#include <QDBusConnectionInterface>
#include <dbusmenuimporter.h>
@@ -62,6 +65,16 @@ AppMenuModel::AppMenuModel(QObject *parent)
connect(KWindowSystem::self(), &KWindowSystem::activeWindowChanged, this, &AppMenuModel::onActiveWindowChanged);
connect(this, &AppMenuModel::modelNeedsUpdate, this, &AppMenuModel::update, Qt::UniqueConnection);
onActiveWindowChanged(KWindowSystem::activeWindow());
+
+ //if our current DBus connection gets lost, close the menu
+ //we'll select the new menu when the focus changes
+ connect(QDBusConnection::sessionBus().interface(), &QDBusConnectionInterface::serviceOwnerChanged, this, [this](const QString &serviceName, const QString &oldOwner, const QString &newOwner)
+ {
+ if (serviceName == m_serviceName && newOwner.isEmpty()) {
+ setMenuAvailable(false);
+ emit modelNeedsUpdate();
+ }
+ });
}
AppMenuModel::~AppMenuModel() = default;
@@ -246,5 +259,5 @@ void AppMenuModel::updateApplicationMenu(const QString &serviceName, const QStri
setMenuAvailable(true);
emit modelNeedsUpdate();
});
-
}
+
--
2.12.0