Assure wayland output interface creation path

Summary:
The Wayland and XDG output interfaces are created or destroyed when the
output is en- or disabled. This follows a clear path of dependencies and
we should not check if this is indeed the case but instead assert on it.

Test Plan: Nested Wayland and Drm sessions.

Reviewers: #kwin, zzag

Reviewed By: #kwin, zzag

Subscribers: kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D23540
This commit is contained in:
Roman Gilg 2019-08-28 18:13:41 +02:00
parent 7f5f64c0c7
commit f2c5f85cae
2 changed files with 9 additions and 11 deletions

View file

@ -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();

View file

@ -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<KWayland::Server::XdgOutputInterface> xdgOutput() const {
return m_xdgOutput;
}
void createXdgOutput();
QPointer<KWayland::Server::OutputDeviceInterface> waylandOutputDevice() const {
return m_waylandOutputDevice;
@ -154,6 +152,9 @@ protected:
QSize orientateSize(const QSize &size) const;
private:
void createWaylandOutput();
void createXdgOutput();
QPointer<KWayland::Server::OutputInterface> m_waylandOutput;
QPointer<KWayland::Server::XdgOutputInterface> m_xdgOutput;
QPointer<KWayland::Server::OutputDeviceInterface> m_waylandOutputDevice;