Commit 696c3d65 authored by Xaver Hugl's avatar Xaver Hugl
Browse files

output changes: handle to-be-enabled outputs first

This prevents situations where we have no enabled outputs
parent dbe2a7ed
......@@ -640,7 +640,8 @@ DrmGpu *DrmBackend::findGpuByFd(int fd) const
bool DrmBackend::applyOutputChanges(const WaylandOutputConfig &config)
{
QVector<DrmOutput*> changed;
QVector<DrmOutput*> toBeEnabled;
QVector<DrmOutput*> toBeDisabled;
for (const auto &gpu : qAsConst(m_gpus)) {
const auto &outputs = gpu->outputs();
for (const auto &o : outputs) {
......@@ -650,10 +651,17 @@ bool DrmBackend::applyOutputChanges(const WaylandOutputConfig &config)
continue;
}
output->queueChanges(config);
changed << output;
if (config.constChangeSet(output)->enabled) {
toBeEnabled << output;
} else {
toBeDisabled << output;
}
}
if (!gpu->testPendingConfiguration()) {
for (const auto &output : qAsConst(changed)) {
for (const auto &output : qAsConst(toBeEnabled)) {
output->revertQueuedChanges();
}
for (const auto &output : qAsConst(toBeDisabled)) {
output->revertQueuedChanges();
}
return false;
......@@ -661,7 +669,10 @@ bool DrmBackend::applyOutputChanges(const WaylandOutputConfig &config)
}
// first, apply changes to drm outputs.
// This may remove the placeholder output and thus change m_outputs!
for (const auto &output : qAsConst(changed)) {
for (const auto &output : qAsConst(toBeEnabled)) {
output->applyQueuedChanges(config);
}
for (const auto &output : qAsConst(toBeDisabled)) {
output->applyQueuedChanges(config);
}
// only then apply changes to the virtual outputs
......@@ -669,7 +680,7 @@ bool DrmBackend::applyOutputChanges(const WaylandOutputConfig &config)
if (!qobject_cast<DrmOutput*>(output)) {
output->applyChanges(config);
}
};
}
if (Compositor::compositing()) {
Compositor::self()->scene()->addRepaintFull();
}
......
......@@ -151,8 +151,20 @@ void Platform::requestOutputsChange(KWaylandServer::OutputConfigurationV2Interfa
bool Platform::applyOutputChanges(const WaylandOutputConfig &config)
{
const auto outputs = enabledOutputs();
for (const auto &output : outputs) {
const auto availableOutputs = outputs();
QVector<AbstractOutput*> toBeEnabledOutputs;
QVector<AbstractOutput*> toBeDisabledOutputs;
for (const auto &output : availableOutputs) {
if (config.constChangeSet(qobject_cast<AbstractWaylandOutput*>(output))->enabled) {
toBeEnabledOutputs << output;
} else {
toBeDisabledOutputs << output;
}
}
for (const auto &output : toBeEnabledOutputs) {
static_cast<AbstractWaylandOutput*>(output)->applyChanges(config);
}
for (const auto &output : toBeDisabledOutputs) {
static_cast<AbstractWaylandOutput*>(output)->applyChanges(config);
}
return true;
......
Supports Markdown
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