summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorKirill Burtsev <kirill.burtsev@qt.io>2019-07-01 18:44:39 +0200
committerKirill Burtsev <kirill.burtsev@qt.io>2019-10-04 17:18:41 +0200
commit425c59783c960e9f568b6c5e8920774ada9b87e5 (patch)
tree7a68a6b2cdc8f1f41d8d12e714f313e87d2c4f9a /src
parent932805807123833bb8f5ae9abda7e946f48d9f0c (diff)
Xcb: fix rounding error in reporting screen refresh rate
Screen refresh rate might not be just integer but with decimal part like, for example, 59.97 Hz. Fix calculation from raw xcb data and its store type as it is qreal already for QScreen::refreshRate API. Task-number: QTBUG-73911 Change-Id: Ia0494e953176c2854f0ed42c4498a29cfef16106 Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
Diffstat (limited to 'src')
-rw-r--r--src/plugins/platforms/xcb/qxcbscreen.cpp2
-rw-r--r--src/plugins/platforms/xcb/qxcbscreen.h2
2 files changed, 2 insertions, 2 deletions
diff --git a/src/plugins/platforms/xcb/qxcbscreen.cpp b/src/plugins/platforms/xcb/qxcbscreen.cpp
index a5a2aeb9aa..0cf0942dab 100644
--- a/src/plugins/platforms/xcb/qxcbscreen.cpp
+++ b/src/plugins/platforms/xcb/qxcbscreen.cpp
@@ -790,7 +790,7 @@ void QXcbScreen::updateRefreshRate(xcb_randr_mode_t mode)
xcb_randr_mode_info_t *modeInfo = modesIter.data;
if (modeInfo->id == mode) {
const uint32_t dotCount = modeInfo->htotal * modeInfo->vtotal;
- m_refreshRate = (dotCount != 0) ? modeInfo->dot_clock / dotCount : 0;
+ m_refreshRate = (dotCount != 0) ? modeInfo->dot_clock / qreal(dotCount) : 0;
m_mode = mode;
break;
}
diff --git a/src/plugins/platforms/xcb/qxcbscreen.h b/src/plugins/platforms/xcb/qxcbscreen.h
index ec3b07bfb7..914ce6307d 100644
--- a/src/plugins/platforms/xcb/qxcbscreen.h
+++ b/src/plugins/platforms/xcb/qxcbscreen.h
@@ -226,7 +226,7 @@ private:
QRect m_availableGeometry;
Qt::ScreenOrientation m_orientation = Qt::PrimaryOrientation;
QXcbCursor *m_cursor;
- int m_refreshRate = 60;
+ qreal m_refreshRate = 60.0;
int m_pixelDensity = 1;
QEdidParser m_edid;
};