diff options
author | Richard Moe Gustavsen <richard.gustavsen@nokia.com> | 2011-08-10 08:18:15 (GMT) |
---|---|---|
committer | Richard Moe Gustavsen <richard.gustavsen@nokia.com> | 2011-08-10 08:20:32 (GMT) |
commit | 3ad6fef72055f7f6912fd66e4be13d65e8875638 (patch) | |
tree | 6e52c4dfeb1bab94d6b26a353f567dc04133d888 /src | |
parent | 222fa517b877e38c918dc8011b13f9269629c427 (diff) | |
download | Qt-3ad6fef72055f7f6912fd66e4be13d65e8875638.zip Qt-3ad6fef72055f7f6912fd66e4be13d65e8875638.tar.gz Qt-3ad6fef72055f7f6912fd66e4be13d65e8875638.tar.bz2 |
Cocoa: change usage of deprecated API (scrolling) in Lion
Apple changed the API for pixel based scrolling, which results
in runtime warnings on the command line. This patch will make
Qt use the new API. In addition, apple removed suppert for
z-scrolling. Since that was never supported in Qt as well, we
also remote code that handles that.
RevBy: msorvig
Diffstat (limited to 'src')
-rw-r--r-- | src/gui/kernel/qcocoaview_mac.mm | 26 |
1 files changed, 14 insertions, 12 deletions
diff --git a/src/gui/kernel/qcocoaview_mac.mm b/src/gui/kernel/qcocoaview_mac.mm index e32fdeb..0fbae59 100644 --- a/src/gui/kernel/qcocoaview_mac.mm +++ b/src/gui/kernel/qcocoaview_mac.mm @@ -66,9 +66,14 @@ #include <qdebug.h> @interface NSEvent (Qt_Compile_Leopard_DeviceDelta) + // SnowLeopard: - (CGFloat)deviceDeltaX; - (CGFloat)deviceDeltaY; - (CGFloat)deviceDeltaZ; + // Lion: + - (CGFloat)scrollingDeltaX; + - (CGFloat)scrollingDeltaY; + - (CGFloat)scrollingDeltaZ; @end @interface NSEvent (Qt_Compile_Leopard_Gestures) @@ -614,7 +619,6 @@ static int qCocoaViewCount = 0; int deltaX = 0; int deltaY = 0; - int deltaZ = 0; const EventRef carbonEvent = (EventRef)[theEvent eventRef]; const UInt32 carbonEventKind = carbonEvent ? ::GetEventKind(carbonEvent) : 0; @@ -627,15 +631,20 @@ static int qCocoaViewCount = 0; // It looks like 1/4 degrees per pixel behaves most native. // (NB: Qt expects the unit for delta to be 8 per degree): const int pixelsToDegrees = 2; // 8 * 1/4 - deltaX = [theEvent deviceDeltaX] * pixelsToDegrees; - deltaY = [theEvent deviceDeltaY] * pixelsToDegrees; - deltaZ = [theEvent deviceDeltaZ] * pixelsToDegrees; + if (QSysInfo::MacintoshVersion <= QSysInfo::MV_10_6) { + // Mac OS 10.6 + deltaX = [theEvent deviceDeltaX] * pixelsToDegrees; + deltaY = [theEvent deviceDeltaY] * pixelsToDegrees; + } else { + // Mac OS 10.7+ + deltaX = [theEvent scrollingDeltaX] * pixelsToDegrees; + deltaY = [theEvent scrollingDeltaY] * pixelsToDegrees; + } } else { // carbonEventKind == kEventMouseWheelMoved // Remove acceleration, and use either -120 or 120 as delta: deltaX = qBound(-120, int([theEvent deltaX] * 10000), 120); deltaY = qBound(-120, int([theEvent deltaY] * 10000), 120); - deltaZ = qBound(-120, int([theEvent deltaZ] * 10000), 120); } #ifndef QT_NO_WHEELEVENT @@ -654,13 +663,6 @@ static int qCocoaViewCount = 0; qt_sendSpontaneousEvent(widgetToGetMouse, &qwe); } - if (deltaZ != 0) { - // Qt doesn't explicitly support wheels with a Z component. In a misguided attempt to - // try to be ahead of the pack, I'm adding this extra value. - QWheelEvent qwe(qlocal, qglobal, deltaZ, buttons, keyMods, (Qt::Orientation)3); - qt_sendSpontaneousEvent(widgetToGetMouse, &qwe); - } - if (deltaX != 0 && deltaY != 0) QMacScrollOptimization::performDelayedScroll(); #endif //QT_NO_WHEELEVENT |