mirror of
https://github.com/gwm17/glfw.git
synced 2024-11-23 10:48:51 -05: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;
|
_glfw.x11.vidmode.available = GL_FALSE;
|
||||||
#endif /*_GLFW_HAS_XF86VIDMODE*/
|
#endif /*_GLFW_HAS_XF86VIDMODE*/
|
||||||
|
|
||||||
// Check for XRandR extension
|
// Check for RandR extension
|
||||||
#ifdef _GLFW_HAS_XRANDR
|
#ifdef _GLFW_HAS_XRANDR
|
||||||
_glfw.x11.randr.available =
|
_glfw.x11.randr.available =
|
||||||
XRRQueryExtension(_glfw.x11.display,
|
XRRQueryExtension(_glfw.x11.display,
|
||||||
|
@ -509,6 +509,13 @@ static GLboolean initDisplay(void)
|
||||||
"X11: Failed to query RandR version");
|
"X11: Failed to query RandR version");
|
||||||
return GL_FALSE;
|
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
|
#else
|
||||||
_glfw.x11.randr.available = GL_FALSE;
|
_glfw.x11.randr.available = GL_FALSE;
|
||||||
|
|
|
@ -192,11 +192,12 @@ void _glfwRestoreVideoMode(_GLFWmonitor* monitor)
|
||||||
// Return a list of available monitors
|
// Return a list of available monitors
|
||||||
//========================================================================
|
//========================================================================
|
||||||
|
|
||||||
_GLFWmonitor** _glfwPlatformGetMonitors(int* count)
|
_GLFWmonitor** _glfwPlatformGetMonitors(int* found)
|
||||||
{
|
{
|
||||||
int found = 0;
|
|
||||||
_GLFWmonitor** monitors = NULL;
|
_GLFWmonitor** monitors = NULL;
|
||||||
|
|
||||||
|
*found = 0;
|
||||||
|
|
||||||
if (_glfw.x11.randr.available)
|
if (_glfw.x11.randr.available)
|
||||||
{
|
{
|
||||||
#if defined (_GLFW_HAS_XRANDR)
|
#if defined (_GLFW_HAS_XRANDR)
|
||||||
|
@ -221,7 +222,6 @@ _GLFWmonitor** _glfwPlatformGetMonitors(int* count)
|
||||||
{
|
{
|
||||||
XRROutputInfo* oi;
|
XRROutputInfo* oi;
|
||||||
XRRCrtcInfo* ci;
|
XRRCrtcInfo* ci;
|
||||||
int widthMM, heightMM;
|
|
||||||
|
|
||||||
oi = XRRGetOutputInfo(_glfw.x11.display, sr, sr->outputs[i]);
|
oi = XRRGetOutputInfo(_glfw.x11.display, sr, sr->outputs[i]);
|
||||||
if (oi->connection != RR_Connected)
|
if (oi->connection != RR_Connected)
|
||||||
|
@ -230,40 +230,49 @@ _GLFWmonitor** _glfwPlatformGetMonitors(int* count)
|
||||||
continue;
|
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);
|
ci = XRRGetCrtcInfo(_glfw.x11.display, sr, oi->crtc);
|
||||||
|
|
||||||
monitors[found] = _glfwCreateMonitor(oi->name,
|
monitors[*found] = _glfwCreateMonitor(oi->name,
|
||||||
sr->outputs[i] == primary,
|
sr->outputs[i] == primary,
|
||||||
widthMM, heightMM,
|
oi->mm_width, oi->mm_height,
|
||||||
ci->x, ci->y);
|
ci->x, ci->y);
|
||||||
|
|
||||||
XRRFreeCrtcInfo(ci);
|
XRRFreeCrtcInfo(ci);
|
||||||
|
|
||||||
if (!monitors[found])
|
if (!monitors[*found])
|
||||||
{
|
{
|
||||||
// TODO: wat
|
// TODO: wat
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
// This is retained until the monitor object is destroyed
|
// This is retained until the monitor object is destroyed
|
||||||
monitors[found]->x11.output = oi;
|
monitors[*found]->x11.output = oi;
|
||||||
found++;
|
(*found)++;
|
||||||
}
|
}
|
||||||
#endif /*_GLFW_HAS_XRANDR*/
|
#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;
|
return monitors;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -356,8 +365,7 @@ GLFWvidmode* _glfwPlatformGetVideoModes(_GLFWmonitor* monitor, int* found)
|
||||||
XRRFreeScreenResources(sr);
|
XRRFreeScreenResources(sr);
|
||||||
#endif /*_GLFW_HAS_XRANDR*/
|
#endif /*_GLFW_HAS_XRANDR*/
|
||||||
}
|
}
|
||||||
|
else
|
||||||
if (result == NULL)
|
|
||||||
{
|
{
|
||||||
*found = 1;
|
*found = 1;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user