diff options
author | axis <qt-info@nokia.com> | 2009-08-19 09:24:04 (GMT) |
---|---|---|
committer | axis <qt-info@nokia.com> | 2009-08-19 09:24:04 (GMT) |
commit | 2d1b49bd21b788ba3e35fc5c41bf3aab42cbda65 (patch) | |
tree | 24dae3a4532870d61282841f6bb186cb008ab747 /src/gui/kernel/qwidget_mac.mm | |
parent | b3a3652abbf1cb4ebba6c6257ecf47f8dc022d93 (diff) | |
parent | 20d2b7312456435e5e1a98dba7c2cc96b44fe83c (diff) | |
download | Qt-2d1b49bd21b788ba3e35fc5c41bf3aab42cbda65.zip Qt-2d1b49bd21b788ba3e35fc5c41bf3aab42cbda65.tar.gz Qt-2d1b49bd21b788ba3e35fc5c41bf3aab42cbda65.tar.bz2 |
Merge branch 'master' of git@scm.dev.nokia.troll.no:qt/qt
Conflicts:
tests/auto/auto.pro
Diffstat (limited to 'src/gui/kernel/qwidget_mac.mm')
-rw-r--r-- | src/gui/kernel/qwidget_mac.mm | 71 |
1 files changed, 71 insertions, 0 deletions
diff --git a/src/gui/kernel/qwidget_mac.mm b/src/gui/kernel/qwidget_mac.mm index fbb05c4..3dd2e65 100644 --- a/src/gui/kernel/qwidget_mac.mm +++ b/src/gui/kernel/qwidget_mac.mm @@ -107,6 +107,7 @@ #include <private/qcocoapanel_mac_p.h> #include "qwidget_p.h" +#include "qevent_p.h" #include "qdnd_p.h" #include <QtGui/qgraphicsproxywidget.h> @@ -729,6 +730,13 @@ static EventTypeSpec window_events[] = { { kEventClassWindow, kEventWindowGetRegion }, { kEventClassWindow, kEventWindowGetClickModality }, { kEventClassWindow, kEventWindowTransitionCompleted }, +#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_6 + { kEventClassGesture, kEventGestureStarted }, + { kEventClassGesture, kEventGestureEnded }, + { kEventClassGesture, kEventGestureMagnify }, + { kEventClassGesture, kEventGestureSwipe }, + { kEventClassGesture, kEventGestureRotate }, +#endif { kEventClassMouse, kEventMouseDown } }; static EventHandlerUPP mac_win_eventUPP = 0; @@ -1013,6 +1021,69 @@ OSStatus QWidgetPrivate::qt_window_event(EventHandlerCallRef er, EventRef event, return SendEventToApplication(event); handled_event = false; break; } + +#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_6 + case kEventClassGesture: { + // First, find the widget that was under + // the mouse when the gesture happened: + HIPoint screenLocation; + if (GetEventParameter(event, kEventParamMouseLocation, typeHIPoint, 0, + sizeof(screenLocation), 0, &screenLocation) != noErr) { + handled_event = false; + break; + } + QWidget *widget = QApplication::widgetAt(screenLocation.x, screenLocation.y); + if (!widget) { + handled_event = false; + break; + } + + QNativeGestureEvent qNGEvent; + qNGEvent.position = QPoint(screenLocation.x, screenLocation.y); + + switch (ekind) { + case kEventGestureStarted: + qNGEvent.gestureType = QNativeGestureEvent::GestureBegin; + break; + case kEventGestureEnded: + qNGEvent.gestureType = QNativeGestureEvent::GestureEnd; + break; + case kEventGestureRotate: { + CGFloat amount; + if (GetEventParameter(event, kEventParamRotationAmount, typeCGFloat, 0, + sizeof(amount), 0, &amount) != noErr) { + handled_event = false; + break; + } + qNGEvent.gestureType = QNativeGestureEvent::Zoom; + qNGEvent.percentage = float(amount); + break; } + case kEventGestureSwipe: { + HIPoint swipeDirection; + if (GetEventParameter(event, kEventParamSwipeDirection, typeHIPoint, 0, + sizeof(swipeDirection), 0, &swipeDirection) != noErr) { + handled_event = false; + break; + } + qNGEvent.gestureType = QNativeGestureEvent::Swipe; + qNGEvent.direction = QSize(-swipeDirection.x, -swipeDirection.y); + break; } + case kEventGestureMagnify: { + CGFloat amount; + if (GetEventParameter(event, kEventParamMagnificationAmount, typeCGFloat, 0, + sizeof(amount), 0, &amount) != noErr) { + handled_event = false; + break; + } + qNGEvent.gestureType = QNativeGestureEvent::Zoom; + qNGEvent.percentage = float(amount); + break; } + } + + QApplication::sendSpontaneousEvent(widget, &qNGEvent); + break; } +#endif // gestures + default: handled_event = false; } |