Front end: a page opened from a tile takes the pad on its main button

This commit is contained in:
The412Banner committed 2026-09-24 10:42:46 -04:00
1 parent fd4c019c9f
commit 41e6f461fd
1 file changed
+13 -1
@@ -315,7 +315,8 @@ private fun FrontEndScreenBody(s: FrontEndState, a: FrontEndActions, page: (@Com
LaunchedEffect(s.isHomeApp) { if (!s.isHomeApp && selected == "android-apps") selected = "steam" }
remember { Motion.scale = Settings.Global.getFloat(ctx.contentResolver, Settings.Global.ANIMATOR_DURATION_SCALE, 1f); true }
BoxWithConstraints(modifier = Modifier.fillMaxSize().background(colors.background).systemBarsPadding()) {
var anyFocused by remember { mutableStateOf(false) }
BoxWithConstraints(modifier = Modifier.fillMaxSize().background(colors.background).systemBarsPadding().onFocusChanged { anyFocused = it.hasFocus }) {
val wide = maxWidth >= 640.dp
val railSelection = when {
s.pageKey == "performance" || s.pageKey == "protons" -> "setup"
@@ -351,6 +352,17 @@ private fun FrontEndScreenBody(s: FrontEndState, a: FrontEndActions, page: (@Com
kotlinx.coroutines.delay(100)
}
}
// A tile or button that opens a page goes away with the page it was on, and focus with it;
// the pad then had nothing to move from (a press landed back on the rail's first item). So
// once the new page is in, a controller lands on its main button.
val inputModeManager = LocalInputModeManager.current
LaunchedEffect(selected, s.pageKey) {
kotlinx.coroutines.delay(450)
if (!anyFocused && inputModeManager.inputMode == InputMode.Keyboard) runCatching {
if (frontFocus.primaryAttached > 0) frontFocus.primary.requestFocus()
else frontFocus.railFor(railSelection).requestFocus()
}
}
val back = if (wide) FocusDirection.Left else FocusDirection.Up
val paneFocus = Modifier
.focusProperties {