Send valid UUIDs for output device globals

Currently, kwin sends invalid uuids. This change makes harder to send
invalid uuids by porting relevant parts of the OutputDeviceInterface to
QUuid.
This commit is contained in:
Vlad Zahorodnii 2021-04-06 22:50:52 +03:00
parent 8f3993c91b
commit da81f4c9e8
3 changed files with 14 additions and 20 deletions

View file

@ -81,8 +81,7 @@ void TestWaylandOutputDevice::init()
QVERIFY(m_display->isRunning());
m_serverOutputDevice = new OutputDeviceInterface(m_display, this);
m_serverOutputDevice->setUuid("1337");
m_serverOutputDevice->setUuid(QUuid("00000000-0000-0000-0000-000000000000"));
OutputDeviceInterface::Mode m0;
m0.id = 0;
@ -228,7 +227,7 @@ void TestWaylandOutputDevice::testRegistry()
QCOMPARE(output.edid(), m_edid);
QCOMPARE(output.enabled(), OutputDevice::Enablement::Enabled);
QCOMPARE(output.uuid(), QStringLiteral("1337"));
QCOMPARE(output.uuid(), QStringLiteral("00000000-0000-0000-0000-000000000000"));
QCOMPARE(output.serialNumber(), m_serialNumber);
QCOMPARE(output.eisaId(), m_eidaId);
}
@ -596,22 +595,16 @@ void TestWaylandOutputDevice::testId()
wl_display_flush(m_connection->display());
QVERIFY(outputChanged.wait());
QCOMPARE(output.uuid(), QStringLiteral("1337"));
QCOMPARE(output.uuid(), QStringLiteral("00000000-0000-0000-0000-000000000000"));
QSignalSpy idChanged(&output, &KWayland::Client::OutputDevice::uuidChanged);
QVERIFY(idChanged.isValid());
m_serverOutputDevice->setUuid("42");
m_serverOutputDevice->setUuid(QUuid("00000000-0000-0000-0000-000000000001"));
QVERIFY(idChanged.wait());
QCOMPARE(idChanged.first().first().toByteArray(), QByteArray("42"));
QCOMPARE(idChanged.first().first().toByteArray(), QByteArray("00000000-0000-0000-0000-000000000001"));
idChanged.clear();
QCOMPARE(output.uuid(), QStringLiteral("42"));
m_serverOutputDevice->setUuid("4711");
QVERIFY(idChanged.wait());
QCOMPARE(idChanged.first().first().toByteArray(), QByteArray("4711"));
idChanged.clear();
QCOMPARE(output.uuid(), QStringLiteral("4711"));
QCOMPARE(output.uuid(), QStringLiteral("00000000-0000-0000-0000-000000000001"));
}
void TestWaylandOutputDevice::testDone()

View file

@ -62,7 +62,7 @@ public:
QByteArray edid;
OutputDeviceInterface::Enablement enabled = OutputDeviceInterface::Enablement::Enabled;
QString uuid;
QUuid uuid;
QPointer<Display> display;
OutputDeviceInterface *q;
@ -568,7 +568,7 @@ OutputDeviceInterface::Enablement OutputDeviceInterface::enabled() const
return d->enabled;
}
void OutputDeviceInterface::setUuid(const QString &uuid)
void OutputDeviceInterface::setUuid(const QUuid &uuid)
{
if (d->uuid != uuid) {
d->uuid = uuid;
@ -577,7 +577,7 @@ void OutputDeviceInterface::setUuid(const QString &uuid)
}
}
QString OutputDeviceInterface::uuid() const
QUuid OutputDeviceInterface::uuid() const
{
return d->uuid;
}
@ -598,7 +598,7 @@ void OutputDeviceInterfacePrivate::sendEnabled(Resource *resource)
void OutputDeviceInterfacePrivate::sendUuid(Resource *resource)
{
send_uuid(resource->handle, uuid);
send_uuid(resource->handle, uuid.toString(QUuid::WithoutBraces));
}
void OutputDeviceInterfacePrivate::updateEnabled()

View file

@ -10,6 +10,7 @@
#include <QObject>
#include <QPoint>
#include <QSize>
#include <QUuid>
#include <QVector>
struct wl_resource;
@ -41,7 +42,7 @@ class KWAYLANDSERVER_EXPORT OutputDeviceInterface : public QObject
Q_PROPERTY(qreal scale READ scaleF WRITE setScaleF NOTIFY scaleFChanged)
Q_PROPERTY(QByteArray edid READ edid WRITE setEdid NOTIFY edidChanged)
Q_PROPERTY(OutputDeviceInterface::Enablement enabled READ enabled WRITE setEnabled NOTIFY enabledChanged)
Q_PROPERTY(QString uuid READ uuid WRITE setUuid NOTIFY uuidChanged)
Q_PROPERTY(QUuid uuid READ uuid WRITE setUuid NOTIFY uuidChanged)
public:
enum class SubPixel {
Unknown,
@ -103,7 +104,7 @@ public:
QByteArray edid() const;
OutputDeviceInterface::Enablement enabled() const;
QString uuid() const;
QUuid uuid() const;
void setPhysicalSize(const QSize &size);
void setGlobalPosition(const QPoint &pos);
@ -133,7 +134,7 @@ public:
void setEdid(const QByteArray &edid);
void setEnabled(OutputDeviceInterface::Enablement enabled);
void setUuid(const QString &uuid);
void setUuid(const QUuid &uuid);
static OutputDeviceInterface *get(wl_resource *native);
static QList<OutputDeviceInterface *>list();