diff --git a/src/wayland/plasmawindowmanagement_interface.cpp b/src/wayland/plasmawindowmanagement_interface.cpp index e3626f4bfd..d3e4e3104f 100644 --- a/src/wayland/plasmawindowmanagement_interface.cpp +++ b/src/wayland/plasmawindowmanagement_interface.cpp @@ -23,7 +23,7 @@ namespace KWaylandServer { -static const quint32 s_version = 14; +static const quint32 s_version = 15; class PlasmaWindowManagementInterfacePrivate : public QtWaylandServer::org_kde_plasma_window_management { @@ -1020,4 +1020,51 @@ QString PlasmaWindowInterface::uuid() const return d->uuid; } +class PlasmaWindowActivationInterfacePrivate : public QtWaylandServer::org_kde_plasma_activation +{ +public: + PlasmaWindowActivationInterfacePrivate(PlasmaWindowActivationInterface *q) + : QtWaylandServer::org_kde_plasma_activation() + , q(q) + { + } + + PlasmaWindowActivationInterface *const q; +}; + +PlasmaWindowActivationInterface::PlasmaWindowActivationInterface() + : d(new PlasmaWindowActivationInterfacePrivate(this)) +{ +} + +PlasmaWindowActivationInterface::~PlasmaWindowActivationInterface() +{ + const auto clientResources = d->resourceMap(); + for (auto resource : clientResources) { + d->send_finished(resource->handle); + } +} + +void PlasmaWindowActivationInterface::sendAppId(const QString &appid) +{ + const auto clientResources = d->resourceMap(); + for (auto resource : clientResources) { + d->send_app_id(resource->handle, appid); + } +} + +KWaylandServer::PlasmaWindowActivationInterface *PlasmaWindowManagementInterface::createActivation(const QString &appid) +{ + auto activation = new PlasmaWindowActivationInterface; + const auto resources = d->resourceMap(); + for (auto resource : resources) { + if (resource->version() < ORG_KDE_PLASMA_WINDOW_MANAGEMENT_ACTIVATION_SINCE_VERSION) { + continue; + } + auto connection = activation->d->add(resource->client(), resource->version()); + d->send_activation(resource->handle, connection->handle); + } + activation->sendAppId(appid); + return activation; +} } diff --git a/src/wayland/plasmawindowmanagement_interface.h b/src/wayland/plasmawindowmanagement_interface.h index 48fd1e384f..562f872907 100644 --- a/src/wayland/plasmawindowmanagement_interface.h +++ b/src/wayland/plasmawindowmanagement_interface.h @@ -18,12 +18,24 @@ class Display; class PlasmaWindowInterface; class SurfaceInterface; class PlasmaVirtualDesktopManagementInterface; +class PlasmaWindowActivationInterfacePrivate; class PlasmaWindowManagementInterfacePrivate; class PlasmaWindowInterfacePrivate; -/** - * @todo Add documentation - */ +class KWAYLANDSERVER_EXPORT PlasmaWindowActivationInterface +{ +public: + ~PlasmaWindowActivationInterface(); + + void sendAppId(const QString &id); + +private: + friend class PlasmaWindowManagementInterface; + explicit PlasmaWindowActivationInterface(); + + QScopedPointer d; +}; + class KWAYLANDSERVER_EXPORT PlasmaWindowManagementInterface : public QObject { Q_OBJECT @@ -60,6 +72,14 @@ public: void setStackingOrderUuids(const QVector &stackingOrderUuids); + /** + * Notify about a new application with @p app_id being started + * + * @returns an instance of @class PlasmaWindowActivationInterface to + * be destroyed as the activation process ends. + */ + PlasmaWindowActivationInterface *createActivation(const QString &app_id); + Q_SIGNALS: void requestChangeShowingDesktop(ShowingDesktopState requestedState);