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)
|
bool DrmBackend::applyOutputChanges(const WaylandOutputConfig &config)
|
||||||
{
|
{
|
||||||
QVector<DrmOutput*> changed;
|
QVector<DrmOutput*> toBeEnabled;
|
||||||
|
QVector<DrmOutput*> toBeDisabled;
|
||||||
for (const auto &gpu : qAsConst(m_gpus)) {
|
for (const auto &gpu : qAsConst(m_gpus)) {
|
||||||
const auto &outputs = gpu->outputs();
|
const auto &outputs = gpu->outputs();
|
||||||
for (const auto &o : outputs) {
|
for (const auto &o : outputs) {
|
||||||
|
@ -645,10 +646,17 @@ bool DrmBackend::applyOutputChanges(const WaylandOutputConfig &config)
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
output->queueChanges(config);
|
output->queueChanges(config);
|
||||||
changed << output;
|
if (config.constChangeSet(output)->enabled) {
|
||||||
|
toBeEnabled << output;
|
||||||
|
} else {
|
||||||
|
toBeDisabled << output;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (!gpu->testPendingConfiguration()) {
|
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();
|
output->revertQueuedChanges();
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
@ -656,7 +664,10 @@ bool DrmBackend::applyOutputChanges(const WaylandOutputConfig &config)
|
||||||
}
|
}
|
||||||
// first, apply changes to drm outputs.
|
// first, apply changes to drm outputs.
|
||||||
// This may remove the placeholder output and thus change m_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);
|
output->applyQueuedChanges(config);
|
||||||
}
|
}
|
||||||
// only then apply changes to the virtual outputs
|
// only then apply changes to the virtual outputs
|
||||||
|
@ -664,7 +675,7 @@ bool DrmBackend::applyOutputChanges(const WaylandOutputConfig &config)
|
||||||
if (!qobject_cast<DrmOutput*>(output)) {
|
if (!qobject_cast<DrmOutput*>(output)) {
|
||||||
output->applyChanges(config);
|
output->applyChanges(config);
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
if (Compositor::compositing()) {
|
if (Compositor::compositing()) {
|
||||||
Compositor::self()->scene()->addRepaintFull();
|
Compositor::self()->scene()->addRepaintFull();
|
||||||
}
|
}
|
||||||
|
|
|
@ -152,7 +152,19 @@ void Platform::requestOutputsChange(KWaylandServer::OutputConfigurationV2Interfa
|
||||||
bool Platform::applyOutputChanges(const WaylandOutputConfig &config)
|
bool Platform::applyOutputChanges(const WaylandOutputConfig &config)
|
||||||
{
|
{
|
||||||
const auto availableOutputs = outputs();
|
const auto availableOutputs = outputs();
|
||||||
|
QVector<AbstractOutput*> toBeEnabledOutputs;
|
||||||
|
QVector<AbstractOutput*> toBeDisabledOutputs;
|
||||||
for (const auto &output : availableOutputs) {
|
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);
|
static_cast<AbstractWaylandOutput*>(output)->applyChanges(config);
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
|
Loading…
Reference in a new issue