platforms/drm: prevent having zero outputs at any time

Instead of updating all outputs first, create the placeholder output
before the last output gets removed.
This commit is contained in:
Xaver Hugl 2021-08-30 14:59:46 +02:00
parent 2696030b00
commit dbf4a59527
2 changed files with 11 additions and 5 deletions

View file

@ -334,10 +334,21 @@ void DrmBackend::addOutput(DrmAbstractOutput *o)
m_enabledOutputs.append(o);
Q_EMIT outputAdded(o);
Q_EMIT outputEnabled(o);
if (m_placeHolderOutput) {
qCDebug(KWIN_DRM) << "removing placeholder output";
primaryGpu()->removeVirtualOutput(m_placeHolderOutput);
m_placeHolderOutput = nullptr;
}
}
void DrmBackend::removeOutput(DrmAbstractOutput *o)
{
if (m_outputs.count() == 1 && !kwinApp()->isTerminating()) {
qCDebug(KWIN_DRM) << "adding placeholder output";
m_placeHolderOutput = primaryGpu()->createVirtualOutput();
// placeholder doesn't actually need to render anything
m_placeHolderOutput->renderLoop()->inhibit();
}
if (m_enabledOutputs.removeOne(o)) {
Q_EMIT outputDisabled(o);
}
@ -366,10 +377,6 @@ void DrmBackend::updateOutputs()
m_placeHolderOutput = primaryGpu()->createVirtualOutput();
// placeholder doesn't actually need to render anything
m_placeHolderOutput->renderLoop()->inhibit();
} else if (m_placeHolderOutput && m_outputs.count() > 1) {
qCDebug(KWIN_DRM) << "removing placeholder output";
primaryGpu()->removeVirtualOutput(m_placeHolderOutput);
m_placeHolderOutput = nullptr;
}
std::sort(m_outputs.begin(), m_outputs.end(), [] (DrmAbstractOutput *a, DrmAbstractOutput *b) {

View file

@ -38,7 +38,6 @@ class KWIN_EXPORT DrmOutput : public DrmAbstractOutput
{
Q_OBJECT
public:
///deletes the output, calling this whilst a page flip is pending will result in an error
~DrmOutput() override;
bool initCursor(const QSize &cursorSize) override;