From ec2d71f0e4af0e0c286f0027d0242f456fdb2bb6 Mon Sep 17 00:00:00 2001 From: "Bradley T. Hughes" Date: Thu, 23 Apr 2009 17:57:46 +0200 Subject: Fix tests/manual/qtouchevent by choking mouse events even for ignored TouchUpdate and TouchEnd events. The behavior we want is that no mouse events are sent if the widget accepts the TouchBegin. --- src/gui/kernel/qapplication_p.h | 1 + src/gui/kernel/qapplication_win.cpp | 19 +++++++++++++++++-- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/src/gui/kernel/qapplication_p.h b/src/gui/kernel/qapplication_p.h index ce7110d..91857ec 100644 --- a/src/gui/kernel/qapplication_p.h +++ b/src/gui/kernel/qapplication_p.h @@ -429,6 +429,7 @@ public: #endif QPointer currentMultitouchWidget; + bool currentMultitouchWidgetAcceptedTouchBegin; static void updateTouchPointsForWidget(QWidget *widget, QTouchEvent *touchEvent); #if defined(Q_WS_WIN) diff --git a/src/gui/kernel/qapplication_win.cpp b/src/gui/kernel/qapplication_win.cpp index 4878ea7..5a4efd6 100644 --- a/src/gui/kernel/qapplication_win.cpp +++ b/src/gui/kernel/qapplication_win.cpp @@ -4003,6 +4003,7 @@ void QApplicationPrivate::initializeMultitouch() CloseTouchInputHandle = static_cast(library.resolve("CloseTouchInputHandle")); currentMultitouchWidget = 0; + currentMultitouchWidgetAcceptedTouchBegin = false; touchInputIDToTouchPointID.clear(); allTouchPoints.clear(); currentTouchPoints.clear(); @@ -4106,6 +4107,9 @@ bool QApplicationPrivate::translateTouchEvent(const MSG &msg) if (!child) child = window; currentMultitouchWidget = child; + // if the TouchBegin handler recurses, we assume that means the event + // has been implicitly accepted and continue to send touch events + currentMultitouchWidgetAcceptedTouchBegin = true; } } @@ -4131,8 +4135,19 @@ bool QApplicationPrivate::translateTouchEvent(const MSG &msg) q->keyboardModifiers(), activeTouchPoints); updateTouchPointsForWidget(widget, &touchEvent); - bool res = QApplication::sendSpontaneousEvent(widget, &touchEvent); - return (qt_tabletChokeMouse = res && touchEvent.isAccepted()); + if (sendTouchBegin) { + bool res = QApplication::sendSpontaneousEvent(widget, &touchEvent); + qt_tabletChokeMouse + = currentMultitouchWidgetAcceptedTouchBegin + = (res && touchEvent.isAccepted()); + } else if (currentMultitouchWidgetAcceptedTouchBegin) { + (void) QApplication::sendSpontaneousEvent(widget, &touchEvent); + qt_tabletChokeMouse = true; + } else { + qt_tabletChokeMouse = false; + } + + return qt_tabletChokeMouse; } return false; -- cgit v0.12