diff --git a/src/backends/drm/drm_backend.cpp b/src/backends/drm/drm_backend.cpp index 4cc0bbab4a..35fa79d177 100644 --- a/src/backends/drm/drm_backend.cpp +++ b/src/backends/drm/drm_backend.cpp @@ -110,8 +110,10 @@ void DrmBackend::createDpmsFilter() void DrmBackend::turnOutputsOn() { m_dpmsFilter.reset(); - for (auto it = m_enabledOutputs.constBegin(), end = m_enabledOutputs.constEnd(); it != end; it++) { - (*it)->setDpmsMode(Output::DpmsMode::On); + for (Output *output : std::as_const(m_outputs)) { + if (output->isEnabled()) { + output->setDpmsMode(Output::DpmsMode::On); + } } } @@ -121,8 +123,8 @@ void DrmBackend::checkOutputsAreOn() // already disabled, all outputs are on return; } - for (auto it = m_enabledOutputs.constBegin(), end = m_enabledOutputs.constEnd(); it != end; it++) { - if ((*it)->dpmsMode() != Output::DpmsMode::On) { + for (Output *output : std::as_const(m_outputs)) { + if (output->isEnabled() && output->dpmsMode() != Output::DpmsMode::On) { // dpms still disabled, need to keep the filter return; } @@ -355,12 +357,7 @@ void DrmBackend::updateOutputs() void DrmBackend::enableOutput(DrmAbstractOutput *output, bool enable) { - if (m_enabledOutputs.contains(output) == enable) { - return; - } if (enable) { - m_enabledOutputs << output; - Q_EMIT outputEnabled(output); checkOutputsAreOn(); if (m_placeHolderOutput && !output->isNonDesktop()) { qCDebug(KWIN_DRM) << "removing placeholder output"; @@ -369,19 +366,17 @@ void DrmBackend::enableOutput(DrmAbstractOutput *output, bool enable) m_placeholderFilter.reset(); } } else { - int normalOutputsCount = std::count_if(m_enabledOutputs.begin(), m_enabledOutputs.end(), [](const auto output) { - return !output->isNonDesktop(); + const int normalOutputsCount = std::count_if(m_outputs.constBegin(), m_outputs.constEnd(), [](const auto output) { + return output->isEnabled() && !output->isNonDesktop(); }); - if (normalOutputsCount == 1 && !output->isNonDesktop() && !kwinApp()->isTerminating()) { + if (normalOutputsCount == 0 && !output->isNonDesktop() && !kwinApp()->isTerminating()) { qCDebug(KWIN_DRM) << "adding placeholder output"; - m_placeHolderOutput = primaryGpu()->createVirtualOutput({}, m_enabledOutputs.constFirst()->pixelSize(), 1, DrmVirtualOutput::Type::Placeholder); + m_placeHolderOutput = primaryGpu()->createVirtualOutput({}, output->pixelSize(), 1, DrmVirtualOutput::Type::Placeholder); // placeholder doesn't actually need to render anything m_placeHolderOutput->renderLoop()->inhibit(); m_placeholderFilter = std::make_unique(); input()->prependInputEventFilter(m_placeholderFilter.get()); } - m_enabledOutputs.removeOne(output); - Q_EMIT outputDisabled(output); } } diff --git a/src/backends/drm/drm_backend.h b/src/backends/drm/drm_backend.h index bde1708704..42e356fe1f 100644 --- a/src/backends/drm/drm_backend.h +++ b/src/backends/drm/drm_backend.h @@ -102,10 +102,7 @@ private: std::unique_ptr m_udev; std::unique_ptr m_udevMonitor; Session *m_session; - // all outputs, enabled and disabled QVector m_outputs; - // only enabled outputs - QVector m_enabledOutputs; DrmVirtualOutput *m_placeHolderOutput = nullptr; bool m_active = false; diff --git a/src/backends/virtual/virtual_backend.cpp b/src/backends/virtual/virtual_backend.cpp index 955a923a52..71f896ffc6 100644 --- a/src/backends/virtual/virtual_backend.cpp +++ b/src/backends/virtual/virtual_backend.cpp @@ -91,7 +91,6 @@ void VirtualBackend::setVirtualOutputs(int count, QVector geometries, QVe Q_ASSERT(geometries.size() == 0 || geometries.size() == count); Q_ASSERT(scales.size() == 0 || scales.size() == count); - const QVector disabled = m_outputsEnabled; const QVector removed = m_outputs; int sumWidth = 0; @@ -112,11 +111,8 @@ void VirtualBackend::setVirtualOutputs(int count, QVector geometries, QVe vo->setEnabled(true); } - for (VirtualOutput *output : disabled) { - output->setEnabled(false); - } - for (VirtualOutput *output : removed) { + output->setEnabled(false); m_outputs.removeOne(output); Q_EMIT outputRemoved(output); delete output; @@ -125,19 +121,6 @@ void VirtualBackend::setVirtualOutputs(int count, QVector geometries, QVe Q_EMIT screensQueried(); } -void VirtualBackend::enableOutput(VirtualOutput *output, bool enable) -{ - if (enable) { - Q_ASSERT(!m_outputsEnabled.contains(output)); - m_outputsEnabled << output; - Q_EMIT outputEnabled(output); - } else { - Q_ASSERT(m_outputsEnabled.contains(output)); - m_outputsEnabled.removeOne(output); - Q_EMIT outputDisabled(output); - } -} - void VirtualBackend::removeOutput(Output *output) { VirtualOutput *virtualOutput = static_cast(output); diff --git a/src/backends/virtual/virtual_backend.h b/src/backends/virtual/virtual_backend.h index 162e0ac059..62a4022d1d 100644 --- a/src/backends/virtual/virtual_backend.h +++ b/src/backends/virtual/virtual_backend.h @@ -53,8 +53,6 @@ public: return QVector{OpenGLCompositing, QPainterCompositing}; } - void enableOutput(VirtualOutput *output, bool enable); - Q_INVOKABLE void removeOutput(Output *output); Q_INVOKABLE QImage captureOutput(Output *output) const; @@ -63,7 +61,6 @@ Q_SIGNALS: private: QVector m_outputs; - QVector m_outputsEnabled; std::unique_ptr m_screenshotDir; }; diff --git a/src/backends/virtual/virtual_output.cpp b/src/backends/virtual/virtual_output.cpp index 823113a6a6..f12584a7b7 100644 --- a/src/backends/virtual/virtual_output.cpp +++ b/src/backends/virtual/virtual_output.cpp @@ -66,9 +66,4 @@ void VirtualOutput::vblank(std::chrono::nanoseconds timestamp) renderLoopPrivate->notifyFrameCompleted(timestamp); } -void VirtualOutput::updateEnablement(bool enable) -{ - m_backend->enableOutput(this, enable); -} - } diff --git a/src/backends/virtual/virtual_output.h b/src/backends/virtual/virtual_output.h index ca1d7b82df..111d195a2c 100644 --- a/src/backends/virtual/virtual_output.h +++ b/src/backends/virtual/virtual_output.h @@ -32,7 +32,6 @@ public: void init(const QPoint &logicalPosition, const QSize &pixelSize); void setGeometry(const QRect &geo); - void updateEnablement(bool enable) override; private: void vblank(std::chrono::nanoseconds timestamp); diff --git a/src/backends/wayland/wayland_output.cpp b/src/backends/wayland/wayland_output.cpp index 1d1848b23d..4666649978 100644 --- a/src/backends/wayland/wayland_output.cpp +++ b/src/backends/wayland/wayland_output.cpp @@ -71,15 +71,6 @@ void WaylandOutput::resize(const QSize &pixelSize) Q_EMIT m_backend->screensQueried(); } -void WaylandOutput::updateEnablement(bool enable) -{ - if (enable) { - Q_EMIT m_backend->outputEnabled(this); - } else { - Q_EMIT m_backend->outputDisabled(this); - } -} - void WaylandOutput::setDpmsMode(DpmsMode mode) { if (mode == DpmsMode::Off) { diff --git a/src/backends/wayland/wayland_output.h b/src/backends/wayland/wayland_output.h index 9becd40f2b..0068ce3058 100644 --- a/src/backends/wayland/wayland_output.h +++ b/src/backends/wayland/wayland_output.h @@ -64,7 +64,6 @@ public: return m_surface; } - void updateEnablement(bool enable) override; void setDpmsMode(DpmsMode mode) override; Q_SIGNALS: diff --git a/src/backends/x11/standalone/x11_standalone_output.cpp b/src/backends/x11/standalone/x11_standalone_output.cpp index 4543fc1ebc..283274d9f3 100644 --- a/src/backends/x11/standalone/x11_standalone_output.cpp +++ b/src/backends/x11/standalone/x11_standalone_output.cpp @@ -72,13 +72,4 @@ void X11Output::setMode(const QSize &size, uint32_t refreshRate) } } -void X11Output::updateEnablement(bool enabled) -{ - if (enabled) { - Q_EMIT m_backend->outputEnabled(this); - } else { - Q_EMIT m_backend->outputDisabled(this); - } -} - } // namespace KWin diff --git a/src/backends/x11/standalone/x11_standalone_output.h b/src/backends/x11/standalone/x11_standalone_output.h index 5acbbc8e9a..ea9c008a7d 100644 --- a/src/backends/x11/standalone/x11_standalone_output.h +++ b/src/backends/x11/standalone/x11_standalone_output.h @@ -33,7 +33,6 @@ public: explicit X11Output(X11StandalonePlatform *backend, QObject *parent = nullptr); bool usesSoftwareCursor() const override; - void updateEnablement(bool enabled) override; RenderLoop *renderLoop() const override; void setRenderLoop(RenderLoop *loop); diff --git a/src/backends/x11/standalone/x11_standalone_placeholderoutput.cpp b/src/backends/x11/standalone/x11_standalone_placeholderoutput.cpp index 4204df4c85..6f002571dc 100644 --- a/src/backends/x11/standalone/x11_standalone_placeholderoutput.cpp +++ b/src/backends/x11/standalone/x11_standalone_placeholderoutput.cpp @@ -34,13 +34,4 @@ RenderLoop *X11PlaceholderOutput::renderLoop() const return m_backend->renderLoop(); } -void X11PlaceholderOutput::updateEnablement(bool enabled) -{ - if (enabled) { - Q_EMIT m_backend->outputEnabled(this); - } else { - Q_EMIT m_backend->outputDisabled(this); - } -} - } // namespace KWin diff --git a/src/backends/x11/standalone/x11_standalone_placeholderoutput.h b/src/backends/x11/standalone/x11_standalone_placeholderoutput.h index 686dd7f759..1dbe1edf4a 100644 --- a/src/backends/x11/standalone/x11_standalone_placeholderoutput.h +++ b/src/backends/x11/standalone/x11_standalone_placeholderoutput.h @@ -23,8 +23,6 @@ public: RenderLoop *renderLoop() const override; private: - void updateEnablement(bool enabled) override; - X11StandalonePlatform *m_backend; }; diff --git a/src/backends/x11/windowed/x11_windowed_output.cpp b/src/backends/x11/windowed/x11_windowed_output.cpp index f9b509c55d..663ce8cb4c 100644 --- a/src/backends/x11/windowed/x11_windowed_output.cpp +++ b/src/backends/x11/windowed/x11_windowed_output.cpp @@ -194,13 +194,4 @@ bool X11WindowedOutput::usesSoftwareCursor() const return false; } -void X11WindowedOutput::updateEnablement(bool enabled) -{ - if (enabled) { - Q_EMIT m_backend->outputEnabled(this); - } else { - Q_EMIT m_backend->outputDisabled(this); - } -} - } // namespace KWin diff --git a/src/backends/x11/windowed/x11_windowed_output.h b/src/backends/x11/windowed/x11_windowed_output.h index f007978736..ffb1cdfd1e 100644 --- a/src/backends/x11/windowed/x11_windowed_output.h +++ b/src/backends/x11/windowed/x11_windowed_output.h @@ -61,7 +61,6 @@ public: QPointF mapFromGlobal(const QPointF &pos) const; bool usesSoftwareCursor() const override; - void updateEnablement(bool enabled) override; QRegion exposedArea() const; void addExposedArea(const QRect &rect); diff --git a/src/platform.h b/src/platform.h index e2bd5f7ba6..430616fd79 100644 --- a/src/platform.h +++ b/src/platform.h @@ -340,19 +340,6 @@ Q_SIGNALS: * This signal is emitted when an output has been disconnected. */ void outputRemoved(Output *output); - /** - * This signal is emitted when the @a output has become activated and it is ready for - * compositing. - */ - void outputEnabled(Output *output); - /** - * This signal is emitted when the @a output has been deactivated and it is no longer - * being composited. The outputDisabled() signal is guaranteed to be emitted before the - * output is removed. - * - * @see outputEnabled, outputRemoved - */ - void outputDisabled(Output *output); protected: explicit Platform(QObject *parent = nullptr);