[drm] Mark outputs as disabled in backend depending on DPMS state
Whenever the dpms of an output changes we update the outputs enabled state in the AbstractBackend.
This commit is contained in:
parent
4f1033f17b
commit
ffa075490e
2 changed files with 21 additions and 0 deletions
|
@ -276,6 +276,7 @@ void DrmBackend::queryResources()
|
|||
continue;
|
||||
}
|
||||
DrmOutput *drmOutput = new DrmOutput(this);
|
||||
connect(drmOutput, &DrmOutput::dpmsChanged, this, &DrmBackend::outputDpmsChanged);
|
||||
drmOutput->m_crtcId = crtcId;
|
||||
if (crtc->mode_valid) {
|
||||
drmOutput->m_mode = crtc->mode;
|
||||
|
@ -502,6 +503,18 @@ void DrmBackend::bufferDestroyed(DrmBuffer *b)
|
|||
m_buffers.removeAll(b);
|
||||
}
|
||||
|
||||
void DrmBackend::outputDpmsChanged()
|
||||
{
|
||||
if (m_outputs.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
bool enabled = false;
|
||||
for (auto it = m_outputs.constBegin(); it != m_outputs.constEnd(); ++it) {
|
||||
enabled = enabled || (*it)->isDpmsEnabled();
|
||||
}
|
||||
setOutputsEnabled(enabled);
|
||||
}
|
||||
|
||||
DrmOutput::DrmOutput(DrmBackend *backend)
|
||||
: QObject()
|
||||
, m_backend(backend)
|
||||
|
@ -896,6 +909,7 @@ void DrmOutput::setDpms(DrmOutput::DpmsMode mode)
|
|||
return;
|
||||
}
|
||||
m_dpmsMode = mode;
|
||||
emit dpmsChanged();
|
||||
if (m_dpmsMode != DpmsMode::On) {
|
||||
connect(input(), &InputRedirection::globalPointerChanged, this, &DrmOutput::reenableDpms);
|
||||
connect(input(), &InputRedirection::pointerButtonStateChanged, this, &DrmOutput::reenableDpms);
|
||||
|
|
|
@ -106,6 +106,7 @@ private:
|
|||
void initCursor();
|
||||
quint32 findCrtc(drmModeRes *res, drmModeConnector *connector, bool *ok = nullptr);
|
||||
bool crtcIsUsed(quint32 crtc);
|
||||
void outputDpmsChanged();
|
||||
DrmOutput *findOutput(quint32 connector);
|
||||
QScopedPointer<Udev> m_udev;
|
||||
QScopedPointer<UdevMonitor> m_udevMonitor;
|
||||
|
@ -150,6 +151,12 @@ public:
|
|||
Off = DRM_MODE_DPMS_OFF
|
||||
};
|
||||
void setDpms(DpmsMode mode);
|
||||
bool isDpmsEnabled() const {
|
||||
return m_dpmsMode == DpmsMode::On;
|
||||
}
|
||||
|
||||
Q_SIGNALS:
|
||||
void dpmsChanged();
|
||||
|
||||
private:
|
||||
friend class DrmBackend;
|
||||
|
|
Loading…
Reference in a new issue