diff --git a/src/gui/kernel/qguiapplication.cpp b/src/gui/kernel/qguiapplication.cpp index 2a1d7e3..c8fa1e5 100644 --- a/src/gui/kernel/qguiapplication.cpp +++ b/src/gui/kernel/qguiapplication.cpp @@ -1888,8 +1888,10 @@ void QGuiApplicationPrivate::processTouchEvent(QWindowSystemInterfacePrivate::To { QGuiApplicationPrivate *d = self; modifier_buttons = e->modifiers; + qDebug() << "QGuiApplicationPrivate" << Q_FUNC_INFO << e->type; if (e->touchType == QEvent::TouchCancel) { + qDebug() << Q_FUNC_INFO << "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); @@ -1906,6 +1908,7 @@ void QGuiApplicationPrivate::processTouchEvent(QWindowSystemInterfacePrivate::To for (QSet::const_iterator winIt = windowsNeedingCancel.constBegin(), winItEnd = windowsNeedingCancel.constEnd(); winIt != winItEnd; ++winIt) { touchEvent.setWindow(*winIt); + qDebug() << Q_FUNC_INFO << "sending touch cancel to " << *winIt << &touchEvent; QGuiApplication::sendSpontaneousEvent(*winIt, &touchEvent); } if (!self->synthesizedMousePoints.isEmpty() && !e->synthetic) { @@ -1913,6 +1916,7 @@ void QGuiApplicationPrivate::processTouchEvent(QWindowSystemInterfacePrivate::To synthItEnd = self->synthesizedMousePoints.constEnd(); synthIt != synthItEnd; ++synthIt) { if (!synthIt->window) continue; + qDebug() << Q_FUNC_INFO << "touch cancel: fale mouse " << synthIt->window.data(); QWindowSystemInterfacePrivate::MouseEvent fake(synthIt->window.data(), e->timestamp, synthIt->pos, @@ -1930,22 +1934,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() << Q_FUNC_INFO << "ill formed sequence, return"; return; + } self->lastTouchType = e->touchType; QWindow *window = e->window.data(); typedef QPair > StatesAndTouchPoints; QHash windowsNeedingEvents; - + qDebug() << Q_FUNC_INFO ; 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() << Q_FUNC_INFO << "processing " << i << touchPoint.state(); // update state QPointer w; QTouchEvent::TouchPoint previousTouchPoint; @@ -2031,8 +2037,10 @@ void QGuiApplicationPrivate::processTouchEvent(QWindowSystemInterfacePrivate::To maskAndPoints.second.append(touchPoint); } - if (windowsNeedingEvents.isEmpty()) + if (windowsNeedingEvents.isEmpty()) { + qDebug() << Q_FUNC_INFO << "no window, return"; return; + } QHash::ConstIterator it = windowsNeedingEvents.constBegin(); const QHash::ConstIterator end = windowsNeedingEvents.constEnd(); @@ -2067,7 +2075,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]; @@ -2084,8 +2091,11 @@ void QGuiApplicationPrivate::processTouchEvent(QWindowSystemInterfacePrivate::To touchPoint.d->lastPos = w->mapFromGlobal(touchPoint.lastScreenPos().toPoint()) + delta; } } - + qDebug() << Q_FUNC_INFO << "sending touch to " <synthetic << "Touch not accepted: " + << !touchEvent.isAccepted() << "Synth hint" << synthesizeMouseFromTouchEventsEnabled(); if (!e->synthetic && !touchEvent.isAccepted() && synthesizeMouseFromTouchEventsEnabled()) { // exclude touchpads as those generate their own mouse events if (touchEvent.device()->type() != QTouchDevice::TouchPad) { @@ -2103,6 +2113,7 @@ void QGuiApplicationPrivate::processTouchEvent(QWindowSystemInterfacePrivate::To if (b != Qt::NoButton) self->synthesizedMousePoints.insert(w, SynthesizedMouseData( touchPoint.pos(), touchPoint.screenPos(), w)); + qDebug() << Q_FUNC_INFO << "sending fake mouse to " <timestamp, touchPoint.pos(), touchPoint.screenPos(), diff --git a/src/gui/kernel/qwindowsysteminterface.cpp b/src/gui/kernel/qwindowsysteminterface.cpp index 6fc63fe..03a1f67 100644 --- a/src/gui/kernel/qwindowsysteminterface.cpp +++ b/src/gui/kernel/qwindowsysteminterface.cpp @@ -392,18 +392,22 @@ void QWindowSystemInterfacePrivate::handleWindowSystemEvent(QWindowSystemInterfa void QWindowSystemInterface::registerTouchDevice(QTouchDevice *device) { + + qDebug() << Q_FUNC_INFO << device->name(); QTouchDevicePrivate::registerDevice(device); } void QWindowSystemInterface::handleTouchEvent(QWindow *w, QTouchDevice *device, const QList &points, Qt::KeyboardModifiers mods) { + qDebug() << "QWindowSystemInterface" << Q_FUNC_INFO ; unsigned long time = QWindowSystemInterfacePrivate::eventTime.elapsed(); handleTouchEvent(w, time, device, points, mods); } QList QWindowSystemInterfacePrivate::convertTouchPoints(const QList &points, QEvent::Type *type) { + qDebug() << "QWindowSystemInterface" << Q_FUNC_INFO << points.size(); QList touchPoints; Qt::TouchPointStates states; QTouchEvent::TouchPoint p; @@ -447,6 +451,7 @@ QList QWindowSystemInterfacePrivate::convertTouchPoints void QWindowSystemInterface::handleTouchEvent(QWindow *tlw, ulong timestamp, QTouchDevice *device, const QList &points, Qt::KeyboardModifiers mods) { + qDebug() << "QWindowSystemInterface" << Q_FUNC_INFO << points.size(); if (!points.size()) // Touch events must have at least one point return; @@ -464,6 +469,7 @@ void QWindowSystemInterface::handleTouchEvent(QWindow *tlw, ulong timestamp, QTo void QWindowSystemInterface::handleTouchCancelEvent(QWindow *w, QTouchDevice *device, Qt::KeyboardModifiers mods) { + qDebug() << "QWindowSystemInterface" << Q_FUNC_INFO ; unsigned long time = QWindowSystemInterfacePrivate::eventTime.elapsed(); handleTouchCancelEvent(w, time, device, mods); } @@ -471,6 +477,7 @@ void QWindowSystemInterface::handleTouchCancelEvent(QWindow *w, QTouchDevice *de void QWindowSystemInterface::handleTouchCancelEvent(QWindow *w, ulong timestamp, QTouchDevice *device, Qt::KeyboardModifiers mods) { + qDebug() << "QWindowSystemInterface" << Q_FUNC_INFO ; QWindowSystemInterfacePrivate::TouchEvent *e = new QWindowSystemInterfacePrivate::TouchEvent(w, timestamp, QEvent::TouchCancel, device, QList(), mods); diff --git a/src/plugins/platforms/windows/qwindowsintegration.cpp b/src/plugins/platforms/windows/qwindowsintegration.cpp index 73df3ec..5e05033 100644 --- a/src/plugins/platforms/windows/qwindowsintegration.cpp +++ b/src/plugins/platforms/windows/qwindowsintegration.cpp @@ -556,6 +556,10 @@ QVariant QWindowsIntegration::styleHint(QPlatformIntegration::StyleHint hint) co // 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). + if (qEnvironmentVariableIsSet("SYNTH_MOUSE")) { + qDebug("asking for mouse to be synthesized"); + return true; + } return false; } return QPlatformIntegration::styleHint(hint); diff --git a/src/plugins/platforms/windows/qwindowsmousehandler.cpp b/src/plugins/platforms/windows/qwindowsmousehandler.cpp index fd00a07..c609eaf 100644 --- a/src/plugins/platforms/windows/qwindowsmousehandler.cpp +++ b/src/plugins/platforms/windows/qwindowsmousehandler.cpp @@ -312,8 +312,12 @@ bool QWindowsMouseHandler::translateMouseEvent(QWindow *window, HWND hwnd, m_windowUnderMouse = currentWindowUnderMouse; } - QWindowSystemInterface::handleMouseEvent(window, winEventPosition, globalPosition, buttons, + if (qEnvironmentVariableIsSet("NO_MOUSE")) { + qDebug("Not sending mouse event"); + } else { + QWindowSystemInterface::handleMouseEvent(window, winEventPosition, globalPosition, buttons, QWindowsKeyMapper::queryKeyboardModifiers()); + } m_previousCaptureWindow = hasCapture ? window : 0; return true; } @@ -380,10 +384,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" << Q_FUNC_INFO << window << msg.message; + const QRect screenGeometry = window->screen()->geometry(); const int winTouchPointCount = msg.wParam; @@ -398,6 +406,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" << Q_FUNC_INFO << "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 +469,7 @@ bool QWindowsMouseHandler::translateTouchEvent(QWindow *window, HWND, QWindowSystemInterface::registerTouchDevice(m_touchDevice); } + qDebug() << "QWindowsMouseHandler" << Q_FUNC_INFO << "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 edd7caf..f307b29 100644 --- a/src/widgets/kernel/qapplication.cpp +++ b/src/widgets/kernel/qapplication.cpp @@ -3851,6 +3851,7 @@ bool QApplicationPrivate::translateRawTouchEvent(QWidget *window, const QList &touchPoints, ulong timestamp) { + qDebug() << "QApplicationPrivate::" << Q_FUNC_INFO << touchPoints.size(); QApplicationPrivate *d = self; typedef QPair > StatesAndTouchPoints; QHash widgetsNeedingEvents; @@ -3861,6 +3862,7 @@ bool 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::" << Q_FUNC_INFO << "processing" << i; // update state QPointer target; @@ -3885,6 +3887,8 @@ bool QApplicationPrivate::translateRawTouchEvent(QWidget *window, target = window; } + qDebug() << "QApplicationPrivate::" << Q_FUNC_INFO + << "SCREEN: "<< (device->type() == QTouchDevice::TouchScreen); if (device->type() == QTouchDevice::TouchScreen) { QWidget *closestWidget = d->findClosestTouchPointTarget(device, touchPoint.screenPos()); QWidget *widget = static_cast(target.data()); @@ -3943,6 +3947,7 @@ bool QApplicationPrivate::translateRawTouchEvent(QWidget *window, touchEvent.setTimestamp(timestamp); touchEvent.setWindow(window->windowHandle()); touchEvent.setTarget(widget); + qDebug() << "QApplicationPrivate::" << Q_FUNC_INFO << "looking at " << widget << &touchEvent; switch (touchEvent.type()) { case QEvent::TouchBegin: @@ -3970,6 +3975,7 @@ bool QApplicationPrivate::translateRawTouchEvent(QWidget *window, void QApplicationPrivate::translateTouchCancel(QTouchDevice *device, ulong timestamp) { + qDebug() << "QApplicationPrivate::" << Q_FUNC_INFO ; QTouchEvent touchEvent(QEvent::TouchCancel, device, QApplication::keyboardModifiers()); touchEvent.setTimestamp(timestamp); QHash::const_iterator it @@ -3986,6 +3992,7 @@ void QApplicationPrivate::translateTouchCancel(QTouchDevice *device, ulong times QWidget *widget = *widIt; touchEvent.setWindow(widget->windowHandle()); touchEvent.setTarget(widget); + qDebug() << "QApplicationPrivate::" << Q_FUNC_INFO << "sending cancel" << widget << &touchEvent; QApplication::sendSpontaneousEvent(widget, &touchEvent); } } diff --git a/src/widgets/kernel/qwidgetwindow.cpp b/src/widgets/kernel/qwidgetwindow.cpp index c19b617..6f09ad5 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() << '>' << Q_FUNC_INFO << event; if (event->type() == QEvent::TouchCancel) { QApplicationPrivate::translateTouchCancel(event->device(), event->timestamp()); event->accept(); @@ -483,6 +484,7 @@ void QWidgetWindow::handleTouchEvent(QTouchEvent *event) } else { event->setAccepted(QApplicationPrivate::translateRawTouchEvent(m_widget, event->device(), event->touchPoints(), event->timestamp())); } + qDebug() << '<' << Q_FUNC_INFO << event->isAccepted(); } void QWidgetWindow::handleKeyEvent(QKeyEvent *event)