summaryrefslogtreecommitdiffstats
path: root/src/plugins/platforms/windows/qwindowscontext.cpp
diff options
context:
space:
mode:
authorFriedemann Kleint <Friedemann.Kleint@qt.io>2020-07-01 14:37:29 +0200
committerFriedemann Kleint <Friedemann.Kleint@qt.io>2020-07-03 07:39:14 +0200
commit3fb31819fd4a209873ef671494cba8bd95dae73a (patch)
treea61b064804d5b2d7010b83cb17f31983885e8a38 /src/plugins/platforms/windows/qwindowscontext.cpp
parent39d99c714bb87bd39e92d85fb1f46c52eb9f8d33 (diff)
Windows QPA: Refactor touch device creation
There was duplicated code in QWindowsMouseHandler::ensureTouchDevice() and QWindowsPointerHandler::ensureTouchDevice() which caused deprecation warnings since the setters of QInputDevice were deprecated. Join the 2 functions into a single creation function and add simple getters and setters. Fix deprecation warnings: qwindowscontext.cpp:357:108: warning: 'void QPointingDevice::setCapabilities(QInputDevice::Capabilities)' is deprecated: Use the constructor qwindowsmousehandler.cpp:132:97: warning: 'void QPointingDevice::setType(QInputDevice::DeviceType)' is deprecated: Use the constructor qwindowsmousehandler.cpp:136:41: warning: 'void QPointingDevice::setCapabilities(QInputDevice::Capabilities)' is deprecated: Use the constructor qwindowsmousehandler.cpp:137:49: warning: 'void QPointingDevice::setMaximumTouchPoints(int)' is deprecated: Use the constructor Change-Id: Iab5385e84d600e45b60f38225175f25ef043c3eb Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io> Reviewed-by: André de la Rocha <andre.rocha@qt.io> Reviewed-by: Oliver Wolff <oliver.wolff@qt.io>
Diffstat (limited to 'src/plugins/platforms/windows/qwindowscontext.cpp')
-rw-r--r--src/plugins/platforms/windows/qwindowscontext.cpp17
1 files changed, 11 insertions, 6 deletions
diff --git a/src/plugins/platforms/windows/qwindowscontext.cpp b/src/plugins/platforms/windows/qwindowscontext.cpp
index f17fc1629b..161777d70f 100644
--- a/src/plugins/platforms/windows/qwindowscontext.cpp
+++ b/src/plugins/platforms/windows/qwindowscontext.cpp
@@ -347,14 +347,19 @@ bool QWindowsContext::initTouch(unsigned integrationOptions)
{
if (d->m_systemInfo & QWindowsContext::SI_SupportsTouch)
return true;
-
- QPointingDevice *touchDevice = (d->m_systemInfo & QWindowsContext::SI_SupportsPointer) ?
- d->m_pointerHandler.ensureTouchDevice() : d->m_mouseHandler.ensureTouchDevice();
+ const bool usePointerHandler = (d->m_systemInfo & QWindowsContext::SI_SupportsPointer) != 0;
+ auto touchDevice = usePointerHandler ? d->m_pointerHandler.touchDevice() : d->m_mouseHandler.touchDevice();
+ if (!touchDevice) {
+ const bool mouseEmulation =
+ (integrationOptions & QWindowsIntegration::DontPassOsMouseEventsSynthesizedFromTouch) == 0;
+ touchDevice = QWindowsPointerHandler::createTouchDevice(mouseEmulation);
+ }
if (!touchDevice)
return false;
-
- if (!(integrationOptions & QWindowsIntegration::DontPassOsMouseEventsSynthesizedFromTouch))
- touchDevice->setCapabilities(touchDevice->capabilities() | QInputDevice::Capability::MouseEmulation);
+ if (usePointerHandler)
+ d->m_pointerHandler.setTouchDevice(touchDevice);
+ else
+ d->m_mouseHandler.setTouchDevice(touchDevice);
QWindowSystemInterface::registerInputDevice(touchDevice);