1
0
Fork 0
mirror of https://github.com/gwm17/glfw.git synced 2024-11-26 12:18:51 -05:00

Removed return value of close callback.

This commit is contained in:
Camilla Berglund 2013-03-06 23:29:37 +01:00
parent 5d8fdc64f9
commit 64afb193e8
5 changed files with 18 additions and 26 deletions

View File

@ -181,9 +181,9 @@ while (!glfwWindowShouldClose(window))
}
@endcode
You can intercept the setting of the close flag by setting a close callback with
@ref glfwSetWindowCloseCallback. The return value of the close callback becomes
the new value of the close flag.
You can be notified when user is attempting to close the window by setting
a close callback with @ref glfwSetWindowCloseCallback. The callback will be
called immediately after the close flag has been set.
You can also set it yourself with @ref glfwSetWindowShouldClose. This can be
useful if you want to interpret other kinds of input as closing the window, like

View File

@ -591,15 +591,11 @@ typedef void (* GLFWwindowsizefun)(GLFWwindow*,int,int);
/*! @brief The function signature for window close callbacks.
* @param[in] window The window that the user attempted to close.
* @return One of @c GL_TRUE or @c GL_FALSE.
* @ingroup window
*
* The return value of the close callback becomes the new value returned by
* @ref glfwWindowShouldClose.
*
* @sa glfwSetWindowCloseCallback
*/
typedef int (* GLFWwindowclosefun)(GLFWwindow*);
typedef void (* GLFWwindowclosefun)(GLFWwindow*);
/*! @brief The function signature for window content refresh callbacks.
* @param[in] window The window whose content needs to be refreshed.
@ -1121,20 +1117,17 @@ GLFWAPI GLFWwindow* glfwCreateWindow(int width, int height, const char* title, G
*/
GLFWAPI void glfwDestroyWindow(GLFWwindow* window);
/*! @brief Checks whether the specified window has been requested to close.
/*! @brief Checks the close flag of the specified window.
* @param[in] window The window to query.
* @return @c GL_TRUE if the window should close, or @c GL_FALSE otherwise.
* @return The value of the close flag.
* @ingroup window
*/
GLFWAPI int glfwWindowShouldClose(GLFWwindow* window);
/*! @brief Sets whether the specified window should close.
* @param[in] window The window whose value to change.
/*! @brief Sets the close flag of the specified window.
* @param[in] window The window whose flag to change.
* @param[in] value The new value.
* @ingroup window
*
* @note Calling this from the close callback will have no effect, as whatever
* value you set will be overwritten by the return value of the close callback.
*/
GLFWAPI void glfwSetWindowShouldClose(GLFWwindow* window, int value);
@ -1367,11 +1360,11 @@ GLFWAPI void glfwSetWindowSizeCallback(GLFWwindow* window, GLFWwindowsizefun cbf
* @ingroup window
*
* This callback is called when the user attempts to close the window, i.e.
* clicks the window's close widget. Calling @ref glfwDestroyWindow does not
* cause this callback to be called.
* for example by clicking the window's close widget. It is called immediately
* after the window's close flag has been set.
*
* The return value of the close callback becomes the new value returned by
* @ref glfwWindowShouldClose.
* @remarks Calling @ref glfwDestroyWindow does not cause this callback to be
* called.
*
* @remarks <b>Mac OS X:</b> Selecting Quit from the application menu will
* trigger the close callback for all windows.

View File

@ -126,10 +126,10 @@ void _glfwInputWindowDamage(_GLFWwindow* window)
void _glfwInputWindowCloseRequest(_GLFWwindow* window)
{
window->closed = GL_TRUE;
if (window->callbacks.close)
window->closed = window->callbacks.close((GLFWwindow*) window);
else
window->closed = GL_TRUE;
window->callbacks.close((GLFWwindow*) window);
}

View File

@ -244,11 +244,11 @@ static void window_size_callback(GLFWwindow* window, int width, int height)
glViewport(0, 0, width, height);
}
static int window_close_callback(GLFWwindow* window)
static void window_close_callback(GLFWwindow* window)
{
printf("%08x at %0.3f: Window close\n", counter++, glfwGetTime());
return closeable;
glfwSetWindowShouldClose(window, closeable);
}
static void window_refresh_callback(GLFWwindow* window)

View File

@ -48,10 +48,9 @@ static void window_size_callback(GLFWwindow* window, int width, int height)
glViewport(0, 0, width, height);
}
static int window_close_callback(GLFWwindow* window)
static void window_close_callback(GLFWwindow* window)
{
printf("Close callback triggered\n");
return GL_TRUE;
}
static void key_callback(GLFWwindow* window, int key, int action)