Fix monitor disappearing on OS X with AGS

When automatic graphics switching is activated, the CGDirectDisplayID
for the display changes, casuing the primary GLFWmonitor to disappear.
This commit is contained in:
Camilla Berglund
2015-09-02 13:42:28 +02:00
parent 8b2da399ee
commit e0084617d5
3 changed files with 9 additions and 2 deletions
+5 -2
View File
@@ -268,7 +268,8 @@ _GLFWmonitor** _glfwPlatformGetMonitors(int* count)
char* name = getDisplayName(displays[i]);
monitor = _glfwAllocMonitor(name, size.width, size.height);
monitor->ns.displayID = displays[i];
monitor->ns.displayID = displays[i];
monitor->ns.unitNumber = CGDisplayUnitNumber(displays[i]);
free(name);
@@ -284,7 +285,9 @@ _GLFWmonitor** _glfwPlatformGetMonitors(int* count)
GLboolean _glfwPlatformIsSameMonitor(_GLFWmonitor* first, _GLFWmonitor* second)
{
return first->ns.displayID == second->ns.displayID;
// HACK: Compare unit numbers instead of display IDs to work around display
// replacement on machines with automatic graphics switching
return first->ns.unitNumber == second->ns.unitNumber;
}
void _glfwPlatformGetMonitorPos(_GLFWmonitor* monitor, int* xpos, int* ypos)
+1
View File
@@ -90,6 +90,7 @@ typedef struct _GLFWmonitorNS
{
CGDirectDisplayID displayID;
CGDisplayModeRef previousMode;
uint32_t unitNumber;
} _GLFWmonitorNS;