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 <Arthur.Krebsbach@Wacom.com>
Reviewed-by: Laszlo Agocs <laszlo.agocs@digia.com>
Reviewed-by: Oliver Wolff <oliver.wolff@digia.com>
This commit is contained in:
Friedemann Kleint 2014-02-26 15:02:30 +01:00 committed by The Qt Project
parent bbc4cc4a47
commit cebdd91f8b
5 changed files with 28 additions and 5 deletions

View File

@ -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;

View File

@ -183,6 +183,8 @@ public:
void setWindowCreationContext(const QSharedPointer<QWindowCreationContext> &ctx);
void setTabletAbsoluteRange(int a);
// Returns a combination of SystemInfoFlags
unsigned systemInfo() const;

View File

@ -143,7 +143,7 @@ struct QWindowsIntegrationPrivate
explicit QWindowsIntegrationPrivate(const QStringList &paramList);
~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 &paramList)
static inline unsigned parseOptions(const QStringList &paramList,
int *tabletAbsoluteRange)
{
unsigned options = 0;
foreach (const QString &param, paramList) {
@ -187,15 +188,21 @@ static inline unsigned parseOptions(const QStringList &paramList)
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 &paramList)
: 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()

View File

@ -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;
}

View File

@ -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<QWindowsTabletDeviceData> m_devices;
int m_currentDevice;