From 64ce247104ecbb5a54462f0f436a91e4fb9578b3 Mon Sep 17 00:00:00 2001 From: Alexander Volkov Date: Fri, 28 Apr 2023 15:46:34 +0300 Subject: [PATCH] Use non-rotated physical size of an output when required 1. In wl_output and kde_output_device_v2 protocols. This should fix dpi calculation in KScreen::Generator::bestScaleForOutput() when panel_orientation is set to rotate a screen by 90 or 270 degrees. 2. When comparing with physical size of libinput device. 3. In calculations with mode sizes which are not rotated. This change makes Output::physicalSize() return the raw physical size, which is used in most of cases. It should be rotated manually if needed. --- src/core/output.cpp | 2 +- src/core/output.h | 5 ++--- src/input.cpp | 7 ++++--- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/core/output.cpp b/src/core/output.cpp index e5c1d5edb4..6151d66156 100644 --- a/src/core/output.cpp +++ b/src/core/output.cpp @@ -181,7 +181,7 @@ QRectF Output::fractionalGeometry() const QSize Output::physicalSize() const { - return orientateSize(m_information.physicalSize); + return m_information.physicalSize; } int Output::refreshRate() const diff --git a/src/core/output.h b/src/core/output.h index 7cc5e5470f..e2a59f62a0 100644 --- a/src/core/output.h +++ b/src/core/output.h @@ -172,7 +172,7 @@ public: qreal scale() const; /** - * Returns the physical size of this output, in millimeters. + * Returns the non-rotated physical size of this output, in millimeters. * * Default implementation returns an invalid QSize. */ @@ -230,6 +230,7 @@ public: }; Q_ENUM(Transform) Transform transform() const; + QSize orientateSize(const QSize &size) const; void applyChanges(const OutputConfiguration &config); @@ -355,8 +356,6 @@ protected: void setInformation(const Information &information); void setState(const State &state); - QSize orientateSize(const QSize &size) const; - EffectScreenImpl *m_effectScreen = nullptr; State m_state; Information m_information; diff --git a/src/input.cpp b/src/input.cpp index 7ae82a9734..f8e8b5fd20 100644 --- a/src/input.cpp +++ b/src/input.cpp @@ -1019,7 +1019,7 @@ public: } m_lastTouchDownTime = time; auto output = workspace()->outputAt(pos); - auto physicalSize = output->physicalSize(); + auto physicalSize = output->orientateSize(output->physicalSize()); if (!physicalSize.isValid()) { physicalSize = QSize(190, 100); } @@ -1053,8 +1053,9 @@ public: return true; } auto output = workspace()->outputAt(pos); - const float xfactor = output->physicalSize().width() / (float)output->geometry().width(); - const float yfactor = output->physicalSize().height() / (float)output->geometry().height(); + const auto physicalSize = output->orientateSize(output->physicalSize()); + const float xfactor = physicalSize.width() / (float)output->geometry().width(); + const float yfactor = physicalSize.height() / (float)output->geometry().height(); auto &point = m_touchPoints[id]; const QPointF dist = pos - point;