Skip to content

Instantly share code, notes, and snippets.

@andreymusth
Created Jul 19, 2021
Embed
What would you like to do?
process full
fun process(
pointerEvent: PointerInputEvent,
positionCalculator: PositionCalculator
): ProcessResult {
// Gets a new PointerInputChangeEvent with the PointerInputEvent.
val internalPointerEvent =
pointerInputChangeEventProducer.produce(pointerEvent, positionCalculator)
// Add new hit paths to the tracker due to down events.
internalPointerEvent.changes.values.forEach { pointerInputChange ->
if (pointerInputChange.changedToDownIgnoreConsumed()) {
root.hitTest(
pointerInputChange.position,
hitResult
)
if (hitResult.isNotEmpty()) {
hitPathTracker.addHitPath(pointerInputChange.id, hitResult)
hitResult.clear()
}
}
}
// Remove [PointerInputFilter]s that are no longer valid and refresh the offset information
// for those that are.
hitPathTracker.removeDetachedPointerInputFilters()
// Dispatch to PointerInputFilters
val dispatchedToSomething = hitPathTracker.dispatchChanges(internalPointerEvent)
var anyMovementConsumed = false
// Remove hit paths from the tracker due to up events, and calculate if we have consumed
// any movement
internalPointerEvent.changes.values.forEach { pointerInputChange ->
if (pointerInputChange.changedToUpIgnoreConsumed()) {
hitPathTracker.removeHitPath(pointerInputChange.id)
}
if (pointerInputChange.positionChangeConsumed()) {
anyMovementConsumed = true
}
}
return ProcessResult(dispatchedToSomething, anyMovementConsumed)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment