Decouple activation feedback from plasma window management global

This commit is contained in:
Vlad Zahorodnii 2021-08-22 12:43:03 +03:00
parent 773995de56
commit 2b3e8d6775
2 changed files with 66 additions and 25 deletions

View file

@ -23,7 +23,8 @@
namespace KWaylandServer namespace KWaylandServer
{ {
static const quint32 s_version = 15; static const quint32 s_version = 14;
static const quint32 s_activationVersion = 1;
class PlasmaWindowManagementInterfacePrivate : public QtWaylandServer::org_kde_plasma_window_management class PlasmaWindowManagementInterfacePrivate : public QtWaylandServer::org_kde_plasma_window_management
{ {
@ -1020,6 +1021,15 @@ QString PlasmaWindowInterface::uuid() const
return d->uuid; return d->uuid;
} }
class PlasmaWindowActivationFeedbackInterfacePrivate : public QtWaylandServer::org_kde_plasma_activation_feedback
{
public:
PlasmaWindowActivationFeedbackInterfacePrivate(Display *display);
protected:
void org_kde_plasma_activation_feedback_destroy(Resource *resource) override;
};
class PlasmaWindowActivationInterfacePrivate : public QtWaylandServer::org_kde_plasma_activation class PlasmaWindowActivationInterfacePrivate : public QtWaylandServer::org_kde_plasma_activation
{ {
public: public:
@ -1032,6 +1042,38 @@ public:
PlasmaWindowActivationInterface *const q; PlasmaWindowActivationInterface *const q;
}; };
PlasmaWindowActivationFeedbackInterfacePrivate::PlasmaWindowActivationFeedbackInterfacePrivate(Display *display)
: QtWaylandServer::org_kde_plasma_activation_feedback(*display, s_activationVersion)
{
}
void PlasmaWindowActivationFeedbackInterfacePrivate::org_kde_plasma_activation_feedback_destroy(Resource *resource)
{
wl_resource_destroy(resource->handle);
}
PlasmaWindowActivationFeedbackInterface::PlasmaWindowActivationFeedbackInterface(Display *display, QObject *parent)
: QObject(parent)
, d(new PlasmaWindowActivationFeedbackInterfacePrivate(display))
{
}
PlasmaWindowActivationFeedbackInterface::~PlasmaWindowActivationFeedbackInterface()
{
}
PlasmaWindowActivationInterface *PlasmaWindowActivationFeedbackInterface::createActivation(const QString &appid)
{
auto activation = new PlasmaWindowActivationInterface;
const auto resources = d->resourceMap();
for (auto resource : resources) {
auto activationResource = activation->d->add(resource->client(), resource->version());
d->send_activation(resource->handle, activationResource->handle);
}
activation->sendAppId(appid);
return activation;
}
PlasmaWindowActivationInterface::PlasmaWindowActivationInterface() PlasmaWindowActivationInterface::PlasmaWindowActivationInterface()
: d(new PlasmaWindowActivationInterfacePrivate(this)) : d(new PlasmaWindowActivationInterfacePrivate(this))
{ {
@ -1053,18 +1095,4 @@ void PlasmaWindowActivationInterface::sendAppId(const QString &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;
}
} }

View file

@ -15,12 +15,13 @@ namespace KWaylandServer
{ {
class Display; class Display;
class PlasmaWindowActivationFeedbackInterfacePrivate;
class PlasmaWindowInterface; class PlasmaWindowInterface;
class SurfaceInterface;
class PlasmaVirtualDesktopManagementInterface; class PlasmaVirtualDesktopManagementInterface;
class PlasmaWindowActivationInterfacePrivate; class PlasmaWindowActivationInterfacePrivate;
class PlasmaWindowManagementInterfacePrivate; class PlasmaWindowManagementInterfacePrivate;
class PlasmaWindowInterfacePrivate; class PlasmaWindowInterfacePrivate;
class SurfaceInterface;
class KWAYLANDSERVER_EXPORT PlasmaWindowActivationInterface class KWAYLANDSERVER_EXPORT PlasmaWindowActivationInterface
{ {
@ -30,12 +31,32 @@ public:
void sendAppId(const QString &id); void sendAppId(const QString &id);
private: private:
friend class PlasmaWindowManagementInterface; friend class PlasmaWindowActivationFeedbackInterface;
explicit PlasmaWindowActivationInterface(); explicit PlasmaWindowActivationInterface();
QScopedPointer<PlasmaWindowActivationInterfacePrivate> d; QScopedPointer<PlasmaWindowActivationInterfacePrivate> d;
}; };
class KWAYLANDSERVER_EXPORT PlasmaWindowActivationFeedbackInterface : public QObject
{
Q_OBJECT
public:
explicit PlasmaWindowActivationFeedbackInterface(Display *display, QObject *parent = nullptr);
~PlasmaWindowActivationFeedbackInterface() override;
/**
* 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);
private:
QScopedPointer<PlasmaWindowActivationFeedbackInterfacePrivate> d;
};
class KWAYLANDSERVER_EXPORT PlasmaWindowManagementInterface : public QObject class KWAYLANDSERVER_EXPORT PlasmaWindowManagementInterface : public QObject
{ {
Q_OBJECT Q_OBJECT
@ -72,14 +93,6 @@ public:
void setStackingOrderUuids(const QVector<QString> &stackingOrderUuids); void setStackingOrderUuids(const QVector<QString> &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: Q_SIGNALS:
void requestChangeShowingDesktop(ShowingDesktopState requestedState); void requestChangeShowingDesktop(ShowingDesktopState requestedState);