From b5434e51e8a1a07d826ff2944e09f2970e9bf3e9 Mon Sep 17 00:00:00 2001 From: Xaver Hugl Date: Sat, 12 Dec 2020 20:22:40 +0000 Subject: [PATCH] add setCurrentMode(size,refreshRate) --- src/wayland/server/outputdevice_interface.cpp | 15 +++++++++++++++ src/wayland/server/outputdevice_interface.h | 5 +++++ 2 files changed, 20 insertions(+) diff --git a/src/wayland/server/outputdevice_interface.cpp b/src/wayland/server/outputdevice_interface.cpp index 125e0a0bd9..44b8b9fdd7 100644 --- a/src/wayland/server/outputdevice_interface.cpp +++ b/src/wayland/server/outputdevice_interface.cpp @@ -265,6 +265,21 @@ void OutputDeviceInterface::setCurrentMode(const int modeId) emit currentModeChanged(); } +bool OutputDeviceInterface::setCurrentMode(const QSize &size, int refreshRate) +{ + Q_D(); + auto mode = std::find_if(d->modes.constBegin(), d->modes.constEnd(), + [size, refreshRate](const Mode &mode) { + return mode.size == size && mode.refreshRate == refreshRate; + } + ); + if (mode == d->modes.constEnd()) { + return false; + } + setCurrentMode((*mode).id); + return true; +} + int32_t OutputDeviceInterface::Private::toTransform() const { switch (transform) { diff --git a/src/wayland/server/outputdevice_interface.h b/src/wayland/server/outputdevice_interface.h index 374f97b34e..64f64721de 100644 --- a/src/wayland/server/outputdevice_interface.h +++ b/src/wayland/server/outputdevice_interface.h @@ -135,6 +135,11 @@ public: */ void addMode(Mode &mode); void setCurrentMode(const int modeId); + /** + * Makes the mode with the specified @a size and @a refreshRate current. + * Returns @c false if no mode with the given attributes exists; otherwise returns @c true. + */ + bool setCurrentMode(const QSize &size, int refreshRate); void setEdid(const QByteArray &edid); void setEnabled(OutputDeviceInterface::Enablement enabled);