feat(session): split the display resolution into landscape and portrait (#2990)

## Summary

Splits the session resolution setting into two: **Landscape resolution**
and **Portrait resolution**. Each has the same options as the old
Resolution row, plus a Follow option so one orientation can mirror the
other.

## Why

A single resolution has to serve both orientations. Presets and Match
screen flip automatically in portrait, but a custom size is used exactly
as typed, so a landscape size in a portrait session is wrong. Users who
play in both orientations couldn't pick a good size for each.

## Behavior

- The Display tab shows **Landscape resolution** and, underneath it,
**Portrait resolution**. Both offer the full existing list: presets,
Match screen, Follow screen, scaled follow options and Custom.
- Each row has an extra option at the top. **Follow portrait** (on the
landscape row) and **Follow landscape** (on the portrait row) use the
other orientation's choice, so someone can set one resolution and let
the other mirror it. The label shows the size it resolves to.
- A session picks the landscape or portrait choice from its orientation.
This uses the same orientation check as the output size, so the
unfolded-controls layout still counts as landscape.
- Custom WxH sizes are flipped to match the target orientation when
followed, e.g. portrait following 1280x720 uses 720x1280.
- If both rows would follow each other, the other row is set to the
concrete size it currently resolves to, so there is never a loop and
nothing visibly changes.
- The glasses output keeps using the landscape resolution.
- Applies to the Steam and Desktop Display tabs, which share the same
row.

## Compatibility

- The existing saved choice (`displayResolution.<mode>`) is now the
landscape resolution, so existing users keep their setting.
- The portrait choice is stored as `displayResolution.portrait.<mode>`
and defaults to Follow landscape, so portrait sessions behave as before
until it is changed. The settings reset covers it through the existing
`displayResolution.` prefix.
- One visible difference: a typed landscape custom size, used as typed
in portrait before, now flips to portrait while portrait follows
landscape.

## Known limitation

"Follow screen" is still decided once when the session starts, not on
every rotation. Re-evaluating it on rotation could make the window
orientation flip repeatedly when no orientation is pinned.

## Changes

- `SessionDisplay`: `LINK_LANDSCAPE` / `LINK_PORTRAIT`, `isLink`,
`orientCustom`, `effectiveChoice`
- `SessionPrefs`: `resolutionStored` (raw value per orientation),
`resolutionChoice(..., portrait)`, `setResolutionChoice(..., portrait)`
with the loop guard, `resolutionChosen(..., portrait)`
- `SessionActivity`: `portraitOutput()` drives the output size,
follow-screen choice and follow scale; the Match-screen default for
programs that draw at the panel size checks the matching orientation
- `ResolutionRow`, `ModeSettingsDialog`, `FrontEndActivity`: two rows,
the Follow option, state and actions
- `DeviceReport`: logs landscape and portrait separately
- Strings: `display_resolution_landscape`,
`display_resolution_portrait`, `display_follow_landscape`,
`display_follow_portrait` in all 33 locales; the unused
`display_resolution` is removed
- Tests: `PortraitResolutionTest`

## Testing

- Unit tests added for the preference logic, follow resolution, loop
guard and reset.
This commit is contained in:
FX1922 authored and GitHub committed 2026-11-22 08:03:03 +03:00
commit aefa5a3c0d
42 files changed
+388 -103

No files matched your search

@@ -586,6 +586,7 @@ class FrontEndActivity : ComponentActivity(), com.droiddeck.launcher.ui.AgentPet
}
private var settingsMode by mutableStateOf<String?>(null)
private var resolution by mutableStateOf(com.droiddeck.launcher.session.SessionDisplay.DEFAULT_RESOLUTION)
private var resolutionPortrait by mutableStateOf(com.droiddeck.launcher.session.SessionDisplay.LINK_LANDSCAPE)
private var fexPreset by mutableStateOf("")
private var forceSsbs by mutableStateOf(false)
private var steamClientArch by mutableStateOf("arm64")
@@ -2593,7 +2594,7 @@ class FrontEndActivity : ComponentActivity(), com.droiddeck.launcher.ui.AgentPet
if (settingsMode != mode) return
com.droiddeck.launcher.ui.ModeSheetRows(
ModeSettings(
mode = mode, resolution = resolution,
mode = mode, resolution = resolution, resolutionPortrait = resolutionPortrait,
panelSize = com.droiddeck.launcher.session.SessionDisplay.panelSize(this),
hdr = hdrOn, hdrReason = hdrReason, hdrDisplay = hdrDisplay, zeroCopy = zeroCopyOn,
upscaler = upscaler, upscaleSharpness = upscaleSharpness,
@@ -2648,7 +2649,8 @@ class FrontEndActivity : ComponentActivity(), com.droiddeck.launcher.ui.AgentPet
onIntegration = ::configureIntegration,
onIntegrationAppInfo = ::openAppInfo,
onIntegrationLocation = ::openWifiDiscoverySettings,
onResolution = { value -> SessionPrefs.setResolutionChoice(this, mode, value); resolution = value },
onResolution = { value -> SessionPrefs.setResolutionChoice(this, mode, value); loadResolutions(mode) },
onResolutionPortrait = { value -> SessionPrefs.setResolutionChoice(this, mode, value, portrait = true); loadResolutions(mode) },
onHdr = { on -> com.droiddeck.launcher.session.SessionHdr.set(this, mode, on); hdrOn = on },
onZeroCopy = { on ->
SessionPrefs.setZeroCopy(this, mode, on); zeroCopyOn = on
@@ -2981,11 +2983,17 @@ class FrontEndActivity : ComponentActivity(), com.droiddeck.launcher.ui.AgentPet
}, "shader-precache").start()
}
private fun loadResolutions(mode: String) {
val panel = com.droiddeck.launcher.session.SessionDisplay.panelSize(this)
resolution = SessionPrefs.resolutionStored(this, mode, panel, false)
resolutionPortrait = SessionPrefs.resolutionStored(this, mode, panel, true)
}
private fun loadModeSettings(mode: String) {
pipAutoEnter = SessionPrefs.pipAutoEnter(this)
unfoldedControls = SessionPrefs.unfoldedControls(this)
unfoldedControlsWithController = SessionPrefs.unfoldedControlsWithController(this)
resolution = SessionPrefs.resolutionChoice(this, mode, com.droiddeck.launcher.session.SessionDisplay.panelSize(this))
loadResolutions(mode)
fexPreset = SessionPrefs.fexPreset(this)
forceSsbs = SessionPrefs.forceSsbs(this)
fastSync = SessionPrefs.fastSync(this)
@@ -2958,16 +2958,18 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde
WaylandCompositor.nativeResizeOutput(size.first, size.second)
}
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))
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)))
SessionPrefs.resolutionChoice(this, mode, com.droiddeck.launcher.session.SessionDisplay.panelSize(this), followPortrait()))
}
private fun applyFollowOrientation(config: android.content.res.Configuration) {
@@ -3033,17 +3035,19 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde
private fun displayMode(): String = SessionPrefs.displayMode(this,
intent.getStringExtra(SessionService.EXTRA_MODE) ?: SessionService.MODE_STEAM, intent.getStringExtra(SessionService.EXTRA_PROGRAM))
private fun portraitOutput(): Boolean = SessionPrefs.portrait(this) && !controlsBelowWanted()
private fun outputSize(): Pair<Int, Int> =
com.droiddeck.launcher.session.SessionDisplay.resolveChoice(com.droiddeck.launcher.session.SessionDisplay.panelSize(this),
resolutionChoice(), SessionPrefs.portrait(this) && !controlsBelowWanted())
resolutionChoice(), portraitOutput())
private fun resolutionChoice(): String {
private fun resolutionChoice(portrait: Boolean = SessionPrefs.portrait(this)): String {
val mode = displayMode()
val program = intent.getStringExtra(SessionService.EXTRA_PROGRAM)
return if (intent.getStringExtra(SessionService.EXTRA_MODE) == SessionService.MODE_RUN &&
Library.drawsAtPanel(program) && !SessionPrefs.resolutionChosen(this, mode))
Library.drawsAtPanel(program) && !SessionPrefs.resolutionChosen(this, mode, portrait))
com.droiddeck.launcher.session.SessionDisplay.MATCH_SCREEN
else SessionPrefs.resolutionChoice(this, mode, com.droiddeck.launcher.session.SessionDisplay.panelSize(this))
else SessionPrefs.resolutionChoice(this, mode, com.droiddeck.launcher.session.SessionDisplay.panelSize(this), portrait)
}
private fun refreshHz(): Float = refreshHz(null)
@@ -4622,7 +4626,9 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde
val tabRow = unfoldedColumn?.getChildAt(0)?.height?.let {
it - (com.droiddeck.launcher.ui.BAR_HEIGHT.value * resources.displayMetrics.density + 0.5f).toInt()
} ?: 0
val gameHeight = if (wanted) com.droiddeck.launcher.session.SessionDisplay.unfoldedGameHeight(width, height, tabRow)
val outputAspect = if (!wanted || SessionState.followScreen) 0f
else outputSize().let { it.first.toFloat() / it.second.coerceAtLeast(1) }
val gameHeight = if (wanted) com.droiddeck.launcher.session.SessionDisplay.unfoldedGameHeight(width, height, tabRow, outputAspect)
else FrameLayout.LayoutParams.MATCH_PARENT
val params = surfaceView.layoutParams as FrameLayout.LayoutParams
if (params.height != gameHeight) {
@@ -207,9 +207,11 @@ object DeviceReport {
k("refresh_rate_mode", runCatching { Settings.Secure.getString(context.contentResolver, "refresh_rate_mode") }.getOrNull() ?: "not set")
val panelSize = com.droiddeck.launcher.session.SessionDisplay.panelSize(context)
for ((label, mode) in listOf("Resolution (Steam)" to SessionService.MODE_STEAM, "Resolution (Desktop)" to SessionService.MODE_DESKTOP)) {
val choice = SessionPrefs.resolutionChoice(context, mode, panelSize)
val size = com.droiddeck.launcher.session.SessionDisplay.resolveChoice(panelSize, choice)
k(label, "$choice (${size.first}x${size.second})")
for ((suffix, portrait) in listOf("landscape" to false, "portrait" to true)) {
val choice = SessionPrefs.resolutionChoice(context, mode, panelSize, portrait)
val size = com.droiddeck.launcher.session.SessionDisplay.resolveChoice(panelSize, choice, portrait)
k("$label $suffix", "$choice (${size.first}x${size.second})")
}
}
k("Foldable", context.packageManager.hasSystemFeature("android.hardware.sensor.hinge_angle"))
@@ -12,6 +12,9 @@ object SessionDisplay {
const val FOLLOW_SCALE_MAX = 8f
private const val FOLLOW_SCALED_PREFIX = "follow/"
const val LINK_LANDSCAPE = "link/landscape"
const val LINK_PORTRAIT = "link/portrait"
const val DEFAULT_RESOLUTION = "720p"
private val PRESET_HEIGHTS = listOf(720, 900, 1080)
@@ -35,6 +38,23 @@ object SessionDisplay {
else -> null
}
fun isLink(choice: String): Boolean = choice == LINK_LANDSCAPE || choice == LINK_PORTRAIT
fun orientCustom(choice: String, portrait: Boolean): String {
val parts = choice.split('x').map { it.toIntOrNull() }
if (parts.size != 2 || parts.any { it == null || it <= 0 }) return choice
val width = parts[0]!!
val height = parts[1]!!
return if ((portrait && width > height) || (!portrait && height > width)) "${height}x$width" else choice
}
fun effectiveChoice(landscape: String, portrait: String, forPortrait: Boolean): String {
val own = if (forPortrait) portrait else landscape
if (!isLink(own)) return own
val other = if (forPortrait) landscape else portrait
return if (isLink(other)) DEFAULT_RESOLUTION else orientCustom(other, forPortrait)
}
fun screenSize(panel: Pair<Int, Int>): Pair<Int, Int> =
(maxOf(panel.first, panel.second) and 1.inv()) to (minOf(panel.first, panel.second) and 1.inv())
@@ -69,8 +89,12 @@ object SessionDisplay {
const val UNFOLDED_MIN_DP = 600
fun unfoldedGameHeight(width: Int, height: Int, tabRow: Int = 0): Int =
(minOf(width * 9 / 16, (height * UNFOLDED_MAX_GAME_SHARE).toInt()) - tabRow.coerceAtLeast(0)).coerceAtLeast(0) and 1.inv()
fun unfoldedGameHeight(width: Int, height: Int, tabRow: Int = 0, aspect: Float = 0f): Int {
val row = tabRow.coerceAtLeast(0)
val cap = (height * UNFOLDED_MAX_GAME_SHARE).toInt()
if (aspect > 0f && aspect < 16f / 9f) return minOf((width / aspect).toInt(), cap - row).coerceAtLeast(0) and 1.inv()
return (minOf(width * 9 / 16, cap) - row).coerceAtLeast(0) and 1.inv()
}
fun unfoldedControlsWanted(
enabled: Boolean,
@@ -1314,14 +1314,31 @@ object SessionPrefs {
private fun resolutionCap(context: Context, mode: String): Int = prefs(context).getInt("resolutionCap.$mode", 720)
fun resolutionChosen(context: Context, mode: String): Boolean =
fun resolutionChosen(context: Context, mode: String, portrait: Boolean = false): Boolean =
prefs(context).contains("displayResolution.$mode") ||
prefs(context).contains("resolutionCap.$mode") || customResolution(context, mode) != null
prefs(context).contains("resolutionCap.$mode") || customResolution(context, mode) != null ||
(portrait && prefs(context).contains("displayResolution.portrait.$mode"))
fun resolutionChoice(context: Context, mode: String, panel: Pair<Int, Int>): String {
fun resolutionChoice(context: Context, mode: String, panel: Pair<Int, Int>, portrait: Boolean = false): String =
SessionDisplay.effectiveChoice(
resolutionStored(context, mode, panel, false), resolutionStored(context, mode, panel, true), portrait)
fun resolutionStored(context: Context, mode: String, panel: Pair<Int, Int>, portrait: Boolean): String {
if (!portrait) return landscapeResolutionStored(context, mode, panel)
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 parseOrientedResolution(value)?.let { "${it.first}x${it.second}" } ?: SessionDisplay.LINK_LANDSCAPE
}
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 ->
if (value == SessionDisplay.MATCH_SCREEN || SessionDisplay.isFollow(value) ||
if (value == SessionDisplay.MATCH_SCREEN || value == SessionDisplay.LINK_PORTRAIT || SessionDisplay.isFollow(value) ||
SessionDisplay.presetHeight(value) != null) return value
parseResolution(value)?.let { return "${it.first}x${it.second}" }
}
@@ -1333,13 +1350,22 @@ object SessionPrefs {
else "${legacy.first}x${legacy.second}"
}
fun setResolutionChoice(context: Context, mode: String, choice: String) {
val value = if (choice == SessionDisplay.MATCH_SCREEN || SessionDisplay.isFollow(choice) ||
fun setResolutionChoice(context: Context, mode: String, choice: String, portrait: Boolean = false) {
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}"
}
prefs(context).edit().putString("displayResolution.$mode", value).apply()
val panel = SessionDisplay.panelSize(context)
val landscapeStored = resolutionStored(context, mode, panel, false)
val portraitStored = resolutionStored(context, mode, panel, true)
val edit = prefs(context).edit()
if (value == link && SessionDisplay.isLink(if (portrait) landscapeStored else portraitStored)) {
val concrete = SessionDisplay.effectiveChoice(landscapeStored, portraitStored, !portrait)
edit.putString(if (portrait) "displayResolution.$mode" else "displayResolution.portrait.$mode", concrete)
}
edit.putString(if (portrait) "displayResolution.portrait.$mode" else "displayResolution.$mode", value).apply()
}
fun fexPreset(context: Context): String = prefs(context).getString("fexPreset", DEFAULT_FEX_PRESET) ?: DEFAULT_FEX_PRESET
@@ -1978,7 +2004,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)
@@ -56,6 +56,7 @@ class DownloadRow(val key: String, val label: String, val detail: String, val pr
class ModeSettings(
val mode: String,
val resolution: String,
val resolutionPortrait: String = com.droiddeck.launcher.session.SessionDisplay.LINK_LANDSCAPE,
val panelSize: Pair<Int, Int> = 1280 to 720,
val hdr: Boolean,
val hdrReason: String?,
@@ -116,6 +117,7 @@ class ModeSettings(
class ModeSettingsActions(
val onResolution: (String) -> Unit,
val onResolutionPortrait: (String) -> Unit = {},
val onHdr: (Boolean) -> Unit,
val onZeroCopy: (Boolean) -> Unit = {},
val onGpuDrivers: () -> Unit = {},
@@ -234,9 +236,20 @@ fun ModeSheetRows(s: ModeSettings, a: ModeSettingsActions, tab: String, extras:
val controlsBelow = SessionPrefs.controlsBelowWanted(context, s.mode,
if (portraitWindow) shortSide else longSide, if (portraitWindow) longSide else shortSide)
val portrait = portraitWindow && !controlsBelow
val displaySize = com.droiddeck.launcher.session.SessionDisplay.resolveChoice(s.panelSize, s.resolution, portrait)
val sessionDisplay = com.droiddeck.launcher.session.SessionDisplay
val landscapeChoice = sessionDisplay.effectiveChoice(s.resolution, s.resolutionPortrait, false)
val portraitChoice = sessionDisplay.effectiveChoice(s.resolution, s.resolutionPortrait, true)
val activeChoice = if (portraitWindow) portraitChoice else landscapeChoice
val displaySize = sessionDisplay.resolveChoice(s.panelSize, activeChoice, portrait)
SettingsGroup(stringResource(R.string.display_session)) {
ResolutionRow(host, s.resolution, s.panelSize, a.onResolution, portrait = portrait)
ResolutionRow(host, "resolution", stringResource(R.string.display_resolution_landscape), s.resolution, landscapeChoice,
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,
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),
@@ -248,7 +261,7 @@ fun ModeSheetRows(s: ModeSettings, a: ModeSettingsActions, tab: String, extras:
}
if (s.stretch16x9 != null && (com.droiddeck.launcher.session.SessionDisplay.canStretch16x9(s.panelSize) ||
com.droiddeck.launcher.session.SessionDisplay.canStretch16x9(displaySize))) {
val canStretch = !com.droiddeck.launcher.session.SessionDisplay.isFollow(s.resolution) &&
val canStretch = !com.droiddeck.launcher.session.SessionDisplay.isFollow(activeChoice) &&
com.droiddeck.launcher.session.SessionDisplay.canStretch16x9(displaySize)
ChoiceRow(host, "game-fit", stringResource(R.string.display_game_fit),
stringResource(if (canStretch) R.string.display_game_fit_hint else R.string.display_game_fit_unavailable),
@@ -707,10 +720,10 @@ internal fun SgdbKeyDialog(hasKey: Boolean, onSave: (String) -> Unit, onDismiss:
@OptIn(androidx.compose.foundation.layout.ExperimentalLayoutApi::class)
@Composable
internal fun CustomResolutionDialog(initial: Pair<Int, Int>?, onSave: (Pair<Int, Int>) -> Unit, onDismiss: () -> Unit) {
internal fun CustomResolutionDialog(initial: Pair<Int, Int>?, onSave: (Pair<Int, Int>) -> Unit, onDismiss: () -> Unit, portrait: Boolean = false) {
var w by remember { mutableStateOf(initial?.first?.toString() ?: "") }
var h by remember { mutableStateOf(initial?.second?.toString() ?: "") }
val parsed = SessionPrefs.parseResolution("${w}x$h")
val parsed = if (portrait) SessionPrefs.parseOrientedResolution("${w}x$h") else SessionPrefs.parseResolution("${w}x$h")
com.droiddeck.launcher.ui.GlideAlertDialog(
onDismissRequest = onDismiss,
title = { Text(stringResource(R.string.mode_custom_res_title)) },
@@ -12,20 +12,25 @@ import com.droiddeck.launcher.session.SessionDisplay
@Composable
fun ResolutionRow(
host: MenuHost, choice: String, panel: Pair<Int, Int>, onPick: (String) -> Unit,
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,
) {
val custom = "custom"
val linked = stored == link
val size = SessionDisplay.resolveChoice(panel, choice, portrait)
val screen = SessionDisplay.resolveChoice(panel, SessionDisplay.MATCH_SCREEN, portrait)
val choices = SessionDisplay.resolutionOptions(panel)
val customFollow = SessionDisplay.isFollow(choice) && choice !in choices
val selected = if (SessionDisplay.isFollow(choice)) choice
val customFollow = !linked && SessionDisplay.isFollow(choice) && choice !in choices
val selected = if (linked) link else if (SessionDisplay.isFollow(choice)) choice
else if (size == screen) SessionDisplay.MATCH_SCREEN else choice
var editCustom by remember { mutableStateOf(false) }
var editFollow by remember { mutableStateOf(false) }
val options = choices.map { value ->
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,
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)
else if (value == SessionDisplay.FOLLOW_SCREEN) stringResource(R.string.display_follow_screen)
@@ -35,18 +40,18 @@ fun ResolutionRow(
else "${dimensions.first}×${dimensions.second}"
} + listOf(SessionDisplay.FOLLOW_CUSTOM to stringResource(R.string.display_follow_screen_scaled,
if (customFollow) SessionDisplay.formatScale(SessionDisplay.followScale(choice) ?: 1f) else "…"
) + if (customFollow) " (${size.first}×${size.second})" else "") + (custom to if (selected in choices) stringResource(R.string.mode_res_custom)
) + if (customFollow) " (${size.first}×${size.second})" else "") + (custom to if (selected in choices || linked) stringResource(R.string.mode_res_custom)
else stringResource(R.string.mode_res_custom_value, size.first, size.second))
ChoiceRow(host, "resolution", stringResource(R.string.display_resolution),
ChoiceRow(host, id, title,
stringResource(R.string.common_applies_next_session),
options, if (selected in choices) selected else if (customFollow) SessionDisplay.FOLLOW_CUSTOM else custom, chipModifier = chipModifier,
options, if (linked || selected in choices) selected else if (customFollow) SessionDisplay.FOLLOW_CUSTOM else custom, chipModifier = chipModifier,
onPick = { value ->
if (value == custom) editCustom = true
else if (value == SessionDisplay.FOLLOW_CUSTOM) editFollow = true
else onPick(value) })
if (editCustom) CustomResolutionDialog(size,
onSave = { value -> editCustom = false; onPick("${value.first}x${value.second}") },
onDismiss = { editCustom = false })
onDismiss = { editCustom = false }, portrait = portrait)
if (editFollow) CustomFollowScaleDialog(SessionDisplay.followScale(choice)?.takeIf { it > 1f },
onSave = { value -> editFollow = false; onPick(SessionDisplay.followScaled(value)) },
onDismiss = { editFollow = false })