From a980cc295e8e1a7876ab4083cce93151d00162aa Mon Sep 17 00:00:00 2001 From: Michal Klocek Date: Thu, 17 Mar 2022 13:09:26 +0100 Subject: Fix wrong assumption about focus in/out event delivery In 2947d79d assumption was made that we never get focus in event for popup reason. Unfortunately this is not true as simply creating window menu and switching between webengineview will trigger the issue. Moreover, focus in and out events with popup reason do not mean change of focus, as in qtbase: if (QWidget *fw = active_window->focusWidget()) { if (fw != QApplication::focusWidget()) { fw->setFocus(Qt::PopupFocusReason) } else { QFocusEvent e(QEvent::FocusIn, Qt::PopupFocusReason); QCoreApplication::sendEvent(fw, &e); } } Therefore it is safe to ignore focus in/out events with popup reason. Note that the fact that ASSERT got not triggered for context menu is due to another race condition issue in qquick event stack delivery. This commit amends 2947d79d8210a7ae4ce2bc02e058628e66011be3. Fixes: QTBUG-101706 Change-Id: I3e761fe5d8054aed72461eba7981c69755877d1b Reviewed-by: Kirill Burtsev (cherry picked from commit 0625a1e16b8698d9c344548e4e929fb385b6a542) Reviewed-by: Qt Cherry-pick Bot --- src/core/render_widget_host_view_qt_delegate_client.cpp | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'src/core') diff --git a/src/core/render_widget_host_view_qt_delegate_client.cpp b/src/core/render_widget_host_view_qt_delegate_client.cpp index 009f2f0ef..e2fb0c694 100644 --- a/src/core/render_widget_host_view_qt_delegate_client.cpp +++ b/src/core/render_widget_host_view_qt_delegate_client.cpp @@ -329,9 +329,13 @@ bool RenderWidgetHostViewQtDelegateClient::forwardEvent(QEvent *event) handleHoverEvent(static_cast(event)); break; case QEvent::FocusIn: - case QEvent::FocusOut: - handleFocusEvent(static_cast(event)); - break; + case QEvent::FocusOut: { + // Focus in/out events for popup event do not mean 'parent' focus change + // and should not be handled by Chromium + QFocusEvent *e = static_cast(event); + if (e->reason() != Qt::PopupFocusReason) + handleFocusEvent(e); + } break; case QEvent::InputMethod: handleInputMethodEvent(static_cast(event)); break; -- cgit v1.2.3