mirror of
https://github.com/Droid-Deck/DroidDeck.git
synced 2026-11-18 12:28:40 +00:00
Refactor screen effects sync and fix game exit handling
This commit is contained in:
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)
|
||||
|
||||
@@ -1632,8 +1632,7 @@ class SessionService : Service() {
|
||||
mainHandler.postDelayed({
|
||||
if (token != gameExitWatchToken || gen != sessionGen || !SessionState.running ||
|
||||
SessionState.stopRequested || SessionState.mode != MODE_STEAM ||
|
||||
!SessionPrefs.returnAfterGame(this) || SessionState.gameId != gameId ||
|
||||
pendingSteamGameId != null) {
|
||||
SessionState.gameId != gameId || pendingSteamGameId != null) {
|
||||
return@postDelayed
|
||||
}
|
||||
|
||||
@@ -1651,6 +1650,11 @@ class SessionService : Service() {
|
||||
|
||||
clearActiveScreenEffectsProfile(gameId, gen, token)
|
||||
|
||||
if (!SessionPrefs.returnAfterGame(this)) {
|
||||
Log.i(TAG, "return after game disabled; keeping the Steam session open")
|
||||
return@postDelayed
|
||||
}
|
||||
|
||||
val written = runCatching { File(LinuxRuntime.sessionRoot(this), "steam-stop").writeText("") }
|
||||
.onFailure { Log.w(TAG, "could not ask the client to exit after game $gameId", it) }.isSuccess
|
||||
if (!written) return@postDelayed
|
||||
|
||||
Reference in new issue
Block a user