mirror of
https://github.com/glfw/glfw.git
synced 2024-11-25 19:42:00 +00:00
Added window parameter to callbacks, handled NULL argument to glfwIsWindow.
This commit is contained in:
parent
29a0ca47f9
commit
e229ccd7c4
@ -364,14 +364,14 @@ typedef struct {
|
|||||||
} GLFWvidmode;
|
} GLFWvidmode;
|
||||||
|
|
||||||
/* Function pointer types */
|
/* Function pointer types */
|
||||||
typedef void (* GLFWwindowsizefun)(int,int);
|
typedef void (* GLFWwindowsizefun)(GLFWwindow,int,int);
|
||||||
typedef int (* GLFWwindowclosefun)(void);
|
typedef int (* GLFWwindowclosefun)(GLFWwindow);
|
||||||
typedef void (* GLFWwindowrefreshfun)(void);
|
typedef void (* GLFWwindowrefreshfun)(GLFWwindow);
|
||||||
typedef void (* GLFWmousebuttonfun)(int,int);
|
typedef void (* GLFWmousebuttonfun)(GLFWwindow,int,int);
|
||||||
typedef void (* GLFWmouseposfun)(int,int);
|
typedef void (* GLFWmouseposfun)(GLFWwindow,int,int);
|
||||||
typedef void (* GLFWmousewheelfun)(int);
|
typedef void (* GLFWmousewheelfun)(GLFWwindow,int);
|
||||||
typedef void (* GLFWkeyfun)(int,int);
|
typedef void (* GLFWkeyfun)(GLFWwindow,int,int);
|
||||||
typedef void (* GLFWcharfun)(int,int);
|
typedef void (* GLFWcharfun)(GLFWwindow,int,int);
|
||||||
|
|
||||||
|
|
||||||
/*************************************************************************
|
/*************************************************************************
|
||||||
|
@ -61,7 +61,8 @@ static void enableMouseCursor(_GLFWwindow* window)
|
|||||||
|
|
||||||
if (window->mousePosCallback)
|
if (window->mousePosCallback)
|
||||||
{
|
{
|
||||||
window->mousePosCallback(window->mousePosX,
|
window->mousePosCallback(window,
|
||||||
|
window->mousePosX,
|
||||||
window->mousePosY);
|
window->mousePosY);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -203,7 +203,7 @@ GLFWAPI void glfwSetMousePosCallback(GLFWwindow window, GLFWmouseposfun cbfun)
|
|||||||
// Call the callback function to let the application know the current
|
// Call the callback function to let the application know the current
|
||||||
// mouse position
|
// mouse position
|
||||||
if (cbfun)
|
if (cbfun)
|
||||||
cbfun(window->mousePosX, window->mousePosY);
|
cbfun(window, window->mousePosX, window->mousePosY);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -222,6 +222,6 @@ GLFWAPI void glfwSetMouseWheelCallback(GLFWwindow window, GLFWmousewheelfun cbfu
|
|||||||
// Call the callback function to let the application know the current
|
// Call the callback function to let the application know the current
|
||||||
// mouse wheel position
|
// mouse wheel position
|
||||||
if (cbfun)
|
if (cbfun)
|
||||||
cbfun(window->wheelPos);
|
cbfun(window, window->wheelPos);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
15
lib/window.c
15
lib/window.c
@ -141,7 +141,7 @@ void _glfwInputKey(_GLFWwindow* window, int key, int action)
|
|||||||
|
|
||||||
// Call user callback function
|
// Call user callback function
|
||||||
if (window->keyCallback && (window->keyRepeat || !keyrepeat) )
|
if (window->keyCallback && (window->keyRepeat || !keyrepeat) )
|
||||||
window->keyCallback(key, action);
|
window->keyCallback(window, key, action);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -186,7 +186,7 @@ void _glfwInputChar(_GLFWwindow* window, int character, int action)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (window->charCallback && (window->keyRepeat || !keyrepeat))
|
if (window->charCallback && (window->keyRepeat || !keyrepeat))
|
||||||
window->charCallback(character, action);
|
window->charCallback(window, character, action);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -206,7 +206,7 @@ void _glfwInputMouseClick(_GLFWwindow* window, int button, int action)
|
|||||||
window->mouseButton[button] = (char) action;
|
window->mouseButton[button] = (char) action;
|
||||||
|
|
||||||
if (window->mouseButtonCallback)
|
if (window->mouseButtonCallback)
|
||||||
window->mouseButtonCallback(button, action);
|
window->mouseButtonCallback(window, button, action);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -580,9 +580,12 @@ GLFWAPI void glfwMakeWindowCurrent(GLFWwindow window)
|
|||||||
GLFWAPI int glfwIsWindow(GLFWwindow window)
|
GLFWAPI int glfwIsWindow(GLFWwindow window)
|
||||||
{
|
{
|
||||||
if (!_glfwInitialized)
|
if (!_glfwInitialized)
|
||||||
return;
|
return GL_FALSE;
|
||||||
|
|
||||||
return window == _glfwLibrary.window;
|
if (window == NULL)
|
||||||
|
return GL_FALSE;
|
||||||
|
|
||||||
|
return (window == _glfwLibrary.window) ? GL_TRUE : GL_FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -873,7 +876,7 @@ GLFWAPI void glfwSetWindowSizeCallback(GLFWwindow window, GLFWwindowsizefun cbfu
|
|||||||
// Call the callback function to let the application know the current
|
// Call the callback function to let the application know the current
|
||||||
// window size
|
// window size
|
||||||
if (cbfun)
|
if (cbfun)
|
||||||
cbfun(window->width, window->height);
|
cbfun(window, window->width, window->height);
|
||||||
}
|
}
|
||||||
|
|
||||||
//========================================================================
|
//========================================================================
|
||||||
|
@ -1088,13 +1088,13 @@ static GLboolean processSingleEvent(void)
|
|||||||
{
|
{
|
||||||
window->wheelPos++; // To verify: is this up or down?
|
window->wheelPos++; // To verify: is this up or down?
|
||||||
if (window->mouseWheelCallback)
|
if (window->mouseWheelCallback)
|
||||||
window->mouseWheelCallback(window->wheelPos);
|
window->mouseWheelCallback(window, window->wheelPos);
|
||||||
}
|
}
|
||||||
else if (event.xbutton.button == Button5)
|
else if (event.xbutton.button == Button5)
|
||||||
{
|
{
|
||||||
window->wheelPos--;
|
window->wheelPos--;
|
||||||
if (window->mouseWheelCallback)
|
if (window->mouseWheelCallback)
|
||||||
window->mouseWheelCallback(window->wheelPos);
|
window->mouseWheelCallback(window, window->wheelPos);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -1155,7 +1155,8 @@ static GLboolean processSingleEvent(void)
|
|||||||
|
|
||||||
if (window->mousePosCallback)
|
if (window->mousePosCallback)
|
||||||
{
|
{
|
||||||
window->mousePosCallback(window->mousePosX,
|
window->mousePosCallback(window,
|
||||||
|
window->mousePosX,
|
||||||
window->mousePosY);
|
window->mousePosY);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1173,7 +1174,8 @@ static GLboolean processSingleEvent(void)
|
|||||||
window->height = event.xconfigure.height;
|
window->height = event.xconfigure.height;
|
||||||
if (window->windowSizeCallback)
|
if (window->windowSizeCallback)
|
||||||
{
|
{
|
||||||
window->windowSizeCallback(window->width,
|
window->windowSizeCallback(window,
|
||||||
|
window->width,
|
||||||
window->height);
|
window->height);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1252,7 +1254,7 @@ static GLboolean processSingleEvent(void)
|
|||||||
// The window's contents was damaged
|
// The window's contents was damaged
|
||||||
|
|
||||||
if (window->windowRefreshCallback)
|
if (window->windowRefreshCallback)
|
||||||
window->windowRefreshCallback();
|
window->windowRefreshCallback(window);
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -1697,7 +1699,7 @@ void _glfwPlatformPollEvents(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (closeRequested && window->windowCloseCallback)
|
if (closeRequested && window->windowCloseCallback)
|
||||||
closeRequested = window->windowCloseCallback();
|
closeRequested = window->windowCloseCallback(window);
|
||||||
|
|
||||||
if (closeRequested)
|
if (closeRequested)
|
||||||
glfwCloseWindow(window);
|
glfwCloseWindow(window);
|
||||||
|
Loading…
Reference in New Issue
Block a user