From 9de40c642fa3942224d473f2f9d2e01faf64a158 Mon Sep 17 00:00:00 2001 From: Vasil Topalovic Date: Fri, 21 Aug 2026 20:32:52 -0400 Subject: [PATCH] fix: hide Windows console when launched from Explorer Detach the console only when this process is the sole attached process, so double-click starts without a console while terminal launches keep stdout/stderr. --- app/main.cpp | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/app/main.cpp b/app/main.cpp index 9f538b9..4ecbf55 100644 --- a/app/main.cpp +++ b/app/main.cpp @@ -24,6 +24,10 @@ #include +#if defined(_WIN32) +# include +#endif + namespace { constexpr i32 kInitialWidth = 1200; @@ -233,6 +237,16 @@ void ProcessMouseEvent(App *app, const MouseEvent &event) { int main(int argc, char **argv) { SDL_SetMainReady(); + // Detach the console when we are its only process (Explorer double-click). + // Keep it when launched from an existing terminal so stderr/stdout still work. +#if defined(_WIN32) + DWORD process_ids[2]; + DWORD count = GetConsoleProcessList(process_ids, 2); + if (count == 1) { + FreeConsole(); + } +#endif + Arena *arena = ArenaAlloc(GB(1)); // --screenshot : draw one frame, save it, exit. Everything else on the