Repository navigation
The launcher comes back to the front when a game it started quits - #110
Conversation
25cd8e1 to
72a76e3
Compare
|
Thanks, this is a good idea. Could you rebase onto current |
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).
72a76e3 to
9a7dfb2
Compare
|
Rebased onto main. Both paths now share one watcher ( |
|
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 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. |
|
Merged, thanks @subyoung! One watcher for Play and console mode with a single switch is a nice cleanup. It ships with the next release. |
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 (
returnAfterPlayin UserDefaults), in both languages.ReturnAfterPlay.swift: the decision as a pure function (shouldReturn, paths compared in their standard spelling) and a small watcher onNSWorkspace.didTerminateApplicationNotification, armed once Play'sopenApplicationsucceeds.LauncherView.swift: tells the watcher which app Play opened.ContentView.swift,Localization.swift: the Settings row and its two strings.Checked
cd frontend && swift test: 171 tests, 0 failures (2 skipped, as before); newReturnAfterPlayTests(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.NX_LAUNCHER_CAPTURE_DIR=<dir> swift test; the new row was checked in thesettings.pngandsettings-notify.pngcaptures.build_ipa_from_nsp.py --platform mac-appon an Apple M2, macOS 27. Opened as Play opens it (NSWorkspace.openApplicationwith its launch environment) and quit: thedidTerminateApplicationNotificationfor it carries the same bundle path Play opened, soshouldReturnis true for it.Scope
dm/,scripts/,docs/,ref/,AGENTS.md) is edited, or it goes through a sync patcher or upstream first (pr-scope)