diff --git a/abstract_output.cpp b/abstract_output.cpp index e62b4fd4bb..703654d20b 100644 --- a/abstract_output.cpp +++ b/abstract_output.cpp @@ -65,6 +65,14 @@ QSize AbstractOutput::physicalSize() const return m_physicalSize; } +int AbstractOutput::refreshRate() const +{ + if (!m_waylandOutput) { + return 60000; + } + return m_waylandOutput->refreshRate(); +} + void AbstractOutput::setGlobalPos(const QPoint &pos) { m_globalPos = pos; diff --git a/abstract_output.h b/abstract_output.h index d34fa5dee2..adca721fae 100644 --- a/abstract_output.h +++ b/abstract_output.h @@ -80,6 +80,11 @@ public: return m_orientation; } + /* + * Current refresh rate in 1/ms + */ + int refreshRate() const; + bool isInternal() const { return m_internal; } diff --git a/outputscreens.cpp b/outputscreens.cpp index d6dd84ae3e..5c56a20897 100644 --- a/outputscreens.cpp +++ b/outputscreens.cpp @@ -93,6 +93,15 @@ QSizeF OutputScreens::physicalSize(int screen) const return enOuts.at(screen)->physicalSize(); } +float OutputScreens::refreshRate(int screen) const +{ + const auto enOuts = m_platform->enabledOutputs(); + if (screen >= enOuts.size()) { + return Screens::refreshRate(screen); + } + return enOuts.at(screen)->refreshRate() / 1000.0f; +} + Qt::ScreenOrientation OutputScreens::orientation(int screen) const { const auto enOuts = m_platform->enabledOutputs(); diff --git a/outputscreens.h b/outputscreens.h index 4d31acb264..56f8f4c0dc 100644 --- a/outputscreens.h +++ b/outputscreens.h @@ -42,7 +42,8 @@ public: QRect geometry(int screen) const override; QSize size(int screen) const override; qreal scale(int screen) const override; - Qt::ScreenOrientation orientation(int screen) const; + float refreshRate(int screen) const override; + Qt::ScreenOrientation orientation(int screen) const override; void updateCount() override; int number(const QPoint &pos) const override; diff --git a/plugins/platforms/drm/drm_output.cpp b/plugins/platforms/drm/drm_output.cpp index d7f948eb3c..5983ec126a 100644 --- a/plugins/platforms/drm/drm_output.cpp +++ b/plugins/platforms/drm/drm_output.cpp @@ -781,15 +781,6 @@ void DrmOutput::updateMode(int modeIndex) setWaylandMode(); } -int DrmOutput::currentRefreshRate() const -{ - auto wlOutput = waylandOutput(); - if (!wlOutput) { - return 60000; - } - return wlOutput->refreshRate(); -} - QSize DrmOutput::pixelSize() const { auto orient = orientation(); diff --git a/plugins/platforms/drm/drm_output.h b/plugins/platforms/drm/drm_output.h index c6ca0c95ff..bcf438c795 100644 --- a/plugins/platforms/drm/drm_output.h +++ b/plugins/platforms/drm/drm_output.h @@ -67,7 +67,6 @@ public: QSize pixelSize() const override; - int currentRefreshRate() const; // These values are defined by the kernel enum class DpmsMode { On = DRM_MODE_DPMS_ON, diff --git a/plugins/platforms/drm/screens_drm.cpp b/plugins/platforms/drm/screens_drm.cpp index 2fa1f51860..b21a279679 100644 --- a/plugins/platforms/drm/screens_drm.cpp +++ b/plugins/platforms/drm/screens_drm.cpp @@ -34,15 +34,6 @@ DrmScreens::DrmScreens(DrmBackend *backend, QObject *parent) DrmScreens::~DrmScreens() = default; -float DrmScreens::refreshRate(int screen) const -{ - const auto enOuts = m_backend->drmEnabledOutputs(); - if (screen >= enOuts.size()) { - return Screens::refreshRate(screen); - } - return enOuts.at(screen)->currentRefreshRate() / 1000.0f; -} - bool DrmScreens::supportsTransformations(int screen) const { const auto enOuts = m_backend->drmEnabledOutputs(); diff --git a/plugins/platforms/drm/screens_drm.h b/plugins/platforms/drm/screens_drm.h index 208b242e26..daa8afdacc 100644 --- a/plugins/platforms/drm/screens_drm.h +++ b/plugins/platforms/drm/screens_drm.h @@ -32,7 +32,6 @@ public: DrmScreens(DrmBackend *backend, QObject *parent = nullptr); virtual ~DrmScreens(); - float refreshRate(int screen) const override; bool supportsTransformations(int screen) const override; DrmBackend *m_backend;