Fix per-game screen effects profile handling

This commit is contained in:
EnzoDLofi committed 2026-11-13 22:16:13 -04:00
1 parent 08f666174e
commit 506e7c5ba4
2 files changed
+38 -6

No files matched your search

@@ -1227,7 +1227,7 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde
onAndroidKeyboard = { pcKeyboardOpen = false; keyboard?.toggle() },
onClose = { pcKeyboardOpen = false },
)
if (!drawerDocked) SessionMenu(docked = false)
if (!drawerDocked) SessionMenu(docked = false, effectsEditorProfileId = effectsEditorProfileId)
LaunchedEffect(achievementsOpen) {
if (achievementsOpen) {
releasePads()
@@ -1277,7 +1277,7 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde
}
@androidx.compose.runtime.Composable
private fun SessionMenu(docked: Boolean) {
private fun SessionMenu(docked: Boolean, effectsEditorProfileId: String?) {
SessionDrawer(drawerOpen || (docked && drawerPinned), drawerPage, drawerControllerActive, onPageChange = { drawerPage = it }, docked = docked,
backRequest = drawerBackRequests, onLayerChange = { drawerLayerOpen = it }, a = DrawerActions(
steam = SessionState.mode == SessionService.MODE_STEAM,
@@ -1353,7 +1353,7 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde
},
onEffects = { e ->
if (drawerOpen && effectsEditorProfileId != null &&
currentScreenEffectsProfileId() == effectsEditorProfileId) {
SessionPrefs.activeScreenEffectsProfileId(this@SessionActivity) == effectsEditorProfileId) {
SessionPrefs.setScreenEffects(this@SessionActivity, effectsEditorProfileId, e)
effects = e
e.push(upscaler)
@@ -3757,7 +3757,12 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde
}
},
menu = {
DroidDeckTheme { SessionMenu(docked = true) }
DroidDeckTheme {
val effectsEditorProfileId = androidx.compose.runtime.remember(drawerOpen, drawerPinned) {
if (drawerOpen || drawerPinned) currentScreenEffectsProfileId() else null
}
SessionMenu(docked = true, effectsEditorProfileId = effectsEditorProfileId)
}
},
onSwap = if (bottomSwapAvailable && com.droiddeck.launcher.input.DualScreen.builtIn(target)) ({ putGameOnBottom(true) }) else null,
onDeckPanel = ::selectDeckPanel,
@@ -108,6 +108,7 @@ class SessionService : Service() {
private var freezePending = false
private var freezeCancelled = false
private var pendingSteamGameId: String? = null
private var pendingSteamPreviousGameId: String? = null
private var pendingSteamGameGeneration = -1
private var pendingSteamGameExitWatchToken = -1
@Volatile private var gameExitWatchToken = 0
@@ -1507,6 +1508,7 @@ class SessionService : Service() {
return
}
val accepted = gameId!!
if (pendingSteamGameId == null) pendingSteamPreviousGameId = SessionState.gameId
if (pendingSteamGameId != null) Log.i(TAG, "replacing a queued game launch with $accepted")
pendingSteamGameExitWatchToken = ++gameExitWatchToken
SessionState.gameId = accepted
@@ -1524,9 +1526,32 @@ class SessionService : Service() {
val gameId = pendingSteamGameId ?: return
val gen = pendingSteamGameGeneration
val exitWatchToken = pendingSteamGameExitWatchToken
if (exitWatchToken != gameExitWatchToken || gen != sessionGen || !SessionState.running || SessionState.stopRequested ||
SessionState.mode != MODE_STEAM || !GameLaunchLink.validId(gameId)) {
// Ignore a stale callback without cancelling a newer queued launch.
if (exitWatchToken != gameExitWatchToken) return
if (gen != sessionGen || !SessionState.running || SessionState.stopRequested ||
SessionState.mode != MODE_STEAM || SessionState.gameId != gameId ||
!GameLaunchLink.validId(gameId)) {
val previousGameId = pendingSteamPreviousGameId
val queuedProfileId = SessionPrefs.screenEffectsProfileId(MODE_STEAM, gameId, null)
val canRestore = gen == sessionGen &&
SessionState.running && !SessionState.stopRequested &&
SessionState.mode == MODE_STEAM &&
SessionPrefs.activeScreenEffectsProfileId(this) == queuedProfileId
cancelQueuedSteamGame()
if (canRestore) {
val restoreGameId = if (SessionState.gameId == gameId) {
previousGameId.also { SessionState.gameId = it }
} else {
SessionState.gameId
}
val restoreProfileId =
SessionPrefs.screenEffectsProfileId(MODE_STEAM, restoreGameId, null)
SessionPrefs.setActiveScreenEffectsProfile(this, restoreProfileId)
SessionPrefs.screenEffects(this, restoreProfileId)
.push(SessionPrefs.upscaler(this))
}
return
}
if (SessionState.suspended) {
@@ -1552,6 +1577,7 @@ class SessionService : Service() {
return
}
pendingSteamGameId = null
pendingSteamPreviousGameId = null
pendingSteamGameGeneration = -1
pendingSteamGameExitWatchToken = -1
SessionEvents.record("steam.game_launch_requested", mapOf("gameId" to gameId, "generation" to gen))
@@ -1629,6 +1655,7 @@ class SessionService : Service() {
private fun cancelQueuedSteamGame(clearMailbox: Boolean = true) {
mainHandler.removeCallbacks(flushSteamGame)
pendingSteamGameId = null
pendingSteamPreviousGameId = null
pendingSteamGameGeneration = -1
pendingSteamGameExitWatchToken = -1
gameExitWatchToken++