platforms/drm: refactor output enablement
This commit is contained in:
parent
9dc6fd35db
commit
866830d5ed
2 changed files with 25 additions and 36 deletions
|
@ -313,36 +313,13 @@ DrmGpu *DrmBackend::addGpu(const QString &fileName)
|
||||||
void DrmBackend::addOutput(DrmAbstractOutput *o)
|
void DrmBackend::addOutput(DrmAbstractOutput *o)
|
||||||
{
|
{
|
||||||
m_outputs.append(o);
|
m_outputs.append(o);
|
||||||
m_enabledOutputs.append(o);
|
|
||||||
Q_EMIT outputAdded(o);
|
Q_EMIT outputAdded(o);
|
||||||
Q_EMIT outputEnabled(o);
|
enableOutput(o, true);
|
||||||
if (m_placeHolderOutput) {
|
|
||||||
qCDebug(KWIN_DRM) << "removing placeholder output";
|
|
||||||
primaryGpu()->removeVirtualOutput(m_placeHolderOutput);
|
|
||||||
m_placeHolderOutput = nullptr;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void DrmBackend::removeOutput(DrmAbstractOutput *o)
|
void DrmBackend::removeOutput(DrmAbstractOutput *o)
|
||||||
{
|
{
|
||||||
if (m_outputs.count() == 1 && !kwinApp()->isTerminating()) {
|
enableOutput(o, false);
|
||||||
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.contains(o)) {
|
|
||||||
if (m_enabledOutputs.count() == 1) {
|
|
||||||
for (const auto &output : qAsConst(m_outputs)) {
|
|
||||||
if (output != o) {
|
|
||||||
output->setEnabled(true);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
m_enabledOutputs.removeOne(o);
|
|
||||||
Q_EMIT outputDisabled(o);
|
|
||||||
}
|
|
||||||
m_outputs.removeOne(o);
|
m_outputs.removeOne(o);
|
||||||
Q_EMIT outputRemoved(o);
|
Q_EMIT outputRemoved(o);
|
||||||
}
|
}
|
||||||
|
@ -501,20 +478,38 @@ void DrmBackend::readOutputsConfiguration()
|
||||||
|
|
||||||
void DrmBackend::enableOutput(DrmAbstractOutput *output, bool enable)
|
void DrmBackend::enableOutput(DrmAbstractOutput *output, bool enable)
|
||||||
{
|
{
|
||||||
|
if (m_enabledOutputs.contains(output) == enable) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (enable) {
|
if (enable) {
|
||||||
Q_ASSERT(!m_enabledOutputs.contains(output));
|
|
||||||
m_enabledOutputs << output;
|
m_enabledOutputs << output;
|
||||||
Q_EMIT output->gpu()->outputEnabled(output);
|
Q_EMIT output->gpu()->outputEnabled(output);
|
||||||
Q_EMIT outputEnabled(output);
|
Q_EMIT outputEnabled(output);
|
||||||
|
checkOutputsAreOn();
|
||||||
|
if (m_placeHolderOutput) {
|
||||||
|
qCDebug(KWIN_DRM) << "removing placeholder output";
|
||||||
|
primaryGpu()->removeVirtualOutput(m_placeHolderOutput);
|
||||||
|
m_placeHolderOutput = nullptr;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
Q_ASSERT(m_enabledOutputs.contains(output));
|
if (m_enabledOutputs.count() == 1) {
|
||||||
|
for (const auto &o : qAsConst(m_outputs)) {
|
||||||
|
if (o != output) {
|
||||||
|
o->setEnabled(true);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (m_enabledOutputs.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();
|
||||||
|
}
|
||||||
m_enabledOutputs.removeOne(output);
|
m_enabledOutputs.removeOne(output);
|
||||||
Q_ASSERT(!m_enabledOutputs.contains(output));
|
|
||||||
Q_EMIT output->gpu()->outputDisabled(output);
|
Q_EMIT output->gpu()->outputDisabled(output);
|
||||||
Q_EMIT outputDisabled(output);
|
Q_EMIT outputDisabled(output);
|
||||||
}
|
}
|
||||||
checkOutputsAreOn();
|
|
||||||
Q_EMIT screensQueried();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void DrmBackend::initCursor()
|
void DrmBackend::initCursor()
|
||||||
|
|
|
@ -572,9 +572,6 @@ void DrmGpu::removeOutput(DrmOutput *output)
|
||||||
{
|
{
|
||||||
m_drmOutputs.removeOne(output);
|
m_drmOutputs.removeOne(output);
|
||||||
m_outputs.removeOne(output);
|
m_outputs.removeOne(output);
|
||||||
if (output->isEnabled()) {
|
|
||||||
Q_EMIT outputDisabled(output);
|
|
||||||
}
|
|
||||||
Q_EMIT outputRemoved(output);
|
Q_EMIT outputRemoved(output);
|
||||||
auto pipeline = output->m_pipeline;
|
auto pipeline = output->m_pipeline;
|
||||||
delete output;
|
delete output;
|
||||||
|
@ -614,9 +611,6 @@ DrmVirtualOutput *DrmGpu::createVirtualOutput()
|
||||||
void DrmGpu::removeVirtualOutput(DrmVirtualOutput *output)
|
void DrmGpu::removeVirtualOutput(DrmVirtualOutput *output)
|
||||||
{
|
{
|
||||||
if (m_outputs.removeOne(output)) {
|
if (m_outputs.removeOne(output)) {
|
||||||
if (output->isEnabled()) {
|
|
||||||
Q_EMIT outputDisabled(output);
|
|
||||||
}
|
|
||||||
Q_EMIT outputRemoved(output);
|
Q_EMIT outputRemoved(output);
|
||||||
delete output;
|
delete output;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue