Remove drag detector dependency on partial consumption

We are removing partial consumption of pointer input from the API,
so I must remove the dependency on it for orientation-locked
drag gesture detectors.

Bug: 175142755
Test: Removed dependent tests and ran independent drag tests.
Change-Id: I3bdf7a9fdb71affacf1add2c05236b88dbef2fc9
diff --git a/compose/foundation/foundation/src/commonMain/kotlin/androidx/compose/foundation/gestures/DragGestureDetector.kt b/compose/foundation/foundation/src/commonMain/kotlin/androidx/compose/foundation/gestures/DragGestureDetector.kt
index 1477c75..d49893c 100644
--- a/compose/foundation/foundation/src/commonMain/kotlin/androidx/compose/foundation/gestures/DragGestureDetector.kt
+++ b/compose/foundation/foundation/src/commonMain/kotlin/androidx/compose/foundation/gestures/DragGestureDetector.kt
@@ -25,7 +25,6 @@
 import androidx.compose.ui.input.pointer.PointerInputScope
 import androidx.compose.ui.input.pointer.anyPositionChangeConsumed
 import androidx.compose.ui.input.pointer.changedToUpIgnoreConsumed
-import androidx.compose.ui.input.pointer.consumePositionChange
 import androidx.compose.ui.input.pointer.positionChange
 import androidx.compose.ui.input.pointer.positionChangeIgnoreConsumed
 import androidx.compose.ui.input.pointer.positionChangedIgnoreConsumed
