diff --git a/abstract_wayland_output.cpp b/abstract_wayland_output.cpp index d743287ff2..db32e8b6c4 100644 --- a/abstract_wayland_output.cpp +++ b/abstract_wayland_output.cpp @@ -157,7 +157,7 @@ void AbstractWaylandOutput::setEnabled(bool enable) } if (enable) { updateDpms(KWayland::Server::OutputInterface::DpmsMode::On); - initWaylandOutput(); + createWaylandOutput(); } else { updateDpms(KWayland::Server::OutputInterface::DpmsMode::Off); delete waylandOutput().data(); @@ -180,21 +180,18 @@ void AbstractWaylandOutput::setWaylandMode(const QSize &size, int refreshRate) void AbstractWaylandOutput::createXdgOutput() { - if (!m_waylandOutput || m_xdgOutput) { - return; - } + Q_ASSERT(!m_waylandOutput.isNull()); + Q_ASSERT(m_xdgOutput.isNull()); + m_xdgOutput = waylandServer()->xdgOutputManager()->createXdgOutput(m_waylandOutput, m_waylandOutput); m_xdgOutput->setLogicalSize(pixelSize() / scale()); m_xdgOutput->setLogicalPosition(globalPos()); m_xdgOutput->done(); } -void AbstractWaylandOutput::initWaylandOutput() +void AbstractWaylandOutput::createWaylandOutput() { - if (!m_waylandOutput.isNull()) { - delete m_waylandOutput.data(); - m_waylandOutput.clear(); - } + Q_ASSERT(m_waylandOutput.isNull()); m_waylandOutput = waylandServer()->display()->createOutput(); createXdgOutput(); diff --git a/abstract_wayland_output.h b/abstract_wayland_output.h index e13f9f8176..20c8dd1410 100644 --- a/abstract_wayland_output.h +++ b/abstract_wayland_output.h @@ -109,7 +109,6 @@ Q_SIGNALS: void modeChanged(); protected: - void initWaylandOutput(); void initWaylandOutputDevice(const QString &model, const QString &manufacturer, const QByteArray &uuid, @@ -119,7 +118,6 @@ protected: QPointer xdgOutput() const { return m_xdgOutput; } - void createXdgOutput(); QPointer waylandOutputDevice() const { return m_waylandOutputDevice; @@ -154,6 +152,9 @@ protected: QSize orientateSize(const QSize &size) const; private: + void createWaylandOutput(); + void createXdgOutput(); + QPointer m_waylandOutput; QPointer m_xdgOutput; QPointer m_waylandOutputDevice;