Skip to content

A Mac game opens on the display of the launcher's window (DM_SCREEN) - #221

Merged
v0lumehi merged 2 commits into
mainfrom
v0lumehi/game-on-launcher-screen
Oct 29, 2026
Merged

v0lumehi merged 2 commits into
mainfrom
v0lumehi/game-on-launcher-screen

Conversation

@v0lumehi

Copy link
Copy Markdown
Collaborator

What and why

With two displays, a Mac game's window opened on the other display than the launcher's in 2 of 3 runs (found with the fullscreen work in #219 and seedds/nxnative#665). The game is a process that is not active yet when it opens its window, so macOS picks the screen. Console mode on an external display could therefore start its game on the built-in one.

  • Host, patch 0031 (Upstream-Status: forwarded seedds/nxnative#670): a new switch DM_SCREEN=<number>, the NSScreenNumber (CGDirectDisplayID). When a connected screen has that number, the window is centred there before it is shown and before any DM_FULLSCREEN request. Unset or unknown: unchanged, with one log line either way. Its Issue: line names this PR, as there is no separate issue. Number 0031 as agreed (main has 0027, Cheats sheet in the launcher, carrying seedds/nxnative#406 #218 becomes 0028 and 0029, Carry seedds/nxnative#665: fullscreen for a game opened from a fullscreen app #219 becomes 0030). The patch applies on current main alone.
  • Launcher: GameStart.environment, which both the library's Play and console mode use, adds DM_SCREEN with the display ID of NSApp.keyWindow?.screen ?? NSScreen.main. Nothing else in the launch flow changes.

Combined with #219: that PR makes the game wait until the app and its Space are active before it asks for fullscreen. This one only places the window first, so from console mode the game's fullscreen request is made on the launcher's display. The two touch neighbouring lines in front_mac.m but do not conflict logically.

@LNPANDY could you try it together with #219 from console mode on an external display? The launcher on the external display should give a game that opens, and goes fullscreen, there.

Checked

  • Tests: python3 scripts/patches.py check passes, python3 -m unittest discover -s scripts/tests passes (39 tests), make -C dm/host GAME=010015100B514000 builds, make -C dm/host/tests GAME=010015100B514000 run passes, dm/tools/env_switches.py --check passes, cd frontend && swift build -c release && swift test passes (403 tests, 13 skipped as before). New: GameStartScreenTests and a line in ConsoleLiveTests.testPlayRoutesToTheLaunchWithTheDesktopEnvironment, which check the value both launch paths get.
  • Visual QA: not a UI change.
  • Run on a device or Mac: a small harness built from the exact switch block (Apple silicon, macOS 27, built-in plus external display): each display's number put the window on that display, an unknown number logged ignored and kept the default, unset kept the default. No game was started with the new host, and the launcher was not run with two displays by hand.

Scope

A Mac game window opened on another display than the launcher's in 2 of 3 runs with two displays. DM_SCREEN=<NSScreenNumber> centres the window on that connected screen before it is shown and before any DM_FULLSCREEN request. Unset or unknown, nothing changes.
…her's window

Play (library and console mode, both through GameStart.environment) adds DM_SCREEN with the NSScreenNumber of the launcher window's screen, else the main screen.
@v0lumehi

Copy link
Copy Markdown
Collaborator Author

Rebased onto main after #219 and the pin bump #223. Patch 0031 now sits after 0030 and applies on pin a662f29. The patch and the launcher change were redone on the new tree, so docs/development.md and GameStart.swift (next to the cloud saves line) have the new context. Checks green locally: patches.py check, scripts tests, host build, host tests, swift build -c release && swift test (436 tests, 14 skipped).

@v0lumehi
v0lumehi force-pushed the v0lumehi/game-on-launcher-screen branch from 4bd7b78 to cee5541 Compare October 29, 2026 21:41
@v0lumehi
v0lumehi merged commit 8c60e49 into main Oct 29, 2026
10 checks passed
@v0lumehi
v0lumehi deleted the v0lumehi/game-on-launcher-screen branch October 29, 2026 21:51
lucaszhongsj pushed a commit to lucaszhongsj/nxnative that referenced this pull request Nov 19, 2026
Upstream-Status: forwarded seedds#670
Reason: a game opens on the launcher's display only with this switch until upstream merges it
Issue: LNPANDY/NX2Apple#221
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant