From b6efafdf6ed6741ad140bd0b3ce79b49463e988d Mon Sep 17 00:00:00 2001 From: Joshua Woodie Date: Sat, 9 Oct 2021 15:23:38 -0400 Subject: [PATCH] Add mouse position to mouse button callback Adds the current mouse position as parameters to the mouse button callback. This is to aid in handling mouse button events properly. Resolves: #752 --- include/GLFW/glfw3.h | 6 +++++- src/input.c | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/include/GLFW/glfw3.h b/include/GLFW/glfw3.h index 95aac6d9..c5436371 100644 --- a/include/GLFW/glfw3.h +++ b/include/GLFW/glfw3.h @@ -1684,6 +1684,10 @@ typedef void (* GLFWwindowcontentscalefun)(GLFWwindow* window, float xscale, flo * may add more actions. * @param[in] mods Bit field describing which [modifier keys](@ref mods) were * held down. + * @param[in] xpos The x-coordinate of the cursor, relative to the left edge of + * the content area. + * @param[in] ypos The y-coordinate of the cursor, relative to the top edge of + * the content area. * * @sa @ref input_mouse_button * @sa @ref glfwSetMouseButtonCallback @@ -1693,7 +1697,7 @@ typedef void (* GLFWwindowcontentscalefun)(GLFWwindow* window, float xscale, flo * * @ingroup input */ -typedef void (* GLFWmousebuttonfun)(GLFWwindow* window, int button, int action, int mods); +typedef void (* GLFWmousebuttonfun)(GLFWwindow* window, int button, int action, int mods, double xpos, double ypos); /*! @brief The function pointer type for cursor position callbacks. * diff --git a/src/input.c b/src/input.c index 83ef6921..948d47de 100644 --- a/src/input.c +++ b/src/input.c @@ -336,7 +336,7 @@ void _glfwInputMouseClick(_GLFWwindow* window, int button, int action, int mods) window->mouseButtons[button] = (char) action; if (window->callbacks.mouseButton) - window->callbacks.mouseButton((GLFWwindow*) window, button, action, mods); + window->callbacks.mouseButton((GLFWwindow*) window, button, action, mods, window->virtualCursorPosX, window->virtualCursorPosY); } // Notifies shared code of a cursor motion event