From 1892d315db3e41ead668eadfe46cb6a975b7737e Mon Sep 17 00:00:00 2001 From: ainyan03 Date: Mon, 10 Aug 2026 08:11:52 +0000 Subject: [PATCH] Bring the SDL simulator window to the foreground on macOS Since SDL 2.30.4, non-bundled binaries are no longer brought to the foreground on macOS 14 or later. Setting SDL_HINT_MAC_BACKGROUND_APP to "0" before SDL_Init restores the previous behaviour, so every application using Panel_sdl::main benefits without modifying its own entry point. The hint is set with normal priority, so users can still override it via the SDL_MAC_BACKGROUND_APP environment variable. --- src/lgfx/v1/platforms/sdl/Panel_sdl.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/lgfx/v1/platforms/sdl/Panel_sdl.cpp b/src/lgfx/v1/platforms/sdl/Panel_sdl.cpp index 13b5cc58..2052d98b 100644 --- a/src/lgfx/v1/platforms/sdl/Panel_sdl.cpp +++ b/src/lgfx/v1/platforms/sdl/Panel_sdl.cpp @@ -257,6 +257,11 @@ namespace lgfx _update_in_semaphore = SDL_CreateSemaphore(0); _update_out_semaphore = SDL_CreateSemaphore(0); for (size_t pin = 0; pin < EMULATED_GPIO_MAX; ++pin) { gpio_hi(pin); } +#if defined ( __APPLE__ ) + /// Since SDL 2.30.4, non-bundled apps are no longer brought to the foreground on macOS 14 or later. + /// Set the hint before SDL_Init so that the window appears in front. (can be overridden by the environment variable) + SDL_SetHint(SDL_HINT_MAC_BACKGROUND_APP, "0"); +#endif /*Initialize the SDL*/ SDL_Init(SDL_INIT_VIDEO); SDL_StartTextInput();