Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion android/package-gamescope.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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 ----------------------------------------------------------
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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 --------------------------------------------------------------
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ index 7333229..d21171d 100644
#include <sys/wait.h>
#if defined(__linux__)
#if HAVE_LIBCAP
@@ -142,6 +146,256 @@ namespace gamescope::Process
@@ -142,6 +146,286 @@
return false;
}

Expand Down Expand Up @@ -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 ) )
Expand All @@ -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.
Expand Down Expand Up @@ -495,8 +525,6 @@ index 7333229..d21171d 100644
void KillProcessTree( std::vector<pid_t> 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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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;

Expand Down
Loading