Commit dddf9d1a authored by Jan Blackquill's avatar Jan Blackquill 🌈
Browse files

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
parent cce8b0bc
......@@ -97,6 +97,8 @@ public:
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 @@ private:
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 @@ org_kde_plasma_window_listener PlasmaWindow::Private::s_listener = {
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 @@ bool PlasmaWindow::isVirtualDesktopChangeable() const
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,
......
......@@ -523,6 +523,21 @@ public:
*/
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 @@ Q_SIGNALS:
*/
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);
......
......@@ -17,7 +17,7 @@
along with this program. If not, see <http://www.gnu.org/licenses/>.
]]></copyright>
<interface name="org_kde_plasma_window_management" version="9">
<interface name="org_kde_plasma_window_management" version="10">
<description summary="application windows management">
This interface manages application windows.
It provides requests to show and hide the desktop and emits
......@@ -84,7 +84,7 @@
</event>
</interface>
<interface name="org_kde_plasma_window" version="8">
<interface name="org_kde_plasma_window" version="10">
<description summary="interface to control application windows">
Manages and control an application window.
......@@ -309,5 +309,16 @@
<arg name="is" type="string" summary="desktop id"/>
</event>
<!-- Version 10 additions -->
<event name="application_menu" since="10">
<description summary="notify the client that the current appmenu changed">
This event will be sent after the application menu
for the window has changed.
</description>
<arg name="service_name" type="string" />
<arg name="object_path" type="string" />
</event>
</interface>
</protocol>
......@@ -185,7 +185,7 @@ static const QMap<Registry::Interface, SuppertedInterfaceData> s_interfaces = {
&Registry::plasmaVirtualDesktopManagementRemoved
}},
{Registry::Interface::PlasmaWindowManagement, {
9,
10,
QByteArrayLiteral("org_kde_plasma_window_management"),
&org_kde_plasma_window_management_interface,
&Registry::plasmaWindowManagementAnnounced,
......
......@@ -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<wl_resource*> 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);
}
}
}
......@@ -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();
/**
......
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