Members of the KDE Community are recommended to subscribe to the kde-community mailing list at https://mail.kde.org/mailman/listinfo/kde-community to allow them to participate in important discussions and receive other important announcements

Commit 2c22acc0 authored by Aleix Pol Gonzalez's avatar Aleix Pol Gonzalez 🐧

PlasmaWindowManagement: adopt changes in the protocol

Offer a PlasmaWindow::uuid so we can identify windows when communicating
with the compositor.
Deprecates the internalId which is the entire reason why this was ported
(that it isn't stable enough).
parent fb63879e
......@@ -53,6 +53,9 @@ include(KDEFrameworkCompilerSettings NO_POLICY_SCOPE)
include(KDECMakeSettings)
include(CheckIncludeFile)
find_package(PlasmaWaylandProtocols 1.1 CONFIG)
set_package_properties(PlasmaWaylandProtocols PROPERTIES TYPE REQUIRED)
check_include_file("linux/input.h" HAVE_LINUX_INPUT_H)
configure_file(config-kwayland.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/config-kwayland.h)
include_directories(${CMAKE_CURRENT_BINARY_DIR})
......
......@@ -100,7 +100,7 @@ ecm_add_wayland_client_protocol(CLIENT_LIB_SRCS
)
ecm_add_wayland_client_protocol(CLIENT_LIB_SRCS
PROTOCOL ${KWayland_SOURCE_DIR}/src/client/protocols/plasma-window-management.xml
PROTOCOL ${PLASMA_WAYLAND_PROTOCOLS_DIR}/plasma-window-management.xml
BASENAME plasma-window-management
)
......@@ -248,7 +248,7 @@ ecm_generate_export_header(KF5WaylandClient
GROUP_BASE_NAME KF
VERSION ${KF5_VERSION}
DEPRECATED_BASE_VERSION 0
DEPRECATION_VERSIONS 5.49 5.50 5.52 5.53
DEPRECATION_VERSIONS 5.49 5.50 5.52 5.53 5.71
)
# TODO: add support for EXCLUDE_DEPRECATED_BEFORE_AND_AT to all KWayland libs
# needs fixing of undeprecated API being still implemented using own deprecated API
......
......@@ -35,16 +35,20 @@ public:
QList<PlasmaWindow*> windows;
PlasmaWindow *activeWindow = nullptr;
QVector<quint32> stackingOrder;
QVector<QByteArray> stackingOrderUuids;
void setup(org_kde_plasma_window_management *wm);
private:
static void showDesktopCallback(void *data, org_kde_plasma_window_management *org_kde_plasma_window_management, uint32_t state);
static void windowCallback(void *data, org_kde_plasma_window_management *org_kde_plasma_window_management, uint32_t id);
static void windowWithUuidCallback(void *data, org_kde_plasma_window_management *org_kde_plasma_window_management, uint32_t id, const char* uuid);
static void stackingOrderCallback(void *data, org_kde_plasma_window_management *org_kde_plasma_window_management, wl_array *ids);
static void stackingOrderUuidsCallback(void *data, org_kde_plasma_window_management *org_kde_plasma_window_management, const char *uuids);
void setShowDesktop(bool set);
void windowCreated(org_kde_plasma_window *id, quint32 internalId);
void windowCreated(org_kde_plasma_window *id, quint32 internalId, const char *uuid);
void setStackingOrder(const QVector<quint32> &ids);
void setStackingOrder(const QVector<QByteArray> &uuids);
static struct org_kde_plasma_window_management_listener s_listener;
PlasmaWindowManagement *q;
......@@ -53,9 +57,10 @@ private:
class Q_DECL_HIDDEN PlasmaWindow::Private
{
public:
Private(org_kde_plasma_window *window, quint32 internalId, PlasmaWindow *q);
Private(org_kde_plasma_window *window, quint32 internalId, const char *uuid, PlasmaWindow *q);
WaylandPointer<org_kde_plasma_window, org_kde_plasma_window_destroy> window;
quint32 internalId;
quint32 internalId; ///< @deprecated
QByteArray uuid;
QString title;
QString appId;
quint32 desktop = 0;
......@@ -143,7 +148,9 @@ PlasmaWindowManagement::Private::Private(PlasmaWindowManagement *q)
org_kde_plasma_window_management_listener PlasmaWindowManagement::Private::s_listener = {
showDesktopCallback,
windowCallback,
stackingOrderCallback
windowWithUuidCallback,
stackingOrderCallback,
stackingOrderUuidsCallback
};
void PlasmaWindowManagement::Private::setup(org_kde_plasma_window_management *windowManagement)
......@@ -189,19 +196,36 @@ void PlasmaWindowManagement::Private::windowCallback(void *data, org_kde_plasma_
timer->setInterval(0);
QObject::connect(timer, &QTimer::timeout, wm->q,
[timer, wm, id] {
wm->windowCreated(org_kde_plasma_window_management_get_window(wm->wm, id), id);
wm->windowCreated(org_kde_plasma_window_management_get_window(wm->wm, id), id, "unavailable");
timer->deleteLater();
}, Qt::QueuedConnection
);
timer->start();
}
void PlasmaWindowManagement::Private::windowCreated(org_kde_plasma_window *id, quint32 internalId)
void PlasmaWindowManagement::Private::windowWithUuidCallback(void *data, org_kde_plasma_window_management *interface, uint32_t id, const char *_uuid)
{
QByteArray uuid(_uuid);
auto wm = reinterpret_cast<PlasmaWindowManagement::Private*>(data);
Q_ASSERT(wm->wm == interface);
QTimer *timer = new QTimer();
timer->setSingleShot(true);
timer->setInterval(0);
QObject::connect(timer, &QTimer::timeout, wm->q,
[timer, wm, id, uuid] {
wm->windowCreated(org_kde_plasma_window_management_get_window_by_uuid(wm->wm, uuid), id, uuid);
timer->deleteLater();
}, Qt::QueuedConnection
);
timer->start();
}
void PlasmaWindowManagement::Private::windowCreated(org_kde_plasma_window *id, quint32 internalId, const char *uuid)
{
if (queue) {
queue->addProxy(id);
}
PlasmaWindow *window = new PlasmaWindow(q, id, internalId);
PlasmaWindow *window = new PlasmaWindow(q, id, internalId, uuid);
window->d->wm = q;
windows << window;
QObject::connect(window, &QObject::destroyed, q,
......@@ -249,6 +273,13 @@ void PlasmaWindowManagement::Private::stackingOrderCallback(void *data, org_kde_
wm->setStackingOrder(destination);
}
void PlasmaWindowManagement::Private::stackingOrderUuidsCallback(void *data, org_kde_plasma_window_management *interface, const char *uuids)
{
auto wm = reinterpret_cast<PlasmaWindowManagement::Private*>(data);
Q_ASSERT(wm->wm == interface);
wm->setStackingOrder(QByteArray(uuids).split(';').toVector());
}
void PlasmaWindowManagement::Private::setStackingOrder(const QVector<quint32> &ids)
{
if (stackingOrder == ids) {
......@@ -258,6 +289,15 @@ void PlasmaWindowManagement::Private::setStackingOrder(const QVector<quint32> &i
emit q->stackingOrderChanged();
}
void PlasmaWindowManagement::Private::setStackingOrder(const QVector<QByteArray> &uuids)
{
if (stackingOrderUuids == uuids) {
return;
}
stackingOrderUuids = uuids;
emit q->stackingOrderUuidsChanged();
}
PlasmaWindowManagement::PlasmaWindowManagement(QObject *parent)
: QObject(parent)
, d(new Private(this))
......@@ -357,6 +397,11 @@ QVector<quint32> PlasmaWindowManagement::stackingOrder() const
return d->stackingOrder;
}
QVector<QByteArray> PlasmaWindowManagement::stackingOrderUuids() const
{
return d->stackingOrderUuids;
}
org_kde_plasma_window_listener PlasmaWindow::Private::s_listener = {
titleChangedCallback,
appIdChangedCallback,
......@@ -788,17 +833,19 @@ void PlasmaWindow::Private::setVirtualDesktopChangeable(bool set)
emit q->virtualDesktopChangeableChanged();
}
PlasmaWindow::Private::Private(org_kde_plasma_window *w, quint32 internalId, PlasmaWindow *q)
PlasmaWindow::Private::Private(org_kde_plasma_window *w, quint32 internalId, const char *uuid, PlasmaWindow *q)
: internalId(internalId)
, uuid(uuid)
, q(q)
{
Q_ASSERT(!this->uuid.isEmpty());
window.setup(w);
org_kde_plasma_window_add_listener(w, &s_listener, this);
}
PlasmaWindow::PlasmaWindow(PlasmaWindowManagement *parent, org_kde_plasma_window *window, quint32 internalId)
PlasmaWindow::PlasmaWindow(PlasmaWindowManagement *parent, org_kde_plasma_window *window, quint32 internalId, const char *uuid)
: QObject(parent)
, d(new Private(window, internalId, this))
, d(new Private(window, internalId, uuid, this))
{
}
......@@ -1075,6 +1122,11 @@ quint32 PlasmaWindow::internalId() const
return d->internalId;
}
QByteArray PlasmaWindow::uuid() const
{
return d->uuid;
}
QPointer<PlasmaWindow> PlasmaWindow::parentWindow() const
{
return d->parentWindow;
......
......@@ -156,10 +156,22 @@ public:
**/
PlasmaWindowModel *createWindowModel();
#if KWAYLANDCLIENT_ENABLE_DEPRECATED_SINCE(5, 71)
/**
* @returns windows stacking order
*
* @deprecated since 5.71, Use stackingOrderUuids
*/
KWAYLANDCLIENT_DEPRECATED_VERSION(5, 71, "Use PlasmaWindow::stackingOrderUuids()")
QVector<quint32> stackingOrder() const;
#endif
/**
* @returns windows stacking order
*
* @since 5.71
*/
QVector<QByteArray> stackingOrderUuids() const;
Q_SIGNALS:
/**
......@@ -197,11 +209,20 @@ Q_SIGNALS:
**/
void removed();
#if KWAYLANDCLIENT_ENABLE_DEPRECATED_SINCE(5, 71)
/**
* The stacking order changed
* @since 5.70
* @deprecated since 5.71, use stackingOrderUuidsChanged
**/
KWAYLANDCLIENT_DEPRECATED_VERSION(5, 71, "Use PlasmaWindow::stackingOrderUuidsChanged()")
void stackingOrderChanged();
#endif
/**
* The stacking order uuids changed
* @since 5.71
**/
void stackingOrderUuidsChanged();
private:
class Private;
......@@ -460,12 +481,24 @@ public:
*/
void requestToggleShaded();
#if KWAYLANDCLIENT_ENABLE_DEPRECATED_SINCE(5, 71)
/**
* An internal window identifier.
* This is not a global window identifier.
* This identifier does not correspond to QWindow::winId in any way.
*
* @deprecated since 5.71, use uuid instead
**/
KWAYLANDCLIENT_DEPRECATED_VERSION(5, 71, "Use PlasmaWindow::uuid(const QString &)")
quint32 internalId() const;
#endif
/**
* A unique identifier for the window
*
* @see QUuid
*/
QByteArray uuid() const;
/**
* The parent window of this PlasmaWindow.
......@@ -703,7 +736,7 @@ Q_SIGNALS:
private:
friend class PlasmaWindowManagement;
explicit PlasmaWindow(PlasmaWindowManagement *parent, org_kde_plasma_window *dataOffer, quint32 internalId);
explicit PlasmaWindow(PlasmaWindowManagement *parent, org_kde_plasma_window *dataOffer, quint32 internalId, const char *uuid);
class Private;
QScopedPointer<Private> d;
};
......
......@@ -269,6 +269,8 @@ QVariant PlasmaWindowModel::data(const QModelIndex &index, int role) const
return window->geometry();
} else if (role == VirtualDesktops) {
return window->plasmaVirtualDesktops();
} else if (role == Uuid) {
return window->uuid();
}
return QVariant();
......
......@@ -106,7 +106,11 @@ public:
/**
* @since 5.53
*/
VirtualDesktops
VirtualDesktops,
/**
* @since 5.71
*/
Uuid,
};
Q_ENUM(AdditionalRoles)
......
This diff is collapsed.
......@@ -171,7 +171,7 @@ static const QMap<Registry::Interface, SuppertedInterfaceData> s_interfaces = {
&Registry::plasmaVirtualDesktopManagementRemoved
}},
{Registry::Interface::PlasmaWindowManagement, {
11,
12,
QByteArrayLiteral("org_kde_plasma_window_management"),
&org_kde_plasma_window_management_interface,
&Registry::plasmaWindowManagementAnnounced,
......
......@@ -97,7 +97,7 @@ ecm_add_wayland_server_protocol(SERVER_LIB_SRCS
)
ecm_add_wayland_server_protocol(SERVER_LIB_SRCS
PROTOCOL ${KWayland_SOURCE_DIR}/src/client/protocols/plasma-window-management.xml
PROTOCOL ${PLASMA_WAYLAND_PROTOCOLS_DIR}/plasma-window-management.xml
BASENAME plasma-window-management
)
......@@ -308,7 +308,7 @@ ecm_generate_export_header(KF5WaylandServer
GROUP_BASE_NAME KF
VERSION ${KF5_VERSION}
DEPRECATED_BASE_VERSION 0
DEPRECATION_VERSIONS 5.5 5.28 5.50 5.52 5.69
DEPRECATION_VERSIONS 5.5 5.28 5.50 5.52 5.69 5.71
)
# TODO: add support for EXCLUDE_DEPRECATED_BEFORE_AND_AT to all KWayland libs
# needs fixing of undeprecated API being still implemented using own deprecated API
......
......@@ -44,6 +44,7 @@ private:
static void unbind(wl_resource *resource);
static void showDesktopCallback(wl_client *client, wl_resource *resource, uint32_t state);
static void getWindowCallback(wl_client *client, wl_resource *resource, uint32_t id, uint32_t internalWindowId);
static void getWindowByUuidCallback(wl_client *client, wl_resource *resource, uint32_t id, const char* uuid);
void bind(wl_client *client, uint32_t version, uint32_t id) override;
void sendShowingDesktopState(wl_resource *r);
......@@ -127,7 +128,8 @@ PlasmaWindowManagementInterface::Private::Private(PlasmaWindowManagementInterfac
#ifndef K_DOXYGEN
const struct org_kde_plasma_window_management_interface PlasmaWindowManagementInterface::Private::s_interface = {
showDesktopCallback,
getWindowCallback
getWindowCallback,
getWindowByUuidCallback
};
#endif
......@@ -195,6 +197,19 @@ void PlasmaWindowManagementInterface::Private::showDesktopCallback(wl_client *cl
emit reinterpret_cast<Private*>(wl_resource_get_user_data(resource))->q->requestChangeShowingDesktop(s);
}
void PlasmaWindowManagementInterface::Private::getWindowByUuidCallback(wl_client *client, wl_resource *resource, uint32_t id, const char* uuid)
{
Q_UNUSED(client);
Q_UNUSED(uuid);
qCritical() << "window_by_uuid is unsupported, port to KWaylandServer::PlasmaWindowManagementInterface";
auto p = reinterpret_cast<Private*>(wl_resource_get_user_data(resource));
PlasmaWindowInterface *window = new PlasmaWindowInterface(p->q, p->q);
window->d->unmapped = true;
window->d->createResource(resource, id);
return;
}
void PlasmaWindowManagementInterface::Private::getWindowCallback(wl_client *client, wl_resource *resource, uint32_t id, uint32_t internalWindowId)
{
Q_UNUSED(client)
......
......@@ -6,9 +6,12 @@
#ifndef WAYLAND_SERVER_PLASMA_WINDOW_MANAGEMENT_INTERFACE_H
#define WAYLAND_SERVER_PLASMA_WINDOW_MANAGEMENT_INTERFACE_H
#include <KWayland/Server/kwaylandserver_export.h>
#if KWAYLANDSERVER_ENABLE_DEPRECATED_SINCE(5, 71)
#include <QObject>
#include <KWayland/Server/kwaylandserver_export.h>
#include "global.h"
#include "resource.h"
......@@ -26,9 +29,9 @@ class SurfaceInterface;
class PlasmaVirtualDesktopManagementInterface;
/**
* @todo Add documentation
* @deprecated 5.71 port to KWaylandServer in Plasma
*/
class KWAYLANDSERVER_EXPORT PlasmaWindowManagementInterface : public Global
class KWAYLANDSERVER_DEPRECATED_EXPORT PlasmaWindowManagementInterface : public Global
{
Q_OBJECT
public:
......@@ -324,3 +327,4 @@ private:
Q_DECLARE_METATYPE(KWayland::Server::PlasmaWindowManagementInterface::ShowingDesktopState)
#endif
#endif
  • @apol Please update the deprecation version to 5.73. Otherwise you run chance to break things for everyone who tested their build against 5.71 & 5.72 and then set the hiding of deprecated API to that level.

    Also do not use KWAYLANDSERVER_DEPRECATED_EXPORT with PlasmaWindowManagementInterface, but instead use `KWAYLANDSERVER_DEPRECATED_VERSION(7, 73, "Port to KWaylandServer") with the constructors, to catch those places where objects of the class are created.

    Edited by Friedrich W. H. Kossebau
  • I can help out here and fix it, if that helps you. Not sure that has the education effect needed to sharpen your awareness though ;)

  • Doing now, as you seem afk, and this might affect others.

  • Doing now, as you seem afk, and this might affect others.

    Thank you. :-)

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