Skip to content

Respect Window::focused when requesting macOS app activation on startup and window creation#24702

Open
ariofrio wants to merge 3 commits into
bevyengine:mainfrom
coldriverstudio:ariofrio/macos-focused-activation
Open

Respect Window::focused when requesting macOS app activation on startup and window creation#24702
ariofrio wants to merge 3 commits into
bevyengine:mainfrom
coldriverstudio:ariofrio/macos-focused-activation

Conversation

@ariofrio

@ariofrio ariofrio commented Jun 22, 2026

Copy link
Copy Markdown
Contributor

Objective

Solution

The design principle is that focused should result in similar behavior on macOS as in other supported platforms (i.e. Windows). This means managing app activation to result in the expected window focusing behavior.

  • Set with_activate_ignoring_other_apps to false if the primary window should be unfocused on startup, or if there is no primary window
  • Call focus_window when a focused window is created to ensure app activation is requested, so that apps that delay creating the first window can still activate the app if desired.

Alternatives Considered

  • Adding a dedicated macOS-only macos_activate_ignoring_other_apps setting to bevy_winit. This is poorly discoverable and has footguns, e.g. what happens when a focused window is created when the app is not activated.

Testing

Tested programmatically on macOS Tahoe 26.5 by checking NSWorkspace.shared.frontmostApplication before and after creating an additional window using bevy_remote:

Startup case Before After
Window { focused: true } App became frontmost; window was focused Same
Window { focused: false } App became frontmost; window was focused despite focused: false App stayed behind current app; window remained unfocused
Mixed startup windows, at least one with focused: true App became frontmost; a window was focused Same
primary_window: None App stayed behind current app Same
After-startup case Before After
primary_window: None, then create visible Window { focused: true } App became frontmost; window was focused Same
primary_window: None, then create visible Window { focused: false } App became frontmost; window was focused despite focused: false App stayed behind current app; window remained unfocused
Startup Window { focused: false }, then set focused = true Window was already focused from startup App became frontmost; window was focused

Showcase

See migration guide.

@ariofrio ariofrio changed the title Request app activation on macOS to respect Window::focused on startup and window creation Respect Window::focused when requesting macOS app activation on startup and window creation Jun 22, 2026
@github-actions

Copy link
Copy Markdown
Contributor

You added a new feature but didn't add a description for it. Please update the root Cargo.toml file.

@alice-i-cecile alice-i-cecile added C-Bug An unexpected or incorrect behavior A-Windowing Platform-agnostic interface layer to run your app in O-MacOS Specific to the MacOS (Apple) desktop operating system D-Straightforward Simple bug fixes and API improvements, docs, test and examples S-Needs-Review Needs reviewer attention (from anyone!) to move forward M-Migration-Guide A breaking change to Bevy's public API that needs to be noted in a migration guide labels Jun 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-Windowing Platform-agnostic interface layer to run your app in C-Bug An unexpected or incorrect behavior D-Straightforward Simple bug fixes and API improvements, docs, test and examples M-Migration-Guide A breaking change to Bevy's public API that needs to be noted in a migration guide O-MacOS Specific to the MacOS (Apple) desktop operating system S-Needs-Review Needs reviewer attention (from anyone!) to move forward

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug: cannot create an unfocused window on Mac for dev

2 participants