Cocoa platform plugin: Implement multitouch support.
authorBjørn Erik Nilsen <bjorn.nilsen@nokia.com>
Mon, 19 Sep 2011 13:07:15 +0000 (15:07 +0200)
committerQt by Nokia <qt-info@nokia.com>
Mon, 19 Sep 2011 14:37:51 +0000 (16:37 +0200)
Change-Id: Ic4b5bc4e48bd1e70cffedf15530b8a933037de66
Reviewed-on: http://codereview.qt-project.org/5153
Reviewed-by: Qt Sanity Bot <qt_sanity_bot@ovi.com>
Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@nokia.com>
src/plugins/platforms/cocoa/cocoa.pro
src/plugins/platforms/cocoa/qcocoawindow.mm
src/plugins/platforms/cocoa/qnsview.mm

index d6801e0..40d3323 100644 (file)
@@ -18,6 +18,7 @@ OBJECTIVE_SOURCES += main.mm \
     qcocoamenu.mm \
     qmenu_mac.mm \
     qcocoahelpers.mm \
+    qmultitouch_mac.mm \
 
 HEADERS += qcocoaintegration.h \
     qcocoabackingstore.h \
@@ -34,6 +35,7 @@ HEADERS += qcocoaintegration.h \
     qcocoamenu.h \
     qmenu_mac.h \
     qcocoahelpers.h \
+    qmultitouch_mac_p.h \
 
 RESOURCES += qcocoaresources.qrc
 
index 7e4d421..00016cb 100644 (file)
@@ -90,6 +90,9 @@ QCocoaWindow::QCocoaWindow(QWindow *tlw)
 
     m_contentView = [[QNSView alloc] initWithQWindow:tlw];
 
+    // Accept touch events by default.
+    [m_contentView setAcceptsTouchEvents:YES];
+
     setGeometry(tlw->geometry());
 
     [m_nsWindow setContentView:m_contentView];
index f3c71d9..f215c9d 100644 (file)
@@ -43,6 +43,7 @@
 
 #include "qnsview.h"
 #include "qcocoahelpers.h"
+#include "qmultitouch_mac_p.h"
 
 #include <QtGui/QWindowSystemInterface>
 #include <QtCore/QDebug>
     [self handleMouseEvent:theEvent];
 }
 
+- (void)touchesBeganWithEvent:(NSEvent *)event;
+{
+    const NSTimeInterval timestamp = [event timestamp];
+    const QList<QWindowSystemInterface::TouchPoint> points = QCocoaTouch::getCurrentTouchPointList(event, /*acceptSingleTouch= ### true or false?*/false);
+    QWindowSystemInterface::handleTouchEvent(m_window, timestamp * 1000, QEvent::TouchBegin,  QTouchEvent::TouchPad, points);
+}
+
+- (void)touchesMovedWithEvent:(NSEvent *)event;
+{
+    const NSTimeInterval timestamp = [event timestamp];
+    const QList<QWindowSystemInterface::TouchPoint> points = QCocoaTouch::getCurrentTouchPointList(event, /*acceptSingleTouch= ### true or false?*/false);
+    QWindowSystemInterface::handleTouchEvent(m_window, timestamp * 1000, QEvent::TouchUpdate,  QTouchEvent::TouchPad, points);
+}
+
+- (void)touchesEndedWithEvent:(NSEvent *)event;
+{
+    const NSTimeInterval timestamp = [event timestamp];
+    const QList<QWindowSystemInterface::TouchPoint> points = QCocoaTouch::getCurrentTouchPointList(event, /*acceptSingleTouch= ### true or false?*/false);
+    QWindowSystemInterface::handleTouchEvent(m_window, timestamp * 1000, QEvent::TouchEnd,  QTouchEvent::TouchPad, points);
+}
+
+- (void)touchesCancelledWithEvent:(NSEvent *)event;
+{
+    const NSTimeInterval timestamp = [event timestamp];
+    const QList<QWindowSystemInterface::TouchPoint> points = QCocoaTouch::getCurrentTouchPointList(event, /*acceptSingleTouch= ### true or false?*/false);
+    QWindowSystemInterface::handleTouchEvent(m_window, timestamp * 1000, QEvent::TouchEnd,  QTouchEvent::TouchPad, points);
+}
+
 #ifndef QT_NO_WHEELEVENT
 - (void)scrollWheel:(NSEvent *)theEvent
 {