Commit daf10794 authored by Daniel Vrátil's avatar Daniel Vrátil 🤖

Wayland: don't update output configuration if there are no changes

Summary:
This prevents the code from unnecesarilly emitting configChanged() if there
was in fact no change. This could lead to an endless loop when a client applies
current config and despite there not being no changes the backend emits
configChanged() to which the client reacts by applying the current config again
etc.

Reviewers: sebas, davidedmundson

Reviewed By: sebas

Subscribers: plasma-devel

Tags: #plasma

Differential Revision: https://phabricator.kde.org/D9906
parent 6e37f303
......@@ -279,6 +279,7 @@ void WaylandConfig::applyConfig(const KScreen::ConfigPtr &newConfig)
using namespace KWayland::Client;
// Create a new configuration object
auto wlOutputConfiguration = m_outputManagement->createConfiguration();
bool changed = false;
Q_FOREACH (auto output, newConfig->outputs()) {
auto o_old = m_outputMap[output->id()];
......@@ -288,16 +289,19 @@ void WaylandConfig::applyConfig(const KScreen::ConfigPtr &newConfig)
// enabled?
bool old_enabled = (o_old->outputDevice()->enabled() == OutputDevice::Enablement::Enabled);
if (old_enabled != output->isEnabled()) {
changed = true;
auto _enablement = output->isEnabled() ? OutputDevice::Enablement::Enabled : OutputDevice::Enablement::Disabled;
wlOutputConfiguration->setEnabled(o_old->outputDevice(), _enablement);
}
// position
if (device->globalPosition() != output->pos()) {
changed = true;
wlOutputConfiguration->setPosition(o_old->outputDevice(), output->pos());
}
if (device->scale() != output->scale()) {
changed = true;
wlOutputConfiguration->setScale(o_old->outputDevice(), output->scale());
}
......@@ -305,6 +309,7 @@ void WaylandConfig::applyConfig(const KScreen::ConfigPtr &newConfig)
auto r_current = o_old->toKScreenRotation(device->transform());
auto r_new = output->rotation();
if (r_current != r_new) {
changed = true;
wlOutputConfiguration->setTransform(device, o_old->toKWaylandTransform(r_new));
}
......@@ -313,10 +318,15 @@ void WaylandConfig::applyConfig(const KScreen::ConfigPtr &newConfig)
QString l_newmodeid = output->currentModeId();
int w_newmodeid = o_old->toKWaylandModeId(l_newmodeid);
if (w_newmodeid != w_currentmodeid) {
changed = true;
wlOutputConfiguration->setMode(device, w_newmodeid);
}
}
if (!changed) {
return;
}
// We now block changes in order to compress events while the compositor is doing its thing
// once it's done or failed, we'll trigger configChanged() only once, and not per individual
// property change.
......
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