Windows QPA: Fix tablet event coords delay for tablets in pen mode

Now that the mouse mode check is only done once for the first event
after the TabletEnterProximityEvent, the m_oldGlobalPosF member has
lost its purpose and should be removed.

Worse, its value was used instead of currentGlobalPosF when in pen mode,
resulting in an unnecessary 1-frame delay in the reported positions
in the tablet events.

Task-number: QTBUG-36937
Change-Id: I6bd2db57898850a65088d9bb41fbfbd96eac54f5
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
This commit is contained in:
Romain Pokrzywka 2018-07-23 16:28:35 -05:00 committed by Romain Pokrzywka
parent 947df4e63e
commit 708fa860bc
2 changed files with 3 additions and 7 deletions

View File

@ -489,11 +489,8 @@ bool QWindowsTabletSupport::translateTabletPacketEvent()
const int z = currentDevice == QTabletEvent::FourDMouse ? int(packet.pkZ) : 0;
// This code is to delay the tablet data one cycle to sync with the mouse location.
QPointF globalPosF = m_oldGlobalPosF;
const QPointF currentGlobalPosF =
QPointF globalPosF =
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.
@ -501,10 +498,10 @@ bool QWindowsTabletSupport::translateTabletPacketEvent()
const QPoint mouseLocation = QWindowsCursor::mousePosition();
if (m_state == PenProximity) {
m_state = PenDown;
m_mode = (mouseLocation - currentGlobalPosF).manhattanLength() > m_absoluteRange
m_mode = (mouseLocation - globalPosF).manhattanLength() > m_absoluteRange
? MouseMode : PenMode;
qCDebug(lcQpaTablet) << __FUNCTION__ << "mode=" << m_mode << "pen:"
<< currentGlobalPosF << "mouse:" << mouseLocation;
<< globalPosF << "mouse:" << mouseLocation;
}
if (m_mode == MouseMode)
globalPosF = mouseLocation;

View File

@ -149,7 +149,6 @@ private:
bool m_tiltSupport;
QVector<QWindowsTabletDeviceData> m_devices;
int m_currentDevice;
QPointF m_oldGlobalPosF;
Mode m_mode = PenMode;
State m_state = PenUp;
};