summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/gui/kernel/qcocoaview_mac.mm54
-rw-r--r--src/gui/kernel/qevent_p.h10
2 files changed, 51 insertions, 13 deletions
diff --git a/src/gui/kernel/qcocoaview_mac.mm b/src/gui/kernel/qcocoaview_mac.mm
index 1d352cb..8c6f394 100644
--- a/src/gui/kernel/qcocoaview_mac.mm
+++ b/src/gui/kernel/qcocoaview_mac.mm
@@ -50,6 +50,7 @@
#include <private/qdnd_p.h>
#include <private/qmacinputcontext_p.h>
#include <private/qmultitouch_mac_p.h>
+#include <private/qevent_p.h>
#include <qscrollarea.h>
#include <qhash.h>
@@ -868,32 +869,65 @@ extern "C" {
- (void)magnifyWithEvent:(NSEvent *)event;
{
- Q_UNUSED(event);
-// qDebug() << "magnifyWithEvent";
+ if (!QApplicationPrivate::tryModalHelper(qwidget, 0))
+ return;
+
+ QNativeGestureEvent qNGEvent;
+ qNGEvent.gestureType = QNativeGestureEvent::Zoom;
+ NSPoint p = [[event window] convertBaseToScreen:[event locationInWindow]];
+ qNGEvent.position = flipPoint(p).toPoint();
+ qNGEvent.percentage = [event magnification];
+ qApp->sendEvent(qwidget, &qNGEvent);
}
- (void)rotateWithEvent:(NSEvent *)event;
{
- Q_UNUSED(event);
-// qDebug() << "rotateWithEvent";
+ if (!QApplicationPrivate::tryModalHelper(qwidget, 0))
+ return;
+
+ QNativeGestureEvent qNGEvent;
+ qNGEvent.gestureType = QNativeGestureEvent::Rotate;
+ NSPoint p = [[event window] convertBaseToScreen:[event locationInWindow]];
+ qNGEvent.position = flipPoint(p).toPoint();
+ qNGEvent.percentage = [event rotation];
+ qApp->sendEvent(qwidget, &qNGEvent);
}
- (void)swipeWithEvent:(NSEvent *)event;
{
- Q_UNUSED(event);
-// qDebug() << "swipeWithEvent";
+ if (!QApplicationPrivate::tryModalHelper(qwidget, 0))
+ return;
+
+ QNativeGestureEvent qNGEvent;
+ qNGEvent.gestureType = QNativeGestureEvent::Swipe;
+ NSPoint p = [[event window] convertBaseToScreen:[event locationInWindow]];
+ qNGEvent.position = flipPoint(p).toPoint();
+ qNGEvent.direction = QSize(-[event deltaX], -[event deltaY]);
+ qApp->sendEvent(qwidget, &qNGEvent);
}
- (void)beginGestureWithEvent:(NSEvent *)event;
{
- Q_UNUSED(event);
-// qDebug() << "beginGestureWithEvent";
+ if (!QApplicationPrivate::tryModalHelper(qwidget, 0))
+ return;
+
+ QNativeGestureEvent qNGEvent;
+ qNGEvent.gestureType = QNativeGestureEvent::GestureBegin;
+ NSPoint p = [[event window] convertBaseToScreen:[event locationInWindow]];
+ qNGEvent.position = flipPoint(p).toPoint();
+ qApp->sendEvent(qwidget, &qNGEvent);
}
- (void)endGestureWithEvent:(NSEvent *)event;
{
- Q_UNUSED(event);
-// qDebug() << "endGestureWithEvent";
+ if (!QApplicationPrivate::tryModalHelper(qwidget, 0))
+ return;
+
+ QNativeGestureEvent qNGEvent;
+ qNGEvent.gestureType = QNativeGestureEvent::GestureEnd;
+ NSPoint p = [[event window] convertBaseToScreen:[event locationInWindow]];
+ qNGEvent.position = flipPoint(p).toPoint();
+ qApp->sendEvent(qwidget, &qNGEvent);
}
#endif // MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_6
diff --git a/src/gui/kernel/qevent_p.h b/src/gui/kernel/qevent_p.h
index 92c4fc1..b21b35c 100644
--- a/src/gui/kernel/qevent_p.h
+++ b/src/gui/kernel/qevent_p.h
@@ -127,11 +127,13 @@ public:
GestureBegin,
GestureEnd,
Pan,
- Pinch
+ Zoom,
+ Rotate,
+ Swipe
};
QNativeGestureEvent()
- : QEvent(QEvent::NativeGesture), gestureType(None)
+ : QEvent(QEvent::NativeGesture), gestureType(None), percentage(0), direction(0, 0)
#ifdef Q_WS_WIN
, sequenceId(0)
#endif
@@ -139,8 +141,10 @@ public:
}
Type gestureType;
-#ifdef Q_WS_WIN
+ float percentage;
QPoint position;
+ QSize direction;
+#ifdef Q_WS_WIN
ulong sequenceId;
#endif
};