macOS window loses focus

Godot Version

4.3

Question

I have a window that is a popup window, always on top that is instantiated from the main window. When I close it either by a designed keypress or by the close_request it is queue_free()

In Windows, focus returns to the main window and I can press the key again (or any other key) to open the subwindow again.

In macOS: the parent window does not get the focus (no keys work). I have to click one time with mouse on the window to get focus back and it all works again.

I guess this something has to do with how mac handles the windows and popup, anybody can point me in the right direction?

I did some try with remembering the last control before the subwindow opened, but no luck

func _on_sub_window_closed():
    if last_focused_control:
        last_focused_control.grab_focus()

Found a workaround making the subwindow unfocusable, not great, but ok for now :smile:

If behavior is different between platforms it may be an engine bug. Try opening an issue here Issues · godotengine/godot · GitHub filling the Bug report form.