From 21aee588af3925aff898fb2bfb8c9a775050efea Mon Sep 17 00:00:00 2001 From: Roman Gilg Date: Fri, 9 Nov 2018 19:42:05 +0100 Subject: [PATCH] Initialize Wayland output in AbstractOutput Summary: Wayland output is on protocol level and not dependent on the hardware platform. Next steps are to do the same for output device and then let the virtual output call into these initializing functions as well. Test Plan: Manually and auto test. Reviewers: #kwin, davidedmundson Reviewed By: #kwin, davidedmundson Subscribers: davidedmundson, kwin Tags: #kwin Differential Revision: https://phabricator.kde.org/D16783 --- abstract_output.cpp | 34 ++++++++++++++++++++++++---- abstract_output.h | 3 +-- plugins/platforms/drm/drm_output.cpp | 31 +++---------------------- plugins/platforms/drm/drm_output.h | 2 +- 4 files changed, 34 insertions(+), 36 deletions(-) diff --git a/abstract_output.cpp b/abstract_output.cpp index 81922e615c..ae8c58502e 100644 --- a/abstract_output.cpp +++ b/abstract_output.cpp @@ -21,6 +21,7 @@ along with this program. If not, see . #include "wayland_server.h" // KWayland +#include #include #include #include @@ -109,11 +110,6 @@ void AbstractOutput::setChanges(KWayland::Server::OutputChangeSet *changes) commitChanges(); } -void AbstractOutput::setWaylandOutput(KWayland::Server::OutputInterface *set) -{ - m_waylandOutput = set; -} - void AbstractOutput::createXdgOutput() { if (!m_waylandOutput || m_xdgOutput) { @@ -127,4 +123,32 @@ void AbstractOutput::setWaylandOutputDevice(KWayland::Server::OutputDeviceInterf m_waylandOutputDevice = set; } +void AbstractOutput::initWaylandOutput() +{ + Q_ASSERT(m_waylandOutputDevice); + + if (!m_waylandOutput.isNull()) { + delete m_waylandOutput.data(); + m_waylandOutput.clear(); + } + m_waylandOutput = waylandServer()->display()->createOutput(); + createXdgOutput(); + + m_waylandOutput->setManufacturer(m_waylandOutputDevice->manufacturer()); + m_waylandOutput->setModel(m_waylandOutputDevice->model()); + m_waylandOutput->setPhysicalSize(rawPhysicalSize()); + + for(const auto &mode: m_waylandOutputDevice->modes()) { + KWayland::Server::OutputInterface::ModeFlags flags; + if (mode.flags & KWayland::Server::OutputDeviceInterface::ModeFlag::Current) { + flags |= KWayland::Server::OutputInterface::ModeFlag::Current; + } + if (mode.flags & KWayland::Server::OutputDeviceInterface::ModeFlag::Preferred) { + flags |= KWayland::Server::OutputInterface::ModeFlag::Preferred; + } + m_waylandOutput->addMode(mode.size, flags, mode.refreshRate); + } + m_waylandOutput->create(); +} + } diff --git a/abstract_output.h b/abstract_output.h index 22bb3ead33..b6ee71a46f 100644 --- a/abstract_output.h +++ b/abstract_output.h @@ -107,8 +107,6 @@ protected: return m_changeset; } - void setWaylandOutput(KWayland::Server::OutputInterface *set); - QPointer xdgOutput() const { return m_xdgOutput; } @@ -139,6 +137,7 @@ protected: void setInternal(bool set) { m_internal = set; } + void initWaylandOutput(); private: QPointer m_changeset; diff --git a/plugins/platforms/drm/drm_output.cpp b/plugins/platforms/drm/drm_output.cpp index 0df3b89221..829fe6ddb4 100644 --- a/plugins/platforms/drm/drm_output.cpp +++ b/plugins/platforms/drm/drm_output.cpp @@ -193,7 +193,8 @@ void DrmOutput::setEnabled(bool enabled) } if (enabled) { setDpms(DpmsMode::On); - initOutput(); + initWaylandOutput(); + initDrmWaylandOutput(); } else { setDpms(DpmsMode::Off); delete waylandOutput().data(); @@ -328,19 +329,9 @@ void DrmOutput::initUuid() m_uuid = hash.result().toHex().left(10); } -void DrmOutput::initOutput() +void DrmOutput::initDrmWaylandOutput() { - auto wlOutputDevice = waylandOutputDevice(); - Q_ASSERT(wlOutputDevice); - auto wlOutput = waylandOutput(); - if (!wlOutput.isNull()) { - delete wlOutput.data(); - wlOutput.clear(); - } - wlOutput = waylandServer()->display()->createOutput(); - setWaylandOutput(wlOutput.data()); - createXdgOutput(); connect(this, &DrmOutput::modeChanged, this, [this] { auto wlOutput = waylandOutput(); @@ -356,9 +347,6 @@ void DrmOutput::initOutput() } } ); - wlOutput->setManufacturer(wlOutputDevice->manufacturer()); - wlOutput->setModel(wlOutputDevice->model()); - wlOutput->setPhysicalSize(rawPhysicalSize()); // set dpms if (!m_dpms.isNull()) { @@ -370,19 +358,6 @@ void DrmOutput::initOutput() }, Qt::QueuedConnection ); } - - for(const auto &mode: wlOutputDevice->modes()) { - KWayland::Server::OutputInterface::ModeFlags flags; - if (mode.flags & KWayland::Server::OutputDeviceInterface::ModeFlag::Current) { - flags |= KWayland::Server::OutputInterface::ModeFlag::Current; - } - if (mode.flags & KWayland::Server::OutputDeviceInterface::ModeFlag::Preferred) { - flags |= KWayland::Server::OutputInterface::ModeFlag::Preferred; - } - wlOutput->addMode(mode.size, flags, mode.refreshRate); - } - - wlOutput->create(); } void DrmOutput::initOutputDevice(drmModeConnector *connector) diff --git a/plugins/platforms/drm/drm_output.h b/plugins/platforms/drm/drm_output.h index a257366301..b6bb256dba 100644 --- a/plugins/platforms/drm/drm_output.h +++ b/plugins/platforms/drm/drm_output.h @@ -124,10 +124,10 @@ private: void initEdid(drmModeConnector *connector); void initDpms(drmModeConnector *connector); void initOutputDevice(drmModeConnector *connector); + void initDrmWaylandOutput(); bool isCurrentMode(const drmModeModeInfo *mode) const; void initUuid(); - void initOutput(); bool initPrimaryPlane(); bool initCursorPlane();