diff --git a/tools/bionic-runtime/gstag.c b/tools/bionic-runtime/gstag.c index 37176b2265..58725e1ad3 100644 --- a/tools/bionic-runtime/gstag.c +++ b/tools/bionic-runtime/gstag.c @@ -1,9 +1,10 @@ -// gstag: tags top-level X windows whose WM_CLASS contains with +// gstag: tags top-level X windows whose WM_CLASS contains (any case) with // STEAM_GAME=, 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 [stop when this pid exits] // If gamescope still focuses another app 8 s after the tag, it sets GAMESCOPECTRL_BASELAYER_APPID once to // ,769 (what Steam writes when it shows a game); Steam can change it again later (e.g. the Steam button). +#define _GNU_SOURCE #include #include #include @@ -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); diff --git a/tools/bionic-runtime/tool/desktop.reg b/tools/bionic-runtime/tool/desktop.reg index c62b8a65d2..328058b344 100644 --- a/tools/bionic-runtime/tool/desktop.reg +++ b/tools/bionic-runtime/tool/desktop.reg @@ -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" diff --git a/tools/bionic-runtime/tool/launch.sh b/tools/bionic-runtime/tool/launch.sh index 27f14b52e1..0cd36ad88a 100644 --- a/tools/bionic-runtime/tool/launch.sh +++ b/tools/bionic-runtime/tool/launch.sh @@ -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"