Drop Platform::{outputEnabled,outputDisabled} signals
Use Output::enabledChanged signal to determine if an output is enabled or disabled.
This commit is contained in:
parent
f956d701c4
commit
ace5b58f7a
15 changed files with 11 additions and 99 deletions
|
@ -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<PlaceholderInputEventFilter>();
|
||||
input()->prependInputEventFilter(m_placeholderFilter.get());
|
||||
}
|
||||
m_enabledOutputs.removeOne(output);
|
||||
Q_EMIT outputDisabled(output);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -102,10 +102,7 @@ private:
|
|||
std::unique_ptr<Udev> m_udev;
|
||||
std::unique_ptr<UdevMonitor> m_udevMonitor;
|
||||
Session *m_session;
|
||||
// all outputs, enabled and disabled
|
||||
QVector<DrmAbstractOutput *> m_outputs;
|
||||
// only enabled outputs
|
||||
QVector<DrmAbstractOutput *> m_enabledOutputs;
|
||||
DrmVirtualOutput *m_placeHolderOutput = nullptr;
|
||||
|
||||
bool m_active = false;
|
||||
|
|
|
@ -91,7 +91,6 @@ void VirtualBackend::setVirtualOutputs(int count, QVector<QRect> geometries, QVe
|
|||
Q_ASSERT(geometries.size() == 0 || geometries.size() == count);
|
||||
Q_ASSERT(scales.size() == 0 || scales.size() == count);
|
||||
|
||||
const QVector<VirtualOutput *> disabled = m_outputsEnabled;
|
||||
const QVector<VirtualOutput *> removed = m_outputs;
|
||||
|
||||
int sumWidth = 0;
|
||||
|
@ -112,11 +111,8 @@ void VirtualBackend::setVirtualOutputs(int count, QVector<QRect> 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<QRect> 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<VirtualOutput *>(output);
|
||||
|
|
|
@ -53,8 +53,6 @@ public:
|
|||
return QVector<CompositingType>{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<VirtualOutput *> m_outputs;
|
||||
QVector<VirtualOutput *> m_outputsEnabled;
|
||||
std::unique_ptr<QTemporaryDir> m_screenshotDir;
|
||||
};
|
||||
|
||||
|
|
|
@ -66,9 +66,4 @@ void VirtualOutput::vblank(std::chrono::nanoseconds timestamp)
|
|||
renderLoopPrivate->notifyFrameCompleted(timestamp);
|
||||
}
|
||||
|
||||
void VirtualOutput::updateEnablement(bool enable)
|
||||
{
|
||||
m_backend->enableOutput(this, enable);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -64,7 +64,6 @@ public:
|
|||
return m_surface;
|
||||
}
|
||||
|
||||
void updateEnablement(bool enable) override;
|
||||
void setDpmsMode(DpmsMode mode) override;
|
||||
|
||||
Q_SIGNALS:
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -23,8 +23,6 @@ public:
|
|||
RenderLoop *renderLoop() const override;
|
||||
|
||||
private:
|
||||
void updateEnablement(bool enabled) override;
|
||||
|
||||
X11StandalonePlatform *m_backend;
|
||||
};
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Reference in a new issue