|
|
|
@ -83,6 +83,9 @@ _GLFWmonitor* _glfwDestroyMonitor(_GLFWmonitor* monitor) |
|
|
|
|
return result; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// todo: This is ugly. The platform should only allocate a list of the current devices.
|
|
|
|
|
// The platform independent code should be in charge of the handling for the initial
|
|
|
|
|
// setup, refreshing and freeing the list.
|
|
|
|
|
void _glfwInitMonitors(void) |
|
|
|
|
{ |
|
|
|
|
_GLFWmonitor** curMonitor; |
|
|
|
@ -106,7 +109,7 @@ void _glfwInitMonitors(void) |
|
|
|
|
|
|
|
|
|
while (EnumDisplayDevices(NULL, adapterNum++, &adapter, 0)) |
|
|
|
|
{ |
|
|
|
|
if (adapter.StateFlags & DISPLAY_DEVICE_MIRRORING_DRIVER) |
|
|
|
|
if (adapter.StateFlags & DISPLAY_DEVICE_MIRRORING_DRIVER || !(adapter.StateFlags & DISPLAY_DEVICE_ACTIVE)) |
|
|
|
|
continue; |
|
|
|
|
|
|
|
|
|
EnumDisplaySettingsEx(adapter.DeviceName, |
|
|
|
@ -120,6 +123,106 @@ void _glfwInitMonitors(void) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void _glfwRefreshMonitors(void) |
|
|
|
|
{ |
|
|
|
|
DISPLAY_DEVICE adapter; |
|
|
|
|
DWORD adapterNum = 0; |
|
|
|
|
|
|
|
|
|
DISPLAY_DEVICE monitor; |
|
|
|
|
|
|
|
|
|
DEVMODE setting; |
|
|
|
|
|
|
|
|
|
_GLFWmonitor* newMonitorList = NULL; |
|
|
|
|
_GLFWmonitor** curMonitor = &newMonitorList; |
|
|
|
|
|
|
|
|
|
_GLFWmonitor* curNewMonitor; |
|
|
|
|
_GLFWmonitor* curOldMonitor; |
|
|
|
|
|
|
|
|
|
while (EnumDisplayDevices(NULL, adapterNum++, &adapter, 0)) |
|
|
|
|
{ |
|
|
|
|
if (adapter.StateFlags & DISPLAY_DEVICE_MIRRORING_DRIVER || !(adapter.StateFlags & DISPLAY_DEVICE_ACTIVE)) |
|
|
|
|
continue; |
|
|
|
|
|
|
|
|
|
EnumDisplaySettingsEx(adapter.DeviceName, ENUM_CURRENT_SETTINGS, &setting, EDS_ROTATEDMODE); |
|
|
|
|
|
|
|
|
|
EnumDisplayDevices(adapter.DeviceName, 0, &monitor, 0); |
|
|
|
|
|
|
|
|
|
curMonitor = _glfwCreateMonitor(curMonitor, &adapter, &monitor, &setting); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
curNewMonitor = newMonitorList; |
|
|
|
|
curOldMonitor = _glfwLibrary.monitorListHead; |
|
|
|
|
|
|
|
|
|
while (_glfwLibrary.monitorCallback && (curNewMonitor || curOldMonitor)) |
|
|
|
|
{ |
|
|
|
|
_GLFWmonitor* lookAheadOldMonitor; |
|
|
|
|
_GLFWmonitor* lookAheadNewMonitor; |
|
|
|
|
|
|
|
|
|
if (curOldMonitor && curNewMonitor && !strcmp(curOldMonitor->name, curOldMonitor->name)) |
|
|
|
|
{ |
|
|
|
|
curNewMonitor = curNewMonitor->next; |
|
|
|
|
curOldMonitor = curOldMonitor->next; |
|
|
|
|
continue; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (curNewMonitor && !curOldMonitor) |
|
|
|
|
{ |
|
|
|
|
_glfwLibrary.monitorCallback(curNewMonitor, GLFW_MONITOR_CONNECTED); |
|
|
|
|
curNewMonitor = curNewMonitor->next; |
|
|
|
|
continue; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (!curNewMonitor && curOldMonitor) |
|
|
|
|
{ |
|
|
|
|
_glfwLibrary.monitorCallback(curOldMonitor, GLFW_MONITOR_DISCONNECTED); |
|
|
|
|
curOldMonitor = curOldMonitor->next; |
|
|
|
|
continue; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
lookAheadOldMonitor = curOldMonitor->next; |
|
|
|
|
lookAheadNewMonitor = curNewMonitor->next; |
|
|
|
|
|
|
|
|
|
while (lookAheadOldMonitor && !strcmp(curNewMonitor->name, lookAheadOldMonitor->name)) |
|
|
|
|
lookAheadOldMonitor = lookAheadOldMonitor->next; |
|
|
|
|
|
|
|
|
|
while (lookAheadNewMonitor && !strcmp(curOldMonitor->name, lookAheadNewMonitor->name)) |
|
|
|
|
lookAheadNewMonitor = lookAheadNewMonitor->next; |
|
|
|
|
|
|
|
|
|
if (!lookAheadOldMonitor) |
|
|
|
|
{ |
|
|
|
|
// nothing found in the old monitor list, that matches the current new monitor.
|
|
|
|
|
_glfwLibrary.monitorCallback(curNewMonitor, GLFW_MONITOR_CONNECTED); |
|
|
|
|
curNewMonitor = curNewMonitor->next; |
|
|
|
|
} |
|
|
|
|
else |
|
|
|
|
{ |
|
|
|
|
while (strcmp(curOldMonitor->name, lookAheadOldMonitor->name)) |
|
|
|
|
{ |
|
|
|
|
_glfwLibrary.monitorCallback(curOldMonitor, GLFW_MONITOR_DISCONNECTED); |
|
|
|
|
curOldMonitor = curOldMonitor->next; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (!lookAheadNewMonitor) |
|
|
|
|
{ |
|
|
|
|
// nothing found in the new monitor list, that matches the current old monitor.
|
|
|
|
|
_glfwLibrary.monitorCallback(curOldMonitor, GLFW_MONITOR_DISCONNECTED); |
|
|
|
|
curOldMonitor = curOldMonitor->next; |
|
|
|
|
} |
|
|
|
|
else |
|
|
|
|
{ |
|
|
|
|
while (strcmp(curNewMonitor->name, lookAheadNewMonitor->name)) |
|
|
|
|
{ |
|
|
|
|
_glfwLibrary.monitorCallback(curNewMonitor, GLFW_MONITOR_CONNECTED); |
|
|
|
|
curNewMonitor = curNewMonitor->next; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
_glfwTerminateMonitors(); |
|
|
|
|
_glfwLibrary.monitorListHead = newMonitorList; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void _glfwTerminateMonitors(void) |
|
|
|
|
{ |
|
|
|
|
while (_glfwLibrary.monitorListHead) |
|
|
|
|