Rely on output device existence

Summary:
For every abstract wayland output an output device interface is created
by the backend directly after instance creation. We can therefore rely on
its existence and remove superfluous checks.

Test Plan: Relevant auto tests pass. Wayland nested and DRM sessions tested.

Reviewers: #kwin, davidedmundson

Reviewed By: #kwin, davidedmundson

Subscribers: kwin

Tags: #kwin

Maniphest Tasks: T11459

Differential Revision: https://phabricator.kde.org/D23486
icc-effect-5.17.5
Roman Gilg 2019-08-27 13:07:11 +02:00
parent 4dfb8150fa
commit 0bcfb4d609
1 changed files with 6 additions and 14 deletions

View File

@ -39,9 +39,9 @@ AbstractWaylandOutput::AbstractWaylandOutput(QObject *parent)
AbstractWaylandOutput::~AbstractWaylandOutput()
{
delete m_waylandOutputDevice.data();
delete m_xdgOutput.data();
delete m_waylandOutput.data();
delete m_waylandOutputDevice.data();
}
QString AbstractWaylandOutput::name() const
@ -73,12 +73,11 @@ int AbstractWaylandOutput::refreshRate() const
void AbstractWaylandOutput::setGlobalPos(const QPoint &pos)
{
m_globalPos = pos;
m_waylandOutputDevice->setGlobalPosition(pos);
if (m_waylandOutput) {
m_waylandOutput->setGlobalPosition(pos);
}
if (m_waylandOutputDevice) {
m_waylandOutputDevice->setGlobalPosition(pos);
}
if (m_xdgOutput) {
m_xdgOutput->setLogicalPosition(pos);
m_xdgOutput->done();
@ -88,6 +87,8 @@ void AbstractWaylandOutput::setGlobalPos(const QPoint &pos)
void AbstractWaylandOutput::setScale(qreal scale)
{
m_scale = scale;
m_waylandOutputDevice->setScaleF(scale);
if (m_waylandOutput) {
// this is the scale that clients will ideally use for their buffers
// this has to be an int which is fine
@ -97,9 +98,6 @@ void AbstractWaylandOutput::setScale(qreal scale)
// don't treat this like it's chosen deliberately
m_waylandOutput->setScale(std::ceil(scale));
}
if (m_waylandOutputDevice) {
m_waylandOutputDevice->setScaleF(scale);
}
if (m_xdgOutput) {
m_xdgOutput->setLogicalSize(pixelSize() / m_scale);
m_xdgOutput->done();
@ -109,7 +107,6 @@ void AbstractWaylandOutput::setScale(qreal scale)
void AbstractWaylandOutput::setChanges(KWayland::Server::OutputChangeSet *changes)
{
qCDebug(KWIN_CORE) << "Set changes in AbstractWaylandOutput.";
Q_ASSERT(!m_waylandOutputDevice.isNull());
bool emitModeChanged = false;
//enabledChanged is handled by plugin code
@ -181,8 +178,6 @@ void AbstractWaylandOutput::createXdgOutput()
void AbstractWaylandOutput::initWaylandOutput()
{
Q_ASSERT(m_waylandOutputDevice);
if (!m_waylandOutput.isNull()) {
delete m_waylandOutput.data();
m_waylandOutput.clear();
@ -230,10 +225,7 @@ void AbstractWaylandOutput::initWaylandOutputDevice(const QString &model,
const QByteArray &uuid,
const QVector<KWayland::Server::OutputDeviceInterface::Mode> &modes)
{
if (!m_waylandOutputDevice.isNull()) {
delete m_waylandOutputDevice.data();
m_waylandOutputDevice.clear();
}
Q_ASSERT(m_waylandOutputDevice.isNull());
m_waylandOutputDevice = waylandServer()->display()->createOutputDevice();
m_waylandOutputDevice->setUuid(uuid);