diff --git a/abstract_output.h b/abstract_output.h --- a/abstract_output.h +++ b/abstract_output.h @@ -107,8 +107,6 @@ return m_changeset; } - void setWaylandOutput(KWayland::Server::OutputInterface *set); - QPointer xdgOutput() const { return m_xdgOutput; } @@ -139,6 +137,7 @@ void setInternal(bool set) { m_internal = set; } + void initWaylandOutput(); private: QPointer m_changeset; diff --git a/abstract_output.cpp b/abstract_output.cpp --- a/abstract_output.cpp +++ b/abstract_output.cpp @@ -21,6 +21,7 @@ #include "wayland_server.h" // KWayland +#include #include #include #include @@ -109,11 +110,6 @@ commitChanges(); } -void AbstractOutput::setWaylandOutput(KWayland::Server::OutputInterface *set) -{ - m_waylandOutput = set; -} - void AbstractOutput::createXdgOutput() { if (!m_waylandOutput || m_xdgOutput) { @@ -127,4 +123,32 @@ 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/plugins/platforms/drm/drm_output.h b/plugins/platforms/drm/drm_output.h --- a/plugins/platforms/drm/drm_output.h +++ b/plugins/platforms/drm/drm_output.h @@ -124,10 +124,10 @@ 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(); diff --git a/plugins/platforms/drm/drm_output.cpp b/plugins/platforms/drm/drm_output.cpp --- a/plugins/platforms/drm/drm_output.cpp +++ b/plugins/platforms/drm/drm_output.cpp @@ -193,7 +193,8 @@ } if (enabled) { setDpms(DpmsMode::On); - initOutput(); + initWaylandOutput(); + initDrmWaylandOutput(); } else { setDpms(DpmsMode::Off); delete waylandOutput().data(); @@ -328,19 +329,9 @@ 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 @@ } } ); - wlOutput->setManufacturer(wlOutputDevice->manufacturer()); - wlOutput->setModel(wlOutputDevice->model()); - wlOutput->setPhysicalSize(rawPhysicalSize()); // set dpms if (!m_dpms.isNull()) { @@ -370,19 +358,6 @@ }, 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)