aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRoman Gilg <[email protected]>2018-11-09 20:28:57 +0100
committerRoman Gilg <[email protected]>2018-11-14 19:57:25 +0100
commit27946199b6b2dd63e4ef0abdb4becae749fe258b (patch)
tree89f6f7dde061bdb0dc9223eb1ccdfba013fea591
parente2b1bcea1b1b4003a6e0262bc3758dbd893030f5 (diff)
Abstract output dpms handling
Summary: Move init and Wayland side changes of dpms modes into AbstractOutput. Reviewers: #kwin, davidedmundson Reviewed By: #kwin, davidedmundson Subscribers: davidedmundson, kwin Tags: #kwin Maniphest Tasks: T10016 Differential Revision: https://phabricator.kde.org/D16787
-rw-r--r--abstract_output.cpp19
-rw-r--r--abstract_output.h10
-rw-r--r--plugins/platforms/drm/drm_backend.cpp2
-rw-r--r--plugins/platforms/drm/drm_output.cpp35
-rw-r--r--plugins/platforms/drm/drm_output.h5
5 files changed, 42 insertions, 29 deletions
diff --git a/abstract_output.cpp b/abstract_output.cpp
index fbb9da2..9d933e4 100644
--- a/abstract_output.cpp
+++ b/abstract_output.cpp
@@ -22,7 +22,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
// KWayland
#include <KWayland/Server/display.h>
-#include <KWayland/Server/output_interface.h>
#include <KWayland/Server/outputchangeset.h>
#include <KWayland/Server/xdgoutput_interface.h>
// KF5
@@ -169,10 +168,16 @@ void AbstractOutput::initWaylandOutput()
m_waylandOutput = waylandServer()->display()->createOutput();
createXdgOutput();
+ /*
+ * add base wayland output data
+ */
m_waylandOutput->setManufacturer(m_waylandOutputDevice->manufacturer());
m_waylandOutput->setModel(m_waylandOutputDevice->model());
m_waylandOutput->setPhysicalSize(rawPhysicalSize());
+ /*
+ * add modes
+ */
for(const auto &mode: m_waylandOutputDevice->modes()) {
KWayland::Server::OutputInterface::ModeFlags flags;
if (mode.flags & KWayland::Server::OutputDeviceInterface::ModeFlag::Current) {
@@ -184,6 +189,18 @@ void AbstractOutput::initWaylandOutput()
m_waylandOutput->addMode(mode.size, flags, mode.refreshRate);
}
m_waylandOutput->create();
+
+ /*
+ * set dpms
+ */
+ m_waylandOutput->setDpmsSupported(m_supportsDpms);
+ // set to last known mode
+ m_waylandOutput->setDpmsMode(m_dpms);
+ connect(m_waylandOutput.data(), &KWayland::Server::OutputInterface::dpmsModeRequested, this,
+ [this] (KWayland::Server::OutputInterface::DpmsMode mode) {
+ updateDpms(mode);
+ }, Qt::QueuedConnection
+ );
}
}
diff --git a/abstract_output.h b/abstract_output.h
index 2494576..0fe38bb 100644
--- a/abstract_output.h
+++ b/abstract_output.h
@@ -30,6 +30,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include <QSize>
#include <QVector>
+#include <KWayland/Server/output_interface.h>
#include <KWayland/Server/outputdevice_interface.h>
namespace KWayland
@@ -139,6 +140,12 @@ protected:
void setInternal(bool set) {
m_internal = set;
}
+ void setDpmsSupported(bool set) {
+ m_supportsDpms = set;
+ }
+ virtual void updateDpms(KWayland::Server::OutputInterface::DpmsMode mode) {
+ Q_UNUSED(mode);
+ }
virtual void updateMode(int modeIndex) {
Q_UNUSED(modeIndex);
}
@@ -152,11 +159,14 @@ private:
QPointer<KWayland::Server::XdgOutputInterface> m_xdgOutput;
QPointer<KWayland::Server::OutputDeviceInterface> m_waylandOutputDevice;
+ KWayland::Server::OutputInterface::DpmsMode m_dpms = KWayland::Server::OutputInterface::DpmsMode::On;
+
QPoint m_globalPos;
qreal m_scale = 1;
QSize m_physicalSize;
Qt::ScreenOrientation m_orientation = Qt::PrimaryOrientation;
bool m_internal = false;
+ bool m_supportsDpms = false;
};
}
diff --git a/plugins/platforms/drm/drm_backend.cpp b/plugins/platforms/drm/drm_backend.cpp
index 634717c..0ae0a70 100644
--- a/plugins/platforms/drm/drm_backend.cpp
+++ b/plugins/platforms/drm/drm_backend.cpp
@@ -144,7 +144,7 @@ void DrmBackend::turnOutputsOn()
{
m_dpmsFilter.reset();
for (auto it = m_enabledOutputs.constBegin(), end = m_enabledOutputs.constEnd(); it != end; it++) {
- (*it)->setDpms(DrmOutput::DpmsMode::On);
+ (*it)->updateDpms(KWayland::Server::OutputInterface::DpmsMode::On);
}
}
diff --git a/plugins/platforms/drm/drm_output.cpp b/plugins/platforms/drm/drm_output.cpp
index 2f55c00..0eb716d 100644
--- a/plugins/platforms/drm/drm_output.cpp
+++ b/plugins/platforms/drm/drm_output.cpp
@@ -192,11 +192,10 @@ void DrmOutput::setEnabled(bool enabled)
return;
}
if (enabled) {
- setDpms(DpmsMode::On);
+ updateDpms(KWayland::Server::OutputInterface::DpmsMode::On);
initWaylandOutput();
- initDrmWaylandOutput();
} else {
- setDpms(DpmsMode::Off);
+ updateDpms(KWayland::Server::OutputInterface::DpmsMode::Off);
delete waylandOutput().data();
}
waylandOutputDevice()->setEnabled(enabled ?
@@ -290,6 +289,7 @@ bool DrmOutput::init(drmModeConnector *connector)
}
setInternal(connector->connector_type == DRM_MODE_CONNECTOR_LVDS || connector->connector_type == DRM_MODE_CONNECTOR_eDP);
+ setDpmsSupported(true);
if (internal()) {
connect(kwinApp(), &Application::screensCreated, this,
@@ -329,21 +329,6 @@ void DrmOutput::initUuid()
m_uuid = hash.result().toHex().left(10);
}
-void DrmOutput::initDrmWaylandOutput()
-{
- auto wlOutput = waylandOutput();
- // set dpms
- if (!m_dpms.isNull()) {
- wlOutput->setDpmsSupported(true);
- wlOutput->setDpmsMode(toWaylandDpmsMode(m_dpmsMode));
- connect(wlOutput.data(), &KWayland::Server::OutputInterface::dpmsModeRequested, this,
- [this] (KWayland::Server::OutputInterface::DpmsMode mode) {
- setDpms(fromWaylandDpmsMode(mode));
- }, Qt::QueuedConnection
- );
- }
-}
-
void DrmOutput::initOutputDevice(drmModeConnector *connector)
{
auto wlOutputDevice = waylandOutputDevice();
@@ -654,21 +639,23 @@ void DrmOutput::initDpms(drmModeConnector *connector)
}
}
-void DrmOutput::setDpms(DrmOutput::DpmsMode mode)
+void DrmOutput::updateDpms(KWayland::Server::OutputInterface::DpmsMode mode)
{
if (m_dpms.isNull()) {
return;
}
- if (mode == m_dpmsModePending) {
+
+ const auto drmMode = fromWaylandDpmsMode(mode);
+ if (drmMode == m_dpmsModePending) {
qCDebug(KWIN_DRM) << "New DPMS mode equals old mode. DPMS unchanged.";
return;
}
- m_dpmsModePending = mode;
+ m_dpmsModePending = drmMode;
if (m_backend->atomicModeSetting()) {
m_modesetRequested = true;
- if (mode == DpmsMode::On) {
+ if (drmMode == DpmsMode::On) {
if (m_pageFlipPending) {
m_pageFlipPending = false;
Compositor::self()->bufferSwapComplete();
@@ -681,12 +668,12 @@ void DrmOutput::setDpms(DrmOutput::DpmsMode mode)
}
}
} else {
- if (drmModeConnectorSetProperty(m_backend->fd(), m_conn->id(), m_dpms->prop_id, uint64_t(mode)) < 0) {
+ if (drmModeConnectorSetProperty(m_backend->fd(), m_conn->id(), m_dpms->prop_id, uint64_t(drmMode)) < 0) {
m_dpmsModePending = m_dpmsMode;
qCWarning(KWIN_DRM) << "Setting DPMS failed";
return;
}
- if (mode == DpmsMode::On) {
+ if (drmMode == DpmsMode::On) {
dpmsOnHandler();
} else {
dpmsOffHandler();
diff --git a/plugins/platforms/drm/drm_output.h b/plugins/platforms/drm/drm_output.h
index a8fda77..38c6c8f 100644
--- a/plugins/platforms/drm/drm_output.h
+++ b/plugins/platforms/drm/drm_output.h
@@ -67,7 +67,7 @@ public:
/**
* Enable or disable the output.
- * This differs from setDpms as it also
+ * This differs from updateDpms as it also
* removes the wl_output
* The default is on
*/
@@ -83,7 +83,6 @@ public:
Suspend = DRM_MODE_DPMS_SUSPEND,
Off = DRM_MODE_DPMS_OFF
};
- void setDpms(DpmsMode mode);
bool isDpmsEnabled() const {
// We care for current as well as pending mode in order to allow first present in AMS.
return m_dpmsModePending == DpmsMode::On;
@@ -119,7 +118,6 @@ private:
void initEdid(drmModeConnector *connector);
void initDpms(drmModeConnector *connector);
void initOutputDevice(drmModeConnector *connector);
- void initDrmWaylandOutput();
bool isCurrentMode(const drmModeModeInfo *mode) const;
void initUuid();
@@ -130,6 +128,7 @@ private:
void dpmsOffHandler();
bool dpmsAtomicOff();
bool atomicReqModesetPopulate(drmModeAtomicReq *req, bool enable);
+ void updateDpms(KWayland::Server::OutputInterface::DpmsMode mode) override;
void updateMode(int modeIndex) override;
void setWaylandMode();