diff --git a/src/input.c b/src/input.c index b0bb3de47..b0cfd454e 100644 --- a/src/input.c +++ b/src/input.c @@ -453,6 +453,15 @@ void _glfwFreeJoystick(_GLFWjoystick* js) memset(js, 0, sizeof(_GLFWjoystick)); } +// Center the cursor in the middle of the window +// +void _glfwCenterCursor(_GLFWwindow* window) +{ + int width, height; + + _glfwPlatformGetWindowSize(window, &width, &height); + _glfwPlatformSetCursorPos(window, width / 2.0, height / 2.0); +} ////////////////////////////////////////////////////////////////////////// ////// GLFW public API ////// diff --git a/src/internal.h b/src/internal.h index 81487e14a..ed86c016e 100644 --- a/src/internal.h +++ b/src/internal.h @@ -601,7 +601,6 @@ int _glfwPlatformCreateCursor(_GLFWcursor* cursor, int _glfwPlatformCreateStandardCursor(_GLFWcursor* cursor, int shape); void _glfwPlatformDestroyCursor(_GLFWcursor* cursor); void _glfwPlatformSetCursor(_GLFWwindow* window, _GLFWcursor* cursor); -void _glfwPlatformCenterCursor(_GLFWwindow* window); const char* _glfwPlatformGetScancodeName(int scancode); int _glfwPlatformGetKeyScancode(int key); @@ -761,6 +760,7 @@ _GLFWjoystick* _glfwAllocJoystick(const char* name, int buttonCount, int hatCount); void _glfwFreeJoystick(_GLFWjoystick* js); +void _glfwCenterCursor(_GLFWwindow* window); GLFWbool _glfwInitVulkan(int mode); void _glfwTerminateVulkan(void); diff --git a/src/window.c b/src/window.c index dbccceeb4..34c8b4a83 100644 --- a/src/window.c +++ b/src/window.c @@ -143,14 +143,6 @@ void _glfwInputWindowMonitor(_GLFWwindow* window, _GLFWmonitor* monitor) window->monitor = monitor; } -void _glfwPlatformCenterCursor(_GLFWwindow* window) -{ - int width, height; - - _glfwPlatformGetWindowSize(window, &width, &height); - _glfwPlatformSetCursorPos(window, width / 2.0, height / 2.0); -} - ////////////////////////////////////////////////////////////////////////// ////// GLFW public API ////// ////////////////////////////////////////////////////////////////////////// @@ -237,7 +229,7 @@ GLFWAPI GLFWwindow* glfwCreateWindow(int width, int height, if (window->monitor) { if (wndconfig.centerCursor) - _glfwPlatformCenterCursor(window); + _glfwCenterCursor(window); } else { diff --git a/src/x11_window.c b/src/x11_window.c index 483efb24b..8918d385b 100644 --- a/src/x11_window.c +++ b/src/x11_window.c @@ -544,7 +544,7 @@ static void disableCursor(_GLFWwindow* window) &_glfw.x11.restoreCursorPosX, &_glfw.x11.restoreCursorPosY); updateCursorImage(window); - _glfwPlatformCenterCursor(window); + _glfwCenterCursor(window); XGrabPointer(_glfw.x11.display, window->x11.handle, True, ButtonPressMask | ButtonReleaseMask | PointerMotionMask, GrabModeAsync, GrabModeAsync,