ui: preserve rail focus on components

This commit is contained in:
xXJsonDeruloXx committed 2026-09-26 22:16:38 -04:00
1 parent 2ba872e7f7
commit 2b1ef0d3e6
3 files changed
+15 -9

No files matched your search

@@ -101,6 +101,7 @@ class MainActivity : ComponentActivity() {
private var showProtons by mutableStateOf(false) private var showProtons by mutableStateOf(false)
// Components page: FEX / DXVK / VKD3D-Proton per Proton (ComponentsManager). // Components page: FEX / DXVK / VKD3D-Proton per Proton (ComponentsManager).
private var showComponents by mutableStateOf(false) private var showComponents by mutableStateOf(false)
private var focusComponentsContent by mutableStateOf(true)
private var compSnapshot by mutableStateOf<ComponentsManager.Snapshot?>(null) private var compSnapshot by mutableStateOf<ComponentsManager.Snapshot?>(null)
private var compCatalog by mutableStateOf<List<ComponentsManager.CatalogItem>>(emptyList()) private var compCatalog by mutableStateOf<List<ComponentsManager.CatalogItem>>(emptyList())
private var compCatalogAt by mutableStateOf(0L) private var compCatalogAt by mutableStateOf(0L)
@@ -348,7 +349,7 @@ class MainActivity : ComponentActivity() {
frameGenLabel = FrameGen.label(this) frameGenLabel = FrameGen.label(this)
}, },
onProtons = { openProtons() }, onProtons = { openProtons() },
onComponents = { openComponents() }, onComponents = { focusContent -> openComponents(focusContent) },
onPerformance = { refreshCores(); showProtons = false; showComponents = false; showMapping = false; showPerformance = true }, onPerformance = { refreshCores(); showProtons = false; showComponents = false; showMapping = false; showPerformance = true },
onRoms = { showRoms = true }, onRoms = { showRoms = true },
onFiles = { startActivity(Intent(this, com.droiddeck.launcher.files.FileManagerActivity::class.java)) }, onFiles = { startActivity(Intent(this, com.droiddeck.launcher.files.FileManagerActivity::class.java)) },
@@ -669,7 +670,8 @@ class MainActivity : ComponentActivity() {
) )
} }
private fun openComponents() { private fun openComponents(focusContent: Boolean = true) {
focusComponentsContent = focusContent
settingsMode = null settingsMode = null
showPerformance = false showPerformance = false
showProtons = false showProtons = false
@@ -755,6 +757,7 @@ class MainActivity : ComponentActivity() {
checking = compChecking, checking = compChecking,
busy = compBusy, busy = compBusy,
downloads = compDownloads, downloads = compDownloads,
requestInitialFocus = focusComponentsContent,
onProton = { compProton = it }, onProton = { compProton = it },
onComp = { compComp = it }, onComp = { compComp = it },
onSwap = { file -> compProton?.let { pid -> componentAction("Swapping") { ComponentsManager.swap(this, pid, file) } } }, onSwap = { file -> compProton?.let { pid -> componentAction("Swapping") { ComponentsManager.swap(this, pid, file) } } },
@@ -101,6 +101,7 @@ fun ComponentsPage(
onRefresh: () -> Unit, onRefresh: () -> Unit,
onImport: () -> Unit, onImport: () -> Unit,
onBack: () -> Unit, onBack: () -> Unit,
requestInitialFocus: Boolean = true,
) { ) {
val colors = MaterialTheme.colorScheme val colors = MaterialTheme.colorScheme
val pal = LocalPalette.current val pal = LocalPalette.current
@@ -207,7 +208,9 @@ fun ComponentsPage(
val storedNames = snapshot.packages.map { it.file }.toSet() val storedNames = snapshot.packages.map { it.file }.toSet()
val available = catalog.filter { it.comp == comp && ComponentsManager.safeName(it.file) !in storedNames } val available = catalog.filter { it.comp == comp && ComponentsManager.safeName(it.file) !in storedNames }
val first = remember { FocusRequester() } val first = remember { FocusRequester() }
LaunchedEffect(p.id, comp) { runCatching { first.requestFocus() } } LaunchedEffect(p.id, comp, requestInitialFocus) {
if (requestInitialFocus) runCatching { first.requestFocus() }
}
val installed: @Composable () -> Unit = { val installed: @Composable () -> Unit = {
SettingsGroup("Installed · ${rows.size}") { SettingsGroup("Installed · ${rows.size}") {
@@ -222,7 +222,7 @@ class FrontEndActions(
val onFrameGenPick: (engine: String, multiplier: Int) -> Unit, val onFrameGenPick: (engine: String, multiplier: Int) -> Unit,
val onProtons: () -> Unit, val onProtons: () -> Unit,
/** The Components page: FEX / DXVK / VKD3D-Proton per Proton. */ /** The Components page: FEX / DXVK / VKD3D-Proton per Proton. */
val onComponents: () -> Unit, val onComponents: (focusContent: Boolean) -> Unit,
val onPerformance: () -> Unit, val onPerformance: () -> Unit,
val onRoms: () -> Unit, val onRoms: () -> Unit,
val onFiles: () -> Unit, val onFiles: () -> Unit,
@@ -431,20 +431,20 @@ private fun FrontEndScreenBody(s: FrontEndState, a: FrontEndActions, page: (@Com
} }
// Bumped each time a rail item is picked, so a controller moves on into the new page. // Bumped each time a rail item is picked, so a controller moves on into the new page.
var railPicks by remember { mutableStateOf(0) } var railPicks by remember { mutableStateOf(0) }
val showRailPage: (String) -> Unit = { key -> val showRailPage: (String, Boolean) -> Unit = { key, focusContent ->
// Components is a full page like Protons or Performance, opened over the current rail // Components is a full page like Protons or Performance, opened over the current rail
// selection rather than replacing it. // selection rather than replacing it.
if (key == "components") a.onComponents() if (key == "components") a.onComponents(focusContent)
else { else {
if (s.pageKey != null) a.onPageBack() if (s.pageKey != null) a.onPageBack()
selected = key selected = key
} }
} }
val onRailFocus: (String) -> Unit = { key -> val onRailFocus: (String) -> Unit = { key ->
if (key != railSelection) showRailPage(key) if (key != railSelection) showRailPage(key, false)
} }
val onRailSelect: (String) -> Unit = { key -> val onRailSelect: (String) -> Unit = { key ->
showRailPage(key) showRailPage(key, true)
railPicks++ railPicks++
} }
val inputModeManager = LocalInputModeManager.current val inputModeManager = LocalInputModeManager.current
@@ -1474,7 +1474,7 @@ private fun LaunchSettings(s: FrontEndState, a: FrontEndActions, host: MenuHost)
val columns = if (LocalNarrowPane.current) 2 else 3 val columns = if (LocalNarrowPane.current) 2 else 3
val controller = a.controller val controller = a.controller
val cards = buildList<@Composable (Modifier) -> Unit> { val cards = buildList<@Composable (Modifier) -> Unit> {
add { m -> SettingCard("Compatibility", "Proton & components", "card:components", m, a.onComponents) } add { m -> SettingCard("Compatibility", "Proton & components", "card:components", m) { a.onComponents(true) } }
add { m -> add { m ->
Box(m) { Box(m) {
SettingCard("Frame generation", s.frameGenLabel, "card:fg", Modifier.fillMaxSize()) { SettingCard("Frame generation", s.frameGenLabel, "card:fg", Modifier.fillMaxSize()) {