Skip to content

Bring the SDL simulator window to the foreground on macOS - #245

Merged
lovyan03 merged 1 commit into
m5stack:developfrom
ainyan03:sdl_mac_foreground
Aug 10, 2026
Merged

Bring the SDL simulator window to the foreground on macOS#245
lovyan03 merged 1 commit into
m5stack:developfrom
ainyan03:sdl_mac_foreground

Conversation

@ainyan03

Copy link
Copy Markdown
Contributor

Overview

Since SDL 2.30.4, non-bundled binaries are no longer brought to the foreground on macOS 14 or later (libsdl-org/SDL#10340 changed the default behaviour of SDL_HINT_MAC_BACKGROUND_APP there). As a result, the simulator window opens behind the frontmost application.

#244 addressed this in the PlatformIO example. This PR moves the same measure into Panel_sdl::setup() so that every application using Panel_sdl benefits without modifying its own entry point (the CMake example and existing user projects that copied an older sdl_main.cpp).

Setting the hint before SDL_Init restores the previous foreground behaviour. SDL_SetHint uses normal priority, so users can still override this via the SDL_MAC_BACKGROUND_APP environment variable.

Verification

  • macOS (Apple Silicon) + Homebrew SDL 2.32.10: without this change the simulator window opens behind the frontmost app; with it, the window comes to the foreground. Verified by checking the frontmost application before/after.
  • Other platforms are unaffected (__APPLE__ guard).

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.
@lovyan03
lovyan03 merged commit 60df0bb into m5stack:develop Aug 10, 2026
23 checks passed
@ainyan03
ainyan03 deleted the sdl_mac_foreground branch August 10, 2026 08:56
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.

2 participants