summaryrefslogtreecommitdiffstats
path: root/src/core
diff options
context:
space:
mode:
authorMichal Klocek <michal.klocek@qt.io>2022-03-17 13:09:26 +0100
committerQt Cherry-pick Bot <cherrypick_bot@qt-project.org>2022-03-18 17:07:32 +0000
commita980cc295e8e1a7876ab4083cce93151d00162aa (patch)
tree8facca469d3e4fdac6891dec99ef91c345dc84ee /src/core
parente88338c87705351cc51f2eedc517033d80676add (diff)
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 <kirill.burtsev@qt.io> (cherry picked from commit 0625a1e16b8698d9c344548e4e929fb385b6a542) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
Diffstat (limited to 'src/core')
-rw-r--r--src/core/render_widget_host_view_qt_delegate_client.cpp10
1 files changed, 7 insertions, 3 deletions
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<QHoverEvent *>(event));
break;
case QEvent::FocusIn:
- case QEvent::FocusOut:
- handleFocusEvent(static_cast<QFocusEvent *>(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<QFocusEvent *>(event);
+ if (e->reason() != Qt::PopupFocusReason)
+ handleFocusEvent(e);
+ } break;
case QEvent::InputMethod:
handleInputMethodEvent(static_cast<QInputMethodEvent *>(event));
break;