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

@@ -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)
) &