1
0
Fork 0
mirror of https://github.com/gwm17/glfw.git synced 2024-11-30 05:58:52 -05:00

Moved internal API code to proper location.

This commit is contained in:
Camilla Berglund 2012-08-14 21:47:09 +02:00
parent 17cac4bfa0
commit cd6d957eca

View File

@ -33,6 +33,116 @@
#include <string.h> #include <string.h>
//////////////////////////////////////////////////////////////////////////
////// GLFW internal API //////
//////////////////////////////////////////////////////////////////////////
//========================================================================
// Initialize the monitor list
//========================================================================
void _glfwInitMonitors(void)
{
_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
//========================================================================
void _glfwTerminateMonitors(void)
{
while (_glfwLibrary.monitorListHead)
_glfwLibrary.monitorListHead = _glfwDestroyMonitor(_glfwLibrary.monitorListHead);
}
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
////// GLFW public API ////// ////// GLFW public API //////
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
@ -148,109 +258,3 @@ GLFWAPI void glfwSetMonitorCallback(GLFWmonitorfun cbfun)
_glfwLibrary.monitorCallback= cbfun; _glfwLibrary.monitorCallback= cbfun;
} }
//========================================================================
// Initialize the monitor list.
//========================================================================
void _glfwInitMonitors(void)
{
_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.
//========================================================================
void _glfwTerminateMonitors(void)
{
while (_glfwLibrary.monitorListHead)
_glfwLibrary.monitorListHead = _glfwDestroyMonitor(_glfwLibrary.monitorListHead);
}