Round refresh rate instead of truncating

From upstream: 621ece63c8
This commit is contained in:
Kovid Goyal 2019-03-06 08:36:59 +05:30
parent 7e8e1e9e89
commit aa2b21456f
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C
3 changed files with 6 additions and 3 deletions

View File

@ -29,6 +29,7 @@
#include <stdlib.h>
#include <limits.h>
#include <math.h>
#include <IOKit/graphics/IOGraphicsLib.h>
#include <CoreVideo/CVBase.h>
@ -148,7 +149,7 @@ static GLFWvidmode vidmodeFromCGDisplayMode(CGDisplayModeRef mode,
GLFWvidmode result;
result.width = (int) CGDisplayModeGetWidth(mode);
result.height = (int) CGDisplayModeGetHeight(mode);
result.refreshRate = (int) CGDisplayModeGetRefreshRate(mode);
result.refreshRate = (int) round(CGDisplayModeGetRefreshRate(mode));
if (result.refreshRate == 0)
{

3
glfw/wl_monitor.c vendored
View File

@ -30,6 +30,7 @@
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#include <math.h>
static void outputHandleGeometry(void* data,
@ -70,7 +71,7 @@ static void outputHandleMode(void* data,
mode.redBits = 8;
mode.greenBits = 8;
mode.blueBits = 8;
mode.refreshRate = refresh / 1000;
mode.refreshRate = (int)round(refresh / 1000.0);
monitor->modeCount++;
monitor->modes =

3
glfw/x11_monitor.c vendored
View File

@ -30,6 +30,7 @@
#include <limits.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
// Check whether the display mode should be included in enumeration
@ -44,7 +45,7 @@ static GLFWbool modeIsGood(const XRRModeInfo* mi)
static int calculateRefreshRate(const XRRModeInfo* mi)
{
if (mi->hTotal && mi->vTotal)
return (int) ((double) mi->dotClock / ((double) mi->hTotal * (double) mi->vTotal));
return (int) round((double) mi->dotClock / ((double) mi->hTotal * (double) mi->vTotal));
else
return 0;
}