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);