mirror of
https://github.com/glfw/glfw.git
synced 2026-09-20 08:23:13 +00:00
Replaced automatic closing with window parameter.
This commit is contained in:
+2
-3
@@ -59,8 +59,7 @@
|
||||
|
||||
- (BOOL)windowShouldClose:(id)sender
|
||||
{
|
||||
window->closeRequested = GL_TRUE;
|
||||
|
||||
_glfwInputWindowCloseRequest(window);
|
||||
return NO;
|
||||
}
|
||||
|
||||
@@ -127,7 +126,7 @@
|
||||
_GLFWwindow* window;
|
||||
|
||||
for (window = _glfwLibrary.windowListHead; window; window = window->next)
|
||||
window->closeRequested = GL_TRUE;
|
||||
_glfwInputWindowCloseRequest(window);
|
||||
|
||||
return NSTerminateCancel;
|
||||
}
|
||||
|
||||
@@ -337,6 +337,7 @@ void _glfwInputWindowPos(_GLFWwindow* window, int x, int y);
|
||||
void _glfwInputWindowSize(_GLFWwindow* window, int width, int height);
|
||||
void _glfwInputWindowIconify(_GLFWwindow* window, int iconified);
|
||||
void _glfwInputWindowDamage(_GLFWwindow* window);
|
||||
void _glfwInputWindowCloseRequest(_GLFWwindow* window);
|
||||
|
||||
// Input event notification (input.c)
|
||||
void _glfwInputKey(_GLFWwindow* window, int key, int action);
|
||||
|
||||
+2
-3
@@ -532,8 +532,7 @@ static LRESULT CALLBACK windowProc(HWND hWnd, UINT uMsg,
|
||||
|
||||
case WM_CLOSE:
|
||||
{
|
||||
// Flag this window for closing (handled in glfwPollEvents)
|
||||
window->closeRequested = GL_TRUE;
|
||||
_glfwInputWindowCloseRequest(window);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -1249,7 +1248,7 @@ void _glfwPlatformPollEvents(void)
|
||||
window = _glfwLibrary.windowListHead;
|
||||
while (window)
|
||||
{
|
||||
window->closeRequested = GL_TRUE;
|
||||
_glfwInputWindowCloseRequest(window);
|
||||
window = window->next;
|
||||
}
|
||||
|
||||
|
||||
+15
-29
@@ -44,31 +44,6 @@ static int Max(int a, int b)
|
||||
}
|
||||
|
||||
|
||||
//========================================================================
|
||||
// Close all GLFW windows with the closed flag set
|
||||
//========================================================================
|
||||
|
||||
static void closeFlaggedWindows(void)
|
||||
{
|
||||
_GLFWwindow* window;
|
||||
|
||||
for (window = _glfwLibrary.windowListHead; window; )
|
||||
{
|
||||
if (window->closeRequested && _glfwLibrary.windowCloseCallback)
|
||||
window->closeRequested = _glfwLibrary.windowCloseCallback(window);
|
||||
|
||||
if (window->closeRequested)
|
||||
{
|
||||
_GLFWwindow* next = window->next;
|
||||
glfwDestroyWindow(window);
|
||||
window = next;
|
||||
}
|
||||
else
|
||||
window = window->next;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//========================================================================
|
||||
// Clear scroll offsets for all windows
|
||||
//========================================================================
|
||||
@@ -206,6 +181,19 @@ void _glfwInputWindowDamage(_GLFWwindow* window)
|
||||
}
|
||||
|
||||
|
||||
//========================================================================
|
||||
// Register window close request events
|
||||
//========================================================================
|
||||
|
||||
void _glfwInputWindowCloseRequest(_GLFWwindow* window)
|
||||
{
|
||||
if (_glfwLibrary.windowCloseCallback)
|
||||
window->closeRequested = _glfwLibrary.windowCloseCallback(window);
|
||||
else
|
||||
window->closeRequested = GL_TRUE;
|
||||
}
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
////// GLFW public API //////
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
@@ -662,6 +650,8 @@ GLFWAPI int glfwGetWindowParam(GLFWwindow handle, int param)
|
||||
return window == _glfwLibrary.activeWindow;
|
||||
case GLFW_ICONIFIED:
|
||||
return window->iconified;
|
||||
case GLFW_CLOSE_REQUESTED:
|
||||
return window->closeRequested;
|
||||
case GLFW_REFRESH_RATE:
|
||||
return window->refreshRate;
|
||||
case GLFW_WINDOW_RESIZABLE:
|
||||
@@ -818,8 +808,6 @@ GLFWAPI void glfwPollEvents(void)
|
||||
clearScrollOffsets();
|
||||
|
||||
_glfwPlatformPollEvents();
|
||||
|
||||
closeFlaggedWindows();
|
||||
}
|
||||
|
||||
|
||||
@@ -838,7 +826,5 @@ GLFWAPI void glfwWaitEvents(void)
|
||||
clearScrollOffsets();
|
||||
|
||||
_glfwPlatformWaitEvents();
|
||||
|
||||
closeFlaggedWindows();
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -711,7 +711,7 @@ static void processSingleEvent(void)
|
||||
// The window manager was asked to close the window, for example by
|
||||
// the user pressing a 'close' window decoration button
|
||||
|
||||
window->closeRequested = GL_TRUE;
|
||||
_glfwInputWindowCloseRequest(window);
|
||||
}
|
||||
else if (_glfwLibrary.X11.wmPing != None &&
|
||||
(Atom) event.xclient.data.l[0] == _glfwLibrary.X11.wmPing)
|
||||
|
||||
Reference in New Issue
Block a user