Added back refresh rate window hint.

This commit is contained in:
Camilla Berglund
2013-05-30 20:42:50 +02:00
parent f5dc6e4007
commit 2cd34386bc
8 changed files with 55 additions and 19 deletions
+24 -8
View File
@@ -67,28 +67,43 @@ void _glfwSetVideoMode(_GLFWmonitor* monitor, const GLFWvidmode* desired)
{
if (_glfw.x11.randr.available)
{
int i;
int i, j;
XRRScreenResources* sr;
XRRCrtcInfo* ci;
XRROutputInfo* oi;
RRMode bestMode = 0;
unsigned int leastSizeDiff = UINT_MAX, leastRateDiff = UINT_MAX;
unsigned int sizeDiff, leastSizeDiff = UINT_MAX;
unsigned int rateDiff, leastRateDiff = UINT_MAX;
sr = XRRGetScreenResources(_glfw.x11.display, _glfw.x11.root);
ci = XRRGetCrtcInfo(_glfw.x11.display, sr, monitor->x11.crtc);
oi = XRRGetOutputInfo(_glfw.x11.display, sr, monitor->x11.output);
for (i = 0; i < sr->nmode; i++)
{
XRRModeInfo* mi = sr->modes + i;
const XRRModeInfo* mi = sr->modes + i;
if (mi->modeFlags & RR_Interlace)
continue;
const unsigned int sizeDiff = (mi->width - desired->width) *
(mi->width - desired->width) +
(mi->height - desired->height) *
(mi->height - desired->height);
for (j = 0; j < oi->nmode; j++)
{
if (oi->modes[j] == mi->id)
break;
}
const unsigned int rateDiff = abs(calculateRefreshRate(mi) - desired->refreshRate);
if (j == oi->nmode)
continue;
sizeDiff = (mi->width - desired->width) *
(mi->width - desired->width) +
(mi->height - desired->height) *
(mi->height - desired->height);
if (desired->refreshRate)
rateDiff = abs(calculateRefreshRate(mi) - desired->refreshRate);
else
rateDiff = UINT_MAX - calculateRefreshRate(mi);
if ((sizeDiff < leastSizeDiff) ||
(sizeDiff == leastSizeDiff && rateDiff < leastRateDiff))
@@ -110,6 +125,7 @@ void _glfwSetVideoMode(_GLFWmonitor* monitor, const GLFWvidmode* desired)
ci->outputs,
ci->noutput);
XRRFreeOutputInfo(oi);
XRRFreeCrtcInfo(ci);
XRRFreeScreenResources(sr);
}