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 -------------------------------------------------------------- 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 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 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..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,256 @@ namespace gamescope::Process +@@ -142,6 +146,286 @@ return false; } @@ -304,6 +304,34 @@ index 7333229..d21171d 100644 + return {}; + } + ++ // 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 ) ++ { ++ 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 ) + { + if ( !*pszValue || IsUnderWindowsDirectory( pszValue ) ) @@ -313,6 +341,8 @@ index 7333229..d21171d 100644 + size_t nLength = strlen( pszBase ); + if ( nLength <= 4 || strcasecmp( pszBase + nLength - 4, ".exe" ) != 0 ) + return false; ++ if ( IsSessionInfrastructure( 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. @@ -495,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 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;