diff options
| author | Rémi Verschelde <rverschelde@gmail.com> | 2023-08-08 16:57:09 +0200 |
|---|---|---|
| committer | Rémi Verschelde <rverschelde@gmail.com> | 2023-08-08 16:57:09 +0200 |
| commit | af722e2bab0ffb719b7aab40f5550e070cef6462 (patch) | |
| tree | ffffac56edba51e402cde4d8e689a926981c7d29 | |
| parent | 5bd5698407252145203d55246b7a0b17395ee410 (diff) | |
| parent | 2f8673dc0717a3000bbbf9d0d8b88dafe5d69769 (diff) | |
| download | redot-engine-af722e2bab0ffb719b7aab40f5550e070cef6462.tar.gz | |
Merge pull request #80187 from Sauermann/fix-mouseover-error-handling
Handle potential platform-specific `Window` mouse-enter/exit bugs gracefully
| -rw-r--r-- | scene/main/window.cpp | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/scene/main/window.cpp b/scene/main/window.cpp index d0658c489d..875b53203a 100644 --- a/scene/main/window.cpp +++ b/scene/main/window.cpp @@ -670,9 +670,14 @@ void Window::_propagate_window_notification(Node *p_node, int p_notification) { void Window::_event_callback(DisplayServer::WindowEvent p_event) { switch (p_event) { case DisplayServer::WINDOW_EVENT_MOUSE_ENTER: { - _propagate_window_notification(this, NOTIFICATION_WM_MOUSE_ENTER); Window *root = get_tree()->get_root(); - DEV_ASSERT(!root->gui.windowmanager_window_over); // Entering a window while a window is hovered should never happen. + if (root->gui.windowmanager_window_over) { +#ifdef DEV_ENABLED + WARN_PRINT_ONCE("Entering a window while a window is hovered should never happen in DisplayServer."); +#endif // DEV_ENABLED + root->gui.windowmanager_window_over->_event_callback(DisplayServer::WINDOW_EVENT_MOUSE_EXIT); + } + _propagate_window_notification(this, NOTIFICATION_WM_MOUSE_ENTER); root->gui.windowmanager_window_over = this; notification(NOTIFICATION_VP_MOUSE_ENTER); if (DisplayServer::get_singleton()->has_feature(DisplayServer::FEATURE_CURSOR_SHAPE)) { @@ -681,7 +686,12 @@ void Window::_event_callback(DisplayServer::WindowEvent p_event) { } break; case DisplayServer::WINDOW_EVENT_MOUSE_EXIT: { Window *root = get_tree()->get_root(); - DEV_ASSERT(root->gui.windowmanager_window_over); // Exiting a window, while no window is hovered should never happen. + if (!root->gui.windowmanager_window_over) { +#ifdef DEV_ENABLED + WARN_PRINT_ONCE("Exiting a window while no window is hovered should never happen in DisplayServer."); +#endif // DEV_ENABLED + return; + } root->gui.windowmanager_window_over->_mouse_leave_viewport(); root->gui.windowmanager_window_over = nullptr; _propagate_window_notification(this, NOTIFICATION_WM_MOUSE_EXIT); |
