From 0c7d19ba33b8f42837c1fb60dc5a6dee47f9de8e Mon Sep 17 00:00:00 2001 From: Joshua Tam <297250+joshuatam@users.noreply.github.com> Date: Sat, 14 Nov 2026 23:00:10 +0800 Subject: [PATCH 1/6] disable A26, A33 and A48 patches --- .../patches/{gamescope => disabled}/0026-A26-uniform-app-id.patch | 0 .../0033-A33-blank-while-game-window-absent.patch | 0 .../0047-A48-bring-nested-app-window-to-front.patch | 0 3 files changed, 0 insertions(+), 0 deletions(-) rename android/patches/{gamescope => disabled}/0026-A26-uniform-app-id.patch (100%) rename android/patches/{gamescope => disabled}/0033-A33-blank-while-game-window-absent.patch (100%) rename android/patches/{gamescope => disabled}/0047-A48-bring-nested-app-window-to-front.patch (100%) diff --git a/android/patches/gamescope/0026-A26-uniform-app-id.patch b/android/patches/disabled/0026-A26-uniform-app-id.patch similarity index 100% rename from android/patches/gamescope/0026-A26-uniform-app-id.patch rename to android/patches/disabled/0026-A26-uniform-app-id.patch diff --git a/android/patches/gamescope/0033-A33-blank-while-game-window-absent.patch b/android/patches/disabled/0033-A33-blank-while-game-window-absent.patch similarity index 100% rename from android/patches/gamescope/0033-A33-blank-while-game-window-absent.patch rename to android/patches/disabled/0033-A33-blank-while-game-window-absent.patch diff --git a/android/patches/gamescope/0047-A48-bring-nested-app-window-to-front.patch b/android/patches/disabled/0047-A48-bring-nested-app-window-to-front.patch similarity index 100% rename from android/patches/gamescope/0047-A48-bring-nested-app-window-to-front.patch rename to android/patches/disabled/0047-A48-bring-nested-app-window-to-front.patch From d66ea2c56ddd8fa0a55b37a70e61c9e798dc907e Mon Sep 17 00:00:00 2001 From: Joshua Tam <297250+joshuatam@users.noreply.github.com> Date: Sat, 7 Nov 2026 16:25:27 +0800 Subject: [PATCH 2/6] update A49 patch --- .../gamescope/0048-A49-nudge-reaper-on-guest-window.patch | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/android/patches/gamescope/0048-A49-nudge-reaper-on-guest-window.patch b/android/patches/gamescope/0048-A49-nudge-reaper-on-guest-window.patch index f9e3ba424..cb290838c 100644 --- a/android/patches/gamescope/0048-A49-nudge-reaper-on-guest-window.patch +++ b/android/patches/gamescope/0048-A49-nudge-reaper-on-guest-window.patch @@ -21,8 +21,7 @@ diff --git a/src/steamcompmgr.cpp b/src/steamcompmgr.cpp index adafff0..773e95c 100644 --- a/src/steamcompmgr.cpp +++ b/src/steamcompmgr.cpp -@@ -5960,6 +5960,14 @@ static void gn_activate_nested_app_window( xwayland_ctx_t *ctx, Window window ) - if ( hint.res_class ) XFree( hint.res_class ); +@@ -5945,6 +5945,14 @@ map_win(xwayland_ctx_t* ctx, Window id, unsigned long sequence) } +// A window whose owner is a guest, or whose owner is unknown, is one the @@ -36,6 +35,7 @@ index adafff0..773e95c 100644 static void map_win(xwayland_ctx_t* ctx, Window id, unsigned long sequence) { + steamcompmgr_win_t *w = find_win(ctx, id); @@ -5969,6 +5977,8 @@ map_win(xwayland_ctx_t* ctx, Window id, unsigned long sequence) return; From 14b0405c2bbabf035d2578db0eb63097c5187ca3 Mon Sep 17 00:00:00 2001 From: Joshua Tam <297250+joshuatam@users.noreply.github.com> Date: Sun, 15 Nov 2026 12:52:54 +0800 Subject: [PATCH 3/6] disable A55 patch --- .../0051-A55-cursor-plane-on-gamenative-drm.patch | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename android/patches/{gamescope => disabled}/0051-A55-cursor-plane-on-gamenative-drm.patch (100%) diff --git a/android/patches/gamescope/0051-A55-cursor-plane-on-gamenative-drm.patch b/android/patches/disabled/0051-A55-cursor-plane-on-gamenative-drm.patch similarity index 100% rename from android/patches/gamescope/0051-A55-cursor-plane-on-gamenative-drm.patch rename to android/patches/disabled/0051-A55-cursor-plane-on-gamenative-drm.patch From abe216f5d28a9861cf0b9853901439df2440d3a8 Mon Sep 17 00:00:00 2001 From: Joshua Tam <297250+joshuatam@users.noreply.github.com> Date: Sun, 15 Nov 2026 20:27:24 +0800 Subject: [PATCH 4/6] android: ship the Win32 activation helper in the gamescope payload gn-activate.exe is the helper that makes the guest's window foreground from inside the wine prefix. WM_ACTIVATE/WM_SETFOCUS can only be raised there, and under `explorer /desktop=shell` every window is an override-redirect child of the desktop that wine never activates, so a title comes up inactive and ignores input until it is clicked. It ships here rather than in the app's assets because it only exists for gamescope sessions, and because the payload VERSION then invalidates the app's staged copy for free: the helper travels with the payload, so a new payload is exactly when a new helper should be copied into the container prefix. Built in the same always-rebuild block as the other artifacts -- the payload has to carry what this run produced, not what happens to be on disk. It is deliberately not passed to resolve_libs: it is a mingw PE, so it has no bionic NEEDEDs to resolve, unlike the guest clients next to it. One new prerequisite follows from this: packaging now needs mingw-w64 on the host, as it already needs the NDK. tools/build-gn-activate.sh reports which bitnesses it could build and the packaging step fails loudly if the 32-bit one is missing, since that is the one a WoW64 prefix runs. --- android/package-gamescope.sh | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/android/package-gamescope.sh b/android/package-gamescope.sh index 32c34821a..4b968a73f 100755 --- a/android/package-gamescope.sh +++ b/android/package-gamescope.sh @@ -77,6 +77,7 @@ DMTEST_BIN="$GNDRM_REL/gn-dmabuf-test" WSITEST_BIN="$GNDRM_REL/gn-wsi-test" XTREE_BIN="$GNDRM_REL/gn-xtree-probe" SCALE_BIN="$GNDRM_REL/gn-scaling-mode" +ACTIVATE_EXE="$GNDRM_DIR/target/win32/gn-activate.exe" LSFG_SO="$GNDRM_REL/liblsfg_engine.so" # --- prerequisites ---------------------------------------------------------- @@ -107,8 +108,13 @@ bash "$GNDRM_DIR/tools/build-shim.sh" android \ || { echo "error: build-shim.sh failed" >&2; exit 1; } bash "$GNDRM_DIR/tools/build-android.sh" \ || { echo "error: build-android.sh failed" >&2; exit 1; } +# The Win32 helper is a separate toolchain (mingw, not the NDK), so it is its own +# step rather than part of build-android.sh. It has to be rebuilt here for the +# same reason as everything else: the payload ships the file this run produced. +bash "$GNDRM_DIR/tools/build-gn-activate.sh" \ + || { echo "error: build-gn-activate.sh failed" >&2; exit 1; } -for f in "$GAMESCOPE_BIN" "$REAPER_BIN" "$SHIM_SO" "$DRM_SO" "$ICD_SO" "$LSFG_SO" "$DMTEST_BIN" "$WSITEST_BIN" "$XTREE_BIN" "$SCALE_BIN"; do +for f in "$GAMESCOPE_BIN" "$REAPER_BIN" "$SHIM_SO" "$DRM_SO" "$ICD_SO" "$LSFG_SO" "$DMTEST_BIN" "$WSITEST_BIN" "$XTREE_BIN" "$SCALE_BIN" "$ACTIVATE_EXE"; do [ -e "$f" ] || { echo "error: missing $f" >&2; exit 1; } done # An artifact older than FRESH_MARK was not written by the run above: either the @@ -344,6 +350,13 @@ cp "$XTREE_BIN" "$STAGE/bin/gn-xtree-probe" # mode change applies without a relaunch. Spawned by the app per committed # selection; links the payload's libxcb. cp "$SCALE_BIN" "$STAGE/bin/gn-scaling-mode" +# bin/gn-activate.exe: a Win32 helper, staged into the container prefix by the +# app and run inside it, which is the only place WM_ACTIVATE can be raised from. +# It is not a Linux binary like the clients above, so it is NOT passed to +# resolve_libs -- mingw's PE has no bionic NEEDEDs. It ships here rather than in +# the app's assets because it only exists for gamescope sessions, and because the +# payload VERSION then invalidates the app's staged copy for free. +cp "$ACTIVATE_EXE" "$STAGE/bin/gn-activate.exe" resolve_libs "$STAGE/bin/gn-dmabuf-test" "$STAGE/bin/gn-wsi-test" "$STAGE/bin/gn-xtree-probe" "$STAGE/bin/gn-scaling-mode" # --- data files -------------------------------------------------------------- From 4fc6701023b82ffe9a8acded235fc84a32c4f5d1 Mon Sep 17 00:00:00 2001 From: Joshua Tam <297250+joshuatam@users.noreply.github.com> Date: Sun, 15 Nov 2026 23:44:08 +0800 Subject: [PATCH 5/6] =?UTF-8?q?android:=20A28=20=E2=80=94=20do=20not=20cou?= =?UTF-8?q?nt=20our=20activation=20helper=20as=20a=20guest?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit gn-activate.exe is guest-shaped by every test the guest rule applies: a wine process whose command line names a .exe outside drive_c/windows. It is session infrastructure, not a guest of the session, and it outlives the title on purpose -- it sets the foreground window, then watches for later windows before idling out. Counting it would hold the session open after the game exits, which is the same mistake the rule already avoids for the shell: A49 nudges the reaper on guest window map/unmap so a session ends promptly, and A28 ends it once no guest image is left. A helper that is still running in that window keeps "no guest image left" from ever becoming true. Excluded by basename in IsGuestImage, next to the drive_c/windows test, so both the per-process rule and the session-wide one share it. --- .../0028-A28-end-session-with-game-process.patch | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/android/patches/gamescope/0028-A28-end-session-with-game-process.patch b/android/patches/gamescope/0028-A28-end-session-with-game-process.patch index 5a4636e42..5225a8e2a 100644 --- a/android/patches/gamescope/0028-A28-end-session-with-game-process.patch +++ b/android/patches/gamescope/0028-A28-end-session-with-game-process.patch @@ -238,7 +238,7 @@ index 7333229..d21171d 100644 #include #if defined(__linux__) #if HAVE_LIBCAP -@@ -142,6 +146,256 @@ namespace gamescope::Process +@@ -142,6 +146,268 @@ namespace gamescope::Process return false; } @@ -304,6 +304,16 @@ index 7333229..d21171d 100644 + return {}; + } + ++ // Our own helper, which is a guest-shaped process by every test here: a wine ++ // process naming a .exe outside drive_c/windows. It is session infrastructure, ++ // not a guest of the session, and it outlives the title on purpose (it ++ // watches for later windows before idling out), so counting it would hold the ++ // session open after the game exits -- the same mistake as counting the shell. ++ static bool IsSessionHelper( const char *pszBase ) ++ { ++ return strcasecmp( pszBase, "gn-activate.exe" ) == 0; ++ } ++ + static bool IsGuestImage( pid_t nPid, const char *pszValue ) + { + if ( !*pszValue || IsUnderWindowsDirectory( pszValue ) ) @@ -313,6 +323,8 @@ index 7333229..d21171d 100644 + size_t nLength = strlen( pszBase ); + if ( nLength <= 4 || strcasecmp( pszBase + nLength - 4, ".exe" ) != 0 ) + return false; ++ if ( IsSessionHelper( pszBase ) ) ++ return false; + + // Started by path: the path says where the image lives. Started by + // name alone: the process's own directory says, or it was wine's. From 1cf09581999630f08964cc6d174b09fda00b6690 Mon Sep 17 00:00:00 2001 From: Joshua Tam <297250+joshuatam@users.noreply.github.com> Date: Mon, 16 Nov 2026 00:15:30 +0800 Subject: [PATCH 6/6] =?UTF-8?q?android:=20A28=20=E2=80=94=20session=20infr?= =?UTF-8?q?astructure=20is=20not=20a=20guest?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The guest rule counts any wine process naming a .exe outside drive_c/windows, and that includes the session's own shell: the launch line is `winhandler.exe "steam.exe"`, so Steam and its helpers are guests by the rule and outlive the title. "No guest image left" then only becomes true when Steam quits, which is not when the game does. So the images that are the session rather than content in it are excluded by basename: gn-activate.exe (ours, and it outlives the title by design while it watches for later windows), winhandler.exe, steam.exe, steamwebhelper.exe, steamhost32.exe, eastub.exe. The list is a judgement, not a derivation: a launcher that is also the game's UI, and a title whose image is named like a shell, are the cases it gets wrong. It also means the session now ends when the game exits with Steam still running -- which is the behaviour the launcher flow was asking for, and the reason the exclusion exists. --- ...28-A28-end-session-with-game-process.patch | 38 +++++++++++++------ 1 file changed, 27 insertions(+), 11 deletions(-) diff --git a/android/patches/gamescope/0028-A28-end-session-with-game-process.patch b/android/patches/gamescope/0028-A28-end-session-with-game-process.patch index 5225a8e2a..39e3d2e1b 100644 --- a/android/patches/gamescope/0028-A28-end-session-with-game-process.patch +++ b/android/patches/gamescope/0028-A28-end-session-with-game-process.patch @@ -238,7 +238,7 @@ index 7333229..d21171d 100644 #include #if defined(__linux__) #if HAVE_LIBCAP -@@ -142,6 +146,268 @@ namespace gamescope::Process +@@ -142,6 +146,286 @@ return false; } @@ -304,14 +304,32 @@ index 7333229..d21171d 100644 + return {}; + } + -+ // Our own helper, which is a guest-shaped process by every test here: a wine -+ // process naming a .exe outside drive_c/windows. It is session infrastructure, -+ // not a guest of the session, and it outlives the title on purpose (it -+ // watches for later windows before idling out), so counting it would hold the -+ // session open after the game exits -- the same mistake as counting the shell. -+ static bool IsSessionHelper( const char *pszBase ) ++ // Processes that are part of the session rather than content in it. They pass ++ // every other test here -- a wine process naming a .exe outside ++ // drive_c/windows -- and counting them would hold the session open after the ++ // game exits, which is exactly what a launcher flow produces: the launch line ++ // is `winhandler.exe "steam.exe"`, so Steam and its helpers outlive the title ++ // and "no guest image left" only becomes true when Steam quits. ++ // ++ // gn-activate.exe is ours: it sets the foreground window, then watches for ++ // later windows before idling out, so it outlives the title by design. ++ static bool IsSessionInfrastructure( const char *pszBase ) + { -+ return strcasecmp( pszBase, "gn-activate.exe" ) == 0; ++ static const char *const ppszShells[] = ++ { ++ "gn-activate.exe", ++ "winhandler.exe", ++ "steam.exe", ++ "steamwebhelper.exe", ++ "steamhost32.exe", ++ "eastub.exe", ++ }; ++ for ( size_t i = 0; i < sizeof( ppszShells ) / sizeof( ppszShells[ 0 ] ); i++ ) ++ { ++ if ( strcasecmp( pszBase, ppszShells[ i ] ) == 0 ) ++ return true; ++ } ++ return false; + } + + static bool IsGuestImage( pid_t nPid, const char *pszValue ) @@ -323,7 +341,7 @@ index 7333229..d21171d 100644 + size_t nLength = strlen( pszBase ); + if ( nLength <= 4 || strcasecmp( pszBase + nLength - 4, ".exe" ) != 0 ) + return false; -+ if ( IsSessionHelper( pszBase ) ) ++ if ( IsSessionInfrastructure( pszBase ) ) + return false; + + // Started by path: the path says where the image lives. Started by @@ -507,8 +525,6 @@ index 7333229..d21171d 100644 void KillProcessTree( std::vector nPids, int nSignal ) { for ( pid_t nPid : nPids ) -diff --git a/src/Utils/Process.h b/src/Utils/Process.h -index 2208dae..1828bce 100644 --- a/src/Utils/Process.h +++ b/src/Utils/Process.h @@ -16,6 +16,34 @@ namespace gamescope::Process