diff --git a/docs/changelog.rst b/docs/changelog.rst index f313940c4..fe09c097a 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -257,6 +257,8 @@ Detailed list of changes - Add an option to :opt:`focus_follows_mouse` to only switch focus on drops rather than movement (:pull:`9896`) +- Fix setting :opt:`momentum_scroll` to zero not *fully* disabling momentum scrolling (:iss:`9904`) + 0.46.2 [2026-03-21] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/glfw/internal.h b/glfw/internal.h index bce35d328..535d50054 100644 --- a/glfw/internal.h +++ b/glfw/internal.h @@ -917,6 +917,7 @@ void glfw_handle_scroll_event_for_momentum(_GLFWwindow *w, const GLFWScrollEvent #else #define momentum_scroll_gesture_detection_timeout_ms 0 #endif +bool glfw_is_momentum_scroll_enabled(void); char* _glfw_strdup(const char* source); diff --git a/glfw/momentum-scroll.c b/glfw/momentum-scroll.c index ae93c0973..e56b9635d 100644 --- a/glfw/momentum-scroll.c +++ b/glfw/momentum-scroll.c @@ -176,13 +176,18 @@ is_suitable_for_momentum(void) { ); } +bool +glfw_is_momentum_scroll_enabled(void) { + return s.friction > 0; +} + void glfw_handle_scroll_event_for_momentum( _GLFWwindow *w, const GLFWScrollEvent *ev, bool stopped, bool is_finger_based ) { const bool is_synthetic_momentum_start_event = stopped && momentum_scroll_gesture_detection_timeout_ms; if (!w) { cancel_existing_scroll(true); return; } - if (!is_finger_based || ev->offset_type != GLFW_SCROLL_OFFEST_HIGHRES || s.friction < 0 || s.friction >= 1) { + if (!is_finger_based || ev->offset_type != GLFW_SCROLL_OFFEST_HIGHRES || !glfw_is_momentum_scroll_enabled()) { if (ev->x_offset != 0 || ev->y_offset != 0) _glfwInputScroll(w, ev); return; } diff --git a/glfw/x11_window.c b/glfw/x11_window.c index fe2ea0af5..718f24bcc 100644 --- a/glfw/x11_window.c +++ b/glfw/x11_window.c @@ -1513,7 +1513,7 @@ handle_xi_motion_event(_GLFWwindow *window, XIDeviceEvent *de) { }; // For high-resolution, finger-based scrolling, use timer-based momentum scrolling - if (d->is_finger_based && type == GLFW_SCROLL_OFFEST_HIGHRES) { + if (d->is_finger_based && type == GLFW_SCROLL_OFFEST_HIGHRES && glfw_is_momentum_scroll_enabled()) { // Reset the timer on each scroll event x11_cancel_momentum_scroll_timer();