From a573f8b14f4e7f9f4e847cbdc67349bfa18474a9 Mon Sep 17 00:00:00 2001 From: The412Banner <205237651+The412Banner@users.noreply.github.com> Date: Tue, 24 Nov 2026 17:19:50 -0500 Subject: [PATCH] fix(session): a fixed portrait resolution applies when landscape is set to Follow screen (#3124) --- .../com/droiddeck/launcher/SessionActivity.kt | 20 +++++-------- .../launcher/session/SessionPrefs.kt | 4 +++ .../launcher/session/SessionState.kt | 3 ++ .../session/PortraitResolutionTest.kt | 30 +++++++++++++++++++ 4 files changed, 45 insertions(+), 12 deletions(-) diff --git a/app/src/main/java/com/droiddeck/launcher/SessionActivity.kt b/app/src/main/java/com/droiddeck/launcher/SessionActivity.kt index 98cabab689..7deb31a83e 100644 --- a/app/src/main/java/com/droiddeck/launcher/SessionActivity.kt +++ b/app/src/main/java/com/droiddeck/launcher/SessionActivity.kt @@ -875,9 +875,10 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde cornerTap = SessionPrefs.drawerCornerTap(this) applyOutputPacing() if (!SessionState.running) { - SessionState.followScreen = followChoice() - SessionState.followScale = followScale() + SessionState.followScales = SessionPrefs.followScales(this, displayMode(), + com.droiddeck.launcher.session.SessionDisplay.panelSize(this)) } + applyFollowChoice() applyFollowOrientation(resources.configuration) goFullscreen() volumeControlStream = android.media.AudioManager.STREAM_MUSIC @@ -2995,16 +2996,10 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde private fun followPortrait(): Boolean = glassesScreen == null && SessionPrefs.portrait(this) - private fun followScale(): Float { - val mode = displayMode() - val choice = SessionPrefs.resolutionChoice(this, mode, com.droiddeck.launcher.session.SessionDisplay.panelSize(this), followPortrait()) - return com.droiddeck.launcher.session.SessionDisplay.followScale(choice) ?: 1f - } - - private fun followChoice(): Boolean { - val mode = displayMode() - return com.droiddeck.launcher.session.SessionDisplay.isFollow( - SessionPrefs.resolutionChoice(this, mode, com.droiddeck.launcher.session.SessionDisplay.panelSize(this), followPortrait())) + private fun applyFollowChoice() { + val scale = SessionState.followScales.let { if (followPortrait()) it.second else it.first } + SessionState.followScreen = scale != null + SessionState.followScale = scale ?: 1f } private fun applyFollowOrientation(config: android.content.res.Configuration) { @@ -3018,6 +3013,7 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde SessionService.setActivityDisplay(this, sessionActivityDisplayId) } cancelTouchGestures() + applyFollowChoice() applyFollowOrientation(newConfig) applyNotchInset() applyUnfoldedControls() diff --git a/app/src/main/java/com/droiddeck/launcher/session/SessionPrefs.kt b/app/src/main/java/com/droiddeck/launcher/session/SessionPrefs.kt index 9645c411cc..7624037de7 100644 --- a/app/src/main/java/com/droiddeck/launcher/session/SessionPrefs.kt +++ b/app/src/main/java/com/droiddeck/launcher/session/SessionPrefs.kt @@ -1343,6 +1343,10 @@ object SessionPrefs { SessionDisplay.effectiveChoice( resolutionStored(context, mode, panel, false), resolutionStored(context, mode, panel, true), portrait) + fun followScales(context: Context, mode: String, panel: Pair): Pair = + SessionDisplay.followScale(resolutionChoice(context, mode, panel, false)) to + SessionDisplay.followScale(resolutionChoice(context, mode, panel, true)) + fun resolutionStored(context: Context, mode: String, panel: Pair, portrait: Boolean): String { if (!portrait) return landscapeResolutionStored(context, mode, panel) val value = prefs(context).getString("displayResolution.portrait.$mode", null) ?: return SessionDisplay.LINK_LANDSCAPE diff --git a/app/src/main/java/com/droiddeck/launcher/session/SessionState.kt b/app/src/main/java/com/droiddeck/launcher/session/SessionState.kt index e695f8b932..92255febec 100644 --- a/app/src/main/java/com/droiddeck/launcher/session/SessionState.kt +++ b/app/src/main/java/com/droiddeck/launcher/session/SessionState.kt @@ -148,6 +148,9 @@ object SessionState { @Volatile var outputSize: Pair = Pair(1920, 1080) + @Volatile + var followScales: Pair = null to null + @Volatile var followScreen = false var followScale = 1f diff --git a/app/src/test/java/com/droiddeck/launcher/session/PortraitResolutionTest.kt b/app/src/test/java/com/droiddeck/launcher/session/PortraitResolutionTest.kt index fb9199157b..f010e97a65 100644 --- a/app/src/test/java/com/droiddeck/launcher/session/PortraitResolutionTest.kt +++ b/app/src/test/java/com/droiddeck/launcher/session/PortraitResolutionTest.kt @@ -1,6 +1,7 @@ package com.droiddeck.launcher.session import android.content.Context +import android.content.pm.ActivityInfo import org.junit.Assert.* import org.junit.Before import org.junit.Test @@ -74,6 +75,35 @@ class PortraitResolutionTest { assertEquals("1440x2560", SessionPrefs.resolutionStored(app, "steam", panel, true)) } + @Test fun followScreenInLandscapeLeavesAFixedPortraitSizeFixed() { + SessionPrefs.setResolutionChoice(app, "steam", SessionDisplay.FOLLOW_SCREEN) + SessionPrefs.setResolutionChoice(app, "steam", "1024x768", portrait = true) + assertEquals(1f to null, SessionPrefs.followScales(app, "steam", panel)) + } + + @Test fun followScreenInPortraitLeavesAFixedLandscapeSizeFixed() { + SessionPrefs.setResolutionChoice(app, "steam", "1080p") + SessionPrefs.setResolutionChoice(app, "steam", SessionDisplay.followScaled(2f), portrait = true) + assertEquals(null to 2f, SessionPrefs.followScales(app, "steam", panel)) + } + + @Test fun followScalesKeepLinkedAndFixedChoices() { + SessionPrefs.setResolutionChoice(app, "steam", SessionDisplay.followScaled(1.5f)) + assertEquals(1.5f to 1.5f, SessionPrefs.followScales(app, "steam", panel)) + SessionPrefs.setResolutionChoice(app, "steam", "1024x768", portrait = true) + SessionPrefs.setResolutionChoice(app, "steam", SessionDisplay.LINK_PORTRAIT) + assertEquals(null to null, SessionPrefs.followScales(app, "steam", panel)) + app.getSharedPreferences("session", Context.MODE_PRIVATE).edit().clear().commit() + assertEquals(null to null, SessionPrefs.followScales(app, "steam", panel)) + } + + @Test fun anAutoOrientationIsNotChangedByFollowScreen() { + assertFalse(SessionPrefs.portrait(app)) + SessionPrefs.setOrientation(app, ActivityInfo.SCREEN_ORIENTATION_USER) + assertEquals(ActivityInfo.SCREEN_ORIENTATION_USER, SessionPrefs.windowOrientation(app, true, 700)) + assertEquals(ActivityInfo.SCREEN_ORIENTATION_USER, SessionPrefs.windowOrientation(app, false, 700)) + } + @Test fun modesKeepSeparateChoices() { SessionPrefs.setResolutionChoice(app, "steam", "1080p", portrait = true) assertEquals(SessionDisplay.LINK_LANDSCAPE, SessionPrefs.resolutionStored(app, "lxqt", panel, true))