diff --git a/src/gui/kernel/qguiapplication.cpp b/src/gui/kernel/qguiapplication.cpp index a1c9af4..29982bf 100644 --- a/src/gui/kernel/qguiapplication.cpp +++ b/src/gui/kernel/qguiapplication.cpp @@ -1849,8 +1849,10 @@ void QGuiApplicationPrivate::processTouchEvent(QWindowSystemInterfacePrivate::To { QGuiApplicationPrivate *d = self; modifier_buttons = e->modifiers; + qDebug() << "QGuiApplicationPrivate" << __FUNCTION__ << e->type; if (e->touchType == QEvent::TouchCancel) { + qDebug() << __FUNCTION__ << "QEvent::TouchCancel"; // The touch sequence has been canceled (e.g. by the compositor). // Send the TouchCancel to all windows with active touches and clean up. QTouchEvent touchEvent(QEvent::TouchCancel, e->device, e->modifiers); @@ -1867,6 +1869,7 @@ void QGuiApplicationPrivate::processTouchEvent(QWindowSystemInterfacePrivate::To for (QSet::const_iterator winIt = windowsNeedingCancel.constBegin(), winItEnd = windowsNeedingCancel.constEnd(); winIt != winItEnd; ++winIt) { touchEvent.setWindow(*winIt); + qDebug() << __FUNCTION__ << "sending touch cancel to " << *winIt << &touchEvent; QGuiApplication::sendSpontaneousEvent(*winIt, &touchEvent); } if (!self->synthesizedMousePoints.isEmpty() && !e->synthetic) { @@ -1874,6 +1877,7 @@ void QGuiApplicationPrivate::processTouchEvent(QWindowSystemInterfacePrivate::To synthItEnd = self->synthesizedMousePoints.constEnd(); synthIt != synthItEnd; ++synthIt) { if (!synthIt->window) continue; + qDebug() << __FUNCTION__ << "touch cancel: fale mouse " << synthIt->window.data(); QWindowSystemInterfacePrivate::MouseEvent fake(synthIt->window.data(), e->timestamp, synthIt->pos, @@ -1891,22 +1895,24 @@ void QGuiApplicationPrivate::processTouchEvent(QWindowSystemInterfacePrivate::To } // Prevent sending ill-formed event sequences: Cancel can only be followed by a Begin. - if (self->lastTouchType == QEvent::TouchCancel && e->touchType != QEvent::TouchBegin) + if (self->lastTouchType == QEvent::TouchCancel && e->touchType != QEvent::TouchBegin) { + qDebug() << __FUNCTION__ << "ill formed sequence, return"; return; + } self->lastTouchType = e->touchType; QWindow *window = e->window.data(); typedef QPair > StatesAndTouchPoints; QHash windowsNeedingEvents; - + qDebug() << __FUNCTION__ ; for (int i = 0; i < e->points.count(); ++i) { QTouchEvent::TouchPoint touchPoint = e->points.at(i); // explicitly detach from the original touch point that we got, so even // if the touchpoint structs are reused, we will make a copy that we'll // deliver to the user (which might want to store the struct for later use). touchPoint.d = touchPoint.d->detach(); - + qDebug() << __FUNCTION__ << "processing " << i << touchPoint.state(); // update state QPointer w; QTouchEvent::TouchPoint previousTouchPoint; @@ -1992,8 +1998,10 @@ void QGuiApplicationPrivate::processTouchEvent(QWindowSystemInterfacePrivate::To maskAndPoints.second.append(touchPoint); } - if (windowsNeedingEvents.isEmpty()) + if (windowsNeedingEvents.isEmpty()) { + qDebug() << __FUNCTION__ << "no window, return"; return; + } QHash::ConstIterator it = windowsNeedingEvents.constBegin(); const QHash::ConstIterator end = windowsNeedingEvents.constEnd(); @@ -2028,7 +2036,6 @@ void QGuiApplicationPrivate::processTouchEvent(QWindowSystemInterfacePrivate::To it.value().second); touchEvent.setTimestamp(e->timestamp); touchEvent.setWindow(w); - const int pointCount = touchEvent.touchPoints().count(); for (int i = 0; i < pointCount; ++i) { QTouchEvent::TouchPoint &touchPoint = touchEvent._touchPoints[i]; @@ -2045,7 +2052,7 @@ void QGuiApplicationPrivate::processTouchEvent(QWindowSystemInterfacePrivate::To touchPoint.d->lastPos = w->mapFromGlobal(touchPoint.lastScreenPos().toPoint()) + delta; } } - + qDebug() << __FUNCTION__ << "sending touch to " <synthetic && !touchEvent.isAccepted() && qApp->testAttribute(Qt::AA_SynthesizeMouseForUnhandledTouchEvents)) { // exclude touchpads as those generate their own mouse events @@ -2064,6 +2071,7 @@ void QGuiApplicationPrivate::processTouchEvent(QWindowSystemInterfacePrivate::To if (b != Qt::NoButton) self->synthesizedMousePoints.insert(w, SynthesizedMouseData( touchPoint.pos(), touchPoint.screenPos(), w)); + qDebug() << __FUNCTION__ << "sending fake mouse to " <timestamp, touchPoint.pos(), touchPoint.screenPos(), diff --git a/src/gui/kernel/qwindowsysteminterface.cpp b/src/gui/kernel/qwindowsysteminterface.cpp index d2add91..5f1a730 100644 --- a/src/gui/kernel/qwindowsysteminterface.cpp +++ b/src/gui/kernel/qwindowsysteminterface.cpp @@ -385,18 +385,22 @@ void QWindowSystemInterfacePrivate::handleWindowSystemEvent(QWindowSystemInterfa void QWindowSystemInterface::registerTouchDevice(QTouchDevice *device) { + + qDebug() << __FUNCTION__ << device->name(); QTouchDevicePrivate::registerDevice(device); } void QWindowSystemInterface::handleTouchEvent(QWindow *w, QTouchDevice *device, const QList &points, Qt::KeyboardModifiers mods) { + qDebug() << "QWindowSystemInterface" << __FUNCTION__ ; unsigned long time = QWindowSystemInterfacePrivate::eventTime.elapsed(); handleTouchEvent(w, time, device, points, mods); } QList QWindowSystemInterfacePrivate::convertTouchPoints(const QList &points, QEvent::Type *type) { + qDebug() << "QWindowSystemInterface" << __FUNCTION__ << points.size(); QList touchPoints; Qt::TouchPointStates states; QTouchEvent::TouchPoint p; @@ -440,6 +444,7 @@ QList QWindowSystemInterfacePrivate::convertTouchPoints void QWindowSystemInterface::handleTouchEvent(QWindow *tlw, ulong timestamp, QTouchDevice *device, const QList &points, Qt::KeyboardModifiers mods) { + qDebug() << "QWindowSystemInterface" << __FUNCTION__ << points.size(); if (!points.size()) // Touch events must have at least one point return; @@ -457,6 +462,7 @@ void QWindowSystemInterface::handleTouchEvent(QWindow *tlw, ulong timestamp, QTo void QWindowSystemInterface::handleTouchCancelEvent(QWindow *w, QTouchDevice *device, Qt::KeyboardModifiers mods) { + qDebug() << "QWindowSystemInterface" << __FUNCTION__ ; unsigned long time = QWindowSystemInterfacePrivate::eventTime.elapsed(); handleTouchCancelEvent(w, time, device, mods); } @@ -464,6 +470,7 @@ void QWindowSystemInterface::handleTouchCancelEvent(QWindow *w, QTouchDevice *de void QWindowSystemInterface::handleTouchCancelEvent(QWindow *w, ulong timestamp, QTouchDevice *device, Qt::KeyboardModifiers mods) { + qDebug() << "QWindowSystemInterface" << __FUNCTION__ ; QWindowSystemInterfacePrivate::TouchEvent *e = new QWindowSystemInterfacePrivate::TouchEvent(w, timestamp, QEvent::TouchCancel, device, QList(), mods); diff --git a/src/plugins/platforms/windows/qwindowsmousehandler.cpp b/src/plugins/platforms/windows/qwindowsmousehandler.cpp index dd16ea1..b409755 100644 --- a/src/plugins/platforms/windows/qwindowsmousehandler.cpp +++ b/src/plugins/platforms/windows/qwindowsmousehandler.cpp @@ -380,10 +380,14 @@ bool QWindowsMouseHandler::translateTouchEvent(QWindow *window, HWND, QtWindows::WindowsEventType, MSG msg, LRESULT *) { + static int tec = 0; #ifndef Q_OS_WINCE typedef QWindowSystemInterface::TouchPoint QTouchPoint; typedef QList QTouchPointList; + + qDebug() << "QWindowsMouseHandler" << __FUNCTION__ << window << msg.message; + const QRect screenGeometry = window->screen()->geometry(); const int winTouchPointCount = msg.wParam; @@ -398,6 +402,15 @@ bool QWindowsMouseHandler::translateTouchEvent(QWindow *window, HWND, QWindowsContext::user32dll.getTouchInputInfo((HANDLE) msg.lParam, msg.wParam, winTouchInputs.data(), sizeof(TOUCHINPUT)); for (int i = 0; i < winTouchPointCount; ++i) { + QString s; + if ( winTouchInputs[i].dwFlags & TOUCHEVENTF_DOWN) + s+=QLatin1String("down"); + if ( winTouchInputs[i].dwFlags & TOUCHEVENTF_UP) + s+=QLatin1String(" up"); + if ( winTouchInputs[i].dwFlags & TOUCHEVENTF_MOVE) + s+=QLatin1String(" move"); + qDebug() << "QWindowsMouseHandler" << __FUNCTION__ << "processing: " << i << winTouchPointCount + << s << hex << winTouchInputs[i].dwFlags << dec ; const TOUCHINPUT &winTouchInput = winTouchInputs[i]; int id = m_touchInputIDToTouchPointID.value(winTouchInput.dwID, -1); if (id == -1) { @@ -452,6 +465,7 @@ bool QWindowsMouseHandler::translateTouchEvent(QWindow *window, HWND, QWindowSystemInterface::registerTouchDevice(m_touchDevice); } + qDebug() << "QWindowsMouseHandler" << __FUNCTION__ << "sending touch event #" << ++tec << "pts: " << touchPoints.size(); QWindowSystemInterface::handleTouchEvent(window, m_touchDevice, touchPoints); diff --git a/src/widgets/kernel/qapplication.cpp b/src/widgets/kernel/qapplication.cpp index ac25d3e..1218211 100644 --- a/src/widgets/kernel/qapplication.cpp +++ b/src/widgets/kernel/qapplication.cpp @@ -3238,6 +3238,7 @@ bool QApplication::notify(QObject *receiver, QEvent *e) // If the touch event wasn't accepted, synthesize a mouse event and see if the widget wants it. if (!touchEvent->isAccepted()) { + qDebug() << __FUNCTION__ <<"Widget does not accept touch" << widget << touchEvent; res = d->translateTouchToMouse(widget, touchEvent); eventAccepted = touchEvent->isAccepted(); if (eventAccepted) @@ -3846,6 +3847,7 @@ void QApplicationPrivate::translateRawTouchEvent(QWidget *window, const QList &touchPoints, ulong timestamp) { + qDebug() << "QApplicationPrivate::" << __FUNCTION__ << touchPoints.size(); QApplicationPrivate *d = self; typedef QPair > StatesAndTouchPoints; QHash widgetsNeedingEvents; @@ -3856,6 +3858,7 @@ void QApplicationPrivate::translateRawTouchEvent(QWidget *window, // if the touchpoint structs are reused, we will make a copy that we'll // deliver to the user (which might want to store the struct for later use). touchPoint.d = touchPoint.d->detach(); + qDebug() << "QApplicationPrivate::" << __FUNCTION__ << "processing" << i; // update state QPointer target; @@ -3880,6 +3883,8 @@ void QApplicationPrivate::translateRawTouchEvent(QWidget *window, target = window; } + qDebug() << "QApplicationPrivate::" << __FUNCTION__ + << "SCREEN: "<< (device->type() == QTouchDevice::TouchScreen); if (device->type() == QTouchDevice::TouchScreen) { QWidget *closestWidget = d->findClosestTouchPointTarget(device, touchPoint.screenPos()); QWidget *widget = static_cast(target.data()); @@ -3902,15 +3907,21 @@ void QApplicationPrivate::translateRawTouchEvent(QWidget *window, maskAndPoints.second.append(touchPoint); } - if (widgetsNeedingEvents.isEmpty()) + qDebug() << "QApplicationPrivate::" << __FUNCTION__ << "widgetsNeedingEvents" << widgetsNeedingEvents.keys(); + if (widgetsNeedingEvents.isEmpty()) { + qDebug() << "QApplicationPrivate::" << __FUNCTION__ << "no widgets, return"; return; + } QHash::ConstIterator it = widgetsNeedingEvents.constBegin(); const QHash::ConstIterator end = widgetsNeedingEvents.constEnd(); for (; it != end; ++it) { + QWidget *widget = it.key(); - if (!QApplicationPrivate::tryModalHelper(widget, 0)) + if (!QApplicationPrivate::tryModalHelper(widget, 0)) { + qDebug() << "QApplicationPrivate::" << __FUNCTION__ << "tryModalHelper FAIL"; continue; + } QEvent::Type eventType; switch (it.value().first) { @@ -3937,6 +3948,7 @@ void QApplicationPrivate::translateRawTouchEvent(QWidget *window, touchEvent.setTimestamp(timestamp); touchEvent.setWindow(window->windowHandle()); touchEvent.setTarget(widget); + qDebug() << "QApplicationPrivate::" << __FUNCTION__ << "looking at " << widget << &touchEvent; switch (touchEvent.type()) { case QEvent::TouchBegin: @@ -3944,6 +3956,7 @@ void QApplicationPrivate::translateRawTouchEvent(QWidget *window, // if the TouchBegin handler recurses, we assume that means the event // has been implicitly accepted and continue to send touch events widget->setAttribute(Qt::WA_WState_AcceptedTouchBeginEvent); + qDebug() << "QApplicationPrivate::" << __FUNCTION__ << "sending begin" << widget << &touchEvent; (void ) QApplication::sendSpontaneousEvent(widget, &touchEvent); break; } @@ -3951,7 +3964,10 @@ void QApplicationPrivate::translateRawTouchEvent(QWidget *window, if (widget->testAttribute(Qt::WA_WState_AcceptedTouchBeginEvent)) { if (touchEvent.type() == QEvent::TouchEnd) widget->setAttribute(Qt::WA_WState_AcceptedTouchBeginEvent, false); + qDebug() << "QApplicationPrivate::" << __FUNCTION__ << widget << "sending end" << &touchEvent; (void) QApplication::sendSpontaneousEvent(widget, &touchEvent); + } else { + qDebug() << "QApplicationPrivate::" << __FUNCTION__ << "NonBegin && !Qt::WA_WState_AcceptedTouchBeginEvent" << widget; } break; } @@ -3960,6 +3976,7 @@ void QApplicationPrivate::translateRawTouchEvent(QWidget *window, void QApplicationPrivate::translateTouchCancel(QTouchDevice *device, ulong timestamp) { + qDebug() << "QApplicationPrivate::" << __FUNCTION__ ; QTouchEvent touchEvent(QEvent::TouchCancel, device, QApplication::keyboardModifiers()); touchEvent.setTimestamp(timestamp); QHash::const_iterator it @@ -3976,6 +3993,7 @@ void QApplicationPrivate::translateTouchCancel(QTouchDevice *device, ulong times QWidget *widget = *widIt; touchEvent.setWindow(widget->windowHandle()); touchEvent.setTarget(widget); + qDebug() << "QApplicationPrivate::" << __FUNCTION__ << "sending cancel" << widget << &touchEvent; QApplication::sendSpontaneousEvent(widget, &touchEvent); } } diff --git a/src/widgets/kernel/qwidgetwindow.cpp b/src/widgets/kernel/qwidgetwindow.cpp index ddb570d..d6019fd 100644 --- a/src/widgets/kernel/qwidgetwindow.cpp +++ b/src/widgets/kernel/qwidgetwindow.cpp @@ -473,6 +473,7 @@ void QWidgetWindow::handleMouseEvent(QMouseEvent *event) void QWidgetWindow::handleTouchEvent(QTouchEvent *event) { + qDebug() << "QWidgetWindow::handleTouchEvent" <type() == QEvent::TouchCancel) QApplicationPrivate::translateTouchCancel(event->device(), event->timestamp()); else