Windows QPA: Fix scaling of tablet coordinates for High DPI scaling

Determine the virtual desktop geometry in native pixels from
the QPlatformScreen siblings. Use the platform window to determine
the local position.

Task-number: QTBUG-36937
Change-Id: Ic250f1b41d8e74099558796112dbd70a7e1f6956
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
This commit is contained in:
Friedemann Kleint 2018-03-02 14:59:57 +01:00 committed by Shawn Rutledge
parent f7b8f2e8b5
commit 8abbb6ec72
3 changed files with 16 additions and 2 deletions

View File

@ -318,6 +318,15 @@ void QWindowsScreen::handleChanges(const QWindowsScreenData &newData)
}
}
QRect QWindowsScreen::virtualGeometry(const QPlatformScreen *screen) // cf QScreen::virtualGeometry()
{
QRect result;
const auto siblings = screen->virtualSiblings();
for (const QPlatformScreen *sibling : siblings)
result |= sibling->geometry();
return result;
}
enum OrientationPreference // matching Win32 API ORIENTATION_PREFERENCE
#if defined(Q_COMPILER_CLASS_ENUM) || defined(Q_CC_MSVC)
: DWORD

View File

@ -113,6 +113,8 @@ public:
const QWindowsScreenData &data() const { return m_data; }
static QRect virtualGeometry(const QPlatformScreen *screen);
private:
QWindowsScreenData m_data;
#ifndef QT_NO_CURSOR

View File

@ -421,7 +421,8 @@ bool QWindowsTabletSupport::translateTabletPacketEvent()
// in which case we snap the position to the mouse position.
// It seems there is no way to find out the mode programmatically, the LOGCONTEXT orgX/Y/Ext
// area is always the virtual desktop.
const QRect virtualDesktopArea = QGuiApplication::primaryScreen()->virtualGeometry();
const QRect virtualDesktopArea =
QWindowsScreen::virtualGeometry(QGuiApplication::primaryScreen()->handle());
qCDebug(lcQpaTablet) << __FUNCTION__ << "processing " << packetCount
<< "target:" << QGuiApplicationPrivate::tabletDevicePoint(uniqueId).target;
@ -455,7 +456,9 @@ bool QWindowsTabletSupport::translateTabletPacketEvent()
if (!target)
continue;
const QPoint localPos = target->mapFromGlobal(globalPos);
const QPlatformWindow *platformWindow = target->handle();
Q_ASSERT(platformWindow);
const QPoint localPos = platformWindow->mapFromGlobal(globalPos);
const qreal pressureNew = packet.pkButtons && (currentPointer == QTabletEvent::Pen || currentPointer == QTabletEvent::Eraser) ?
m_devices.at(m_currentDevice).scalePressure(packet.pkNormalPressure) :