This commit is contained in:
Kovid Goyal 2026-04-22 07:43:57 +05:30
parent 77f2fef6a7
commit 6b9d449b0d
No known key found for this signature in database
GPG key ID: 06BC317B515ACE7C
4 changed files with 10 additions and 2 deletions

View file

@ -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]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

1
glfw/internal.h vendored
View file

@ -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);

View file

@ -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;
}

2
glfw/x11_window.c vendored
View file

@ -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();