Windows: Add command line parameter enabling OS-synthesized mouse events from touch.

Applications launched with -platform windows:mousefromtouch will
receive OS-synthesized mouse events.

Task-number: QTBUG-31386
Change-Id: I1c49486589c4a7fa4fb5525f7a5adca09b1cfb89
Reviewed-by: Joerg Bornemann <joerg.bornemann@digia.com>
This commit is contained in:
Friedemann Kleint 2013-09-06 11:16:29 +03:00 committed by The Qt Project
parent c03d0a9846
commit 560de9725d
3 changed files with 15 additions and 7 deletions

View File

@ -342,6 +342,8 @@ static inline unsigned parseOptions(const QStringList &paramList)
}
} else if (param == QLatin1String("gl=gdi")) {
options |= QWindowsIntegration::DisableArb;
} else if (param == QLatin1String("mousefromtouch")) {
options |= QWindowsIntegration::PassOsMouseEventsSynthesizedFromTouch;
}
}
return options;
@ -557,13 +559,15 @@ QVariant QWindowsIntegration::styleHint(QPlatformIntegration::StyleHint hint) co
break;
case QPlatformIntegration::UseRtlExtensions:
return QVariant(d->m_context.useRTLExtensions());
#ifdef Q_OS_WINCE
case QPlatformIntegration::SynthesizeMouseFromTouchEvents:
#ifdef Q_OS_WINCE
// We do not want Qt to synthesize mouse events as Windows also does that.
// Alternatively, Windows-generated touch mouse events can be identified and
// ignored by checking GetMessageExtraInfo() for MI_WP_SIGNATURE (0xFF515700).
return false;
#endif // Q_OS_WINCE
#else // Q_OS_WINCE
return QVariant(!(d->m_options & PassOsMouseEventsSynthesizedFromTouch));
#endif // !Q_OS_WINCE
default:
break;
}

View File

@ -58,7 +58,8 @@ public:
FontDatabaseNative = 0x2,
DisableArb = 0x4,
NoNativeDialogs = 0x8,
XpNativeDialogs = 0x10
XpNativeDialogs = 0x10,
PassOsMouseEventsSynthesizedFromTouch = 0x20 // Pass OS-generated mouse events from touch.
};
explicit QWindowsIntegration(const QStringList &paramList);

View File

@ -169,10 +169,13 @@ bool QWindowsMouseHandler::translateMouseEvent(QWindow *window, HWND hwnd,
#ifndef Q_OS_WINCE
// Check for events synthesized from touch. Lower byte is touch index, 0 means pen.
static const bool passSynthesizedMouseEvents = QWindowsIntegration::instance()->options() & QWindowsIntegration::PassOsMouseEventsSynthesizedFromTouch;
if (!passSynthesizedMouseEvents) {
const quint64 extraInfo = GetMessageExtraInfo();
const bool fromTouch = (extraInfo & signatureMask) == miWpSignature && (extraInfo & 0xff);
if (fromTouch)
return false;
}
#endif // !Q_OS_WINCE
const QPoint winEventPosition(GET_X_LPARAM(msg.lParam), GET_Y_LPARAM(msg.lParam));