diff --git a/src/wayland/server/outputdevice_interface.cpp b/src/wayland/server/outputdevice_interface.cpp index 4ae68ceafe..f600116853 100644 --- a/src/wayland/server/outputdevice_interface.cpp +++ b/src/wayland/server/outputdevice_interface.cpp @@ -136,12 +136,9 @@ OutputDeviceInterface::OutputDeviceInterface(Display *display, QObject *parent) Q_D(); connect(this, &OutputDeviceInterface::currentModeChanged, this, [this, d] { - auto currentModeIt = std::find_if(d->modes.constBegin(), d->modes.constEnd(), [](const Mode &mode) { return mode.flags.testFlag(ModeFlag::Current); }); - if (currentModeIt == d->modes.constEnd()) { - return; - } + Q_ASSERT(d->currentMode.id >= 0); for (auto it = d->resources.constBegin(); it != d->resources.constEnd(); ++it) { - d->sendMode((*it).resource, *currentModeIt); + d->sendMode((*it).resource, d->currentMode); d->sendDone(*it); } wl_display_flush_clients(*(d->display)); @@ -187,9 +184,10 @@ int OutputDeviceInterface::refreshRate() const void OutputDeviceInterface::addMode(Mode &mode) { Q_ASSERT(!isValid()); + Q_ASSERT(mode.id >= 0); + Q_ASSERT(mode.size.isValid()); Q_D(); - auto currentModeIt = std::find_if(d->modes.begin(), d->modes.end(), [](const Mode &mode) { return mode.flags.testFlag(ModeFlag::Current); diff --git a/src/wayland/server/outputdevice_interface.h b/src/wayland/server/outputdevice_interface.h index a9424cb671..2d20f0d8b3 100644 --- a/src/wayland/server/outputdevice_interface.h +++ b/src/wayland/server/outputdevice_interface.h @@ -132,6 +132,13 @@ public: void setSubPixel(SubPixel subPixel); void setTransform(Transform transform); void setColorCurves(const ColorCurves &colorCurves); + + /** + * Add an additional mode to this output device. This is only allowed before create() is called + * on the object. + * + * @param mode must have a valid size and non-negative id. + */ void addMode(Mode &mode); void setCurrentMode(const int modeId);