Refactor screen effects sync and fix game exit handling

This commit is contained in:
EnzoDLofi committed 2026-11-13 22:16:13 -04:00
1 parent afc44f03b8
commit 0349745c49
2 files changed
+16 -20

No files matched your search

@@ -548,10 +548,7 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde
}
private val screenEffectsProfilePrefListener = android.content.SharedPreferences.OnSharedPreferenceChangeListener { _, key ->
if (key == SessionPrefs.SCREEN_EFFECTS_ACTIVE_PROFILE_KEY) uiHandler.post {
val profileId = SessionPrefs.activeScreenEffectsProfileId(this@SessionActivity)
observedScreenEffectsProfileId = profileId
effects = SessionPrefs.screenEffects(this@SessionActivity, profileId)
effects.push(upscaler)
syncActiveScreenEffectsProfile()
}
}
private val shortcutPrefListener = android.content.SharedPreferences.OnSharedPreferenceChangeListener { _, key ->
@@ -989,13 +986,7 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde
val effectsEditorProfileId = if (drawerOpen) activeEffectsProfileId else null
androidx.compose.runtime.LaunchedEffect(effectsEditorProfileId) {
if (effectsEditorProfileId != null) {
val activeProfileId =
SessionPrefs.activeScreenEffectsProfileId(this@SessionActivity)
observedScreenEffectsProfileId = activeProfileId
val activeEffects =
SessionPrefs.screenEffects(this@SessionActivity, activeProfileId)
effects = activeEffects
activeEffects.push(upscaler)
syncActiveScreenEffectsProfile()
}
}
val uiPointer = appUiOwnsPointer()
@@ -2012,6 +2003,13 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde
}, "drawer-game-no-steam").start()
}
private fun syncActiveScreenEffectsProfile() {
val profileId = SessionPrefs.activeScreenEffectsProfileId(this)
observedScreenEffectsProfileId = profileId
effects = SessionPrefs.screenEffects(this, profileId)
effects.push(upscaler)
}
private fun currentScreenEffectsProfileId(): String? {
if (SessionState.running) {
return observedScreenEffectsProfileId
@@ -3807,13 +3805,7 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde
if (drawerOpen || drawerPinned) activeEffectsProfileId else null
androidx.compose.runtime.LaunchedEffect(effectsEditorProfileId) {
if (effectsEditorProfileId != null) {
val activeProfileId =
SessionPrefs.activeScreenEffectsProfileId(this@SessionActivity)
observedScreenEffectsProfileId = activeProfileId
val activeEffects =
SessionPrefs.screenEffects(this@SessionActivity, activeProfileId)
effects = activeEffects
activeEffects.push(upscaler)
syncActiveScreenEffectsProfile()
}
}
SessionMenu(docked = true, effectsEditorProfileId = effectsEditorProfileId)