Use the portrait resolution in the controls-below layout and size the game area to the output aspect

This commit is contained in:
FX192 committed 2026-11-21 23:50:19 +03:00
1 parent 567181d05f
commit 0399c3e510
4 files changed
+20 -21

No files matched your search

@@ -2956,17 +2956,7 @@ 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 followPortrait(): Boolean = glassesScreen == null && SessionPrefs.portrait(this)
private fun followScale(): Float {
val mode = displayMode()
@@ -3045,13 +3035,11 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde
private fun portraitOutput(): Boolean = SessionPrefs.portrait(this) && !controlsBelowWanted()
private fun outputSize(): Pair<Int, Int> {
val portrait = portraitOutput()
return com.droiddeck.launcher.session.SessionDisplay.resolveChoice(com.droiddeck.launcher.session.SessionDisplay.panelSize(this),
resolutionChoice(portrait), portrait)
}
private fun outputSize(): Pair<Int, Int> =
com.droiddeck.launcher.session.SessionDisplay.resolveChoice(com.droiddeck.launcher.session.SessionDisplay.panelSize(this),
resolutionChoice(), portraitOutput())
private fun resolutionChoice(portrait: Boolean = portraitOutput()): 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 &&
@@ -4636,7 +4624,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) {
@@ -89,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,
@@ -239,7 +239,7 @@ fun ModeSheetRows(s: ModeSettings, a: ModeSettingsActions, tab: String, extras:
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 (portrait) portraitChoice else landscapeChoice
val activeChoice = if (portraitWindow) portraitChoice else landscapeChoice
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,
@@ -55,6 +55,11 @@ class SessionDisplayTest {
@Test fun unfoldedControlsKeepTheGameSixteenByNineAcrossTheWidth() {
assertEquals(606, SessionDisplay.unfoldedGameHeight(1080, 1920))
assertEquals(606, SessionDisplay.unfoldedGameHeight(1080, 1920, 0, 16f / 9f))
assertEquals(606, SessionDisplay.unfoldedGameHeight(1080, 1920, 0, 2.2f))
assertEquals(1080, SessionDisplay.unfoldedGameHeight(1440, 3039, 192, 4f / 3f))
assertEquals(1080, SessionDisplay.unfoldedGameHeight(1440, 3039, 0, 4f / 3f))
assertEquals(2238, SessionDisplay.unfoldedGameHeight(1440, 3039, 0, 0.5f))
assertEquals(1376, SessionDisplay.unfoldedGameHeight(2448, 1848))
assertEquals(1038, SessionDisplay.unfoldedGameHeight(1848, 2448))
assertEquals(864, SessionDisplay.unfoldedGameHeight(1920, 1080))