fix XRandR refresh rate calculation

main
Caiyi Hsu 2024-01-27 11:25:43 +08:00 committed by Sam Lantinga
parent 44a2c4d512
commit 5ba839e83b
1 changed files with 15 additions and 2 deletions

View File

@ -402,8 +402,21 @@ static SDL_bool CheckXRandR(Display *display, int *major, int *minor)
static float CalculateXRandRRefreshRate(const XRRModeInfo *info)
{
if (info->hTotal && info->vTotal) {
return ((100 * (Sint64)info->dotClock) / (info->hTotal * info->vTotal)) / 100.0f;
double vTotal = info->vTotal;
if (info->modeFlags & RR_DoubleScan) {
/* doublescan doubles the number of lines */
vTotal *= 2;
}
if (info->modeFlags & RR_Interlace) {
/* interlace splits the frame into two fields */
/* the field rate is what is typically reported by monitors */
vTotal /= 2;
}
if (info->hTotal && vTotal) {
return ((100 * (Sint64)info->dotClock) / (info->hTotal * vTotal)) / 100.0f;
}
return 0.0f;
}