From 129e2526b7fe8dd0df8b5a6a83475946f3333f06 Mon Sep 17 00:00:00 2001 From: Benjamin Port Date: Tue, 21 Apr 2020 16:50:51 +0200 Subject: [PATCH] [Wayland] Add to PlasmaWindowManagement protocol windows stacking order Reviewers: zzag, davidedmundson Subscribers: kde-frameworks-devel Tags: #frameworks Differential Revision: https://phabricator.kde.org/D29054 --- .../plasmawindowmanagement_interface.cpp | 45 ++++++++++++++++++- .../plasmawindowmanagement_interface.h | 14 ++++++ 2 files changed, 58 insertions(+), 1 deletion(-) diff --git a/src/wayland/plasmawindowmanagement_interface.cpp b/src/wayland/plasmawindowmanagement_interface.cpp index 0dccda9773..3a0e846290 100644 --- a/src/wayland/plasmawindowmanagement_interface.cpp +++ b/src/wayland/plasmawindowmanagement_interface.cpp @@ -31,12 +31,14 @@ class PlasmaWindowManagementInterface::Private : public Global::Private public: Private(PlasmaWindowManagementInterface *q, Display *d); void sendShowingDesktopState(); + void sendStackingOrderChanged(); ShowingDesktopState state = ShowingDesktopState::Disabled; QVector resources; QList windows; QPointer plasmaVirtualDesktopManagementInterface = nullptr; quint32 windowIdCounter = 0; + QVector stackingOrder; private: static void unbind(wl_resource *resource); @@ -45,6 +47,7 @@ private: void bind(wl_client *client, uint32_t version, uint32_t id) override; void sendShowingDesktopState(wl_resource *r); + void sendStackingOrderChanged(wl_resource *r); PlasmaWindowManagementInterface *q; static const struct org_kde_plasma_window_management_interface s_interface; @@ -113,7 +116,7 @@ private: static const struct org_kde_plasma_window_interface s_interface; }; -const quint32 PlasmaWindowManagementInterface::Private::s_version = 10; +const quint32 PlasmaWindowManagementInterface::Private::s_version = 11; PlasmaWindowManagementInterface::Private::Private(PlasmaWindowManagementInterface *q, Display *d) : Global::Private(d, &org_kde_plasma_window_management_interface, s_version) @@ -152,6 +155,30 @@ void PlasmaWindowManagementInterface::Private::sendShowingDesktopState(wl_resour org_kde_plasma_window_management_send_show_desktop_changed(r, s); } +void PlasmaWindowManagementInterface::Private::sendStackingOrderChanged() +{ + for (wl_resource *r : resources) { + sendStackingOrderChanged(r); + } +} + +void PlasmaWindowManagementInterface::Private::sendStackingOrderChanged(wl_resource *r) +{ + if (wl_resource_get_version(r) < ORG_KDE_PLASMA_WINDOW_MANAGEMENT_STACKING_ORDER_CHANGED_SINCE_VERSION) { + return; + } + + wl_array wlIds; + wl_array_init(&wlIds); + const size_t memLength = sizeof(uint32_t) * stackingOrder.size(); + void *s = wl_array_add(&wlIds, memLength); + memcpy(s, stackingOrder.data(), memLength); + + org_kde_plasma_window_management_send_stacking_order_changed(r, &wlIds); + + wl_array_release(&wlIds); +} + void PlasmaWindowManagementInterface::Private::showDesktopCallback(wl_client *client, wl_resource *resource, uint32_t state) { Q_UNUSED(client) @@ -207,6 +234,7 @@ void PlasmaWindowManagementInterface::Private::bind(wl_client *client, uint32_t for (auto it = windows.constBegin(); it != windows.constEnd(); ++it) { org_kde_plasma_window_management_send_window(shell, (*it)->d->windowId); } + sendStackingOrderChanged(); } void PlasmaWindowManagementInterface::Private::unbind(wl_resource *resource) @@ -266,6 +294,16 @@ void PlasmaWindowManagementInterface::unmapWindow(PlasmaWindowInterface *window) window->d->unmap(); } +void PlasmaWindowManagementInterface::setStackingOrder(const QVector& stackingOrder) +{ + Q_D(); + if (d->stackingOrder == stackingOrder) { + return; + } + d->stackingOrder = stackingOrder; + d->sendStackingOrderChanged(); +} + void PlasmaWindowManagementInterface::setPlasmaVirtualDesktopManagementInterface(PlasmaVirtualDesktopManagementInterface *manager) { Q_D(); @@ -958,5 +996,10 @@ void PlasmaWindowInterface::setApplicationMenuPaths(const QString &serviceName, d->setApplicationMenuPaths(serviceName, objectPath); } +quint32 PlasmaWindowInterface::internalId() const +{ + return d->windowId; +} + } } diff --git a/src/wayland/plasmawindowmanagement_interface.h b/src/wayland/plasmawindowmanagement_interface.h index 65f37fd7a7..7fe20e5721 100644 --- a/src/wayland/plasmawindowmanagement_interface.h +++ b/src/wayland/plasmawindowmanagement_interface.h @@ -73,6 +73,13 @@ public: */ PlasmaVirtualDesktopManagementInterface *plasmaVirtualDesktopManagementInterface() const; + + /** + * Associate stacking order to this window management + * @since 5.70 + */ + void setStackingOrder(const QVector &stackingOrder); + Q_SIGNALS: void requestChangeShowingDesktop(ShowingDesktopState requestedState); @@ -221,6 +228,13 @@ public: */ void setApplicationMenuPaths(const QString &serviceName, const QString &objectPath); + /** + * Return the window internal id + * + * @since 5.70 + */ + quint32 internalId() const; + Q_SIGNALS: void closeRequested(); /**