From cebdd91f8bbebf43fd2ec3c4dd2f49f46172d47e Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Wed, 26 Feb 2014 15:02:30 +0100 Subject: Windows: Add platform plugin parameter for tablet absolute range. Make the range for detecting relative (mouse mode) configureable using -platform windows:tabletabsoluterange=50 Task-number: QTBUG-36937 Change-Id: I44f928e53cb41b246c44554ec7f71bfbdf03c147 Reviewed-by: Arthur Krebsbach Reviewed-by: Laszlo Agocs Reviewed-by: Oliver Wolff --- src/plugins/platforms/windows/qwindowscontext.cpp | 10 ++++++++++ src/plugins/platforms/windows/qwindowscontext.h | 2 ++ src/plugins/platforms/windows/qwindowsintegration.cpp | 13 ++++++++++--- src/plugins/platforms/windows/qwindowstabletsupport.cpp | 4 ++-- src/plugins/platforms/windows/qwindowstabletsupport.h | 4 ++++ 5 files changed, 28 insertions(+), 5 deletions(-) diff --git a/src/plugins/platforms/windows/qwindowscontext.cpp b/src/plugins/platforms/windows/qwindowscontext.cpp index 08f3ab4dbd..f67fb9bc19 100644 --- a/src/plugins/platforms/windows/qwindowscontext.cpp +++ b/src/plugins/platforms/windows/qwindowscontext.cpp @@ -341,6 +341,16 @@ QWindowsContext::~QWindowsContext() m_instance = 0; } +void QWindowsContext::setTabletAbsoluteRange(int a) +{ +#if !defined(QT_NO_TABLETEVENT) && !defined(Q_OS_WINCE) + if (!d->m_tabletSupport.isNull()) + d->m_tabletSupport->setAbsoluteRange(a); +#else + Q_UNUSED(a) +#endif +} + QWindowsContext *QWindowsContext::instance() { return m_instance; diff --git a/src/plugins/platforms/windows/qwindowscontext.h b/src/plugins/platforms/windows/qwindowscontext.h index 1fea059ed9..f5dbd072c7 100644 --- a/src/plugins/platforms/windows/qwindowscontext.h +++ b/src/plugins/platforms/windows/qwindowscontext.h @@ -183,6 +183,8 @@ public: void setWindowCreationContext(const QSharedPointer &ctx); + void setTabletAbsoluteRange(int a); + // Returns a combination of SystemInfoFlags unsigned systemInfo() const; diff --git a/src/plugins/platforms/windows/qwindowsintegration.cpp b/src/plugins/platforms/windows/qwindowsintegration.cpp index e5d9444966..3735865845 100644 --- a/src/plugins/platforms/windows/qwindowsintegration.cpp +++ b/src/plugins/platforms/windows/qwindowsintegration.cpp @@ -143,7 +143,7 @@ struct QWindowsIntegrationPrivate explicit QWindowsIntegrationPrivate(const QStringList ¶mList); ~QWindowsIntegrationPrivate(); - const unsigned m_options; + unsigned m_options; QWindowsContext m_context; QPlatformFontDatabase *m_fontDatabase; #ifndef QT_NO_CLIPBOARD @@ -165,7 +165,8 @@ struct QWindowsIntegrationPrivate QWindowsServices m_services; }; -static inline unsigned parseOptions(const QStringList ¶mList) +static inline unsigned parseOptions(const QStringList ¶mList, + int *tabletAbsoluteRange) { unsigned options = 0; foreach (const QString ¶m, paramList) { @@ -187,15 +188,21 @@ static inline unsigned parseOptions(const QStringList ¶mList) options |= QWindowsIntegration::DontPassOsMouseEventsSynthesizedFromTouch; } else if (param.startsWith(QLatin1String("verbose="))) { QWindowsContext::verbose = param.right(param.size() - 8).toInt(); + } else if (param.startsWith(QLatin1String("tabletabsoluterange="))) { + *tabletAbsoluteRange = param.rightRef(param.size() - 20).toInt(); } } return options; } QWindowsIntegrationPrivate::QWindowsIntegrationPrivate(const QStringList ¶mList) - : m_options(parseOptions(paramList)) + : m_options(0) , m_fontDatabase(0) { + int tabletAbsoluteRange = -1; + m_options = parseOptions(paramList, &tabletAbsoluteRange); + if (tabletAbsoluteRange >= 0) + m_context.setTabletAbsoluteRange(tabletAbsoluteRange); } QWindowsIntegrationPrivate::~QWindowsIntegrationPrivate() diff --git a/src/plugins/platforms/windows/qwindowstabletsupport.cpp b/src/plugins/platforms/windows/qwindowstabletsupport.cpp index 8b863ec43d..484ed9cb05 100644 --- a/src/plugins/platforms/windows/qwindowstabletsupport.cpp +++ b/src/plugins/platforms/windows/qwindowstabletsupport.cpp @@ -159,6 +159,7 @@ bool QWindowsWinTab32DLL::init() QWindowsTabletSupport::QWindowsTabletSupport(HWND window, HCTX context) : m_window(window) , m_context(context) + , m_absoluteRange(20) , m_tiltSupport(false) , m_currentDevice(-1) { @@ -402,7 +403,6 @@ 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. - enum { absoluteRange = 20 }; const QRect virtualDesktopArea = QGuiApplication::primaryScreen()->virtualGeometry(); qCDebug(lcQpaTablet) << __FUNCTION__ << "processing " << packetCount @@ -427,7 +427,7 @@ bool QWindowsTabletSupport::translateTabletPacketEvent() // Positions should be almost the same if we are in absolute // mode. If they are not, use the mouse location. - if ((mouseLocation - globalPos).manhattanLength() > absoluteRange) { + if ((mouseLocation - globalPos).manhattanLength() > m_absoluteRange) { globalPos = mouseLocation; globalPosF = globalPos; } diff --git a/src/plugins/platforms/windows/qwindowstabletsupport.h b/src/plugins/platforms/windows/qwindowstabletsupport.h index 5e29cd9554..527d9dbf37 100644 --- a/src/plugins/platforms/windows/qwindowstabletsupport.h +++ b/src/plugins/platforms/windows/qwindowstabletsupport.h @@ -124,6 +124,9 @@ public: bool translateTabletProximityEvent(WPARAM wParam, LPARAM lParam); bool translateTabletPacketEvent(); + int absoluteRange() const { return m_absoluteRange; } + void setAbsoluteRange(int a) { m_absoluteRange = a; } + private: unsigned options() const; QWindowsTabletDeviceData tabletInit(const quint64 uniqueId, const UINT cursorType) const; @@ -131,6 +134,7 @@ private: static QWindowsWinTab32DLL m_winTab32DLL; const HWND m_window; const HCTX m_context; + int m_absoluteRange; bool m_tiltSupport; QVector m_devices; int m_currentDevice; -- cgit v1.2.3