Commit 0c0a2710 authored by Roman Gilg's avatar Roman Gilg

[server] Use cached current mode more and assert validness

We can use the cached current mode in one more case. Additionally make it
more explicit what a valid mode is and when to add them.

Test Plan: Relevant autotests pass. KWin Wayland nested and DRM session work.

Reviewers: #kwin, davidedmundson

Reviewed By: #kwin, davidedmundson

Subscribers: kde-frameworks-devel

Tags: #frameworks

Differential Revision:
parent ce5e25a4
......@@ -136,12 +136,9 @@ OutputDeviceInterface::OutputDeviceInterface(Display *display, QObject *parent)
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()) {
Q_ASSERT(d-> >= 0);
for (auto it = d->resources.constBegin(); it != d->resources.constEnd(); ++it) {
d->sendMode((*it).resource, *currentModeIt);
d->sendMode((*it).resource, d->currentMode);
......@@ -187,9 +184,10 @@ int OutputDeviceInterface::refreshRate() const
void OutputDeviceInterface::addMode(Mode &mode)
Q_ASSERT( >= 0);
auto currentModeIt = std::find_if(d->modes.begin(), d->modes.end(),
[](const Mode &mode) {
return mode.flags.testFlag(ModeFlag::Current);
......@@ -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);
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment