mirror of
https://github.com/gwm17/glfw.git
synced 2024-11-23 10:48:51 -05:00
Monitor enumeration fixes.
This commit is contained in:
parent
c8166e58d3
commit
68b7ea86d2
|
@ -307,6 +307,8 @@ _GLFWmonitor** _glfwPlatformGetMonitors(int* count)
|
||||||
_glfwInputError(GLFW_PLATFORM_ERROR,
|
_glfwInputError(GLFW_PLATFORM_ERROR,
|
||||||
"Cocoa: Failed to find NSScreen for CGDisplay %s",
|
"Cocoa: Failed to find NSScreen for CGDisplay %s",
|
||||||
monitors[i]->name);
|
monitors[i]->name);
|
||||||
|
|
||||||
|
free(monitors);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -131,7 +131,7 @@ GLFWAPI int glfwInit(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
_glfw.monitors = _glfwPlatformGetMonitors(&_glfw.monitorCount);
|
_glfw.monitors = _glfwPlatformGetMonitors(&_glfw.monitorCount);
|
||||||
if (_glfw.monitors == NULL || _glfw.monitorCount == 0)
|
if (_glfw.monitors == NULL)
|
||||||
{
|
{
|
||||||
_glfwErrorCallback(GLFW_PLATFORM_ERROR, "No monitors found");
|
_glfwErrorCallback(GLFW_PLATFORM_ERROR, "No monitors found");
|
||||||
_glfwPlatformTerminate();
|
_glfwPlatformTerminate();
|
||||||
|
|
|
@ -107,6 +107,8 @@ _GLFWmonitor** _glfwPlatformGetMonitors(int* count)
|
||||||
DWORD adapterIndex = 0;
|
DWORD adapterIndex = 0;
|
||||||
int primaryIndex = 0;
|
int primaryIndex = 0;
|
||||||
|
|
||||||
|
*count = 0;
|
||||||
|
|
||||||
for (;;)
|
for (;;)
|
||||||
{
|
{
|
||||||
DISPLAY_DEVICE adapter, display;
|
DISPLAY_DEVICE adapter, display;
|
||||||
|
@ -152,6 +154,8 @@ _GLFWmonitor** _glfwPlatformGetMonitors(int* count)
|
||||||
_glfwDestroyMonitors(monitors, found);
|
_glfwDestroyMonitors(monitors, found);
|
||||||
_glfwInputError(GLFW_PLATFORM_ERROR,
|
_glfwInputError(GLFW_PLATFORM_ERROR,
|
||||||
"Failed to convert string to UTF-8");
|
"Failed to convert string to UTF-8");
|
||||||
|
|
||||||
|
free(monitors);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -162,15 +162,15 @@ void _glfwRestoreVideoMode(_GLFWmonitor* monitor)
|
||||||
////// GLFW platform API //////
|
////// GLFW platform API //////
|
||||||
//////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
_GLFWmonitor** _glfwPlatformGetMonitors(int* found)
|
_GLFWmonitor** _glfwPlatformGetMonitors(int* count)
|
||||||
{
|
{
|
||||||
_GLFWmonitor** monitors = NULL;
|
_GLFWmonitor** monitors = NULL;
|
||||||
|
|
||||||
*found = 0;
|
*count = 0;
|
||||||
|
|
||||||
if (_glfw.x11.randr.available)
|
if (_glfw.x11.randr.available)
|
||||||
{
|
{
|
||||||
int i;
|
int i, found = 0;
|
||||||
RROutput primary;
|
RROutput primary;
|
||||||
XRRScreenResources* sr;
|
XRRScreenResources* sr;
|
||||||
|
|
||||||
|
@ -206,21 +206,21 @@ _GLFWmonitor** _glfwPlatformGetMonitors(int* found)
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
monitors[*found] = _glfwCreateMonitor(oi->name,
|
monitors[found] = _glfwCreateMonitor(oi->name,
|
||||||
oi->mm_width, oi->mm_height);
|
oi->mm_width, oi->mm_height);
|
||||||
|
|
||||||
monitors[*found]->x11.output = output;
|
monitors[found]->x11.output = output;
|
||||||
monitors[*found]->x11.crtc = oi->crtc;
|
monitors[found]->x11.crtc = oi->crtc;
|
||||||
|
|
||||||
XRRFreeOutputInfo(oi);
|
XRRFreeOutputInfo(oi);
|
||||||
XRRFreeCrtcInfo(ci);
|
XRRFreeCrtcInfo(ci);
|
||||||
|
|
||||||
(*found)++;
|
found++;
|
||||||
}
|
}
|
||||||
|
|
||||||
XRRFreeScreenResources(sr);
|
XRRFreeScreenResources(sr);
|
||||||
|
|
||||||
for (i = 0; i < *found; i++)
|
for (i = 0; i < found; i++)
|
||||||
{
|
{
|
||||||
if (monitors[i]->x11.output == primary)
|
if (monitors[i]->x11.output == primary)
|
||||||
{
|
{
|
||||||
|
@ -230,6 +230,14 @@ _GLFWmonitor** _glfwPlatformGetMonitors(int* found)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (found == 0)
|
||||||
|
{
|
||||||
|
free(monitors);
|
||||||
|
monitors = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
*count = found;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -239,7 +247,7 @@ _GLFWmonitor** _glfwPlatformGetMonitors(int* found)
|
||||||
_glfw.x11.screen),
|
_glfw.x11.screen),
|
||||||
DisplayHeightMM(_glfw.x11.display,
|
DisplayHeightMM(_glfw.x11.display,
|
||||||
_glfw.x11.screen));
|
_glfw.x11.screen));
|
||||||
*found = 1;
|
*count = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
return monitors;
|
return monitors;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user