1From ba46d636b750238a67165f5036d49ee82a08fcd0 Mon Sep 17 00:00:00 2001
2From: Jeffy Chen <jeffy.chen@rock-chips.com>
3Date: Fri, 16 Oct 2020 11:50:20 +0800
4Subject: [PATCH 22/28] Support force using mouse events instead of touch
5
6Set "QT_TOUCH_TO_MOUSE" environment to enable it:
7export QT_TOUCH_TO_MOUSE=1
8
9Signed-off-by: Jeffy Chen <jeffy.chen@rock-chips.com>
10---
11 src/gui/kernel/qguiapplication.cpp | 6 ++++++
12 1 file changed, 6 insertions(+)
13
14diff --git a/src/gui/kernel/qguiapplication.cpp b/src/gui/kernel/qguiapplication.cpp
15index a95331e2..66d305d2 100644
16--- a/src/gui/kernel/qguiapplication.cpp
17+++ b/src/gui/kernel/qguiapplication.cpp
18@@ -3053,10 +3053,16 @@ void QGuiApplicationPrivate::processTouchEvent(QWindowSystemInterfacePrivate::To
19             }
20         }
21
22+        // Force using mouse events instead of touch
23+        char *buf = getenv("QT_TOUCH_TO_MOUSE");
24+        if (buf && buf[0] == '1')
25+            goto fake_mouse;
26+
27         QGuiApplication::sendSpontaneousEvent(w, &touchEvent);
28         if (!e->synthetic() && !touchEvent.isAccepted() && qApp->testAttribute(Qt::AA_SynthesizeMouseForUnhandledTouchEvents)) {
29             // exclude devices which generate their own mouse events
30             if (!(touchEvent.device()->capabilities() & QTouchDevice::MouseEmulation)) {
31+fake_mouse:
32                 const QList<QTouchEvent::TouchPoint> &touchPoints = touchEvent.touchPoints();
33                 QEvent::Type mouseEventType = QEvent::MouseMove;
34                 Qt::MouseButton button = Qt::NoButton;
35--
362.20.1
37
38