summaryrefslogtreecommitdiffstats
path: root/src/plugins/platforms/windows
diff options
context:
space:
mode:
authorQt Forward Merge Bot <qt_forward_merge_bot@qt-project.org>2018-03-18 01:00:11 +0100
committerQt Forward Merge Bot <qt_forward_merge_bot@qt-project.org>2018-03-18 01:00:11 +0100
commitd58f3c4878b78699bd23507352a2f55881d9b76f (patch)
tree577e5fe415ed1741a7a6938451ba54bbbdcf1490 /src/plugins/platforms/windows
parent6c7fff8c91d68912797fa84360ab374b858f44c4 (diff)
parentf6f40014c417aa90d4c805719e70910f522047e4 (diff)
Merge remote-tracking branch 'origin/5.11' into dev
Diffstat (limited to 'src/plugins/platforms/windows')
-rw-r--r--src/plugins/platforms/windows/qwindowstabletsupport.cpp32
-rw-r--r--src/plugins/platforms/windows/qwindowstabletsupport.h15
2 files changed, 36 insertions, 11 deletions
diff --git a/src/plugins/platforms/windows/qwindowstabletsupport.cpp b/src/plugins/platforms/windows/qwindowstabletsupport.cpp
index dcad23e446..280519d39d 100644
--- a/src/plugins/platforms/windows/qwindowstabletsupport.cpp
+++ b/src/plugins/platforms/windows/qwindowstabletsupport.cpp
@@ -406,6 +406,7 @@ bool QWindowsTabletSupport::translateTabletProximityEvent(WPARAM /* wParam */, L
qCDebug(lcQpaTablet) << "leave proximity for device #" << m_currentDevice;
if (m_currentDevice < 0 || m_currentDevice >= m_devices.size()) // QTBUG-65120, spurious leave observed
return false;
+ m_state = PenUp;
if (totalPacks > 0) {
QWindowSystemInterface::handleTabletLeaveProximityEvent(proximityBuffer[0].pkTime,
m_devices.at(m_currentDevice).currentDevice,
@@ -438,6 +439,7 @@ bool QWindowsTabletSupport::translateTabletProximityEvent(WPARAM /* wParam */, L
m_devices.push_back(tabletInit(uniqueId, cursorType));
}
m_devices[m_currentDevice].currentPointerType = pointerType(currentCursor);
+ m_state = PenProximity;
qCDebug(lcQpaTablet) << "enter proximity for device #"
<< m_currentDevice << m_devices.at(m_currentDevice);
QWindowSystemInterface::handleTabletEnterProximityEvent(proximityBuffer[0].pkTime,
@@ -458,7 +460,8 @@ bool QWindowsTabletSupport::translateTabletPacketEvent()
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, depending on it settings:
+ // The tablet can be used in 2 different modes (reflected in enum Mode),
+ // depending on its settings:
// 1) Absolute (pen) mode:
// The coordinates are scaled to the virtual desktop (by default). The user
// can also choose to scale to the monitor or a region of the screen.
@@ -473,8 +476,11 @@ bool QWindowsTabletSupport::translateTabletPacketEvent()
const QRect virtualDesktopArea =
QWindowsScreen::virtualGeometry(QGuiApplication::primaryScreen()->handle());
- qCDebug(lcQpaTablet) << __FUNCTION__ << "processing " << packetCount
- << "target:" << QGuiApplicationPrivate::tabletDevicePoint(uniqueId).target;
+ if (QWindowsContext::verbose > 1) {
+ qCDebug(lcQpaTablet) << __FUNCTION__ << "processing" << packetCount
+ << "mode=" << m_mode << "target:"
+ << QGuiApplicationPrivate::tabletDevicePoint(uniqueId).target;
+ }
const Qt::KeyboardModifiers keyboardModifiers = QWindowsKeyMapper::queryKeyboardModifiers();
@@ -485,20 +491,24 @@ bool QWindowsTabletSupport::translateTabletPacketEvent()
// This code is to delay the tablet data one cycle to sync with the mouse location.
QPointF globalPosF = m_oldGlobalPosF;
- m_oldGlobalPosF = m_devices.at(m_currentDevice).scaleCoordinates(packet.pkX, packet.pkY, virtualDesktopArea);
+ const QPointF currentGlobalPosF =
+ m_devices.at(m_currentDevice).scaleCoordinates(packet.pkX, packet.pkY, virtualDesktopArea);
+ m_oldGlobalPosF = currentGlobalPosF;
QWindow *target = QGuiApplicationPrivate::tabletDevicePoint(uniqueId).target; // Pass to window that grabbed it.
- QPoint globalPos = globalPosF.toPoint();
// Get Mouse Position and compare to tablet info
const QPoint mouseLocation = QWindowsCursor::mousePosition();
-
- // Positions should be almost the same if we are in absolute
- // mode. If they are not, use the mouse location.
- if ((mouseLocation - globalPos).manhattanLength() > m_absoluteRange) {
- globalPos = mouseLocation;
- globalPosF = globalPos;
+ if (m_state == PenProximity) {
+ m_state = PenDown;
+ m_mode = (mouseLocation - currentGlobalPosF).manhattanLength() > m_absoluteRange
+ ? MouseMode : PenMode;
+ qCDebug(lcQpaTablet) << __FUNCTION__ << "mode=" << m_mode << "pen:"
+ << currentGlobalPosF << "mouse:" << mouseLocation;
}
+ if (m_mode == MouseMode)
+ globalPosF = mouseLocation;
+ const QPoint globalPos = globalPosF.toPoint();
if (!target)
target = QWindowsScreen::windowAt(globalPos, CWP_SKIPINVISIBLE | CWP_SKIPTRANSPARENT);
diff --git a/src/plugins/platforms/windows/qwindowstabletsupport.h b/src/plugins/platforms/windows/qwindowstabletsupport.h
index 7878e962e1..340818c3f7 100644
--- a/src/plugins/platforms/windows/qwindowstabletsupport.h
+++ b/src/plugins/platforms/windows/qwindowstabletsupport.h
@@ -112,6 +112,19 @@ class QWindowsTabletSupport
explicit QWindowsTabletSupport(HWND window, HCTX context);
public:
+ enum Mode
+ {
+ PenMode,
+ MouseMode
+ };
+
+ enum State
+ {
+ PenUp,
+ PenProximity,
+ PenDown
+ };
+
~QWindowsTabletSupport();
static QWindowsTabletSupport *create();
@@ -137,6 +150,8 @@ private:
QVector<QWindowsTabletDeviceData> m_devices;
int m_currentDevice;
QPointF m_oldGlobalPosF;
+ Mode m_mode = PenMode;
+ State m_state = PenUp;
};
QT_END_NAMESPACE