0028-Fix-updating-tablet-pressure-resolution-on-every-pro.patch 2.88 KB
Newer Older
1
diff --git a/src/plugins/platforms/windows/qwindowstabletsupport.cpp b/src/plugins/platforms/windows/qwindowstabletsupport.cpp
2
index fa209f09c..462be8b3f 100644
3 4
--- a/src/plugins/platforms/windows/qwindowstabletsupport.cpp
+++ b/src/plugins/platforms/windows/qwindowstabletsupport.cpp
5
@@ -434,6 +434,14 @@ bool QWindowsTabletSupport::translateTabletProximityEvent(WPARAM /* wParam */, L
6 7 8 9 10 11 12 13 14 15 16 17
     if (m_currentDevice < 0) {
         m_currentDevice = m_devices.size();
         m_devices.push_back(tabletInit(uniqueId, cursorType));
+    } else {
+        /**
+         * The user can switch pressure sensitivity level in the driver,
+         * which will make our saved values invalid (this option is
+         * provided by Wacom drivers for compatibility reasons, and
+         * it can be adjusted on the fly)
+         */
+        m_devices[m_currentDevice] = tabletInit(uniqueId, cursorType);
     }
18 19 20 21
     m_devices[m_currentDevice].currentPointerType = pointerType(currentCursor);
     m_state = PenProximity;
@@ -454,7 +462,6 @@ bool QWindowsTabletSupport::translateTabletPacketEvent()
         return false;
22
 
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56
     const int currentDevice = m_devices.at(m_currentDevice).currentDevice;
-    const int currentPointer = m_devices.at(m_currentDevice).currentPointerType;
     const qint64 uniqueId = m_devices.at(m_currentDevice).uniqueId;
 
     // The tablet can be used in 2 different modes (reflected in enum Mode),
@@ -484,6 +491,28 @@ bool QWindowsTabletSupport::translateTabletPacketEvent()
     for (int i = 0; i < packetCount ; ++i) {
         const PACKET &packet = localPacketBuf[i];
 
+        int currentPointer = m_devices.at(m_currentDevice).currentPointerType;
+
+        const int packetPointerType = pointerType(packet.pkCursor);
+        if (!packet.pkButtons && packetPointerType != currentPointer) {
+
+            QWindowSystemInterface::handleTabletLeaveProximityEvent(packet.pkTime,
+                                                                    m_devices.at(m_currentDevice).currentDevice,
+                                                                    m_devices.at(m_currentDevice).currentPointerType,
+                                                                    m_devices.at(m_currentDevice).uniqueId);
+
+
+
+            m_devices[m_currentDevice].currentPointerType = packetPointerType;
+
+            QWindowSystemInterface::handleTabletEnterProximityEvent(packet.pkTime,
+                                                                    m_devices.at(m_currentDevice).currentDevice,
+                                                                    m_devices.at(m_currentDevice).currentPointerType,
+                                                                    m_devices.at(m_currentDevice).uniqueId);
+
+            currentPointer = packetPointerType;
+        }
+
         const int z = currentDevice == QTabletEvent::FourDMouse ? int(packet.pkZ) : 0;
 
         QPointF globalPosF =