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

Moved flagged window closing into a separate function.

This commit is contained in:
Camilla Berglund 2010-09-14 01:43:31 +02:00
parent d874f7ac98
commit 5a8dcead1e

View File

@ -44,6 +44,32 @@ static int Max(int a, int b)
return (a > b) ? a : b; return (a > b) ? a : b;
} }
//========================================================================
// Close all GLFW windows with the closed flag set
//========================================================================
static void closeFlaggedWindows(void)
{
_GLFWwindow* window;
for (window = _glfwLibrary.windowListHead; window; )
{
if (window->closed && window->windowCloseCallback)
window->closed = window->windowCloseCallback(window);
if (window->closed)
{
_GLFWwindow* next = window->next;
glfwCloseWindow(window);
window = next;
}
else
window = window->next;
}
}
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
////// GLFW internal API ////// ////// GLFW internal API //////
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
@ -1044,8 +1070,6 @@ GLFWAPI void glfwSetWindowRefreshCallback(GLFWwindow window, GLFWwindowrefreshfu
GLFWAPI void glfwPollEvents(void) GLFWAPI void glfwPollEvents(void)
{ {
_GLFWwindow* window;
if (!_glfwInitialized) if (!_glfwInitialized)
{ {
_glfwSetError(GLFW_NOT_INITIALIZED); _glfwSetError(GLFW_NOT_INITIALIZED);
@ -1054,20 +1078,7 @@ GLFWAPI void glfwPollEvents(void)
_glfwPlatformPollEvents(); _glfwPlatformPollEvents();
for (window = _glfwLibrary.windowListHead; window; ) closeFlaggedWindows();
{
if (window->closed && window->windowCloseCallback)
window->closed = window->windowCloseCallback(window);
if (window->closed)
{
_GLFWwindow* next = window->next;
glfwCloseWindow(window);
window = next;
}
else
window = window->next;
}
} }
@ -1084,5 +1095,7 @@ GLFWAPI void glfwWaitEvents(void)
} }
_glfwPlatformWaitEvents(); _glfwPlatformWaitEvents();
closeFlaggedWindows();
} }