On 2/4/20 4:27 PM, Dmitry Timoshkov wrote:
Zhiyi Zhang <zzhang(a)codeweavers.com> wrote:
+static DWORD get_frequency( const XRRModeInfo *mode ) +{ + if (mode->hTotal && mode->vTotal) + { + double v_total = mode->vTotal; + + if (mode->modeFlags & RR_DoubleScan) + v_total *= 2; + if (mode->modeFlags & RR_Interlace) + v_total /= 2; + + /* Adding 0.05 instead of 0.5 to round so that common frequencies like + * 59.94Hz and 23.976Hz become 59Hz and 24Hz. Using 0.5 would make + * 59.94Hz become 60Hz and would make it seem like there are two 60Hz modes */ + return mode->dotClock / (mode->hTotal * v_total) + 0.05; + } + + return 0; +} It seems that floating point (and especially double) is not needed here to do a proper calculation.
It's needed. See https://gitlab.freedesktop.org/xorg/app/xrandr/commit/00c795e99fe29ecd56e05e...