MacOS: Fix focus grab warning on macOS when running game in embedded mode. #113300
+7
−2
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes focus grab warning on macOS when running game in embedded mode.
Issue
When running a game with "Embed Game on Next Play" enabled on macOS, the following warning is printed:
"This control can't grab focus. Use set_focus_mode() and set_focus_behavior_recursive()
to allow a control to get focus."
Root Cause
EmbeddedProcessMacOSis explicitly configured withset_focus_mode(FOCUS_NONE)in its constructor,while
GameViewunconditionally callsgrab_focus()on it when starting the game instance.The focus is intentionally delegated to the child
layer_hostwhich usesFOCUS_ALL.However,
grab_focus()on the parent process still triggers the warning even though thisis the intended design on macOS.
Solution
Add a focus mode check before calling
grab_focus()inGameView::_play_pressed()andGameView::_instance_starting(). This prevents the warning when the control is explicitlyset to not accept focus, matching the macOS-specific implementation's design.
Changes Made
if (embedded_process->get_focus_mode_with_override() != FOCUS_NONE)guardbefore
embedded_process->grab_focus()calls ingame_view.cppTesting