summaryrefslogtreecommitdiffstats
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 16:12:56 +0000
commita6bb1d15b748b1f0921d18517181d8890db24de9 (patch)
treeda865acec24d1a4821a79f18a5aa3c1fe4af7c95
parent5e7ed5d4c1b2988311f2c5cccde014a0d03ea062 (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>
-rw-r--r--src/core/render_widget_host_view_qt_delegate_client.cpp10
-rw-r--r--src/webenginewidgets/render_widget_host_view_qt_delegate_widget.cpp7
2 files changed, 8 insertions, 9 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 0a93a6082..98969c5eb 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;
diff --git a/src/webenginewidgets/render_widget_host_view_qt_delegate_widget.cpp b/src/webenginewidgets/render_widget_host_view_qt_delegate_widget.cpp
index 3d4e127dc..05ca9e3b1 100644
--- a/src/webenginewidgets/render_widget_host_view_qt_delegate_widget.cpp
+++ b/src/webenginewidgets/render_widget_host_view_qt_delegate_widget.cpp
@@ -75,16 +75,11 @@ protected:
}
void focusInEvent(QFocusEvent *event) override
{
- Q_ASSERT(event->reason() != Qt::PopupFocusReason);
m_client->forwardEvent(event);
}
void focusOutEvent(QFocusEvent *event) override
{
- // The keyboard events are supposed to go to the parent RenderHostView and WebUI
- // popups should never have focus, therefore ignore focusOutEvent as losing focus
- // will trigger pop close request from blink
- if (event->reason() != Qt::PopupFocusReason)
- m_client->forwardEvent(event);
+ m_client->forwardEvent(event);
}
void inputMethodEvent(QInputMethodEvent *event) override
{