summaryrefslogtreecommitdiffstats
path: root/src/plugins/platforms
diff options
context:
space:
mode:
authorDmitry Kazakov <dimula73@gmail.com>2019-04-17 17:39:10 +0300
committerFriedemann Kleint <Friedemann.Kleint@qt.io>2020-10-06 14:03:08 +0000
commitf4442d467039b1161a5025bf5d728adf0e73a077 (patch)
tree92a01a260e966a9dbe870de9afe6f9a6dcce8731 /src/plugins/platforms
parentf80026ef9a74ddf33bf3a717291c55a63e577650 (diff)
WinTab: Switch stylus pointer type when the tablet is in the tablet proximity
Some convertible tablet devices have a special stylus button that converts the stylus into an eraser. Such button can be pressed right when the stylus is in tablet surface proximity, so we should check that not only during proximity event handling, but also while parsing normal wintab packets. Make sure that we don't switch tablet pointer type while any **mapped** stylus button is pressed. Pressing the "eraser" button is reported in pkButtons, but it maps to none by CSR_SYSBTNMAP https://bugs.kde.org/show_bug.cgi?id=405747 https://bugs.kde.org/show_bug.cgi?id=408454 Pick-to: 5.15 Change-Id: I1d254f0cf79be6ceb194b1c4b314a11831f50170 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
Diffstat (limited to 'src/plugins/platforms')
-rw-r--r--src/plugins/platforms/windows/qwindowstabletsupport.cpp25
1 files changed, 21 insertions, 4 deletions
diff --git a/src/plugins/platforms/windows/qwindowstabletsupport.cpp b/src/plugins/platforms/windows/qwindowstabletsupport.cpp
index 9c831036d9..f16015b96a 100644
--- a/src/plugins/platforms/windows/qwindowstabletsupport.cpp
+++ b/src/plugins/platforms/windows/qwindowstabletsupport.cpp
@@ -529,7 +529,6 @@ bool QWindowsTabletSupport::translateTabletPacketEvent()
return false;
const auto currentDevice = m_devices.at(m_currentDevice).currentDevice;
- const auto 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),
@@ -561,6 +560,27 @@ bool QWindowsTabletSupport::translateTabletPacketEvent()
const int z = m_devices.at(m_currentDevice).zCapability ? int(packet.pkZ) : 0;
+ const auto currentPointer = m_devices.at(m_currentDevice).currentPointerType;
+ const auto packetPointerType = pointerType(packet.pkCursor);
+
+ const Qt::MouseButtons buttons =
+ convertTabletButtons(packet.pkButtons, m_devices.at(m_currentDevice));
+
+ if (buttons == Qt::NoButton && packetPointerType != currentPointer) {
+
+ QWindowSystemInterface::handleTabletLeaveProximityEvent(packet.pkTime,
+ int(currentDevice),
+ int(currentPointer),
+ uniqueId);
+
+ m_devices[m_currentDevice].currentPointerType = packetPointerType;
+
+ QWindowSystemInterface::handleTabletEnterProximityEvent(packet.pkTime,
+ int(currentDevice),
+ int(packetPointerType),
+ uniqueId);
+ }
+
QPointF globalPosF =
m_devices.at(m_currentDevice).scaleCoordinates(packet.pkX, packet.pkY, virtualDesktopArea);
@@ -627,9 +647,6 @@ bool QWindowsTabletSupport::translateTabletPacketEvent()
<< tiltY << "tanP:" << tangentialPressure << "rotation:" << rotation;
}
- Qt::MouseButtons buttons =
- convertTabletButtons(packet.pkButtons, m_devices.at(m_currentDevice));
-
QWindowSystemInterface::handleTabletEvent(target, packet.pkTime, QPointF(localPos), globalPosF,
int(currentDevice), int(currentPointer),
buttons,