Skip to content

The launcher comes back to the front when a game it started quits - #110

Merged
v0lumehi merged 1 commit into
LNPANDY:mainfrom
subyoung:return-after-play
Oct 30, 2026
Merged

v0lumehi merged 1 commit into
LNPANDY:mainfrom
subyoung:return-after-play

Conversation

@subyoung

@subyoung subyoung commented Oct 28, 2026 •

Copy link
Copy Markdown
Contributor

What and why

Play opens the game's own app and the launcher stays wherever it was. After a session (often played with a controller) nothing is in front to pick the next game with, and the launcher has to be found in the Dock or with Cmd-Tab.

Now, when a game that Play started quits, the launcher comes back to the front (unhidden, activated, its window ordered front). A game opened from Finder is left alone. Settings → App has a switch, Come back when a game quits, on by default (returnAfterPlay in UserDefaults), in both languages.

  • ReturnAfterPlay.swift: the decision as a pure function (shouldReturn, paths compared in their standard spelling) and a small watcher on NSWorkspace.didTerminateApplicationNotification, armed once Play's openApplication succeeds.
  • LauncherView.swift: tells the watcher which app Play opened.
  • ContentView.swift, Localization.swift: the Settings row and its two strings.

Checked

  • Tests: cd frontend && swift test: 171 tests, 0 failures (2 skipped, as before); new ReturnAfterPlayTests (5): a game it started, the same app under another spelling of its path, other apps / no bundle / a game opened from Finder / switched off, on until switched off, both languages.
  • Visual QA: NX_LAUNCHER_CAPTURE_DIR=<dir> swift test; the new row was checked in the settings.png and settings-notify.png captures.
  • Run on a Mac: Super Mario Bros. Wonder 1.2.1 (010015100B514000), built with build_ipa_from_nsp.py --platform mac-app on an Apple M2, macOS 27. Opened as Play opens it (NSWorkspace.openApplication with its launch environment) and quit: the didTerminateApplicationNotification for it carries the same bundle path Play opened, so shouldReturn is true for it.

Scope

  • No vendored file (dm/, scripts/, docs/, ref/, AGENTS.md) is edited, or it goes through a sync patcher or upstream first (pr-scope)
  • No keys, game files or data extracted from a game in the change or the attachments

@v0lumehi

Copy link
Copy Markdown
Collaborator

Thanks, this is a good idea. Could you rebase onto current main? The branch is 156 commits behind and conflicts in ContentView.swift. One thing changed meanwhile: console mode (#169) already brings the launcher back when a game it started quits (LiveConsoleDriver.gameDidTerminate, matched by the process ID). It would be best if both paths shared one watcher and one Settings switch, so the normal launcher and console mode behave the same.

Play opens the game's app and the launcher stayed where it was: after a session there was nothing in front to pick the next game with. Console mode (LNPANDY#169) already came back on its own, with its own watcher; the desktop Play did not.

One watcher now serves both (GameReturnWatcher, ReturnAfterPlay.swift). The desktop Play and console mode register the process they opened, by its process ID, as LNPANDY#169 matched it; a game opened from Finder is left alone. When one quits, the caller's own bookkeeping runs (console mode ends its Starting state and keeps the selected game), and the launcher comes forward (unhidden, activated, its window in front) when Settings > App leaves "Come back when a game quits" on, the default. Console mode's own terminate observer and activation are gone, so the two ways of starting a game behave the same and the one switch covers both. The setting has its Swedish entry.

Checked: swift build; swift test, 364 tests, 0 failures (ReturnAfterPlayTests: a started game comes back once, another process changes nothing, switched off the bookkeeping still runs; ConsoleLiveTests unchanged, including testStartingEndsWhenTheGameQuits).
@subyoung

Copy link
Copy Markdown
Contributor Author

Rebased onto main. Both paths now share one watcher (GameReturnWatcher, matched by process ID as #169 does) and the one Settings switch: console mode registers the game it starts there, and its own terminate observer is gone. The setting has its Swedish entry.

@v0lumehi

Copy link
Copy Markdown
Collaborator

Thanks for the rebase, @subyoung, this reads well. One watcher keyed by process ID for both Play and console mode, the console's own terminate observer gone, and console mode keeping its own bookkeeping in onQuit is exactly the shape we hoped for. The tests cover the decision and both paths.

Two notes, no changes needed for them:

It is a feature, so it merges after the 48 hours from its first posting if nobody objects. CI on forks needs a maintainer to approve the workflow run first.

@v0lumehi v0lumehi added launcher The NX2Apple launcher app mac Mac enhancement New feature or request labels Oct 30, 2026
@v0lumehi
v0lumehi merged commit d990988 into LNPANDY:main Oct 30, 2026
9 checks passed
@v0lumehi

Copy link
Copy Markdown
Collaborator

Merged, thanks @subyoung! One watcher for Play and console mode with a single switch is a nice cleanup. It ships with the next release.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request launcher The NX2Apple launcher app mac Mac

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants