Commit 778ee5f5 authored by David Edmundson's avatar David Edmundson

Update AppMenu for an app having multiple windows

parent 189a19f4
......@@ -361,11 +361,11 @@ QPlatformMenuBar *KdePlatformTheme::createPlatformMenuBar() const
if (m_kwaylandIntegration) {
if (oldWindow) {
m_kwaylandIntegration->setAppMenu(QString(), QString());
m_kwaylandIntegration->setAppMenu(oldWindow, QString(), QString());
}
if (newWindow) {
m_kwaylandIntegration->setAppMenu(serviceName, objectPath);
m_kwaylandIntegration->setAppMenu(newWindow, serviceName, objectPath);
}
}
});
......
......@@ -140,7 +140,7 @@ void KWaylandIntegration::shellSurfaceCreated(QWindow *w)
if (m_appMenuManager) {
auto menu = m_appMenuManager->create(s, w);
w->setProperty("org.kde.plasma.integration.appmenu", QVariant::fromValue(menu));
menu->setAddress(m_appMenuServiceName, m_appMenuObjectPath);
menu->setAddress(m_windowInfo[w].appMenuServiceName, m_windowInfo[w].appMenuObjectPath);
}
}
......@@ -171,11 +171,16 @@ void KWaylandIntegration::setWindowProperty(QWindow *window, const QByteArray &n
}
}
void KWaylandIntegration::setAppMenu(const QString &serviceName, const QString &objectPath)
void KWaylandIntegration::setAppMenu(QWindow *window, const QString &serviceName, const QString &objectPath)
{
m_appMenuServiceName = serviceName;
m_appMenuObjectPath = objectPath;
auto menu = property("org.kde.plasma.integration.appmenu").value<AppMenu*>();
if (!m_windowInfo.contains(window)) { //effectively makes this connect unique
connect(window, &QObject::destroyed, this, [=]() {
m_windowInfo.remove(window);
});
}
m_windowInfo[window].appMenuServiceName = serviceName;
m_windowInfo[window].appMenuObjectPath = objectPath;
auto menu = window->property("org.kde.plasma.integration.appmenu").value<AppMenu*>();
if (menu) {
menu->setAddress(serviceName, objectPath);
}
......
......@@ -21,6 +21,7 @@
#define KWAYLANDINTEGRATION_H
#include <QObject>
#include <QHash>
class QWindow;
......@@ -42,7 +43,7 @@ public:
void init();
void setWindowProperty(QWindow *window, const QByteArray &name, const QByteArray &value);
void setAppMenu(const QString &serviceName, const QString &objectPath);
void setAppMenu(QWindow *window, const QString &serviceName, const QString &objectPath);
bool eventFilter(QObject *watched, QEvent *event) override;
......@@ -54,8 +55,11 @@ private:
KWayland::Client::ServerSideDecorationManager *m_decoration = nullptr;
KWayland::Client::AppMenuManager *m_appMenuManager = nullptr;
QString m_appMenuServiceName;
QString m_appMenuObjectPath;
struct WindowInfo {
QString appMenuServiceName;
QString appMenuObjectPath;
};
QHash<QWindow*, WindowInfo> m_windowInfo;
};
#endif
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