Introduce Platform::{outputAdded, outputRemoved} signals

These new signals can be useful if you are interested only in when a
specific output gets added or removed.
This commit is contained in:
Vlad Zahorodnii 2020-11-07 20:27:38 +02:00
parent c766e5da6d
commit 6f83132bd1
7 changed files with 13 additions and 11 deletions

View file

@ -498,6 +498,8 @@ Q_SIGNALS:
* Emitted by backends using a one screen (nested window) approach and when the size of that changes.
*/
void screenSizeChanged();
void outputAdded(AbstractOutput *output);
void outputRemoved(AbstractOutput *output);
protected:
explicit Platform(QObject *parent = nullptr);

View file

@ -332,6 +332,7 @@ void DrmBackend::addOutput(DrmOutput *o)
m_outputs.append(o);
m_enabledOutputs.append(o);
emit o->gpu()->outputEnabled(o);
emit outputAdded(o);
}
void DrmBackend::removeOutput(DrmOutput *o)
@ -339,6 +340,7 @@ void DrmBackend::removeOutput(DrmOutput *o)
emit o->gpu()->outputDisabled(o);
m_outputs.removeOne(o);
m_enabledOutputs.removeOne(o);
emit outputRemoved(o);
}
bool DrmBackend::updateOutputs()

View file

@ -105,7 +105,7 @@ EglWaylandBackend::EglWaylandBackend(WaylandBackend *b)
connect(m_backend, &WaylandBackend::outputAdded, this, &EglWaylandBackend::createEglWaylandOutput);
connect(m_backend, &WaylandBackend::outputRemoved, this,
[this] (WaylandOutput *output) {
[this] (AbstractOutput *output) {
auto it = std::find_if(m_outputs.begin(), m_outputs.end(),
[output] (const EglWaylandOutput *o) {
return o->m_waylandOutput == output;
@ -133,9 +133,9 @@ void EglWaylandBackend::cleanupSurfaces()
m_outputs.clear();
}
bool EglWaylandBackend::createEglWaylandOutput(WaylandOutput *waylandOutput)
bool EglWaylandBackend::createEglWaylandOutput(AbstractOutput *waylandOutput)
{
auto *output = new EglWaylandOutput(waylandOutput, this);
auto *output = new EglWaylandOutput(static_cast<WaylandOutput *>(waylandOutput), this);
if (!output->init(this)) {
return false;
}

View file

@ -87,7 +87,7 @@ private:
bool initBufferConfigs();
bool initRenderingContext();
bool createEglWaylandOutput(WaylandOutput *output);
bool createEglWaylandOutput(AbstractOutput *output);
void cleanupSurfaces() override;
void cleanupOutput(EglWaylandOutput *output);

View file

@ -137,7 +137,7 @@ WaylandQPainterBackend::WaylandQPainterBackend(Wayland::WaylandBackend *b)
}
connect(m_backend, &WaylandBackend::outputAdded, this, &WaylandQPainterBackend::createOutput);
connect(m_backend, &WaylandBackend::outputRemoved, this,
[this] (WaylandOutput *waylandOutput) {
[this] (AbstractOutput *waylandOutput) {
auto it = std::find_if(m_outputs.begin(), m_outputs.end(),
[waylandOutput] (WaylandQPainterOutput *output) {
return output->m_waylandOutput == waylandOutput;
@ -161,9 +161,9 @@ bool WaylandQPainterBackend::perScreenRendering() const
return true;
}
void WaylandQPainterBackend::createOutput(WaylandOutput *waylandOutput)
void WaylandQPainterBackend::createOutput(AbstractOutput *waylandOutput)
{
auto *output = new WaylandQPainterOutput(waylandOutput, this);
auto *output = new WaylandQPainterOutput(static_cast<WaylandOutput *>(waylandOutput), this);
output->init(m_backend->shmPool());
m_outputs << output;
}

View file

@ -27,6 +27,7 @@ class Buffer;
namespace KWin
{
class AbstractOutput;
namespace Wayland
{
class WaylandBackend;
@ -79,7 +80,7 @@ public:
bool perScreenRendering() const override;
private:
void createOutput(WaylandOutput *waylandOutput);
void createOutput(AbstractOutput *waylandOutput);
void frameRendered();
WaylandBackend *m_backend;

View file

@ -203,9 +203,6 @@ public:
}
Q_SIGNALS:
void outputAdded(WaylandOutput *output);
void outputRemoved(WaylandOutput *output);
void systemCompositorDied();
void connectionFailed();