output changes: handle to-be-enabled outputs first
This prevents situations where we have no enabled outputs
This commit is contained in:
parent
2693482d10
commit
1247a7b698
2 changed files with 28 additions and 5 deletions
|
@ -635,7 +635,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) {
|
||||
|
@ -645,10 +646,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;
|
||||
|
@ -656,7 +664,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
|
||||
|
@ -664,7 +675,7 @@ bool DrmBackend::applyOutputChanges(const WaylandOutputConfig &config)
|
|||
if (!qobject_cast<DrmOutput*>(output)) {
|
||||
output->applyChanges(config);
|
||||
}
|
||||
};
|
||||
}
|
||||
if (Compositor::compositing()) {
|
||||
Compositor::self()->scene()->addRepaintFull();
|
||||
}
|
||||
|
|
|
@ -152,7 +152,19 @@ void Platform::requestOutputsChange(KWaylandServer::OutputConfigurationV2Interfa
|
|||
bool Platform::applyOutputChanges(const WaylandOutputConfig &config)
|
||||
{
|
||||
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;
|
||||
|
|
Loading…
Reference in a new issue