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