diff --git a/src/wayland/autotests/client/test_xdg_output.cpp b/src/wayland/autotests/client/test_xdg_output.cpp index 19913ba46a..5acccf14b0 100644 --- a/src/wayland/autotests/client/test_xdg_output.cpp +++ b/src/wayland/autotests/client/test_xdg_output.cpp @@ -68,6 +68,9 @@ void TestXdgOutput::init() m_serverXdgOutput = m_serverXdgOutputManager->createXdgOutput(m_serverOutput, this); m_serverXdgOutput->setLogicalSize(QSize(1280, 720)); //a 1.5 scale factor m_serverXdgOutput->setLogicalPosition(QPoint(11,12)); //not a sensible value for one monitor, but works for this test + m_serverXdgOutput->setName("testName"); + m_serverXdgOutput->setDescription("testDescription"); + m_serverXdgOutput->done(); // setup connection @@ -144,10 +147,15 @@ void TestXdgOutput::testChanges() xdgOutputChanged.clear(); QCOMPARE(xdgOutput->logicalPosition(), QPoint(11,12)); QCOMPARE(xdgOutput->logicalSize(), QSize(1280,720)); + QCOMPARE(xdgOutput->name(), "testName"); + QCOMPARE(xdgOutput->description(), "testDescription"); - //dynamic updates + + // dynamic updates m_serverXdgOutput->setLogicalPosition(QPoint(1000, 2000)); m_serverXdgOutput->setLogicalSize(QSize(100,200)); + // names cannot dynamically change according to the spec + m_serverXdgOutput->done(); QVERIFY(xdgOutputChanged.wait()); diff --git a/src/wayland/server/xdgoutput_interface.cpp b/src/wayland/server/xdgoutput_interface.cpp index 2f03d8e877..5f6d7cc185 100644 --- a/src/wayland/server/xdgoutput_interface.cpp +++ b/src/wayland/server/xdgoutput_interface.cpp @@ -40,7 +40,7 @@ private: static const quint32 s_version; }; -const quint32 XdgOutputManagerInterface::Private::s_version = 1; +const quint32 XdgOutputManagerInterface::Private::s_version = 2; #ifndef K_DOXYGEN const struct zxdg_output_manager_v1_interface XdgOutputManagerInterface::Private::s_interface = { @@ -56,6 +56,8 @@ public: ~XdgOutputV1Interface(); void setLogicalSize(const QSize &size); void setLogicalPosition(const QPoint &pos); + void setName(const QString &name); + void setDescription(const QString &description); void done(); private: class Private; @@ -68,6 +70,8 @@ public: void resourceDisconnected(XdgOutputV1Interface *resource); QPoint pos; QSize size; + QString name; + QString description; bool dirty = false; bool doneOnce = false; QList resources; @@ -204,6 +208,16 @@ QPoint XdgOutputInterface::logicalPosition() const return d->pos; } +void XdgOutputInterface::setName(const QString &name) +{ + d->name = name; +} + +void XdgOutputInterface::setDescription(const QString &description) +{ + d->description = description; +} + void XdgOutputInterface::done() { d->doneOnce = true; @@ -220,6 +234,8 @@ void XdgOutputInterface::Private::resourceConnected(XdgOutputV1Interface *resour { resource->setLogicalPosition(pos); resource->setLogicalSize(size); + resource->setName(name); + resource->setDescription(description); if (doneOnce) { resource->done(); } @@ -270,6 +286,28 @@ void XdgOutputV1Interface::setLogicalPosition(const QPoint &pos) zxdg_output_v1_send_logical_position(d->resource, pos.x(), pos.y()); } +void XdgOutputV1Interface::setName(const QString &name) +{ + if (!d->resource) { + return; + } + if (wl_resource_get_version(d->resource) < ZXDG_OUTPUT_V1_NAME_SINCE_VERSION) { + return; + } + zxdg_output_v1_send_name(d->resource, name.toUtf8().constData()); +} + +void XdgOutputV1Interface::setDescription(const QString &description) +{ + if (!d->resource) { + return; + } + if (wl_resource_get_version(d->resource) < ZXDG_OUTPUT_V1_DESCRIPTION_SINCE_VERSION) { + return; + } + zxdg_output_v1_send_description(d->resource, description.toUtf8().constData()); +} + void XdgOutputV1Interface::done() { if (!d->resource) { diff --git a/src/wayland/server/xdgoutput_interface.h b/src/wayland/server/xdgoutput_interface.h index fde80b7381..d8cbcf9998 100644 --- a/src/wayland/server/xdgoutput_interface.h +++ b/src/wayland/server/xdgoutput_interface.h @@ -87,6 +87,32 @@ public: */ QPoint logicalPosition() const; + /** + * @brief Sets a short name of the output + * This should be consistent across reboots for the same monitor + * It should be set once before the first done call + * @since 5.XDGOUTPUT + */ + void setName(const QString &name); + /** + * The last set name + * @since 5.XDGOUTPUT + */ + void name() const; + + /** + * @brief Sets a longer description of the output + * This should be consistent across reboots for the same monitor + * It should be set once before the first done call + * @since 5.XDGOUTPUT + */ + void setDescription(const QString &description); + /** + * The last set description + * @since 5.XDGOUTPUT + */ + void description() const; + /** * Submit changes to all clients */