@@ -236,11 +235,7 @@
 ) = awaitTouchSlopOrCancellation(
     pointerId = pointerId,
     onTouchSlopReached = onTouchSlopReached,
-    getDragDirectionValue = { it.y },
-    consumeMotion = { change, consumed ->
-        change.consumePositionChange(0f, consumed)
-    },
-    getCrossDirectionValue = { it.x }
+    getDragDirectionValue = { it.y }
 )
 
 /**
@@ -366,11 +361,7 @@
 ) = awaitTouchSlopOrCancellation(
     pointerId = pointerId,
     onTouchSlopReached = onTouchSlopReached,
-    getDragDirectionValue = { it.x },
-    consumeMotion = { change, consumed ->
-        change.consumePositionChange(consumed, 0f)
-    },
-    getCrossDirectionValue = { it.y }
+    getDragDirectionValue = { it.x }
 )
 
 /**
@@ -539,16 +530,13 @@
  *
  * When touch slop is detected, [onTouchSlopReached] is called with the change and the distance
  * beyond the touch slop. [getDragDirectionValue] should return the position change in the direction
- * of the drag and [getCrossDirectionValue] should return the position change along the
- * perpendicular axis. If [onTouchSlopReached] does not consume the position change, touch slop
+ * of the drag axis. If [onTouchSlopReached] does not consume the position change, touch slop
  * will not have been considered detected and the detection will continue or, if it is consumed,
  * the [PointerInputChange] that was consumed will be returned.
  *
  * This works with [awaitTouchSlopOrCancellation] for the other axis to ensure that only horizontal
  * or vertical dragging is done, but not both.
  *
- * [consumeMotion] should consume the position change along the drag axis.
- *
  * @return The [PointerInputChange] of the event that was consumed in [onTouchSlopReached] or
  * `null` if all pointers are raised or the position change was consumed by another gesture
  * detector.
@@ -556,9 +544,7 @@
 private suspend inline fun HandlePointerInputScope.awaitTouchSlopOrCancellation(
     pointerId: PointerId,
     onTouchSlopReached: (PointerInputChange, Float) -> Unit,
-    getDragDirectionValue: (Offset) -> Float,
-    consumeMotion: (PointerInputChange, Float) -> Unit,
-    getCrossDirectionValue: (Offset) -> Float
+    getDragDirectionValue: (Offset) -> Float
 ): PointerInputChange? {
     if (currentEvent.isPointerUp(pointerId)) {
         return null // The pointer has already been lifted, so the gesture is canceled
@@ -566,7 +552,6 @@
     val touchSlop = viewConfiguration.touchSlop
     var pointer: PointerId = pointerId
     var totalPositionChange = 0f
-    var totalCrossPositionChange = 0f
 
     while (true) {
         val event = awaitPointerEvent()
@@ -587,11 +572,8 @@
             val positionChange = getDragDirectionValue(currentPosition) -
                 getDragDirectionValue(previousPosition)
             totalPositionChange += positionChange
-            totalCrossPositionChange +=
-                getCrossDirectionValue(currentPosition) - getCrossDirectionValue(previousPosition)
 
             val inDirection = abs(totalPositionChange)
-            val crossDirection = abs(totalCrossPositionChange)
             if (inDirection < touchSlop) {
                 // verify that nothing else consumed the drag event
                 awaitPointerEvent(PointerEventPass.Final)
@@ -599,22 +581,6 @@
                     return null
                 }
             } else {
-                if (crossDirection > inDirection) {
-                    // Consume the position change in the direction that we care about
-                    consumeMotion(dragEvent, positionChange)
-
-                    // give the other direction a chance to consume
-                    awaitPointerEvent(PointerEventPass.Final)
-
-                    // Unconsume the position change
-                    consumeMotion(dragEvent, -positionChange)
-
-                    if (dragEvent.anyPositionChangeConsumed()) {
-                        return null
-                    } else {
-                        totalCrossPositionChange = 0f
-                    }
-                }
                 onTouchSlopReached(
                     dragEvent,
                     totalPositionChange - (sign(totalPositionChange) * touchSlop)
diff --git a/compose/foundation/foundation/src/test/kotlin/androidx/compose/foundation/gestures/DragGestureDetectorTest.kt b/compose/foundation/foundation/src/test/kotlin/androidx/compose/foundation/gestures/DragGestureDetectorTest.kt
index c9642e5..99a7772 100644
--- a/compose/foundation/foundation/src/test/kotlin/androidx/compose/foundation/gestures/DragGestureDetectorTest.kt
+++ b/compose/foundation/foundation/src/test/kotlin/androidx/compose/foundation/gestures/DragGestureDetectorTest.kt
@@ -357,75 +357,6 @@
     }
 
     /**
-     * When this drag direction is less than the other drag direction, it should wait
-     * before locking the orientation.
-     */
-    @Test
-    fun dragLockedWithLowPriority() = util.executeInComposition {
-        if (!twoAxisDrag) {
-            down().moveBy(
-                dragMotion + (crossDragMotion * 2f),
-                final = {
-                    // The other direction should have priority, but it should consume the
-                    // in-direction position change
-                    assertEquals(dragMotion, consumed.positionChange)
-
-                    // but it shouldn't have called the callback, yet
-                    assertFalse(dragged)
-                }
-            )
-                .up()
-            assertTrue(dragged)
-            assertTrue(gestureEnded)
-            assertFalse(gestureCanceled)
-            assertEquals(0f, dragDistance)
-        }
-    }
-
-    /**
-     * When this drag direction is less than the other drag direction, it should wait
-     * before locking the orientation. When the other direction locks, it should not drag.
-     */
-    @Test
-    fun dragLockFailWithLowPriority() = util.executeInComposition {
-        if (!twoAxisDrag) {
-            down().moveBy(
-                dragMotion + (crossDragMotion * 2f),
-                final = {
-                    consumeAllChanges()
-                }
-            )
-                .up()
-            assertFalse(dragged)
-            assertFalse(gestureEnded)
-            assertFalse(gestureCanceled)
-        }
-    }
-
-    /**
-     * When this drag direction is less than the other drag direction, it should wait
-     * before locking the orientation. When the other direction locks, it should not drag.
-     */
-    @Test
-    fun dragLockFailNested() = util.executeInComposition {
-        if (!twoAxisDrag) {
-            down().moveBy(
-                dragMotion + (crossDragMotion * 2f),
-                final = {
-                    assertEquals(crossDragMotion * 2f, positionChange())
-                    consumeAllChanges()
-                }
-            ).also {
-                assertEquals(dragMotion, it.positionChange())
-            }
-                .up()
-            assertFalse(dragged)
-            assertFalse(gestureEnded)
-            assertFalse(gestureCanceled)
-        }
-    }
-
-    /**
      * When a drag is not consumed, it should lead to the touch slop being reset. This is
      * important when you drag your finger to
      */