Modern Apps git

← Modern-Apps.git

pipes: keep edge strokes from triggering the back gesture (#ux-audit)

Commit
74f17b3d6c2366510580d3b996753501ca2bc2ec
Author
Vayun Mathur <[email protected]>
When
2026-11-13 01:26 UTC (23 days ago)
Parents
43168a5
Symptom: starting a stroke on a dot or pipe in the leftmost or
rightmost column often fired the system back gesture instead,
leaving the level (and, before progress was saved, losing the board).

Root cause: the game screen is full-screen and the board fills the
width on phones, so its edge cells sit inside the system's
gesture-navigation back zone. Nothing told the system that touches on
the board are the app's.

Fix: add Modifier.systemGestureExclusion() to the board canvas, so its
bounds are reported as system-gesture exclusion rects. Android caps
exclusions at 200dp of height per edge; the system picks the area, so
on very tall boards the far top/bottom of an edge may still respond to
back, which keeps a way out for gesture-nav users.

User-visible effect: swipes that start on the board's edge cells draw
pipes; back still works from outside the board and via the top bar.

Verification: GameBoardGestureTest.boardOptsOutOfSystemBackGestures
asserts the host view reports a non-empty exclusion rect after
layout.

Diff

games/pipes/src/main/java/com/vayunmathur/games/pipes/ui/GameBoard.kt
diff --git a/games/pipes/src/main/java/com/vayunmathur/games/pipes/ui/GameBoard.kt b/games/pipes/src/main/java/com/vayunmathur/games/pipes/ui/GameBoard.ktindex c624403254..4f39f6f296 100644--- a/games/pipes/src/main/java/com/vayunmathur/games/pipes/ui/GameBoard.kt+++ b/games/pipes/src/main/java/com/vayunmathur/games/pipes/ui/GameBoard.kt@@ -5,6 +5,7 @@ import androidx.compose.foundation.gestures.awaitEachGesture import androidx.compose.foundation.gestures.awaitFirstDown import androidx.compose.foundation.layout.BoxWithConstraints import androidx.compose.foundation.layout.size+import androidx.compose.foundation.systemGestureExclusion import androidx.compose.runtime.Composable import androidx.compose.runtime.getValue import androidx.compose.runtime.remember@@ -61,6 +62,9 @@ fun GameBoard(         modifier = Modifier             .size(boardSize)             .testTag(GAME_BOARD_TAG)+            // Strokes start at the board's edge cells, which on a full-width board sit in+            // the system back-gesture zone; claim the board so they draw instead of exiting.+            .systemGestureExclusion()             .pointerInput(geometry, isLevelWon) {                 if (isLevelWon) return@pointerInput                 // One stroke per gesture, driven only by the first finger: a second finger
games/pipes/src/test/java/com/vayunmathur/games/pipes/ui/GameBoardGestureTest.kt
diff --git a/games/pipes/src/test/java/com/vayunmathur/games/pipes/ui/GameBoardGestureTest.kt b/games/pipes/src/test/java/com/vayunmathur/games/pipes/ui/GameBoardGestureTest.ktindex 9c8dcd6fdf..39b80c8891 100644--- a/games/pipes/src/test/java/com/vayunmathur/games/pipes/ui/GameBoardGestureTest.kt+++ b/games/pipes/src/test/java/com/vayunmathur/games/pipes/ui/GameBoardGestureTest.kt@@ -109,4 +109,20 @@ class GameBoardGestureTest {         assertTrue(CellPos(0, 2) in extends, "extends=$extends")         assertEquals(1, commits)     }++    @Test fun boardOptsOutOfSystemBackGestures() {+        var view: android.view.View? = null+        rule.setContent {+            view = androidx.compose.ui.platform.LocalView.current+            GameBoard(+                level, PipesGameState(), null, emptyList(),+                onStartDraw = {}, onExtendPath = {}, onCommitDraw = {},+                isLevelWon = false, modifier = Modifier.size(300.dp),+            )+        }+        rule.waitForIdle()+        val rects = view!!.systemGestureExclusionRects+        assertTrue(rects.isNotEmpty(), "no gesture exclusion rects")+        assertTrue(rects.any { it.width() > 0 && it.height() > 0 })+    } }