Windows multitouch tweaks

* Fix special case of first single touch. While another touch
is active, any new touch must not get the ID of the (ignored)
first touch.

* reset "last-touch" coordinate on touch-begin.
Previously it was possible that the first motion event was
ignored.

NB: This does not fix missing events when the first touch
coincides with any other finger (gesture?).
This commit is contained in:
Robin Gareus 2025-01-15 03:31:54 +01:00
parent 91fe10165e
commit 90755045f5
No known key found for this signature in database
GPG key ID: A090BCE02CF57F04

View file

@ -249,7 +249,8 @@ touch_idx_lookup (DWORD id)
static int
touch_idx_map (DWORD id)
{
GList* g = g_list_find (touch_mapper, GUINT_TO_POINTER(G_MAXUINT));
/* when there is an active touch, skip index 0 (mouse) */
GList* g = touch_mapper ? g_list_find (touch_mapper->next, GUINT_TO_POINTER(G_MAXUINT)): NULL;
if (!g) {
touch_mapper = g_list_append (touch_mapper, GUINT_TO_POINTER(id));
} else {
@ -267,6 +268,20 @@ touch_idx_unmap (DWORD id)
}
int rv = g_list_position (touch_mapper, g);
g->data = GUINT_TO_POINTER(G_MAXULONG);
/* last touch clears the list */
gboolean empty = TRUE;
for (g = touch_mapper; g && empty; g = g->next) {
if (g->data != GUINT_TO_POINTER(G_MAXULONG)) {
empty = FALSE;
break;
}
}
if (empty) {
g_list_free (touch_mapper);
touch_mapper = NULL;
}
return rv;
}
@ -2118,8 +2133,13 @@ handle_wm_pointer (GdkEventType type, GdkWindow* window, MSG* msg)
return FALSE;
}
if (type == GDK_TOUCH_BEGIN) {
last_touch_x[touch_sequence] = -1;
last_touch_y[touch_sequence] = -1;
} else {
last_touch_x[touch_sequence] = (int)point.x;
last_touch_y[touch_sequence] = (int)point.y;
}
/* first single touch is already handled by Windows as mouse event */
if (touch_sequence == 0) {