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>
This commit is contained in:
Kirill Burtsev 2019-07-01 18:44:39 +02:00
parent 9328058071
commit 425c59783c
2 changed files with 2 additions and 2 deletions

View File

@ -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;
}

View File

@ -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;
};