summaryrefslogtreecommitdiffstats
path: root/src/plugins/platforms/windows/qwindowspointerhandler.cpp
diff options
context:
space:
mode:
authorFriedemann Kleint <Friedemann.Kleint@qt.io>2020-10-16 11:50:27 +0200
committerFriedemann Kleint <Friedemann.Kleint@qt.io>2020-10-26 10:14:05 +0200
commite3470a98e98c8a789a4cb298a0afaacf0cc62ce9 (patch)
tree346f0960c073bfb87fd2969fc89dc693fab48e96 /src/plugins/platforms/windows/qwindowspointerhandler.cpp
parentd9edad81177954c89619b6dee70ca76f2f4709ef (diff)
Windows QPA: Use a QSharedPointer for the touch device
For reasons of symmetry with the tablet devices. As a drive by, give it more distinct IDs. Task-number: QTBUG-46412 Change-Id: Ie667621246b26db6fdda84c5ff2455fe38633cb3 Reviewed-by: Oliver Wolff <oliver.wolff@qt.io>
Diffstat (limited to 'src/plugins/platforms/windows/qwindowspointerhandler.cpp')
-rw-r--r--src/plugins/platforms/windows/qwindowspointerhandler.cpp19
1 files changed, 11 insertions, 8 deletions
diff --git a/src/plugins/platforms/windows/qwindowspointerhandler.cpp b/src/plugins/platforms/windows/qwindowspointerhandler.cpp
index 41f17f5c3bf..7c021700f29 100644
--- a/src/plugins/platforms/windows/qwindowspointerhandler.cpp
+++ b/src/plugins/platforms/windows/qwindowspointerhandler.cpp
@@ -82,7 +82,6 @@ qint64 QWindowsPointerHandler::m_nextInputDeviceId = 1;
QWindowsPointerHandler::~QWindowsPointerHandler()
{
- delete m_touchDevice;
}
bool QWindowsPointerHandler::translatePointerEvent(QWindow *window, HWND hwnd, QtWindows::WindowsEventType et, MSG msg, LRESULT *result)
@@ -320,7 +319,7 @@ static bool isValidWheelReceiver(QWindow *candidate)
return false;
}
-QPointingDevice *QWindowsPointerHandler::createTouchDevice(bool mouseEmulation)
+QWindowsPointerHandler::QPointingDevicePtr QWindowsPointerHandler::createTouchDevice(bool mouseEmulation)
{
const int digitizers = GetSystemMetrics(SM_DIGITIZER);
if (!(digitizers & (NID_INTEGRATED_TOUCH | NID_EXTERNAL_TOUCH)))
@@ -339,15 +338,19 @@ QPointingDevice *QWindowsPointerHandler::createTouchDevice(bool mouseEmulation)
capabilities.setFlag(QInputDevice::Capability::MouseEmulation);
}
- qCDebug(lcQpaEvents) << "Digitizers:" << Qt::hex << Qt::showbase << (digitizers & ~NID_READY)
+ const int flags = digitizers & ~NID_READY;
+ qCDebug(lcQpaEvents) << "Digitizers:" << Qt::hex << Qt::showbase << flags
<< "Ready:" << (digitizers & NID_READY) << Qt::dec << Qt::noshowbase
<< "Tablet PC:" << tabletPc << "Max touch points:" << maxTouchPoints << "Capabilities:" << capabilities;
const int buttonCount = type == QInputDevice::DeviceType::TouchScreen ? 1 : 3;
// TODO: use system-provided name and device ID rather than empty-string and m_nextInputDeviceId
- return new QPointingDevice(QString(), m_nextInputDeviceId++,
- type, QPointingDevice::PointerType::Finger,
- capabilities, maxTouchPoints, buttonCount);
+ const qint64 systemId = m_nextInputDeviceId++ | (qint64(flags << 2));
+ auto d = new QPointingDevice(QString(), systemId, type,
+ QPointingDevice::PointerType::Finger,
+ capabilities, maxTouchPoints, buttonCount,
+ QString(), QPointingDeviceUniqueId::fromNumericId(systemId));
+ return QPointingDevicePtr(d);
}
void QWindowsPointerHandler::clearEvents()
@@ -466,7 +469,7 @@ bool QWindowsPointerHandler::translateTouchEvent(QWindow *window, HWND hwnd,
return false;
if (msg.message == WM_POINTERCAPTURECHANGED) {
- QWindowSystemInterface::handleTouchCancelEvent(window, m_touchDevice,
+ QWindowSystemInterface::handleTouchCancelEvent(window, m_touchDevice.data(),
QWindowsKeyMapper::queryKeyboardModifiers());
m_lastTouchPositions.clear();
return true;
@@ -550,7 +553,7 @@ bool QWindowsPointerHandler::translateTouchEvent(QWindow *window, HWND hwnd,
if (allStates == QEventPoint::State::Released)
m_touchInputIDToTouchPointID.clear();
- QWindowSystemInterface::handleTouchEvent(window, m_touchDevice, touchPoints,
+ QWindowSystemInterface::handleTouchEvent(window, m_touchDevice.data(), touchPoints,
QWindowsKeyMapper::queryKeyboardModifiers());
return false; // Allow mouse messages to be generated.
}