From 8cdab04d7fd57aaabd790349cd8a4e9ec21a7edd Mon Sep 17 00:00:00 2001 From: Markus Sauermann <6299227+Sauermann@users.noreply.github.com> Date: Sun, 18 Jun 2023 13:45:26 +0200 Subject: [PATCH] Fix that the focus-out notification got sent deferred Currently the window receives a focus-out notification, directly after it popup, because currently the signal is sent deferred. The original intention was that the previously focused window must receive a focus-out notification. This change makes the notification more precise by only sending the focus-out to the previously focused window. --- scene/main/window.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/scene/main/window.cpp b/scene/main/window.cpp index e8395f59c96..eab280e67a8 100644 --- a/scene/main/window.cpp +++ b/scene/main/window.cpp @@ -1624,7 +1624,15 @@ void Window::popup(const Rect2i &p_screen_rect) { // Send a focus-out notification when opening a Window Manager Popup. SceneTree *scene_tree = get_tree(); if (scene_tree) { - scene_tree->notify_group_flags(SceneTree::GROUP_CALL_DEFERRED, "_viewports", NOTIFICATION_WM_WINDOW_FOCUS_OUT); + List list; + scene_tree->get_nodes_in_group("_viewports", &list); + for (Node *n : list) { + Window *w = Object::cast_to(n); + if (w && !w->get_embedder() && w->has_focus()) { + w->_event_callback(DisplayServer::WINDOW_EVENT_FOCUS_OUT); + break; + } + } } }