Improve our reaction when primary changes

Ensure we sanitise the input so a client can't randomly crash KWin that
way.
This commit is contained in:
Aleix Pol 2021-11-18 17:12:37 +01:00 committed by Aleix Pol Gonzalez
parent 039b1d031e
commit afd525ced0

View file

@ -158,8 +158,15 @@ void Platform::requestOutputsChange(KWaylandServer::OutputConfigurationV2Interfa
}
if (applyOutputChanges(cfg)) {
if (config->primaryChanged()) {
setPrimaryOutput(findOutput(config->primary()->uuid()));
if (config->primaryChanged() || !primaryOutput()->isEnabled()) {
auto requestedPrimaryOutput = findOutput(config->primary()->uuid());
if (requestedPrimaryOutput && requestedPrimaryOutput->isEnabled()) {
setPrimaryOutput(requestedPrimaryOutput);
} else {
auto defaultPrimaryOutput = enabledOutputs().constFirst();
qCWarning(KWIN_CORE) << "Requested invalid primary screen, using" << defaultPrimaryOutput;
setPrimaryOutput(defaultPrimaryOutput);
}
}
Q_EMIT screens()->changed();
config->setApplied();