mirror of
https://github.com/glfw/glfw.git
synced 2024-11-10 00:51:47 +00:00
RandR and fallback path fixes.
This commit is contained in:
parent
be8856af65
commit
747b6d8805
@ -492,7 +492,7 @@ static GLboolean initDisplay(void)
|
||||
_glfw.x11.vidmode.available = GL_FALSE;
|
||||
#endif /*_GLFW_HAS_XF86VIDMODE*/
|
||||
|
||||
// Check for XRandR extension
|
||||
// Check for RandR extension
|
||||
#ifdef _GLFW_HAS_XRANDR
|
||||
_glfw.x11.randr.available =
|
||||
XRRQueryExtension(_glfw.x11.display,
|
||||
@ -509,6 +509,13 @@ static GLboolean initDisplay(void)
|
||||
"X11: Failed to query RandR version");
|
||||
return GL_FALSE;
|
||||
}
|
||||
|
||||
// The GLFW RandR path requires at least version 1.3
|
||||
if (_glfw.x11.randr.versionMajor == 1 &&
|
||||
_glfw.x11.randr.versionMinor < 3)
|
||||
{
|
||||
_glfw.x11.randr.available = GL_FALSE;
|
||||
}
|
||||
}
|
||||
#else
|
||||
_glfw.x11.randr.available = GL_FALSE;
|
||||
|
@ -192,11 +192,12 @@ void _glfwRestoreVideoMode(_GLFWmonitor* monitor)
|
||||
// Return a list of available monitors
|
||||
//========================================================================
|
||||
|
||||
_GLFWmonitor** _glfwPlatformGetMonitors(int* count)
|
||||
_GLFWmonitor** _glfwPlatformGetMonitors(int* found)
|
||||
{
|
||||
int found = 0;
|
||||
_GLFWmonitor** monitors = NULL;
|
||||
|
||||
*found = 0;
|
||||
|
||||
if (_glfw.x11.randr.available)
|
||||
{
|
||||
#if defined (_GLFW_HAS_XRANDR)
|
||||
@ -221,7 +222,6 @@ _GLFWmonitor** _glfwPlatformGetMonitors(int* count)
|
||||
{
|
||||
XRROutputInfo* oi;
|
||||
XRRCrtcInfo* ci;
|
||||
int widthMM, heightMM;
|
||||
|
||||
oi = XRRGetOutputInfo(_glfw.x11.display, sr, sr->outputs[i]);
|
||||
if (oi->connection != RR_Connected)
|
||||
@ -230,40 +230,49 @@ _GLFWmonitor** _glfwPlatformGetMonitors(int* count)
|
||||
continue;
|
||||
}
|
||||
|
||||
if (oi->mm_width && oi->mm_height)
|
||||
{
|
||||
widthMM = oi->mm_width;
|
||||
heightMM = oi->mm_height;
|
||||
}
|
||||
else
|
||||
{
|
||||
widthMM = DisplayWidthMM(_glfw.x11.display, _glfw.x11.screen);
|
||||
heightMM = DisplayHeightMM(_glfw.x11.display, _glfw.x11.screen);
|
||||
}
|
||||
|
||||
ci = XRRGetCrtcInfo(_glfw.x11.display, sr, oi->crtc);
|
||||
|
||||
monitors[found] = _glfwCreateMonitor(oi->name,
|
||||
sr->outputs[i] == primary,
|
||||
widthMM, heightMM,
|
||||
ci->x, ci->y);
|
||||
monitors[*found] = _glfwCreateMonitor(oi->name,
|
||||
sr->outputs[i] == primary,
|
||||
oi->mm_width, oi->mm_height,
|
||||
ci->x, ci->y);
|
||||
|
||||
XRRFreeCrtcInfo(ci);
|
||||
|
||||
if (!monitors[found])
|
||||
if (!monitors[*found])
|
||||
{
|
||||
// TODO: wat
|
||||
return NULL;
|
||||
}
|
||||
|
||||
// This is retained until the monitor object is destroyed
|
||||
monitors[found]->x11.output = oi;
|
||||
found++;
|
||||
monitors[*found]->x11.output = oi;
|
||||
(*found)++;
|
||||
}
|
||||
#endif /*_GLFW_HAS_XRANDR*/
|
||||
}
|
||||
else
|
||||
{
|
||||
int widthMM, heightMM;
|
||||
|
||||
monitors = (_GLFWmonitor**) calloc(1, sizeof(_GLFWmonitor*));
|
||||
if (!monitors)
|
||||
{
|
||||
_glfwInputError(GLFW_OUT_OF_MEMORY, NULL);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
widthMM = DisplayWidthMM(_glfw.x11.display, _glfw.x11.screen);
|
||||
heightMM = DisplayHeightMM(_glfw.x11.display, _glfw.x11.screen);
|
||||
|
||||
monitors[0] = _glfwCreateMonitor("Display",
|
||||
GL_TRUE,
|
||||
widthMM, heightMM,
|
||||
0, 0);
|
||||
|
||||
*found = 1;
|
||||
}
|
||||
|
||||
*count = found;
|
||||
return monitors;
|
||||
}
|
||||
|
||||
@ -356,8 +365,7 @@ GLFWvidmode* _glfwPlatformGetVideoModes(_GLFWmonitor* monitor, int* found)
|
||||
XRRFreeScreenResources(sr);
|
||||
#endif /*_GLFW_HAS_XRANDR*/
|
||||
}
|
||||
|
||||
if (result == NULL)
|
||||
else
|
||||
{
|
||||
*found = 1;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user