Title: [98719] trunk/Tools
Revision
98719
Author
[email protected]
Date
2011-10-28 05:28:31 -0700 (Fri, 28 Oct 2011)

Log Message

[Qt] Fix the Ctrl behavior for touch mocking in MiniBrowser.
https://bugs.webkit.org/show_bug.cgi?id=71106

Reviewed by Simon Hausmann.

Holding Ctrl allows multiple touch points to be held on the screen using
mouse buttons. It would previously only prevent TouchReleased to be sent
and would require another MouseButtonRelease to be sent without holding Ctrl.

This patch makes sure that all held touch points are released when Ctrl
is released if MouseButtonRelease was received.
It also removes the touch QEvent::Type logic since it's currently handled
by QtGui by observing the modified touch points.

* MiniBrowser/qt/MiniBrowserApplication.cpp:
(MiniBrowserApplication::notify):
(MiniBrowserApplication::sendTouchEvent):
* MiniBrowser/qt/MiniBrowserApplication.h:

Modified Paths

Diff

Modified: trunk/Tools/ChangeLog (98718 => 98719)


--- trunk/Tools/ChangeLog	2011-10-28 12:20:13 UTC (rev 98718)
+++ trunk/Tools/ChangeLog	2011-10-28 12:28:31 UTC (rev 98719)
@@ -1,3 +1,24 @@
+2011-10-28  Jocelyn Turcotte  <[email protected]>
+
+        [Qt] Fix the Ctrl behavior for touch mocking in MiniBrowser.
+        https://bugs.webkit.org/show_bug.cgi?id=71106
+
+        Reviewed by Simon Hausmann.
+
+        Holding Ctrl allows multiple touch points to be held on the screen using
+        mouse buttons. It would previously only prevent TouchReleased to be sent
+        and would require another MouseButtonRelease to be sent without holding Ctrl.
+
+        This patch makes sure that all held touch points are released when Ctrl
+        is released if MouseButtonRelease was received.
+        It also removes the touch QEvent::Type logic since it's currently handled
+        by QtGui by observing the modified touch points.
+
+        * MiniBrowser/qt/MiniBrowserApplication.cpp:
+        (MiniBrowserApplication::notify):
+        (MiniBrowserApplication::sendTouchEvent):
+        * MiniBrowser/qt/MiniBrowserApplication.h:
+
 2011-10-28  Kenneth Rohde Christiansen  <[email protected]>
 
         [Qt] MiniBrowser needs a -window-size option

Modified: trunk/Tools/MiniBrowser/qt/MiniBrowserApplication.cpp (98718 => 98719)


--- trunk/Tools/MiniBrowser/qt/MiniBrowserApplication.cpp	2011-10-28 12:20:13 UTC (rev 98718)
+++ trunk/Tools/MiniBrowser/qt/MiniBrowserApplication.cpp	2011-10-28 12:28:31 UTC (rev 98719)
@@ -96,6 +96,14 @@
     }
 
     QWindow* targetWindow = qobject_cast<QWindow*>(target);
+    if (event->type() == QEvent::KeyRelease && static_cast<QKeyEvent*>(event)->key() == Qt::Key_Control) {
+        foreach (int id, m_heldTouchPoints)
+            if (m_touchPoints.contains(id))
+                m_touchPoints[id].state = Qt::TouchPointReleased;
+        m_heldTouchPoints.clear();
+        sendTouchEvent(targetWindow);
+    }
+
     if (targetWindow && isMouseEvent(event)) {
         const QMouseEvent* const mouseEvent = static_cast<QMouseEvent*>(event);
 
@@ -115,20 +123,24 @@
         case QEvent::MouseMove:
             if (!mouseEvent->buttons() || !m_touchPoints.contains(mouseEvent->buttons()))
                 return QApplication::notify(target, event);
-            touchPoint.state = Qt::TouchPointMoved;
             touchPoint.id = mouseEvent->buttons();
+            touchPoint.state = Qt::TouchPointMoved;
             break;
         case QEvent::MouseButtonRelease:
-            if (mouseEvent->modifiers().testFlag(Qt::ControlModifier))
-                return QApplication::notify(target, event);
             touchPoint.state = Qt::TouchPointReleased;
             touchPoint.id = mouseEvent->button();
+            if (mouseEvent->modifiers().testFlag(Qt::ControlModifier)) {
+                m_heldTouchPoints.insert(touchPoint.id);
+                return QApplication::notify(target, event);
+            }
             break;
         default:
             Q_ASSERT_X(false, "multi-touch mocking", "unhandled event type");
         }
 
         // Update current touch-point
