Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Synthesize remove events on PointerChange.ACTION_UP and PointerChange.ACTION_POINTER_UP #55157

Merged
merged 23 commits into from
Sep 14, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
format
  • Loading branch information
Gray Mackall committed Sep 12, 2024
commit 274111d21d3dff99f83718881b0bd6d1cf1b8207
Original file line number Diff line number Diff line change
Expand Up @@ -70,21 +70,23 @@ private long readPointerDeviceKind(ByteBuffer buffer) {
}

private long readPointerDeviceKindForPointer(ByteBuffer buffer, int pointerIndex) {
return buffer.getLong(3 * AndroidTouchProcessor.BYTES_PER_FIELD +
(AndroidTouchProcessor.BYTES_PER_FIELD
* AndroidTouchProcessor.POINTER_DATA_FIELD_COUNT
* pointerIndex));
return buffer.getLong(
3 * AndroidTouchProcessor.BYTES_PER_FIELD
+ (AndroidTouchProcessor.BYTES_PER_FIELD
* AndroidTouchProcessor.POINTER_DATA_FIELD_COUNT
* pointerIndex));
}

private long readPointerSignalKind(ByteBuffer buffer) {
return readPointerSignalKindForPointer(buffer, 0);
}

private long readPointerSignalKindForPointer(ByteBuffer buffer, int pointerIndex) {
return buffer.getLong(4 * AndroidTouchProcessor.BYTES_PER_FIELD +
(AndroidTouchProcessor.BYTES_PER_FIELD
* AndroidTouchProcessor.POINTER_DATA_FIELD_COUNT
* pointerIndex));
return buffer.getLong(
4 * AndroidTouchProcessor.BYTES_PER_FIELD
+ (AndroidTouchProcessor.BYTES_PER_FIELD
* AndroidTouchProcessor.POINTER_DATA_FIELD_COUNT
* pointerIndex));
}

private long readDevice(ByteBuffer buffer) {
Expand All @@ -96,21 +98,23 @@ private double readPointerPhysicalX(ByteBuffer buffer) {
}

private double readPointerPhysicalXForPointer(ByteBuffer buffer, int pointerIndex) {
return buffer.getDouble(7 * AndroidTouchProcessor.BYTES_PER_FIELD +
(AndroidTouchProcessor.BYTES_PER_FIELD
* AndroidTouchProcessor.POINTER_DATA_FIELD_COUNT
* pointerIndex));
return buffer.getDouble(
7 * AndroidTouchProcessor.BYTES_PER_FIELD
+ (AndroidTouchProcessor.BYTES_PER_FIELD
* AndroidTouchProcessor.POINTER_DATA_FIELD_COUNT
* pointerIndex));
}

private double readPointerPhysicalY(ByteBuffer buffer) {
return readPointerPhysicalYForPointer(buffer, 0);
}

private double readPointerPhysicalYForPointer(ByteBuffer buffer, int pointerIndex) {
return buffer.getDouble(8 * AndroidTouchProcessor.BYTES_PER_FIELD +
(AndroidTouchProcessor.BYTES_PER_FIELD
* AndroidTouchProcessor.POINTER_DATA_FIELD_COUNT
* pointerIndex));
return buffer.getDouble(
8 * AndroidTouchProcessor.BYTES_PER_FIELD
+ (AndroidTouchProcessor.BYTES_PER_FIELD
* AndroidTouchProcessor.POINTER_DATA_FIELD_COUNT
* pointerIndex));
}

private long readButtons(ByteBuffer buffer) {
Expand Down Expand Up @@ -289,9 +293,12 @@ public void normalTouch() {
assertEquals(AndroidTouchProcessor.PointerSignalKind.NONE, readPointerSignalKind(packet));
assertEquals(10.0, readPointerPhysicalX(packet));
assertEquals(5.0, readPointerPhysicalY(packet));
assertEquals(AndroidTouchProcessor.PointerChange.REMOVE, readPointerChangeForPointer(packet, 1));
assertEquals(AndroidTouchProcessor.PointerDeviceKind.TOUCH, readPointerDeviceKindForPointer(packet, 1));
assertEquals(AndroidTouchProcessor.PointerSignalKind.NONE, readPointerSignalKindForPointer(packet, 1));
assertEquals(
AndroidTouchProcessor.PointerChange.REMOVE, readPointerChangeForPointer(packet, 1));
assertEquals(
AndroidTouchProcessor.PointerDeviceKind.TOUCH, readPointerDeviceKindForPointer(packet, 1));
assertEquals(
AndroidTouchProcessor.PointerSignalKind.NONE, readPointerSignalKindForPointer(packet, 1));
assertEquals(10.0, readPointerPhysicalXForPointer(packet, 1));
assertEquals(5.0, readPointerPhysicalYForPointer(packet, 1));
inOrder.verifyNoMoreInteractions();
Expand Down