Correctly handle pointer cancel events

The cancel event ends the motion, it doesn't apply to a single pointer
like it was previously expected.
This commit is contained in:
Jules Aguillon 2022-12-04 18:21:59 +01:00
parent aaf3d8b630
commit 804ea84981
2 changed files with 5 additions and 7 deletions

View File

@ -172,7 +172,7 @@ public class Keyboard2View extends View
_pointers.onTouchMove(event.getX(p), event.getY(p), event.getPointerId(p)); _pointers.onTouchMove(event.getX(p), event.getY(p), event.getPointerId(p));
break; break;
case MotionEvent.ACTION_CANCEL: case MotionEvent.ACTION_CANCEL:
_pointers.onTouchCancel(event.getPointerId(event.getActionIndex())); _pointers.onTouchCancel();
break; break;
default: default:
return (false); return (false);

View File

@ -48,6 +48,8 @@ public final class Pointers implements Handler.Callback
public void clear() public void clear()
{ {
for (Pointer p : _ptrs)
stopKeyRepeat(p);
_ptrs.clear(); _ptrs.clear();
} }
@ -128,13 +130,9 @@ public final class Pointers implements Handler.Callback
} }
} }
public void onTouchCancel(int pointerId) public void onTouchCancel()
{ {
Pointer ptr = getPtr(pointerId); clear();
if (ptr == null)
return;
stopKeyRepeat(ptr);
removePtr(ptr);
_handler.onPointerFlagsChanged(true); _handler.onPointerFlagsChanged(true);
} }