diff --git a/app/src/main/cpp/waylandcomp/src/compositor.c b/app/src/main/cpp/waylandcomp/src/compositor.c index aba2baa587..6fb0d32c0a 100644 --- a/app/src/main/cpp/waylandcomp/src/compositor.c +++ b/app/src/main/cpp/waylandcomp/src/compositor.c @@ -3210,23 +3210,32 @@ static void touch_down(int id, double x, double y) { struct surface *target = touch_target_at(x, y); if (!target) return; struct wl_client *client = wl_resource_get_client(target->resource); + /* A down on an id that is still held means that sequence's up was lost: end it first. The + * fingers still down are counted only after that - counted before, a lost up left any_active + * set, and on the pointer path every later touch was dropped (a tap or swipe did nothing). */ + if (g_touch_points[id].surface) touch_cancel_client(client); int any_active = 0; for (int i = 0; i < MAX_TOUCH_POINTS; i++) { struct surface *active = g_touch_points[i].surface; if (!active) continue; - any_active = 1; if (active != target) { touch_cancel_all(); any_active = 0; break; } + any_active = 1; } - if (g_touch_points[id].surface) touch_cancel_client(client); struct seat_touch *st; int has_touch = 0; for_each_touch_of(client, st) has_touch = 1; + /* One line per gesture (first finger), so a test can see where a touch went. */ + if (!any_active) { + char name[160]; + describe(target, name, sizeof(name)); + banner_log("touch", "%s gets %s", name, has_touch ? "touch" : "the pointer (it takes no touch)"); + } if (!has_touch) { - if (any_active) return; + if (any_active) return; /* one finger drives the pointer; a second one is ignored */ g_touch_points[id].surface = target; g_touch_points[id].pointer_fallback = 1; pointer_event(x, y, BTN_LEFT, 1); diff --git a/app/src/main/java/com/droiddeck/launcher/SessionActivity.kt b/app/src/main/java/com/droiddeck/launcher/SessionActivity.kt index c797f1ad92..4e208eeed4 100644 --- a/app/src/main/java/com/droiddeck/launcher/SessionActivity.kt +++ b/app/src/main/java/com/droiddeck/launcher/SessionActivity.kt @@ -1231,7 +1231,13 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback { WaylandCompositor.nativeSendTouch(action, event.getPointerId(index), (x * 1919f).toInt(), (y * 1079f).toInt()) } when (event.actionMasked) { - MotionEvent.ACTION_DOWN, MotionEvent.ACTION_POINTER_DOWN -> sendTouch(0, event.actionIndex) + // A first finger starts a new gesture, and Android has ended every earlier one: whatever + // the compositor still holds (an up lost to the drawer opening mid-touch) goes first. + MotionEvent.ACTION_DOWN -> { + WaylandCompositor.nativeSendTouch(3, -1, 0, 0) + sendTouch(0, event.actionIndex) + } + MotionEvent.ACTION_POINTER_DOWN -> sendTouch(0, event.actionIndex) MotionEvent.ACTION_MOVE -> for (index in 0 until event.pointerCount) sendTouch(1, index) MotionEvent.ACTION_UP, MotionEvent.ACTION_POINTER_UP -> sendTouch(2, event.actionIndex) MotionEvent.ACTION_CANCEL -> WaylandCompositor.nativeSendTouch(3, -1, 0, 0)