From 520a67e50ed7717518d3072f8568de00b791f20a Mon Sep 17 00:00:00 2001 From: "Bradley T. Hughes" Date: Wed, 29 Apr 2009 15:44:08 +0200 Subject: Use a widget attribute to keep track of whether or not TouchBegin has been accepted --- src/corelib/global/qnamespace.h | 1 + src/gui/kernel/qapplication.cpp | 1 + src/gui/kernel/qapplication_p.h | 1 - src/gui/kernel/qapplication_win.cpp | 12 +++++------- 4 files changed, 7 insertions(+), 8 deletions(-) diff --git a/src/corelib/global/qnamespace.h b/src/corelib/global/qnamespace.h index b73a873..15da2d6 100644 --- a/src/corelib/global/qnamespace.h +++ b/src/corelib/global/qnamespace.h @@ -486,6 +486,7 @@ public: WA_TranslucentBackground = 120, WA_AcceptTouchEvents = 121, + WA_AcceptedTouchBeginEvent = 122, // Add new attributes before this line WA_AttributeCount diff --git a/src/gui/kernel/qapplication.cpp b/src/gui/kernel/qapplication.cpp index 4e61f66..bc9b827 100644 --- a/src/gui/kernel/qapplication.cpp +++ b/src/gui/kernel/qapplication.cpp @@ -4013,6 +4013,7 @@ bool QApplication::notify(QObject *receiver, QEvent *e) res = widget->testAttribute(Qt::WA_AcceptTouchEvents) && d->notify_helper(widget, touchEvent); eventAccepted = touchEvent->isAccepted(); + widget->setAttribute(Qt::WA_AcceptedTouchBeginEvent, res && eventAccepted); touchEvent->spont = false; if (res && eventAccepted) { // the first widget to accept the TouchBegin gets an implicit grab. diff --git a/src/gui/kernel/qapplication_p.h b/src/gui/kernel/qapplication_p.h index 91857ec..ce7110d 100644 --- a/src/gui/kernel/qapplication_p.h +++ b/src/gui/kernel/qapplication_p.h @@ -429,7 +429,6 @@ 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 7e07104..f1fb0a4 100644 --- a/src/gui/kernel/qapplication_win.cpp +++ b/src/gui/kernel/qapplication_win.cpp @@ -4000,7 +4000,6 @@ void QApplicationPrivate::initializeMultitouch() CloseTouchInputHandle = static_cast(library.resolve("CloseTouchInputHandle")); currentMultitouchWidget = 0; - currentMultitouchWidgetAcceptedTouchBegin = false; touchInputIDToTouchPointID.clear(); allTouchPoints.clear(); currentTouchPoints.clear(); @@ -4106,7 +4105,7 @@ bool QApplicationPrivate::translateTouchEvent(const MSG &msg) 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; + currentMultitouchWidget->setAttribute(Qt::WA_AcceptedTouchBeginEvent); } } @@ -4133,11 +4132,10 @@ bool QApplicationPrivate::translateTouchEvent(const MSG &msg) updateTouchPointsForWidget(widget, &touchEvent); if (sendTouchBegin) { - bool res = QApplication::sendSpontaneousEvent(widget, &touchEvent); - qt_tabletChokeMouse - = currentMultitouchWidgetAcceptedTouchBegin - = (res && touchEvent.isAccepted()); - } else if (currentMultitouchWidgetAcceptedTouchBegin) { + bool res = QApplication::sendSpontaneousEvent(widget, &touchEvent) + && touchEvent.isAccepted(); + qt_tabletChokeMouse = res; + } else if (widget->testAttribute(Qt::WA_AcceptedTouchBeginEvent)) { (void) QApplication::sendSpontaneousEvent(widget, &touchEvent); qt_tabletChokeMouse = true; } else { -- cgit v0.12