mirror of
https://github.com/glfw/glfw.git
synced 2026-08-29 03:04:14 +02:00
Added window position callback.
This commit is contained in:
@@ -199,6 +199,7 @@ struct _GLFWwindow
|
||||
int glRobustness;
|
||||
PFNGLGETSTRINGIPROC GetStringi;
|
||||
|
||||
GLFWwindowposfun windowPosCallback;
|
||||
GLFWwindowsizefun windowSizeCallback;
|
||||
GLFWwindowclosefun windowCloseCallback;
|
||||
GLFWwindowrefreshfun windowRefreshCallback;
|
||||
|
||||
24
src/window.c
24
src/window.c
@@ -119,8 +119,14 @@ void _glfwInputWindowFocus(_GLFWwindow* window, GLboolean focused)
|
||||
|
||||
void _glfwInputWindowPos(_GLFWwindow* window, int x, int y)
|
||||
{
|
||||
if (window->positionX == x && window->positionY == y)
|
||||
return;
|
||||
|
||||
window->positionX = x;
|
||||
window->positionY = y;
|
||||
|
||||
if (window->windowPosCallback)
|
||||
window->windowPosCallback(window, x, y);
|
||||
}
|
||||
|
||||
|
||||
@@ -764,6 +770,24 @@ GLFWAPI void* glfwGetWindowUserPointer(GLFWwindow handle)
|
||||
}
|
||||
|
||||
|
||||
//========================================================================
|
||||
// Set callback function for window position changes
|
||||
//========================================================================
|
||||
|
||||
GLFWAPI void glfwSetWindowPosCallback(GLFWwindow handle, GLFWwindowposfun cbfun)
|
||||
{
|
||||
_GLFWwindow* window = (_GLFWwindow*) handle;
|
||||
|
||||
if (!_glfwInitialized)
|
||||
{
|
||||
_glfwSetError(GLFW_NOT_INITIALIZED, NULL);
|
||||
return;
|
||||
}
|
||||
|
||||
window->windowPosCallback = cbfun;
|
||||
}
|
||||
|
||||
|
||||
//========================================================================
|
||||
// Set callback function for window size changes
|
||||
//========================================================================
|
||||
|
||||
Reference in New Issue
Block a user