Make PopupMenu hide after its parent window loss focus #98245
+55
−1
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.
Previously
PopupMenu
s were still on screen after their parent was minimized. It was quite annoying, especially in Editor, because it limits its fps to 1 per second when minimized, even if one of the popup menus is still visible. It's also worth mentioning that no other app I use behaves like this. Their popups always hide after minimizing the main window or they can't just be minimized while popup is visible.Before
Screencast.from.2024-10-16.21-09-35.mp4
After
Screencast.from.2024-10-16.21-11-24.mp4
I decided to fix this by adding two flags which are also visible from scripts:
Window::return_to_transient
(default:false
)PopupMenu::hide_on_parent_unfocused
(default:true
)Also I had to add auxiliary const method
Window::get_transient_parent()
to be able to use the "focus_exited" signal of the parent window from its child popup.Previous behavior can be achieved by setting
return_to_transient
totrue
andhide_on_parent_unfocused
tofalse
.Three things I'm not sure about are:
PopupMenu::hide_on_parent_unfocused
and related stuff (I chose this name because there isPopup::_parent_focused()
method.Window::return_to_transient
flag. Honestly, I don't even know what exactly doERR_MAIN_THREAD_GUARD
andERR_READ_THREAD_GUARD_V
macros do