diff --git a/autotests/client/test_wayland_outputdevice.cpp b/autotests/client/test_wayland_outputdevice.cpp --- a/autotests/client/test_wayland_outputdevice.cpp +++ b/autotests/client/test_wayland_outputdevice.cpp @@ -63,6 +63,9 @@ KWayland::Server::Display *m_display; KWayland::Server::OutputDeviceInterface *m_serverOutputDevice; QByteArray m_edid; + QString m_serialNumber; + QString m_eidaId; + KWayland::Server::OutputDeviceInterface::ColorCurves m_initColorCurves; KWayland::Client::ConnectionThread *m_connection; KWayland::Client::EventQueue *m_queue; @@ -117,6 +120,11 @@ m_edid = QByteArray::fromBase64("AP///////wAQrBbwTExLQQ4WAQOANCB46h7Frk80sSYOUFSlSwCBgKlA0QBxTwEBAQEBAQEBKDyAoHCwI0AwIDYABkQhAAAaAAAA/wBGNTI1TTI0NUFLTEwKAAAA/ABERUxMIFUyNDEwCiAgAAAA/QA4TB5REQAKICAgICAgAToCAynxUJAFBAMCBxYBHxITFCAVEQYjCQcHZwMMABAAOC2DAQAA4wUDAQI6gBhxOC1AWCxFAAZEIQAAHgEdgBhxHBYgWCwlAAZEIQAAngEdAHJR0B4gbihVAAZEIQAAHowK0Iog4C0QED6WAAZEIQAAGAAAAAAAAAAAAAAAAAAAPg=="); m_serverOutputDevice->setEdid(m_edid); + m_serialNumber = "23498723948723"; + m_serverOutputDevice->setSerialNumber(m_serialNumber); + m_eidaId = "asdffoo"; + m_serverOutputDevice->setEisaId(m_eidaId); + m_initColorCurves.red.clear(); m_initColorCurves.green.clear(); m_initColorCurves.blue.clear(); @@ -207,6 +215,9 @@ QCOMPARE(output.transform(), KWayland::Client::OutputDevice::Transform::Normal); QCOMPARE(output.enabled(), OutputDevice::Enablement::Enabled); QCOMPARE(output.edid(), QByteArray()); + QCOMPARE(output.eisaId(), QString()); + QCOMPARE(output.serialNumber(), QString()); + QSignalSpy outputChanged(&output, &KWayland::Client::OutputDevice::done); QVERIFY(outputChanged.isValid()); @@ -234,7 +245,8 @@ QCOMPARE(output.edid(), m_edid); QCOMPARE(output.enabled(), OutputDevice::Enablement::Enabled); QCOMPARE(output.uuid(), QByteArray("1337")); - + QCOMPARE(output.serialNumber(), m_serialNumber); + QCOMPARE(output.eisaId(), m_eidaId); } void TestWaylandOutputDevice::testModeChanges() diff --git a/src/client/outputdevice.h b/src/client/outputdevice.h --- a/src/client/outputdevice.h +++ b/src/client/outputdevice.h @@ -167,6 +167,14 @@ * Textual description of the model. **/ QString model() const; + /** + * Textual representation of serial number. + */ + QString serialNumber() const; + /** + * Textual representation of EISA identifier. + */ + QString eisaId() const; /** * Size in the current mode. **/ diff --git a/src/client/outputdevice.cpp b/src/client/outputdevice.cpp --- a/src/client/outputdevice.cpp +++ b/src/client/outputdevice.cpp @@ -51,6 +51,8 @@ QString manufacturer; QString model; qreal scale = 1.0; + QString serialNumber; + QString eisaId; SubPixel subPixel = SubPixel::Unknown; Transform transform = Transform::Normal; Modes modes; @@ -80,11 +82,16 @@ static void colorcurvesCallback(void *data, org_kde_kwin_outputdevice *output, wl_array *red, wl_array *green, wl_array *blue); + static void serialNumberCallback(void *data, org_kde_kwin_outputdevice *output, const char *serialNumber); + static void eisaIdCallback(void *data, org_kde_kwin_outputdevice *output, const char *eisa); + void setPhysicalSize(const QSize &size); void setGlobalPosition(const QPoint &pos); void setManufacturer(const QString &manufacturer); void setModel(const QString &model); void setScale(qreal scale); + void setSerialNumber(const QString &serialNumber); + void setEisaId(const QString &eisaId); void setSubPixel(SubPixel subPixel); void setTransform(Transform transform); void addMode(uint32_t flags, int32_t width, int32_t height, int32_t refresh, int32_t mode_id); @@ -142,13 +149,16 @@ enabledCallback, uuidCallback, scaleFCallback, - colorcurvesCallback + colorcurvesCallback, + serialNumberCallback, + eisaIdCallback }; void OutputDevice::Private::geometryCallback(void *data, org_kde_kwin_outputdevice *output, int32_t x, int32_t y, int32_t physicalWidth, int32_t physicalHeight, - int32_t subPixel, const char *make, const char *model, int32_t transform) + int32_t subPixel, const char *make, const char *model, + int32_t transform) { Q_UNUSED(transform) auto o = reinterpret_cast(data); @@ -344,6 +354,20 @@ } } +void OutputDevice::Private::serialNumberCallback(void *data, org_kde_kwin_outputdevice *output, const char *raw) +{ + auto o = reinterpret_cast(data); + Q_UNUSED(output); + o->setSerialNumber(raw); +} + +void OutputDevice::Private::eisaIdCallback(void *data, org_kde_kwin_outputdevice *output, const char *raw) +{ + auto o = reinterpret_cast(data); + Q_UNUSED(output); + o->setEisaId(raw); +} + void OutputDevice::setup(org_kde_kwin_outputdevice *output) { d->setup(output); @@ -374,6 +398,16 @@ model = m; } +void OutputDevice::Private::setSerialNumber(const QString &sn) +{ + serialNumber = sn; +} + +void OutputDevice::Private::setEisaId(const QString &e) +{ + eisaId = e; +} + void OutputDevice::Private::setPhysicalSize(const QSize &size) { physicalSize = size; @@ -417,6 +451,16 @@ return d->model; } +QString OutputDevice::serialNumber() const +{ + return d->serialNumber; +} + +QString OutputDevice::eisaId() const +{ + return d->eisaId; +} + org_kde_kwin_outputdevice *OutputDevice::output() { return d->output; diff --git a/src/client/protocols/outputdevice.xml b/src/client/protocols/outputdevice.xml --- a/src/client/protocols/outputdevice.xml +++ b/src/client/protocols/outputdevice.xml @@ -273,6 +273,21 @@ summary="blue color ramp"/> + + + Serial ID of the monitor, sent on startup before the first done event. + + + + + + EISA ID of the monitor, sent on startup before the first done event. + + + + diff --git a/src/server/outputdevice_interface.h b/src/server/outputdevice_interface.h --- a/src/server/outputdevice_interface.h +++ b/src/server/outputdevice_interface.h @@ -45,13 +45,19 @@ * @see OutputManagementInterface * @since 5.5 */ + +//KF6 TODO - This class sends absolute garbage over the wire constantly. +//sendDone needs to be explicit, anything related to the geometry event needs to be in a single method + class KWAYLANDSERVER_EXPORT OutputDeviceInterface : public Global { Q_OBJECT Q_PROPERTY(QSize physicalSize READ physicalSize WRITE setPhysicalSize NOTIFY physicalSizeChanged) Q_PROPERTY(QPoint globalPosition READ globalPosition WRITE setGlobalPosition NOTIFY globalPositionChanged) Q_PROPERTY(QString manufacturer READ manufacturer WRITE setManufacturer NOTIFY manufacturerChanged) Q_PROPERTY(QString model READ model WRITE setModel NOTIFY modelChanged) + Q_PROPERTY(QString serialNumber READ serialNumber WRITE setSerialNumber NOTIFY serialNumberChanged) + Q_PROPERTY(QString eisaId READ eisaId WRITE setEisaId NOTIFY eisaIdChanged) Q_PROPERTY(QSize pixelSize READ pixelSize NOTIFY pixelSizeChanged) Q_PROPERTY(int refreshRate READ refreshRate NOTIFY refreshRateChanged) Q_PROPERTY(qreal scale READ scaleF WRITE setScaleF NOTIFY scaleFChanged) @@ -103,6 +109,8 @@ QPoint globalPosition() const; QString manufacturer() const; QString model() const; + QString serialNumber() const; + QString eisaId() const; QSize pixelSize() const; int refreshRate() const; int scale() const; @@ -121,6 +129,8 @@ void setGlobalPosition(const QPoint &pos); void setManufacturer(const QString &manufacturer); void setModel(const QString &model); + void setSerialNumber(const QString &serialNumber); + void setEisaId(const QString &eisaId); void setScale(int scale); void setScaleF(qreal scale); void setSubPixel(SubPixel subPixel); @@ -141,6 +151,8 @@ void globalPositionChanged(const QPoint&); void manufacturerChanged(const QString&); void modelChanged(const QString&); + void serialNumberChanged(const QString&); + void eisaIdChanged(const QString &); void pixelSizeChanged(const QSize&); void refreshRateChanged(int); //@deprecated see scaleChanged(real) diff --git a/src/server/outputdevice_interface.cpp b/src/server/outputdevice_interface.cpp --- a/src/server/outputdevice_interface.cpp +++ b/src/server/outputdevice_interface.cpp @@ -46,6 +46,8 @@ void updateGeometry(); void updateScale(); void updateColorCurves(); + void updateSerialNumber(); + void updateEisaId(); void sendUuid(); void sendEdid(); @@ -56,6 +58,8 @@ QString manufacturer = QStringLiteral("org.kde.kwin"); QString model = QStringLiteral("none"); qreal scale = 1.0; + QString serialNumber; + QString eisaId; SubPixel subPixel = SubPixel::Unknown; Transform transform = Transform::Normal; ColorCurves colorCurves; @@ -77,6 +81,8 @@ void sendGeometry(wl_resource *resource); void sendScale(const ResourceData &data); void sendColorCurves(const ResourceData &data); + void sendEisaId(const ResourceData &data); + void sendSerialNumber(const ResourceData &data); static const quint32 s_version; OutputDeviceInterface *q; @@ -142,6 +148,9 @@ connect(this, &OutputDeviceInterface::modelChanged, this, [this, d] { d->updateGeometry(); }); connect(this, &OutputDeviceInterface::manufacturerChanged, this, [this, d] { d->updateGeometry(); }); connect(this, &OutputDeviceInterface::scaleFChanged, this, [this, d] { d->updateScale(); }); + //DAVE FIXME + connect(this, &OutputDeviceInterface::serialNumberChanged, this, [this, d] { d->updateGeometry(); }); + connect(this, &OutputDeviceInterface::eisaIdChanged, this, [this, d] { d->updateGeometry(); }); connect(this, &OutputDeviceInterface::scaleChanged, this, [this, d] { d->updateScale(); }); connect(this, &OutputDeviceInterface::colorCurvesChanged, this, [this, d] { d->updateColorCurves(); }); } @@ -339,6 +348,8 @@ sendGeometry(resource); sendScale(r); sendColorCurves(r); + sendEisaId(r); + sendSerialNumber(r); auto currentModeIt = modes.constEnd(); for (auto it = modes.constBegin(); it != modes.constEnd(); ++it) { @@ -355,8 +366,8 @@ sendMode(resource, *currentModeIt); } - sendUuid(); sendEdid(); + sendUuid(); sendEnabled(); sendDone(r); @@ -395,7 +406,8 @@ void OutputDeviceInterface::Private::sendGeometry(wl_resource *resource) { - org_kde_kwin_outputdevice_send_geometry(resource, + wl_resource_post_event(resource, + ORG_KDE_KWIN_OUTPUTDEVICE_GEOMETRY, globalPosition.x(), globalPosition.y(), physicalSize.width(), @@ -440,6 +452,23 @@ wl_array_release(&wlBlue); } +void KWayland::Server::OutputDeviceInterface::Private::sendSerialNumber(const ResourceData &data) +{ + if (wl_resource_get_version(data.resource) >= ORG_KDE_KWIN_OUTPUTDEVICE_SERIAL_NUMBER_SINCE_VERSION) { + org_kde_kwin_outputdevice_send_serial_number(data.resource, + qPrintable(serialNumber)); + } +} + +void KWayland::Server::OutputDeviceInterface::Private::sendEisaId(const ResourceData &data) +{ + if (wl_resource_get_version(data.resource) >= ORG_KDE_KWIN_OUTPUTDEVICE_EISA_ID_SINCE_VERSION) { + org_kde_kwin_outputdevice_send_eisa_id(data.resource, + qPrintable(eisaId)); + } +} + + void OutputDeviceInterface::Private::sendDone(const ResourceData &data) { org_kde_kwin_outputdevice_send_done(data.resource); @@ -492,6 +521,8 @@ SETTER(setGlobalPosition, const QPoint&, globalPosition) SETTER(setManufacturer, const QString&, manufacturer) SETTER(setModel, const QString&, model) +SETTER(setSerialNumber, const QString&, serialNumber) +SETTER(setEisaId, const QString&, eisaId) SETTER(setSubPixel, SubPixel, subPixel) SETTER(setTransform, Transform, transform) @@ -543,6 +574,18 @@ return d->model; } +QString OutputDeviceInterface::serialNumber() const +{ + Q_D(); + return d->serialNumber; +} + +QString OutputDeviceInterface::eisaId() const +{ + Q_D(); + return d->eisaId; +} + int OutputDeviceInterface::scale() const { Q_D();