From ffa075490ef7fc216108ab44c6c88bc27ad10a49 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Gr=C3=A4=C3=9Flin?= Date: Mon, 31 Aug 2015 11:41:19 +0200 Subject: [PATCH] [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. --- backends/drm/drm_backend.cpp | 14 ++++++++++++++ backends/drm/drm_backend.h | 7 +++++++ 2 files changed, 21 insertions(+) diff --git a/backends/drm/drm_backend.cpp b/backends/drm/drm_backend.cpp index 02b93b2b68..a1b1607cdb 100644 --- a/backends/drm/drm_backend.cpp +++ b/backends/drm/drm_backend.cpp @@ -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); diff --git a/backends/drm/drm_backend.h b/backends/drm/drm_backend.h index 6c3f27bee3..c4b9472327 100644 --- a/backends/drm/drm_backend.h +++ b/backends/drm/drm_backend.h @@ -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 m_udev; QScopedPointer 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;