diff --git a/src/win32/win32_window.c b/src/win32/win32_window.c index 81d4497c..565bcd66 100644 --- a/src/win32/win32_window.c +++ b/src/win32/win32_window.c @@ -1690,12 +1690,6 @@ void _glfwPlatformPollEvents(void) MSG msg; _GLFWwindow* window; - for (window = _glfwLibrary.windowListHead; window; window = window->next) - { - window->scrollX = 0; - window->scrollY = 0; - } - window = _glfwLibrary.cursorLockWindow; if (window) { diff --git a/src/window.c b/src/window.c index b5e9db7c..f87d3af4 100644 --- a/src/window.c +++ b/src/window.c @@ -70,6 +70,22 @@ static void closeFlaggedWindows(void) } +//======================================================================== +// Clear scroll offsets for all windows +//======================================================================== + +void clearScrollOffsets(void) +{ + _GLFWwindow* window; + + for (window = _glfwLibrary.windowListHead; window; window = window->next) + { + window->scrollX = 0; + window->scrollY = 0; + } +} + + //======================================================================== // Clear all input state //======================================================================== @@ -90,7 +106,7 @@ void clearInputState(_GLFWwindow* window) window->mousePosX = 0; window->mousePosY = 0; - // Set mouse wheel position to 0 + // Set scroll offsets to (0,0) window->scrollX = 0; window->scrollY = 0; @@ -1193,6 +1209,8 @@ GLFWAPI void glfwPollEvents(void) return; } + clearScrollOffsets(); + _glfwPlatformPollEvents(); closeFlaggedWindows(); @@ -1211,6 +1229,8 @@ GLFWAPI void glfwWaitEvents(void) return; } + clearScrollOffsets(); + _glfwPlatformWaitEvents(); closeFlaggedWindows(); diff --git a/src/x11/x11_window.c b/src/x11/x11_window.c index 8ae0b256..a1528835 100644 --- a/src/x11/x11_window.c +++ b/src/x11/x11_window.c @@ -1813,12 +1813,6 @@ void _glfwPlatformPollEvents(void) { _GLFWwindow* window; - for (window = _glfwLibrary.windowListHead; window; window = window->next) - { - window->scrollX = 0; - window->scrollY = 0; - } - // Flag that the cursor has not moved window = _glfwLibrary.cursorLockWindow; if (window)