diff --git a/abstract_output.h b/abstract_output.h --- a/abstract_output.h +++ b/abstract_output.h @@ -103,6 +103,9 @@ return false; } +Q_SIGNALS: + void modeChanged(); + protected: void initWaylandOutput(); @@ -142,6 +145,7 @@ virtual void transform(KWayland::Server::OutputDeviceInterface::Transform transform) { Q_UNUSED(transform); } + void setWaylandMode(const QSize &size, int refreshRate); private: QPointer m_waylandOutput; diff --git a/abstract_output.cpp b/abstract_output.cpp --- a/abstract_output.cpp +++ b/abstract_output.cpp @@ -100,6 +100,7 @@ m_xdgOutput->setLogicalSize(pixelSize() / m_scale); m_xdgOutput->done(); } + emit modeChanged(); } void AbstractOutput::setChanges(KWayland::Server::OutputChangeSet *changes) @@ -132,6 +133,18 @@ } } +void AbstractOutput::setWaylandMode(const QSize &size, int refreshRate) +{ + if (m_waylandOutput.isNull()) { + return; + } + m_waylandOutput->setCurrentMode(size, refreshRate); + if (m_xdgOutput) { + m_xdgOutput->setLogicalSize(pixelSize() / scale()); + m_xdgOutput->done(); + } +} + void AbstractOutput::createXdgOutput() { if (!m_waylandOutput || m_xdgOutput) { 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 @@ -99,7 +99,6 @@ Q_SIGNALS: void dpmsChanged(); - void modeChanged(); private: friend class DrmBackend; @@ -132,6 +131,7 @@ bool dpmsAtomicOff(); bool atomicReqModesetPopulate(drmModeAtomicReq *req, bool enable); void updateMode(int modeIndex) override; + void setWaylandMode(); void transform(KWayland::Server::OutputDeviceInterface::Transform transform) override; void automaticRotation(); 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 @@ -332,22 +332,6 @@ void DrmOutput::initDrmWaylandOutput() { auto wlOutput = waylandOutput(); - connect(this, &DrmOutput::modeChanged, this, - [this] { - auto wlOutput = waylandOutput(); - if (wlOutput.isNull()) { - return; - } - wlOutput->setCurrentMode(QSize(m_mode.hdisplay, m_mode.vdisplay), - refreshRateForMode(&m_mode)); - auto xdg = xdgOutput(); - if (xdg) { - xdg->setLogicalSize(pixelSize() / scale()); - xdg->done(); - } - } - ); - // set dpms if (!m_dpms.isNull()) { wlOutput->setDpmsSupported(true); @@ -825,7 +809,9 @@ // the cursor might need to get rotated updateCursor(); showCursor(); - emit modeChanged(); + + // TODO: are these calls not enough in updateMode already? + setWaylandMode(); } void DrmOutput::updateMode(int modeIndex) @@ -842,7 +828,13 @@ } m_mode = connector->modes[modeIndex]; m_modesetRequested = true; - emit modeChanged(); + setWaylandMode(); +} + +void DrmOutput::setWaylandMode() +{ + AbstractOutput::setWaylandMode(QSize(m_mode.hdisplay, m_mode.vdisplay), + refreshRateForMode(&m_mode)); } void DrmOutput::pageFlipped() @@ -961,7 +953,7 @@ updateCursor(); showCursor(); // TODO: forward to OutputInterface and OutputDeviceInterface - emit modeChanged(); + setWaylandMode(); emit screens()->changed(); } return false;