Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit d441a8bc authored by omarmt's avatar omarmt
Browse files

multiPointerDraggable set an order for PointerEventScopes

The order is important here: we want to make sure that the previous
PointerEventScope is initialized first. This ensures that the following
PointerEventScope doesn't receive more events than the first one.

Test: A lot of manual testing (Hard to reproduce it, seems a race condition)
Bug: 352522308
Flag: com.android.systemui.scene_container
Change-Id: Iba816edd0cd3a62c3acc8ee3ff5af746b0293905
parent 218de6a5
Loading
Loading
Loading
Loading
+44 −37
Original line number Diff line number Diff line
@@ -241,6 +241,10 @@ internal class MultiPointerDraggableNode(
                }
            }

            // The order is important here: we want to make sure that the previous PointerEventScope
            // is initialized first. This ensures that the following PointerEventScope doesn't
            // receive more events than the first one.
            launch {
                awaitPointerEventScope {
                    while (isActive) {
                        try {
@@ -258,7 +262,9 @@ internal class MultiPointerDraggableNode(
                                onDragEnd = { controller ->
                                    val viewConfiguration = currentValueOf(LocalViewConfiguration)
                                    val maxVelocity =
                                    viewConfiguration.maximumFlingVelocity.let { Velocity(it, it) }
                                        viewConfiguration.maximumFlingVelocity.let {
                                            Velocity(it, it)
                                        }
                                    val velocity = velocityTracker.calculateVelocity(maxVelocity)
                                    controller.onStop(
                                        velocity =
@@ -284,6 +290,7 @@ internal class MultiPointerDraggableNode(
                }
            }
        }
    }

    /**
     * Detect drag gestures in the given [orientation].