From 779fb0d5c55a1b1a42fc21ede6bdd4307f70d286 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Fri, 9 Jan 2026 13:15:37 +0530 Subject: [PATCH] Cancel momentum scroll on button and key events --- glfw/internal.h | 1 + glfw/wl_init.c | 2 ++ 2 files changed, 3 insertions(+) diff --git a/glfw/internal.h b/glfw/internal.h index 2c7ded8c2..66faf6034 100644 --- a/glfw/internal.h +++ b/glfw/internal.h @@ -886,6 +886,7 @@ int _glfwPlatformSetWindowBlur(_GLFWwindow* handle, int value); MonitorGeometry _glfwPlatformGetMonitorGeometry(_GLFWmonitor* monitor); bool _glfwPlatformGrabKeyboard(bool grab); void glfw_handle_scroll_event_for_momentum(_GLFWwindow *w, const GLFWScrollEvent *ev, bool stopped, bool is_finger_based); +#define glfw_cancel_momentum_scroll() glfw_handle_scroll_event_for_momentum(NULL, NULL, false, false) char* _glfw_strdup(const char* source); diff --git a/glfw/wl_init.c b/glfw/wl_init.c index aa97435d1..43a2d274a 100644 --- a/glfw/wl_init.c +++ b/glfw/wl_init.c @@ -135,6 +135,7 @@ static void pointerHandleButton(void* data UNUSED, uint32_t button, uint32_t state) { + glfw_cancel_momentum_scroll(); _glfw.wl.serial = serial; _glfw.wl.input_serial = serial; _glfw.wl.pointer_serial = serial; _GLFWwindow* window = _glfw.wl.pointerFocus; @@ -395,6 +396,7 @@ static void keyboardHandleKey(void* data UNUSED, uint32_t key, uint32_t state) { + glfw_cancel_momentum_scroll(); _GLFWwindow* window = _glfwWindowForId(_glfw.wl.keyboardFocusId); if (!window) return;