Windows QPA: Fix handling of mouse messages synthesized by the OS

The old handler only marked mouse events associated with mouse messages
synthesized by the OS with Qt::MouseEventSynthesizedBySystem when these
messages resulted from touch screen, not tablet input. Quick seems to
depend on this behavior.

Fixes: QTBUG-76617
Change-Id: Ib863d73ae9325f9a19d8a175817fef4e82f7df0b
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
This commit is contained in:
André de la Rocha 2019-07-10 18:09:38 +02:00 committed by Andre de la Rocha
parent de8bd9ec6b
commit 786c588171
2 changed files with 8 additions and 4 deletions

View File

@ -80,13 +80,12 @@ bool QWindowsPointerHandler::translatePointerEvent(QWindow *window, HWND hwnd, Q
*result = 0; *result = 0;
const quint32 pointerId = GET_POINTERID_WPARAM(msg.wParam); const quint32 pointerId = GET_POINTERID_WPARAM(msg.wParam);
POINTER_INPUT_TYPE pointerType; if (!QWindowsContext::user32dll.getPointerType(pointerId, &m_pointerType)) {
if (!QWindowsContext::user32dll.getPointerType(pointerId, &pointerType)) {
qWarning() << "GetPointerType() failed:" << qt_error_string(); qWarning() << "GetPointerType() failed:" << qt_error_string();
return false; return false;
} }
switch (pointerType) { switch (m_pointerType) {
case QT_PT_POINTER: case QT_PT_POINTER:
case QT_PT_MOUSE: case QT_PT_MOUSE:
case QT_PT_TOUCHPAD: { case QT_PT_TOUCHPAD: {
@ -728,7 +727,11 @@ bool QWindowsPointerHandler::translateMouseEvent(QWindow *window,
} }
Qt::MouseEventSource source = Qt::MouseEventNotSynthesized; Qt::MouseEventSource source = Qt::MouseEventNotSynthesized;
if (isMouseEventSynthesizedFromPenOrTouch()) { // Following the logic of the old mouse handler, only events synthesized
// for touch screen are marked as such. On some systems, using the bit 7 of
// the extra msg info for checking if synthesized for touch does not work,
// so we use the pointer type of the last pointer message.
if (isMouseEventSynthesizedFromPenOrTouch() && m_pointerType == QT_PT_TOUCH) {
if (QWindowsIntegration::instance()->options() & QWindowsIntegration::DontPassOsMouseEventsSynthesizedFromTouch) if (QWindowsIntegration::instance()->options() & QWindowsIntegration::DontPassOsMouseEventsSynthesizedFromTouch)
return false; return false;
source = Qt::MouseEventSynthesizedBySystem; source = Qt::MouseEventSynthesizedBySystem;

View File

@ -82,6 +82,7 @@ private:
bool m_needsEnterOnPointerUpdate = false; bool m_needsEnterOnPointerUpdate = false;
QEvent::Type m_lastEventType = QEvent::None; QEvent::Type m_lastEventType = QEvent::None;
Qt::MouseButton m_lastEventButton = Qt::NoButton; Qt::MouseButton m_lastEventButton = Qt::NoButton;
DWORD m_pointerType = 0;
}; };
QT_END_NAMESPACE QT_END_NAMESPACE