+        if (m_touchPoints.isEmpty())
+            touchPoint.isPrimary = true;
         m_touchPoints.insert(touchPoint.id, touchPoint);
 
         // Update states for all other touch-points
@@ -137,37 +149,22 @@
                 it.value().state = Qt::TouchPointStationary;
         }
 
-        QList<QWindowSystemInterface::TouchPoint> touchPoints = m_touchPoints.values();
-        QWindowSystemInterface::TouchPoint& firstPoint = touchPoints.first();
-        firstPoint.isPrimary = true;
+        sendTouchEvent(targetWindow);
+    }
 
-        QEvent::Type eventType;
-        switch (touchPoint.state) {
-        case Qt::TouchPointPressed:
-            eventType = QEvent::TouchBegin;
-            break;
-        case Qt::TouchPointReleased:
-            eventType = QEvent::TouchEnd;
-            break;
-        case Qt::TouchPointStationary:
-            // Don't send the event if nothing changed.
-            return QApplication::notify(target, event);
-        default:
-            eventType = QEvent::TouchUpdate;
-            break;
-        }
+    return QApplication::notify(target, event);
+}
 
-        m_pendingFakeTouchEventCount++;
-        QWindowSystemInterface::handleTouchEvent(targetWindow, eventType, QTouchEvent::TouchScreen, touchPoints);
+void MiniBrowserApplication::sendTouchEvent(QWindow* targetWindow)
+{
+    m_pendingFakeTouchEventCount++;
+    QWindowSystemInterface::handleTouchEvent(targetWindow, QEvent::None, QTouchEvent::TouchScreen, m_touchPoints.values());
 
-        // Get rid of touch-points that are no longer valid
-        foreach (const QWindowSystemInterface::TouchPoint& touchPoint, m_touchPoints) {
-            if (touchPoint.state ==  Qt::TouchPointReleased)
-                m_touchPoints.remove(touchPoint.id);
-        }
+    // Get rid of touch-points that are no longer valid
+    foreach (const QWindowSystemInterface::TouchPoint& touchPoint, m_touchPoints) {
+    if (touchPoint.state ==  Qt::TouchPointReleased)
+        m_touchPoints.remove(touchPoint.id);
     }
-
-    return QApplication::notify(target, event);
 }
 
 static void printHelp(const QString& programName)

Modified: trunk/Tools/MiniBrowser/qt/MiniBrowserApplication.h (98718 => 98719)


--- trunk/Tools/MiniBrowser/qt/MiniBrowserApplication.h	2011-10-28 12:20:13 UTC (rev 98718)
+++ trunk/Tools/MiniBrowser/qt/MiniBrowserApplication.h	2011-10-28 12:28:31 UTC (rev 98719)
@@ -85,6 +85,7 @@
     virtual bool notify(QObject*, QEvent*);
 
 private:
+    void sendTouchEvent(QWindow* targetWindow);
     void handleUserOptions();
 
 private:
@@ -96,6 +97,7 @@
     QStringList m_urls;
 
     QHash<int, QWindowSystemInterface::TouchPoint> m_touchPoints;
+    QSet<int> m_heldTouchPoints;
 };
 
 QML_DECLARE_TYPE(WindowOptions);
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to