From 95aa2c083b68f9737c018e723e48dff2f5ca0e33 Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Sat, 28 Mar 2026 01:38:13 -0600 Subject: [PATCH] [gpu] Add drag threshold for tap detection on mobile Small finger movements (< 5 pixels) during a touch no longer count as a drag, allowing tap-to-toggle-animation to work reliably on touchscreens. Co-Authored-By: Claude Opus 4.6 (1M context) --- util/gpu/demo-view.cc | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/util/gpu/demo-view.cc b/util/gpu/demo-view.cc index 92cdd9552..db3e1c059 100644 --- a/util/gpu/demo-view.cc +++ b/util/gpu/demo-view.cc @@ -426,7 +426,16 @@ demo_view_motion_func (demo_view_t *vu, double x, double y) if (!vu->buttons) return; - vu->dragged = true; + /* Only count as dragged if moved more than a few pixels (helps touch). */ + if (!vu->dragged) + { + double dx = x - vu->beginx; + double dy = y - vu->beginy; + if (dx * dx + dy * dy > 25) + vu->dragged = true; + else + return; + } int width, height; glfwGetWindowSize (vu->window, &width, &height);