From 330a02d862329893957532f46655c52c755f3731 Mon Sep 17 00:00:00 2001 From: Vlad Zahorodnii Date: Mon, 5 Sep 2022 14:37:10 +0300 Subject: [PATCH] wayland: Implement wl_output version 4 wl_output version 4 adds name and description properties. Those properties were added in wayland 1.20, which we already require. --- src/wayland/output_interface.cpp | 21 ++++++++++++++++++++- src/wayland/output_interface.h | 2 ++ src/waylandoutput.cpp | 2 ++ 3 files changed, 24 insertions(+), 1 deletion(-) diff --git a/src/wayland/output_interface.cpp b/src/wayland/output_interface.cpp index 9f06d37814..8d7ef2f250 100644 --- a/src/wayland/output_interface.cpp +++ b/src/wayland/output_interface.cpp @@ -18,7 +18,7 @@ namespace KWaylandServer { -static const int s_version = 3; +static const int s_version = 4; class OutputInterfacePrivate : public QtWaylandServer::wl_output { @@ -43,6 +43,8 @@ public: KWin::Output::SubPixel subPixel = KWin::Output::SubPixel::Unknown; KWin::Output::Transform transform = KWin::Output::Transform::Normal; OutputInterface::Mode mode; + QString name; + QString description; private: void output_destroy_global() override; @@ -158,6 +160,13 @@ void OutputInterfacePrivate::output_bind_resource(Resource *resource) return; // We are waiting for the wl_output global to be destroyed. } + if (resource->version() >= WL_OUTPUT_NAME_SINCE_VERSION) { + send_name(name); + } + if (resource->version() >= WL_OUTPUT_DESCRIPTION_SINCE_VERSION) { + send_description(description); + } + sendMode(resource); sendScale(resource); sendGeometry(resource); @@ -242,6 +251,16 @@ void OutputInterface::setMode(const QSize &size, int refreshRate) setMode({size, refreshRate}); } +void OutputInterface::setName(const QString &name) +{ + d->name = name; +} + +void OutputInterface::setDescription(const QString &description) +{ + d->description = description; +} + QSize OutputInterface::physicalSize() const { return d->physicalSize; diff --git a/src/wayland/output_interface.h b/src/wayland/output_interface.h index 95f1c7b261..5999a8a035 100644 --- a/src/wayland/output_interface.h +++ b/src/wayland/output_interface.h @@ -76,6 +76,8 @@ public: void setTransform(KWin::Output::Transform transform); void setMode(const Mode &mode); void setMode(const QSize &size, int refreshRate = 60000); + void setName(const QString &name); + void setDescription(const QString &description); /** * @returns all wl_resources bound for the @p client diff --git a/src/waylandoutput.cpp b/src/waylandoutput.cpp index 54a19769f2..3e5bdd0ec6 100644 --- a/src/waylandoutput.cpp +++ b/src/waylandoutput.cpp @@ -20,6 +20,8 @@ WaylandOutput::WaylandOutput(Output *output, QObject *parent) { const QRect geometry = m_platformOutput->geometry(); + m_waylandOutput->setName(output->name()); + m_waylandOutput->setDescription(output->description()); m_waylandOutput->setTransform(output->transform()); m_waylandOutput->setManufacturer(output->manufacturer()); m_waylandOutput->setModel(output->model());