summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVolker Hilsheimer <volker.hilsheimer@qt.io>2023-04-26 19:15:58 +0200
committerQt Cherry-pick Bot <cherrypick_bot@qt-project.org>2023-04-28 14:12:18 +0000
commit7e063b92bf8ffb3e1c8d5327b0e27a2466c849f8 (patch)
tree54ee72382308ad5905ec85b6a4e042d4d907baaf
parent72235540cb5215a7487385eb91f3b13021cce470 (diff)
downloadqtbase-7e063b92bf8ffb3e1c8d5327b0e27a2466c849f8.tar.gz
Don't set focus when moving the cursor with a touch pad
On macOS, swiping with a single finger on the track pad (which Qt identifies as a QInputDevice::DeviceType::TouchPad) results in a TouchBegin event. For widgets that accept touch events (perhaps implicitly because they want pan gestures, like QGraphicsView), this results in a TouchBegin event to be delivered. QApplication::notify will then check the widget's focus policy, and with ClickFocus set, will set focus on the widget. This is not what we want for a TouchBegin on a touch pad, so skip the setting of the focus for that device type. Fixes: QTBUG-112922 Change-Id: Ie828793a784cc0e2fa47954bf5b396d6a44bd5e8 Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io> (cherry picked from commit 127e33d4c6e000ed1fab0f2ea926918ed0bf3bd3) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
-rw-r--r--src/widgets/kernel/qapplication.cpp3
1 files changed, 2 insertions, 1 deletions
diff --git a/src/widgets/kernel/qapplication.cpp b/src/widgets/kernel/qapplication.cpp
index d155f278fa..8b6adc0176 100644
--- a/src/widgets/kernel/qapplication.cpp
+++ b/src/widgets/kernel/qapplication.cpp
@@ -3062,7 +3062,8 @@ bool QApplication::notify(QObject *receiver, QEvent *e)
bool eventAccepted = touchEvent->isAccepted();
bool acceptTouchEvents = w->testAttribute(Qt::WA_AcceptTouchEvents);
- if (acceptTouchEvents && e->spontaneous()) {
+ if (acceptTouchEvents && e->spontaneous()
+ && touchEvent->device()->type() != QInputDevice::DeviceType::TouchPad) {
const QPoint localPos = touchEvent->points()[0].position().toPoint();
QApplicationPrivate::giveFocusAccordingToFocusPolicy(w, e, localPos);
}