From 56e26801224d093ab5c414702841ff4969d5ae12 Mon Sep 17 00:00:00 2001 From: Carson Black Date: Wed, 19 Feb 2020 21:20:51 -0500 Subject: [PATCH] Add application menu dbus paths to org_kde_plasma_window interface Summary: This patch adds an interface allowing a compositor to send the service name and object path of a PlasmaWindow's application menu to the client. Reviewers: #kwin, zzag, davidedmundson Reviewed By: #kwin, zzag, davidedmundson Subscribers: davidedmundson, kde-frameworks-devel Tags: #frameworks Differential Revision: https://phabricator.kde.org/D27464 --- .../plasmawindowmanagement_interface.cpp | 19 ++++++++++++++++++- .../plasmawindowmanagement_interface.h | 7 +++++++ 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/src/wayland/plasmawindowmanagement_interface.cpp b/src/wayland/plasmawindowmanagement_interface.cpp index 040d890123..57f49e2e6c 100644 --- a/src/wayland/plasmawindowmanagement_interface.cpp +++ b/src/wayland/plasmawindowmanagement_interface.cpp @@ -82,6 +82,7 @@ public: void setState(org_kde_plasma_window_management_state flag, bool set); void setParentWindow(PlasmaWindowInterface *parent); void setGeometry(const QRect &geometry); + void setApplicationMenuPaths(const QString &service, const QString &object); wl_resource *resourceForParent(PlasmaWindowInterface *parent, wl_resource *child) const; QVector resources; @@ -125,7 +126,7 @@ private: static const struct org_kde_plasma_window_interface s_interface; }; -const quint32 PlasmaWindowManagementInterface::Private::s_version = 9; +const quint32 PlasmaWindowManagementInterface::Private::s_version = 10; PlasmaWindowManagementInterface::Private::Private(PlasmaWindowManagementInterface *q, Display *d) : Global::Private(d, &org_kde_plasma_window_management_interface, s_version) @@ -588,6 +589,17 @@ void PlasmaWindowInterface::Private::setGeometry(const QRect &geo) } } +void PlasmaWindowInterface::Private::setApplicationMenuPaths(const QString &service, const QString &object) +{ + for (auto it = resources.constBegin(); it != resources.constEnd(); ++it) { + auto resource = *it; + if (wl_resource_get_version(resource) < ORG_KDE_PLASMA_WINDOW_APPLICATION_MENU_SINCE_VERSION) { + continue; + } + org_kde_plasma_window_send_application_menu(resource, qUtf8Printable(service), qUtf8Printable(object)); + } +} + void PlasmaWindowInterface::Private::closeCallback(wl_client *client, wl_resource *resource) { Q_UNUSED(client) @@ -946,5 +958,10 @@ void PlasmaWindowInterface::setGeometry(const QRect &geometry) d->setGeometry(geometry); } +void PlasmaWindowInterface::setApplicationMenuPaths(const QString &serviceName, const QString &objectPath) +{ + d->setApplicationMenuPaths(serviceName, objectPath); +} + } } diff --git a/src/wayland/plasmawindowmanagement_interface.h b/src/wayland/plasmawindowmanagement_interface.h index 8b226182ca..5c0743c7eb 100644 --- a/src/wayland/plasmawindowmanagement_interface.h +++ b/src/wayland/plasmawindowmanagement_interface.h @@ -228,6 +228,13 @@ public: */ QStringList plasmaVirtualDesktops() const; + /** + * Set the application menu D-BUS service name and object path for the window. + * + * @since 5.69 + */ + void setApplicationMenuPaths(const QString &serviceName, const QString &objectPath); + Q_SIGNALS: void closeRequested(); /**