Repository navigation
Conversation
Owner
|
Thank you for this! This is getting merged! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Resolves #276
Root Cause Analysis
In Steam Big Picture mode on macOS, clicking Resume Game deactivates the Big Picture UI and attempts to reactivate the game by calling
ActivateApplication(pid)/ActivateProcess(pid)(insteamui.dylibandsteamclient.dylib):[NSRunningApplication runningApplicationWithProcessIdentifier:tracked_pid] activateWithOptions:NSApplicationActivateIgnoringOtherAppsNSRunningApplication, so window activation succeeds./bin/sh -c '...compat_run.sh waitforexitandrun ...'. Because/bin/shis a non-GUI CLI process (not an application bundle),runningApplicationWithProcessIdentifier:sh_pidreturnsnil.[nil activateWithOptions:2], which silently returnsNO. Steam deactivates Big Picture, but WindowServer never brings the game forward, dropping focus to whatever inactive background window was behind Big Picture ("switching to the non-active application").Solution
dylib/hooks/hook_activate.c:+[NSRunningApplication runningApplicationWithProcessIdentifier:].orig_running_appreturns a validNSRunningApplication, return it immediately (zero impact on native apps or already-recognized processes).orig_running_appreturnsnilforpid > 1:proc_listchildpids()breadth-first to find child GUI processes likewine.app/wine64-preloader.open -n -W -a "$loader_app"(wherelaunchdreparents the app to PID 1), inspect[[NSWorkspace sharedWorkspace] runningApplications]and resolve the newest, non-terminated application matchingcom.notproton.launcher.*.overlay-shim/overlay_shim.m:np_overlay_shim_set_active(0)), dispatch[[NSApplication sharedApplication] activateIgnoringOtherApps:YES]on the main thread inside Wine so the Cocoa game window regains key focus.dylib/tests/activatecheck.c:NSRunningApplication.proc_listchildpids.com.notproton.launcher.*applications with terminated filter and launch timestamp comparison.nilfor unrelated processes.Verification
All existing and new test suites pass with 0 failures:
make -s activatecheck: passed (100%)make -s overlay-shim-tests: 10 passed, 0 skipped (100%)make -s launchercheck: all passedmake -s envcheck: all passedmake -s defaults-check: all passedmake -s runcheck: all passedmake -s scriptcheck: 28 scripts lint and parse cleanmake clean && make -s all) succeeds and codesigns properly.