[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) <noreply@anthropic.com>
This commit is contained in:
Behdad EsfahbodandClaude Opus 4.6 committed 2026-03-28 01:38:13 -06:00
1 parent 2dbb476313
commit 95aa2c083b
1 file changed
+10 -1
+10 -1
View File
@@ -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);