From 76922a706f0584ce2aa1a0ca758cf0c6196ea729 Mon Sep 17 00:00:00 2001 From: Alexander Volkov Date: Tue, 9 Dec 2014 18:52:24 +0300 Subject: Decide whether to synthesize mouse events on a per device basis Currently Qt uses the QPlatformIntegration::StyleHint SynthesizeMouseFromTouchEvents to check whether to synthesize mouse events from touch events. But not only platform plugins can produce touch events, they can be created by e.g. QTest::touchEvent() and in this case we almost definitely need synthesizing regardless of the platform. This commit introduces a QTouchDevice::MouseEmulation capability which replaces use of the QPlatformIntegration::SynthesizeMouseFromTouchEvents. So it's possible to pass QTouchDevice without this capability to QTest::touchEvent() and be sure that mouse events will be synthesized. Notice that touch pads always emulate mouse events. As a result we can activate some tests which were disabled for specific platform configurations by commits 6c1670d8c273819435867c42725c0db0eee597dc and e9760f1559361c39f269fb89f1ebd01f6ee8378d. Change-Id: Idc82fa4007a095fc1cb5934979361b0023d2b793 Reviewed-by: Laszlo Agocs --- src/plugins/platforms/windows/qwindowsintegration.cpp | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) (limited to 'src/plugins/platforms/windows/qwindowsintegration.cpp') diff --git a/src/plugins/platforms/windows/qwindowsintegration.cpp b/src/plugins/platforms/windows/qwindowsintegration.cpp index 63dcb6abf8..af7ecd5834 100644 --- a/src/plugins/platforms/windows/qwindowsintegration.cpp +++ b/src/plugins/platforms/windows/qwindowsintegration.cpp @@ -227,6 +227,18 @@ QWindowsIntegrationPrivate::QWindowsIntegrationPrivate(const QStringList ¶mL qCDebug(lcQpaWindows) << __FUNCTION__ << "DpiAwareness=" << dpiAwareness <<",Scaling=" << QWindowsScaling::factor(); + + QTouchDevice *touchDevice = m_context.touchDevice(); + if (touchDevice) { +#ifdef Q_OS_WINCE + touchDevice->setCapabilities(touchDevice->capabilities() | QTouchDevice::MouseEmulation); +#else + if (!(m_options & QWindowsIntegration::DontPassOsMouseEventsSynthesizedFromTouch)) { + touchDevice->setCapabilities(touchDevice->capabilities() | QTouchDevice::MouseEmulation); + } +#endif + QWindowSystemInterface::registerTouchDevice(touchDevice); + } } QWindowsIntegrationPrivate::~QWindowsIntegrationPrivate() @@ -496,13 +508,6 @@ QVariant QWindowsIntegration::styleHint(QPlatformIntegration::StyleHint hint) co break; case QPlatformIntegration::UseRtlExtensions: return QVariant(d->m_context.useRTLExtensions()); - case QPlatformIntegration::SynthesizeMouseFromTouchEvents: -#ifdef Q_OS_WINCE - // We do not want Qt to synthesize mouse events as Windows also does that. - return false; -#else // Q_OS_WINCE - return QVariant(bool(d->m_options & DontPassOsMouseEventsSynthesizedFromTouch)); -#endif // !Q_OS_WINCE default: break; } -- cgit v1.2.3