From 10fe5c5f777e52c418f2b5e18fa4540f6eb25431 Mon Sep 17 00:00:00 2001 From: Kurt Himebauch <136133082+xXJSONDeruloXx@users.noreply.github.com> Date: Sun, 25 Oct 2026 12:37:47 -0400 Subject: [PATCH] feat: stretch 16:9 games to screens wider than 16:9 too (#1558) * feat: stretch 16:9 games to screens wider than 16:9 too * fix: don't offer 16:9 game fit while the session follows the screen --- .../droiddeck/launcher/session/SessionDisplay.kt | 2 +- .../droiddeck/launcher/ui/ModeSettingsDialog.kt | 3 ++- app/src/main/res/values/strings.xml | 2 +- .../launcher/session/SessionDisplayTest.kt | 5 ++++- .../overlay/usr/local/bin/droiddeck-session | 15 ++++++++++++--- 5 files changed, 20 insertions(+), 7 deletions(-) diff --git a/app/src/main/java/com/droiddeck/launcher/session/SessionDisplay.kt b/app/src/main/java/com/droiddeck/launcher/session/SessionDisplay.kt index c0bba60936..39ed2c43e9 100644 --- a/app/src/main/java/com/droiddeck/launcher/session/SessionDisplay.kt +++ b/app/src/main/java/com/droiddeck/launcher/session/SessionDisplay.kt @@ -79,5 +79,5 @@ object SessionDisplay { } fun canStretch16x9(size: Pair): Boolean = - (size.second * 16 + 4) / 9 / 2 * 2 > size.first + (size.second * 16 + 4) / 9 / 2 * 2 > size.first || (size.first * 9 + 8) / 16 / 2 * 2 > size.second } diff --git a/app/src/main/java/com/droiddeck/launcher/ui/ModeSettingsDialog.kt b/app/src/main/java/com/droiddeck/launcher/ui/ModeSettingsDialog.kt index c546a34c35..8e83598386 100644 --- a/app/src/main/java/com/droiddeck/launcher/ui/ModeSettingsDialog.kt +++ b/app/src/main/java/com/droiddeck/launcher/ui/ModeSettingsDialog.kt @@ -221,7 +221,8 @@ 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.canStretch16x9(displaySize) + val canStretch = s.resolution != com.droiddeck.launcher.session.SessionDisplay.FOLLOW_SCREEN && + 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), listOf(false to stringResource(R.string.display_preserve), true to stringResource(R.string.display_stretch)), diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 1044953c7b..01e94757df 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -2003,7 +2003,7 @@ Resolution 16:9 game fit How 16:9 games fit this display. Next session. - Choose Match screen or a custom size narrower than 16:9. + Choose Match screen or a custom size that isn\'t 16:9. Keep proportions Stretch to display Image scaling diff --git a/app/src/test/java/com/droiddeck/launcher/session/SessionDisplayTest.kt b/app/src/test/java/com/droiddeck/launcher/session/SessionDisplayTest.kt index 48d77d0b0d..7962ef6fc8 100644 --- a/app/src/test/java/com/droiddeck/launcher/session/SessionDisplayTest.kt +++ b/app/src/test/java/com/droiddeck/launcher/session/SessionDisplayTest.kt @@ -96,7 +96,10 @@ class SessionDisplayTest { @Test fun gameStretchAvailabilityMatchesTheRuntimeIncludingRounding() { assertTrue(SessionDisplay.canStretch16x9(960 to 720)) assertFalse(SessionDisplay.canStretch16x9(1280 to 720)) - assertFalse(SessionDisplay.canStretch16x9(1600 to 720)) + assertTrue(SessionDisplay.canStretch16x9(1600 to 720)) + assertTrue(SessionDisplay.canStretch16x9(2400 to 1080)) + assertFalse(SessionDisplay.canStretch16x9(1920 to 1080)) + assertFalse(SessionDisplay.canStretch16x9(1366 to 768)) val wide = SessionDisplay.resolve(1440 to 1080, 0, SessionPrefs.SHAPE_WIDE) assertFalse(SessionDisplay.canStretch16x9(wide)) } diff --git a/tools/linuxfs/overlay/usr/local/bin/droiddeck-session b/tools/linuxfs/overlay/usr/local/bin/droiddeck-session index 8628db6725..2688d9a8a6 100755 --- a/tools/linuxfs/overlay/usr/local/bin/droiddeck-session +++ b/tools/linuxfs/overlay/usr/local/bin/droiddeck-session @@ -211,13 +211,19 @@ if [ -z "${BL_INSIDE:-}" ]; then width=${BL_WIDTH:-1280} height=${BL_HEIGHT:-720} nested=$width + nested_h=$height if [ "${BL_FOLLOW_OUTPUT:-0}" = 1 ]; then echo "== gamescope: the output follows the screen (${width}x${height} to start)" elif [ "$mode" = steam ] && [ "${BL_GAMESCOPE_STRETCH_16X9:-0}" = 1 ]; then wide=$(( (height * 16 + 4) / 9 / 2 * 2 )) + tall=$(( (width * 9 + 8) / 16 / 2 * 2 )) if [ "$wide" -gt "$width" ]; then nested=$wide - echo "== gamescope: games at ${nested}x${height} stretched to the ${width}x${height} output" + elif [ "$tall" -gt "$height" ]; then + nested_h=$tall + fi + if [ "$nested" != "$width" ] || [ "$nested_h" != "$height" ]; then + echo "== gamescope: games at ${nested}x${nested_h} stretched to the ${width}x${height} output" fi fi # Off unless Performance asks for it. Compositing the cursor here adds a second @@ -225,8 +231,11 @@ if [ -z "${BL_INSIDE:-}" ]; then if [ "$mode" = steam ] && [ "${BL_CURSOR_COMPOSITE:-0}" = 1 ]; then export gamescope_cursor_composite=2 fi - args=(--backend wayland --expose-wayland -f -W "$width" -H "$height" -w "$nested" -h "$height") - [ "$nested" != "$width" ] && args+=(-S stretch) && export BL_STRETCHED=1 + args=(--backend wayland --expose-wayland -f -W "$width" -H "$height" -w "$nested" -h "$nested_h") + if [ "$nested" != "$width" ] || [ "$nested_h" != "$height" ]; then + args+=(-S stretch) + export BL_STRETCHED=1 + fi if [ "${BL_FPS:-0}" -gt 0 ]; then args+=(-r "$BL_FPS") elif [ "${BL_REFRESH:-0}" -gt 0 ]; then