fix(bionic): run games on gamescope's X server, not a Wine desktop

The Wine virtual desktop reported 60 Hz modes only, so a game set to the screen's 144 Hz did not find its mode:
DiRT Showdown fell back to 1024x768 at 60 Hz on DroidDeck-Bionic, while DroidDeck-Proton kept 1280x720 at 144 Hz
in the same prefix. Games now start straight on gamescope's X server like on DroidDeck-Proton: same modes and
refresh rate, gamescope manages each game window. gstag tags every window of the prefix (WM_CLASS holds the Windows
program name, matched on ".exe" in any case) and stops with the game.
This commit is contained in:
The412Banner committed 2026-11-16 21:02:44 -05:00
1 parent a566e255af
commit 1e659a5ea0
3 files changed
+17 -8

No files matched your search

+3 -2
View File
@@ -1,9 +1,10 @@
// gstag: tags top-level X windows whose WM_CLASS contains <match> with
// gstag: tags top-level X windows whose WM_CLASS contains <match> (any case) with
// STEAM_GAME=<appid>, so gamescope treats a game started outside Steam's process tree
// as the game (stand-in until a bionic winex11 sets STEAM_GAME itself).
// Usage: gstag <display> <appid> <match> <seconds> [stop when this pid exits]
// If gamescope still focuses another app 8 s after the tag, it sets GAMESCOPECTRL_BASELAYER_APPID once to
// <appid>,769 (what Steam writes when it shows a game); Steam can change it again later (e.g. the Steam button).
#define _GNU_SOURCE
#include <errno.h>
#include <signal.h>
#include <stddef.h>
@@ -212,7 +213,7 @@ int main(int argc, char **argv) {
for (int i = 0; i < npending; ) {
char cls[512];
uint32_t w = pending[i];
if (wm_class(w, cls, sizeof cls) && strstr(cls, match)) {
if (wm_class(w, cls, sizeof cls) && strcasestr(cls, match)) {
set_card(w, a_game, appid);
if (ntagged < 256) tagged[ntagged++] = w;
if (!tagged_at) tagged_at = time(NULL);
+2 -2
View File
@@ -1,7 +1,7 @@
Windows Registry Editor Version 5.00
; Wine's desktop as a black screen behind games: background colour, and no shell/taskbar or tray on the
; "Default" virtual desktop launch.sh starts.
; Black instead of Wine's default colour, and no shell/taskbar or tray, if a game is run on a Wine desktop
; (launch.sh itself runs games straight on gamescope).
[HKEY_CURRENT_USER\Control Panel\Colors]
"Background"="0 0 0"
+12 -4
View File
@@ -146,17 +146,25 @@ fi
name=${EXE##*/}
comm=$(echo "$name" | cut -c1-15)
game_pids() { grep -lx "$comm" /proc/[0-9]*/comm 2>/dev/null | cut -d/ -f3; }
wine_ explorer /desktop=Default,${BL_WIDTH:-1280}x${BL_HEIGHT:-720} "$name" "$@" &
# The game's windows go straight to gamescope's X server, as with DroidDeck-Proton (no Wine desktop): the game
# sees gamescope's real modes and refresh rate, and gamescope manages its windows.
wine_ "$EXE" "$@" &
WP=$!
# Steam's overlay library marks a game's windows with the app ID Steam tracks (STEAM_GAME); that library is
# glibc-only, so tag Wine's desktop window from outside, or gamescope never shows it.
[ "${SteamAppId:-0}" != 0 ] && "$LINKER" "$PACK/bin/gstag" 0 "$SteamAppId" explorer.exe 86400 $WP > "$COMPAT/gstag.log" 2>&1 &
trap 'echo "$(date +%H:%M:%S) stopped by Steam"; stop_wine; exit 0' TERM INT HUP
# glibc-only, so this prefix's windows (WM_CLASS = the Windows program name) are tagged from outside, or gamescope
# never shows them.
GT=
if [ "${SteamAppId:-0}" != 0 ]; then
"$LINKER" "$PACK/bin/gstag" 0 "$SteamAppId" .exe 86400 > "$COMPAT/gstag.log" 2>&1 &
GT=$!
fi
trap 'echo "$(date +%H:%M:%S) stopped by Steam"; [ -n "$GT" ] && kill $GT 2>/dev/null; stop_wine; exit 0' TERM INT HUP
n=0
while [ $n -lt 90 ] && [ -z "$(game_pids)" ]; do sleep 1; n=$((n + 1)); done
echo "$(date +%H:%M:%S) game process $(game_pids | tr '\n' ' ')after ${n}s"
while [ -n "$(game_pids)" ]; do sleep 2; done
echo "$(date +%H:%M:%S) game exited"
[ -n "$GT" ] && kill $GT 2>/dev/null
stop_wine
wait $WP
echo "$(date +%H:%M:%S) done"