diff --git a/src/client/plasmawindowmanagement.h b/src/client/plasmawindowmanagement.h --- a/src/client/plasmawindowmanagement.h +++ b/src/client/plasmawindowmanagement.h @@ -523,6 +523,21 @@ */ QStringList plasmaVirtualDesktops() const; + /** + * Return the D-BUS service name for a window's + * application menu. + * + * @since 5.69 + */ + QString applicationMenuServiceName() const; + /** + * Return the D-BUS object path to a windows's + * application menu. + * + * @since 5.69 + */ + QString applicationMenuObjectPath() const; + Q_SIGNALS: /** * The window title changed. @@ -681,6 +696,14 @@ */ void plasmaVirtualDesktopLeft(const QString &id); + /** + * This signal is emitted when either the D-BUS service name or + * object path for the window's application menu changes. + * + * @since 5.69 + **/ + void applicationMenuChanged(); + private: friend class PlasmaWindowManagement; explicit PlasmaWindow(PlasmaWindowManagement *parent, org_kde_plasma_window *dataOffer, quint32 internalId); diff --git a/src/client/plasmawindowmanagement.cpp b/src/client/plasmawindowmanagement.cpp --- a/src/client/plasmawindowmanagement.cpp +++ b/src/client/plasmawindowmanagement.cpp @@ -97,6 +97,8 @@ QStringList plasmaVirtualDesktops; QRect geometry; quint32 pid = 0; + QString applicationMenuServiceName; + QString applicationMenuObjectPath; private: static void titleChangedCallback(void *data, org_kde_plasma_window *window, const char *title); @@ -112,6 +114,7 @@ static void iconChangedCallback(void *data, org_kde_plasma_window *org_kde_plasma_window); static void virtualDesktopEnteredCallback(void *data, org_kde_plasma_window *org_kde_plasma_window, const char *id); static void virtualDesktopLeftCallback(void *data, org_kde_plasma_window *org_kde_plasma_window, const char *id); + static void appmenuChangedCallback(void *data, org_kde_plasma_window *org_kde_plasma_window, const char *service_name, const char *object_path); void setActive(bool set); void setMinimized(bool set); void setMaximized(bool set); @@ -353,9 +356,22 @@ iconChangedCallback, pidChangedCallback, virtualDesktopEnteredCallback, - virtualDesktopLeftCallback + virtualDesktopLeftCallback, + appmenuChangedCallback }; +void PlasmaWindow::Private::appmenuChangedCallback(void *data, org_kde_plasma_window *window, const char *service_name, const char *object_path) +{ + Q_UNUSED(window) + + Private *p = cast(data); + + p->applicationMenuServiceName = QString::fromUtf8(service_name); + p->applicationMenuObjectPath = QString::fromUtf8(object_path); + + emit p->q->applicationMenuChanged(); +} + void PlasmaWindow::Private::parentWindowCallback(void *data, org_kde_plasma_window *window, org_kde_plasma_window *parent) { Q_UNUSED(window) @@ -928,6 +944,16 @@ return d->virtualDesktopChangeable; } +QString PlasmaWindow::applicationMenuObjectPath() const +{ + return d->applicationMenuObjectPath; +} + +QString PlasmaWindow::applicationMenuServiceName() const +{ + return d->applicationMenuServiceName; +} + void PlasmaWindow::requestActivate() { org_kde_plasma_window_set_state(d->window, diff --git a/src/client/protocols/plasma-window-management.xml b/src/client/protocols/plasma-window-management.xml --- a/src/client/protocols/plasma-window-management.xml +++ b/src/client/protocols/plasma-window-management.xml @@ -17,7 +17,7 @@ along with this program. If not, see . ]]> - + This interface manages application windows. It provides requests to show and hide the desktop and emits @@ -84,7 +84,7 @@ - + Manages and control an application window. @@ -309,5 +309,16 @@ + + + + + This event will be sent after the application menu + for the window has changed. + + + + + diff --git a/src/client/registry.cpp b/src/client/registry.cpp --- a/src/client/registry.cpp +++ b/src/client/registry.cpp @@ -185,7 +185,7 @@ &Registry::plasmaVirtualDesktopManagementRemoved }}, {Registry::Interface::PlasmaWindowManagement, { - 9, + 10, QByteArrayLiteral("org_kde_plasma_window_management"), &org_kde_plasma_window_management_interface, &Registry::plasmaWindowManagementAnnounced, diff --git a/src/server/plasmawindowmanagement_interface.h b/src/server/plasmawindowmanagement_interface.h --- a/src/server/plasmawindowmanagement_interface.h +++ b/src/server/plasmawindowmanagement_interface.h @@ -228,6 +228,13 @@ */ 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(); /** diff --git a/src/server/plasmawindowmanagement_interface.cpp b/src/server/plasmawindowmanagement_interface.cpp --- a/src/server/plasmawindowmanagement_interface.cpp +++ b/src/server/plasmawindowmanagement_interface.cpp @@ -82,6 +82,7 @@ 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 @@ 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::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 @@ d->setGeometry(geometry); } +void PlasmaWindowInterface::setApplicationMenuPaths(const QString &serviceName, const QString &objectPath) +{ + d->setApplicationMenuPaths(serviceName, objectPath); +} + } }