fix(session): address review on the landscape and portrait resolution split

Accept generated portrait sizes on reload, use the right orientation and output target when deciding follow screen, show the real size behind each Follow option, treat a saved portrait Desktop resolution as chosen, and update the orientation hint in every locale.
This commit is contained in:
FX192 committed 2026-11-21 22:46:45 +03:00
1 parent 50dace9958
commit a9054aac3f
38 files changed
+78 -42

No files matched your search

@@ -2956,16 +2956,28 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde
WaylandCompositor.nativeResizeOutput(size.first, size.second)
}
private fun followPortrait(): Boolean {
if (glassesScreen != null) return false
if (::sessionRoot.isInitialized && sessionRoot.width > 0) return portraitOutput()
val portraitWindow = SessionPrefs.portrait(this)
val panel = com.droiddeck.launcher.session.SessionDisplay.panelSize(this)
val long = maxOf(panel.first, panel.second)
val short = minOf(panel.first, panel.second)
val below = SessionPrefs.controlsBelowWanted(this, intent.getStringExtra(SessionService.EXTRA_MODE) ?: SessionService.MODE_STEAM,
if (portraitWindow) short else long, if (portraitWindow) long else short)
return portraitWindow && !below
}
private fun followScale(): Float {
val mode = displayMode()
val choice = SessionPrefs.resolutionChoice(this, mode, com.droiddeck.launcher.session.SessionDisplay.panelSize(this), portraitOutput())
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), portraitOutput()))
SessionPrefs.resolutionChoice(this, mode, com.droiddeck.launcher.session.SessionDisplay.panelSize(this), followPortrait()))
}
private fun applyFollowOrientation(config: android.content.res.Configuration) {
@@ -1310,9 +1310,13 @@ object SessionPrefs {
val value = prefs(context).getString("displayResolution.portrait.$mode", null) ?: return SessionDisplay.LINK_LANDSCAPE
if (value == SessionDisplay.LINK_LANDSCAPE || value == SessionDisplay.MATCH_SCREEN || SessionDisplay.isFollow(value) ||
SessionDisplay.presetHeight(value) != null) return value
return parseResolution(value)?.let { "${it.first}x${it.second}" } ?: SessionDisplay.LINK_LANDSCAPE
return parseOrientedResolution(value)?.let { "${it.first}x${it.second}" } ?: SessionDisplay.LINK_LANDSCAPE
}
private fun parseOrientedResolution(text: String): Pair<Int, Int>? =
parseResolution(text) ?: text.trim().split('x', 'X', '×', '*').takeIf { it.size == 2 }
?.let { parseResolution("${it[1]}x${it[0]}") }?.let { it.second to it.first }
private fun landscapeResolutionStored(context: Context, mode: String, panel: Pair<Int, Int>): String {
val saved = prefs(context)
saved.getString("displayResolution.$mode", null)?.let { value ->
@@ -1332,7 +1336,7 @@ object SessionPrefs {
val link = if (portrait) SessionDisplay.LINK_LANDSCAPE else SessionDisplay.LINK_PORTRAIT
val value = if (choice == link || choice == SessionDisplay.MATCH_SCREEN || SessionDisplay.isFollow(choice) ||
SessionDisplay.presetHeight(choice) != null) choice else {
val size = requireNotNull(parseResolution(choice)) { "Invalid resolution" }
val size = requireNotNull(if (portrait) parseOrientedResolution(choice) else parseResolution(choice)) { "Invalid resolution" }
"${size.first}x${size.second}"
}
val panel = SessionDisplay.panelSize(context)
@@ -1982,7 +1986,7 @@ object SessionPrefs {
fun displayMode(context: Context, mode: String, program: String?): String =
if (mode == SessionService.MODE_RUN && com.droiddeck.launcher.runtime.UserApps.launches(program) &&
resolutionChosen(context, SessionService.MODE_DESKTOP)) SessionService.MODE_DESKTOP
(resolutionChosen(context, SessionService.MODE_DESKTOP) || resolutionChosen(context, SessionService.MODE_DESKTOP, true))) SessionService.MODE_DESKTOP
else prefMode(mode)
fun pipAutoEnter(context: Context): Boolean = prefs(context).getBoolean("pipAutoEnter", true)
@@ -243,9 +243,13 @@ fun ModeSheetRows(s: ModeSettings, a: ModeSettingsActions, tab: String, extras:
val displaySize = sessionDisplay.resolveChoice(s.panelSize, activeChoice, portrait)
SettingsGroup(stringResource(R.string.display_session)) {
ResolutionRow(host, "resolution", stringResource(R.string.display_resolution_landscape), s.resolution, landscapeChoice,
com.droiddeck.launcher.session.SessionDisplay.LINK_PORTRAIT, s.panelSize, a.onResolution, portrait = false)
com.droiddeck.launcher.session.SessionDisplay.LINK_PORTRAIT,
if (sessionDisplay.isLink(s.resolutionPortrait)) landscapeChoice else sessionDisplay.orientCustom(s.resolutionPortrait, false),
s.panelSize, a.onResolution, portrait = false)
ResolutionRow(host, "resolution-portrait", stringResource(R.string.display_resolution_portrait), s.resolutionPortrait, portraitChoice,
com.droiddeck.launcher.session.SessionDisplay.LINK_LANDSCAPE, s.panelSize, a.onResolutionPortrait, portrait = true)
com.droiddeck.launcher.session.SessionDisplay.LINK_LANDSCAPE,
if (sessionDisplay.isLink(s.resolution)) portraitChoice else sessionDisplay.orientCustom(s.resolution, true),
s.panelSize, a.onResolutionPortrait, portrait = true)
s.picturePosition?.let { position ->
ChoiceRow(host, "picture-position", stringResource(R.string.display_picture_position), null,
listOf("top" to stringResource(R.string.display_position_top),
@@ -12,7 +12,7 @@ import com.droiddeck.launcher.session.SessionDisplay
@Composable
fun ResolutionRow(
host: MenuHost, id: String, title: String, stored: String, choice: String, link: String,
host: MenuHost, id: String, title: String, stored: String, choice: String, link: String, followTarget: String,
panel: Pair<Int, Int>, onPick: (String) -> Unit,
chipModifier: Modifier = Modifier,
portrait: Boolean = false,
@@ -27,8 +27,9 @@ fun ResolutionRow(
else if (size == screen) SessionDisplay.MATCH_SCREEN else choice
var editCustom by remember { mutableStateOf(false) }
var editFollow by remember { mutableStateOf(false) }
val followSize = SessionDisplay.resolveChoice(panel, followTarget, portrait)
val linkLabel = stringResource(if (link == SessionDisplay.LINK_LANDSCAPE) R.string.display_follow_landscape else R.string.display_follow_portrait,
size.first, size.second)
followSize.first, followSize.second)
val options = listOf(link to linkLabel) + choices.map { value ->
val dimensions = SessionDisplay.resolveChoice(panel, value, portrait)
value to if (value == SessionDisplay.MATCH_SCREEN) stringResource(R.string.display_match_screen, screen.first, screen.second)