From 016c7940a55f472e5c6222a37c059d1e859d135d Mon Sep 17 00:00:00 2001 From: Dmitry Kazakov Date: Wed, 17 Apr 2019 17:39:10 +0300 Subject: 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 Change-Id: I1d254f0cf79be6ceb194b1c4b314a11831f50170 Reviewed-by: Friedemann Kleint (cherry picked from commit f4442d467039b1161a5025bf5d728adf0e73a077) --- .../platforms/windows/qwindowstabletsupport.cpp | 25 ++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/src/plugins/platforms/windows/qwindowstabletsupport.cpp b/src/plugins/platforms/windows/qwindowstabletsupport.cpp index d57e7640ad..100367e941 100644 --- a/src/plugins/platforms/windows/qwindowstabletsupport.cpp +++ b/src/plugins/platforms/windows/qwindowstabletsupport.cpp @@ -524,7 +524,6 @@ bool QWindowsTabletSupport::translateTabletPacketEvent() return false; 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), @@ -556,6 +555,27 @@ bool QWindowsTabletSupport::translateTabletPacketEvent() const int z = currentDevice == QTabletEvent::FourDMouse ? 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); @@ -622,9 +642,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, currentDevice, currentPointer, buttons, -- cgit v1.2.3