Skip to content

Windows: kill startup console window + grab fullscreen focus on launch#175

Merged
JRickey merged 1 commit into
mainfrom
agent/fix-windows-console-focus
May 14, 2026
Merged

Windows: kill startup console window + grab fullscreen focus on launch#175
JRickey merged 1 commit into
mainfrom
agent/fix-windows-console-focus

Conversation

@JRickey
Copy link
Copy Markdown
Owner

@JRickey JRickey commented May 13, 2026

Summary

Two Windows-specific launch issues reported by a user:

  1. 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.cpp shells out to curl via _popen from the in-game menu's update check, and uses system("start ...") for launching the .bat updater script / opening the releases page. Both _popen and system on Windows invoke cmd.exe to 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 new RunCaptureNoWindow helper that uses CreateProcessA with CREATE_NO_WINDOW + a redirected stdout pipe, and replaces the system("start ...") calls with ShellExecuteA.

  2. 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 SetForegroundWindow to newly-spawned processes by default. Bumps libultraship to perform the standard AttachThreadInput + 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 — new RunCaptureNoWindow helper (Win32 only), used for both the CheckForUpdatesAsync tag query and the StartGameUpdate download. ShellExecuteA replaces system("start ...") in OpenReleasePage and the update_game.bat launch.
  • libultraship bump → JRickey/libultraship@ssb64 commit c16c03f0 (Win32 foreground-focus dance in gfx_sdl2.cpp::Init and gfx_dxgi.cpp::Init).

Linux/macOS paths are untouched; the Win32 changes are guarded by #if defined(_WIN32).

Test plan

  • Linux Debug build (cmake --build .claude/worktrees/fix-windows-console-focus/build --target ssb64 -j 4) — clean.
  • Windows Release build via CI / local: verify no cmd.exe window appears at launch, and a fullscreen-on-startup launch grabs foreground focus.
  • Trigger update check from the in-game menu on Windows; verify no console flash.
  • Trigger update download on Windows (artificial pre-release tag); verify progress UI still updates and update_game.bat still applies.

🤖 Generated with Claude Code

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>
@JRickey JRickey merged commit 523f6db into main May 14, 2026
@JRickey JRickey deleted the agent/fix-windows-console-focus branch May 14, 2026 22:10
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