فهرست منبع

fix XRandR refresh rate calculation

Caiyi Hsu 1 سال پیش
والد
کامیت
5ba839e83b
1فایلهای تغییر یافته به همراه15 افزوده شده و 2 حذف شده
  1. 15 2
      src/video/x11/SDL_x11modes.c

+ 15 - 2
src/video/x11/SDL_x11modes.c

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