mirror of
https://github.com/glfw/glfw.git
synced 2024-11-11 21:13:50 +00:00
Moved monitor callback to shared implementation.
This commit is contained in:
parent
f228d23024
commit
df64773a44
@ -388,6 +388,7 @@ GLboolean _glfwIsValidContext(_GLFWwindow* window, _GLFWwndconfig* wndconfig);
|
|||||||
|
|
||||||
// Monitor management (monitor.c)
|
// Monitor management (monitor.c)
|
||||||
void _glfwInitMonitors(void);
|
void _glfwInitMonitors(void);
|
||||||
|
void _glfwRefreshMonitors(void);
|
||||||
void _glfwTerminateMonitors(void);
|
void _glfwTerminateMonitors(void);
|
||||||
|
|
||||||
#endif // _internal_h_
|
#endif // _internal_h_
|
||||||
|
@ -154,6 +154,90 @@ void _glfwInitMonitors(void)
|
|||||||
_glfwLibrary.monitorListHead = _glfwCreateMonitors();
|
_glfwLibrary.monitorListHead = _glfwCreateMonitors();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//========================================================================
|
||||||
|
// Refresh monitor list and notify callback.
|
||||||
|
//========================================================================
|
||||||
|
|
||||||
|
void _glfwRefreshMonitors(void)
|
||||||
|
{
|
||||||
|
_GLFWmonitor* newMonitorList;
|
||||||
|
_GLFWmonitor* curNewMonitor;
|
||||||
|
_GLFWmonitor* curOldMonitor;
|
||||||
|
|
||||||
|
newMonitorList = _glfwCreateMonitors();
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
//========================================================================
|
//========================================================================
|
||||||
// Delete the monitor list.
|
// Delete the monitor list.
|
||||||
//========================================================================
|
//========================================================================
|
||||||
|
@ -117,81 +117,3 @@ _GLFWmonitor* _glfwCreateMonitors(void)
|
|||||||
return monitorList;
|
return monitorList;
|
||||||
}
|
}
|
||||||
|
|
||||||
void _glfwRefreshMonitors(void)
|
|
||||||
{
|
|
||||||
_GLFWmonitor* curNewMonitor;
|
|
||||||
_GLFWmonitor* curOldMonitor;
|
|
||||||
|
|
||||||
curNewMonitor = _glfwCreateMonitors();
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
@ -337,8 +337,6 @@ typedef struct _GLFWmonitorWin32
|
|||||||
void _glfwInitTimer(void);
|
void _glfwInitTimer(void);
|
||||||
|
|
||||||
// Monitor support
|
// Monitor support
|
||||||
void _glfwInitMonitors(void);
|
|
||||||
void _glfwRefreshMonitors(void);
|
|
||||||
_GLFWmonitor* _glfwCreateMonitors(void);
|
_GLFWmonitor* _glfwCreateMonitors(void);
|
||||||
_GLFWmonitor* _glfwDestroyMonitor(_GLFWmonitor* monitor);
|
_GLFWmonitor* _glfwDestroyMonitor(_GLFWmonitor* monitor);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user