From 8d422f300567fb594311ea7d1af7003cc7915e32 Mon Sep 17 00:00:00 2001 From: Vlad Zahorodnii Date: Thu, 26 Aug 2021 15:06:16 +0300 Subject: [PATCH] Remove globalPos() in AbstractWaylandOutput It's confusing to have globalPos() and geometry() as both can return the same information. This change drops globalPos() function as it's not used outside the AbstractWaylandOutput class and renames setGlobalPos() to moveTo() to avoid having a setter without matching getter. --- src/abstract_wayland_output.cpp | 11 +++-------- src/abstract_wayland_output.h | 4 +--- src/plugins/platforms/drm/drm_backend.cpp | 4 ++-- src/plugins/platforms/virtual/virtual_output.cpp | 2 +- src/plugins/platforms/wayland/wayland_output.cpp | 2 +- .../platforms/x11/windowed/x11windowed_output.cpp | 2 +- 6 files changed, 9 insertions(+), 16 deletions(-) diff --git a/src/abstract_wayland_output.cpp b/src/abstract_wayland_output.cpp index 5ba940ded7..e6152bd76b 100644 --- a/src/abstract_wayland_output.cpp +++ b/src/abstract_wayland_output.cpp @@ -55,7 +55,7 @@ QUuid AbstractWaylandOutput::uuid() const QRect AbstractWaylandOutput::geometry() const { - return QRect(globalPos(), pixelSize() / scale()); + return QRect(m_position, pixelSize() / scale()); } QSize AbstractWaylandOutput::physicalSize() const @@ -68,12 +68,7 @@ int AbstractWaylandOutput::refreshRate() const return m_refreshRate; } -QPoint AbstractWaylandOutput::globalPos() const -{ - return m_position; -} - -void AbstractWaylandOutput::setGlobalPos(const QPoint &pos) +void AbstractWaylandOutput::moveTo(const QPoint &pos) { if (m_position != pos) { m_position = pos; @@ -168,7 +163,7 @@ void AbstractWaylandOutput::applyChanges(const KWaylandServer::OutputChangeSet * } if (changeSet->positionChanged()) { qCDebug(KWIN_CORE) << "Server setting position: " << changeSet->position(); - setGlobalPos(changeSet->position()); + moveTo(changeSet->position()); // may just work already! overallSizeCheckNeeded = true; } diff --git a/src/abstract_wayland_output.h b/src/abstract_wayland_output.h index 2b07e37c84..cdf61ea895 100644 --- a/src/abstract_wayland_output.h +++ b/src/abstract_wayland_output.h @@ -107,7 +107,7 @@ public: QString model() const override; QString serialNumber() const override; - void setGlobalPos(const QPoint &pos); + void moveTo(const QPoint &pos); void setScale(qreal scale); void applyChanges(const KWaylandServer::OutputChangeSet *changeSet) override; @@ -156,8 +156,6 @@ protected: const QSize &physicalSize, const QVector &modes, const QByteArray &edid); - QPoint globalPos() const; - bool internal() const { return m_internal; } diff --git a/src/plugins/platforms/drm/drm_backend.cpp b/src/plugins/platforms/drm/drm_backend.cpp index 31c6b0b066..3a50f5d229 100644 --- a/src/plugins/platforms/drm/drm_backend.cpp +++ b/src/plugins/platforms/drm/drm_backend.cpp @@ -490,7 +490,7 @@ void DrmBackend::readOutputsConfiguration() qCDebug(KWIN_DRM) << "Reading output configuration for " << *it; if (!outputInfo.isEmpty()) { const QJsonObject pos = outputInfo["pos"].toObject(); - (*it)->setGlobalPos({pos["x"].toInt(), pos["y"].toInt()}); + (*it)->moveTo({pos["x"].toInt(), pos["y"].toInt()}); if (const QJsonValue scale = outputInfo["scale"]; !scale.isUndefined()) { (*it)->setScale(scale.toDouble(1.)); } @@ -501,7 +501,7 @@ void DrmBackend::readOutputsConfiguration() (*it)->updateMode(size["width"].toInt(), size["height"].toInt(), mode["refresh"].toDouble() * 1000); } } else { - (*it)->setGlobalPos(pos); + (*it)->moveTo(pos); (*it)->setTransformInternal(DrmOutput::Transform::Normal); } pos.setX(pos.x() + (*it)->geometry().width()); diff --git a/src/plugins/platforms/virtual/virtual_output.cpp b/src/plugins/platforms/virtual/virtual_output.cpp index 909b182648..d91219cda6 100644 --- a/src/plugins/platforms/virtual/virtual_output.cpp +++ b/src/plugins/platforms/virtual/virtual_output.cpp @@ -64,7 +64,7 @@ void VirtualOutput::init(const QPoint &logicalPosition, const QSize &pixelSize) void VirtualOutput::setGeometry(const QRect &geo) { // TODO: set mode to have updated pixelSize - setGlobalPos(geo.topLeft()); + moveTo(geo.topLeft()); } void VirtualOutput::vblank(std::chrono::nanoseconds timestamp) diff --git a/src/plugins/platforms/wayland/wayland_output.cpp b/src/plugins/platforms/wayland/wayland_output.cpp index bf671dc2af..9847a618e5 100644 --- a/src/plugins/platforms/wayland/wayland_output.cpp +++ b/src/plugins/platforms/wayland/wayland_output.cpp @@ -79,7 +79,7 @@ void WaylandOutput::setGeometry(const QPoint &logicalPosition, const QSize &pixe // TODO: set mode to have updated pixelSize Q_UNUSED(pixelSize) - setGlobalPos(logicalPosition); + moveTo(logicalPosition); } void WaylandOutput::updateEnablement(bool enable) diff --git a/src/plugins/platforms/x11/windowed/x11windowed_output.cpp b/src/plugins/platforms/x11/windowed/x11windowed_output.cpp index 27565c04fb..a15cfe6e05 100644 --- a/src/plugins/platforms/x11/windowed/x11windowed_output.cpp +++ b/src/plugins/platforms/x11/windowed/x11windowed_output.cpp @@ -151,7 +151,7 @@ void X11WindowedOutput::setGeometry(const QPoint &logicalPosition, const QSize & { // TODO: set mode to have updated pixelSize Q_UNUSED(pixelSize); - setGlobalPos(logicalPosition); + moveTo(logicalPosition); } void X11WindowedOutput::setWindowTitle(const QString &title)