fix(display): keep the 16:9 stretch size on the game screen after Steam resizes it (#2738)

This commit is contained in:
Kurt Himebauch authored and GitHub committed 2026-11-24 17:49:49 -05:00
1 parent 925e9743a8
commit bb6523cd9c
3 files changed
+78 -2

No files matched your search

@@ -215,6 +215,15 @@ Still to check by hand: pasting Android text into a game.
Force fullscreen is still unsafe without a matching Game Resolution: with the default (native),
a game drawing at another size fights it as in run 4. It stays off by default.
## Stretch 16:9 with two Xwayland servers
With "Stretch 16:9 to panel" the games' server starts at the 16:9 nested size, but the client sets it
to the output size at every launch (run 7), so games saw a near-square screen and letterboxed
themselves. While stretching, the session script rewrites a `GAMESCOPE_XWAYLAND_MODE_CONTROL` that
sizes the game server (`1`) to exactly the output into the nested size with `allow_super_res` set,
since gamescope otherwise clamps it to the output. A Game Resolution chosen in Steam is a different
size and is kept.
## Force fullscreen removed (`feat/remove-force-fullscreen`)
With games on their own Xwayland server, FlatOut 2 no longer shrinks under the QAM, which was the
@@ -540,7 +540,7 @@ if [ -z "${DD_INSIDE:-}" ]; then
args=(--backend "$backend" --expose-wayland -f -W "$width" -H "$height" -w "$nested" -h "$nested_h")
if [ "${game_size:-0}" != 1 ] && { [ "$nested" != "$width" ] || [ "$nested_h" != "$height" ]; }; then
args+=(-S stretch)
export DD_STRETCHED=1
export DD_STRETCHED=1 DD_STRETCH_OUTPUT="${width}x${height}" DD_STRETCH_GAME="${nested}x${nested_h}"
fi
if [ "${DD_REFRESH:-0}" -gt 0 ]; then
args+=(-r "$DD_REFRESH")
@@ -593,6 +593,12 @@ dd_xprop_set_all() {
done
[ "$ok" = 1 ]
}
dd_stretch_game_screen() {
local idx w h super
IFS=', ' read -r idx w h super <<<"$1"
[ "$idx" = 1 ] && [ "${w}x${h}" = "$2" ] && [ "${super:-0}" = 0 ] || return 1
xprop -root -f GAMESCOPE_XWAYLAND_MODE_CONTROL 32c -set GAMESCOPE_XWAYLAND_MODE_CONTROL "$idx, ${3%x*}, ${3#*x}, 1" 2>/dev/null
}
export GDK_BACKEND=x11 QT_QPA_PLATFORM=xcb SDL_VIDEODRIVER=x11
reap_orphans() {
local round p stat pid left
@@ -1205,7 +1211,7 @@ case $mode in
[ "${DD_STRETCHED:-0}" = 1 ] && stretch=1
[ "${DD_RESTORE_ON_RESUME:-1}" = 1 ] && restore=1
atoms=(STEAM_TOUCH_CLICK_MODE GAMESCOPE_FOCUSED_APP)
[ "$stretch" = 1 ] && atoms+=(GAMESCOPE_NEW_SCALING_SCALER)
[ "$stretch" = 1 ] && atoms+=(GAMESCOPE_NEW_SCALING_SCALER GAMESCOPE_XWAYLAND_MODE_CONTROL)
prop_value() {
case $1 in *'not found'*|*=) pv=$2; return ;; esac
pv=${1#*=}
@@ -1273,6 +1279,11 @@ case $mode in
xprop -root -f GAMESCOPE_NEW_SCALING_SCALER 32c -set GAMESCOPE_NEW_SCALING_SCALER 4 2>/dev/null \
&& echo "== stretch 16:9 to panel: the client's scaler was Auto, set to Stretch"
;;
GAMESCOPE_XWAYLAND_MODE_CONTROL*)
prop_value "$line" ""
dd_stretch_game_screen "$pv" "$DD_STRETCH_OUTPUT" "$DD_STRETCH_GAME" \
&& echo "== stretch 16:9 to panel: the client sized the game screen to the output ($DD_STRETCH_OUTPUT), set to $DD_STRETCH_GAME"
;;
esac
done < <(xprop -spy -root "${atoms[@]}" 2>/dev/null)
) &
+56
View File
@@ -0,0 +1,56 @@
import os
from pathlib import Path
import subprocess
import tempfile
import unittest
SESSION = Path(__file__).resolve().parents[1] / 'linuxfs/overlay/usr/local/bin/droiddeck-session'
OUTPUT = '2184x1968'
GAME = '3498x1968'
class StretchGameScreenTest(unittest.TestCase):
def call(self, value):
source = SESSION.read_text()
start = source.index('dd_stretch_game_screen() {')
end = source.index('\n}\n', start) + 3
with tempfile.TemporaryDirectory() as directory:
log = Path(directory) / 'xprop.log'
fake = Path(directory) / 'xprop'
fake.write_text('#!/bin/bash\nprintf "%s\\n" "$*" >> "$XPROP_LOG"\n')
fake.chmod(0o755)
env = dict(os.environ, XPROP_LOG=str(log), PATH=directory + os.pathsep + os.environ['PATH'])
script = source[start:end] + f'dd_stretch_game_screen "{value}" {OUTPUT} {GAME}\n'
result = subprocess.run(['bash', '-c', script], env=env, capture_output=True, text=True, timeout=5)
written = log.read_text().splitlines() if log.exists() else []
return result.returncode, written
def test_the_game_screen_the_client_sizes_to_the_output_is_given_the_stretched_size(self):
status, written = self.call('1, 2184, 1968, 0')
self.assertEqual(0, status)
self.assertEqual(['-root -f GAMESCOPE_XWAYLAND_MODE_CONTROL 32c -set GAMESCOPE_XWAYLAND_MODE_CONTROL 1, 3498, 1968, 1'], written)
def test_a_game_resolution_chosen_in_steam_is_kept(self):
status, written = self.call('1, 1280, 720, 0')
self.assertNotEqual(0, status)
self.assertEqual([], written)
def test_the_clients_own_screen_is_left_alone(self):
status, written = self.call('0, 2184, 1968, 0')
self.assertNotEqual(0, status)
self.assertEqual([], written)
def test_the_stretched_size_is_not_rewritten_again(self):
status, written = self.call('1, 3498, 1968, 1')
self.assertNotEqual(0, status)
self.assertEqual([], written)
def test_a_missing_property_is_ignored(self):
status, written = self.call('')
self.assertNotEqual(0, status)
self.assertEqual([], written)
if __name__ == '__main__':
unittest.main()