diff --git a/docs/development/steam-display-scaling.md b/docs/development/steam-display-scaling.md index d31d22aa58..51371ef503 100644 --- a/docs/development/steam-display-scaling.md +++ b/docs/development/steam-display-scaling.md @@ -159,7 +159,7 @@ restored): the session starts at `size=1280x720` and the device report shows `72 ## Follow-ups -- **Two Xwayland servers and per-game Game Resolution.** Still to verify: whether the client shows +- **Two Xwayland servers and per-game Game Resolution** (done, see below). Was to verify: whether the client shows Game Resolution under game Properties in our session, the Android clipboard bridge for games on `:1`, and the drawer's live Force fullscreen toggle (it writes `GAMESCOPE_FORCE_WINDOWS_FULLSCREEN` only on `:0`'s root, and gamescope reads it per server). The client's devtools (port 8080 when @@ -177,3 +177,40 @@ Two temporary session-script hooks, not kept on this branch: `BL_STEAM_MAX_HEIGH `GAMESCOPE_STEAM_MAX_HEIGHT` on the root window, and `BL_GAME_XWAYLAND_MODE=WxH` wrote `GAMESCOPE_XWAYLAND_MODE_CONTROL = 1,W,H,0` five seconds after `GAMESCOPE_FOCUSED_APP` showed a game. `--xwayland-count 2` and `STEAM_MULTIPLE_XWAYLANDS=1` went through `Download/droiddeck-env`. + +## Two Xwayland servers by default (`feat/steam-dual-xwayland`) + +Steam sessions now start gamescope with `--xwayland-count 2` and `STEAM_MULTIPLE_XWAYLANDS=1`. +`BL_XWAYLAND_COUNT=1` in `Download/droiddeck-env` goes back to one. The session script's +root-window requests that are meant for the game (the drawer's live Force fullscreen, +`GAMESCOPE_FORCE_WINDOWS_FULLSCREEN`, and the resume watcher's `GAMESCOPE_RESTORE_FOCUS_WINDOW`) +go to both displays, `$DISPLAY` and `STEAM_GAME_DISPLAY_0`. gamescope reads both per server, so +writing only to `:0` would have reached the Steam client and not the game. + +Clipboard: gamescope copies a selection made on any of its Xwayland servers to all of them +(`gamescope_set_selection`), so the Android text `droiddeck-clipboard` puts on `:0` reaches games +on `:1` without changes here. + +Device runs (Thor, no `droiddeck-env`): + +| Run | Game | Game Resolution | Force fullscreen | Result | +|---|---|---|---|---| +| d1 | Alan Wake's American Nightmare | 1280x720 (set in Steam) | on | The client set `#1` to 1280x720 itself. 2 frame-size changes, `:1` steady at 10 dma-bufs, memory steady. No storm | +| d2 | Alan Wake's American Nightmare | 1280x720 | on → off → on, live | `stretch games to fill the screen: 0 (live)` then `1`, written to both displays. Game stable | +| d5 | 198X | default | off | The client set `#1` to native 1920x1080. Full screen, 60 fps | + +Steam saves the per-game choice as `"ResolutionOverride2" "1280x720"` under the app in +`userdata//config/localconfig.vdf`. + +Checked by hand (2026-10-06, Thor, Force fullscreen off): +- **FlatOut 2**, the game Force fullscreen was added for, does not shrink when the QAM opens over + it and closes again. With the client's overlay on another X server, the game keeps its own X + keyboard focus and never sees the deactivation that made it shrink. +- Resume after the Steam menu: the resume watcher's restore request reaches both servers + (`restore requested for focus window` logged once for the client's window and once for the + game's). + +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. diff --git a/tools/linuxfs/overlay/usr/local/bin/droiddeck-session b/tools/linuxfs/overlay/usr/local/bin/droiddeck-session index 7e3c9df385..09571069f4 100755 --- a/tools/linuxfs/overlay/usr/local/bin/droiddeck-session +++ b/tools/linuxfs/overlay/usr/local/bin/droiddeck-session @@ -172,6 +172,17 @@ if [ -z "${BL_INSIDE:-}" ]; then args+=(-r "$BL_REFRESH") fi [ "$mode" = steam ] && args+=(-e) + # Two Xwayland servers, as SteamOS runs Steam: the client on the first, games on the second + # (STEAM_GAME_DISPLAY_0). The client then sizes the games' server to each game's Game Resolution + # (GAMESCOPE_XWAYLAND_MODE_CONTROL; native unless one is set), and gamescope scales it to the + # output. With one server the client and its games share the output's size, and a game drawing at + # another size fights --force-windows-fullscreen: the resize storm piled up GPU buffers until the + # low-memory killer ended the session (docs/development/steam-display-scaling.md). + # BL_XWAYLAND_COUNT=1 in Download/droiddeck-env goes back to one. + if [ "$mode" = steam ] && [ "${BL_XWAYLAND_COUNT:-2}" -gt 1 ]; then + args+=(--xwayland-count "${BL_XWAYLAND_COUNT:-2}") + export STEAM_MULTIPLE_XWAYLANDS=1 + fi # Touch passes through to the client as touch until the client says otherwise, as SteamOS's # gamescope-session starts it (TOUCH_MODE=4). The client sets the mode itself (STEAM_TOUCH_CLICK_MODE) # only once it has a controller; until then gamescope's own default made a finger a left-click @@ -206,6 +217,21 @@ if [ -z "${BL_INSIDE:-}" ]; then fi # gamescope manages X windows: toolkits go through Xwayland, not gamescope's own Wayland socket. +# Root-window requests for the game (fullscreen, restore) go to every display gamescope gave us: +# the client's ($DISPLAY) and, with two servers, the games' (STEAM_GAME_DISPLAY_0); gamescope reads +# them per server. +bl_displays() { + printf '%s\n' "$DISPLAY" + [ -n "${STEAM_GAME_DISPLAY_0:-}" ] && [ "$STEAM_GAME_DISPLAY_0" != "$DISPLAY" ] && printf '%s\n' "$STEAM_GAME_DISPLAY_0" + return 0 +} +bl_xprop_set_all() { + local d ok=1 + for d in $(bl_displays); do + DISPLAY=$d xprop -root -f "$1" 32c -set "$1" "$2" 2>/dev/null || ok=0 + done + [ "$ok" = 1 ] +} export GDK_BACKEND=x11 QT_QPA_PLATFORM=xcb SDL_VIDEODRIVER=x11 # gamescope's reaper waits for every process left under it before the compositor comes down. A # process a game left behind - a Wine service blocked on a server that is already gone - is @@ -453,7 +479,7 @@ case $mode in { read -r want || [ -n "$want" ]; } < "$HOME/.droiddeck-fill" 2>/dev/null || continue case $want in 0|1) ;; *) continue ;; esac [ "$want" = "$last" ] && continue - if xprop -root -f GAMESCOPE_FORCE_WINDOWS_FULLSCREEN 32c -set GAMESCOPE_FORCE_WINDOWS_FULLSCREEN "$want" 2>/dev/null; then + if bl_xprop_set_all GAMESCOPE_FORCE_WINDOWS_FULLSCREEN "$want"; then echo "== stretch games to fill the screen: $want (live)" last=$want fi @@ -486,7 +512,7 @@ case $mode in case $app in ''|*[!0-9]*) prev=; continue ;; esac if [ "$prev" = 769 ] && [ "$app" != 769 ]; then nap 1 - xprop -root -f GAMESCOPE_RESTORE_FOCUS_WINDOW 32c -set GAMESCOPE_RESTORE_FOCUS_WINDOW 1 2>/dev/null \ + bl_xprop_set_all GAMESCOPE_RESTORE_FOCUS_WINDOW 1 \ && echo "== resume: asked gamescope to restore the game window (app $app)" fi prev=$app