Windows: kill startup console window + grab fullscreen focus on launch#175
Merged
Conversation
Two issues observed at startup on Windows:
1. A cmd.exe console window appeared in the background alongside the
game. Root cause: Updater.cpp shelled out to curl/start/.bat via
_popen() and system() — both of those C-runtime helpers create a
transient cmd.exe to interpret their argument, and because the game
is linked /SUBSYSTEM:WINDOWS (no parent console) the OS allocates a
fresh visible console window for the child. Replace _popen() in
the startup tag-check and the update download with a CreateProcessA
wrapper that uses CREATE_NO_WINDOW + a redirected stdout pipe.
Replace system("start ...") in OpenReleasePage and the update-apply
path with ShellExecuteA, which hands off to the shell without first
spawning a console-host cmd.exe.
2. Launching fullscreen left the window backgrounded in the taskbar
until clicked. Bumps libultraship to claw foreground focus on launch
in both the DXGI (default DX11) and SDL2 (OpenGL) Windows backends.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
4 tasks
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.
Summary
Two Windows-specific launch issues reported by a user:
A cmd.exe console window flashed up in the background at startup (and showed as a second process in Task Manager next to BattleShip.exe). Root cause:
port/enhancements/Updater.cppshells out tocurlvia_popenfrom the in-game menu's update check, and usessystem("start ...")for launching the .bat updater script / opening the releases page. Both_popenandsystemon Windows invokecmd.exeto interpret their argument — and because BattleShip is linked/SUBSYSTEM:WINDOWS(no parent console), Windows allocates a fresh visible console window for that child. This patch routes the curl invocations through a newRunCaptureNoWindowhelper that usesCreateProcessAwithCREATE_NO_WINDOW+ a redirected stdout pipe, and replaces thesystem("start ...")calls withShellExecuteA.Game launched in fullscreen didn't take foreground focus — the window appeared minimized in the taskbar with a flashing icon until clicked. Cause: Win32 denies
SetForegroundWindowto newly-spawned processes by default. Bumps libultraship to perform the standardAttachThreadInput+HWND_TOPMOST-toggle dance after window creation / fullscreen transition in both the DXGI (default DX11) and SDL2 (OpenGL) Windows backends.Changes
port/enhancements/Updater.cpp— newRunCaptureNoWindowhelper (Win32 only), used for both theCheckForUpdatesAsynctag query and theStartGameUpdatedownload.ShellExecuteAreplacessystem("start ...")inOpenReleasePageand theupdate_game.batlaunch.libultrashipbump → JRickey/libultraship@ssb64 commitc16c03f0(Win32 foreground-focus dance ingfx_sdl2.cpp::Initandgfx_dxgi.cpp::Init).Linux/macOS paths are untouched; the Win32 changes are guarded by
#if defined(_WIN32).Test plan
cmake --build .claude/worktrees/fix-windows-console-focus/build --target ssb64 -j 4) — clean.update_game.batstill applies.🤖 Generated with Claude Code