summaryrefslogtreecommitdiffstats
path: root/src/gui/kernel/qapplication_mac.mm
diff options
context:
space:
mode:
authorRichard Moe Gustavsen <richard.gustavsen@nokia.com>2009-10-27 08:14:28 (GMT)
committerRichard Moe Gustavsen <richard.gustavsen@nokia.com>2009-10-27 09:25:49 (GMT)
commit0fd6390800969d174dba819c54c4183a99e8f83c (patch)
tree79e6d0a1d2beb61d0afa988607db018f92447503 /src/gui/kernel/qapplication_mac.mm
parent5a4909d9f87b9abf471908a085c0e9f31b7e0a50 (diff)
downloadQt-0fd6390800969d174dba819c54c4183a99e8f83c.zip
Qt-0fd6390800969d174dba819c54c4183a99e8f83c.tar.gz
Qt-0fd6390800969d174dba819c54c4183a99e8f83c.tar.bz2
Implement support for wheel delta with finer resolution than 15 deg.
At the moment, Qt, in many places, does not really understand that a mouse wheel, or touch pad, might operate on a much higher granularity than 15 degrees (that is, a delta of 120). This is clear disadvantage on mac, since the mighty mouse, and track pad, got a resolution that is close to 1 degree. This is called pixel scrolling. This patch first and formost changes the implementation of QAbstractSlider::wheelEvent to _really_ understand what to do when delta is less than 120. Rather than accumulate delta until 120 is reached, then scroll with a value equal to: offset * step * QApplication::wheelScrollLines (default = 3), we multiply offset directly, before waiting for 120. This means that event tough offset is below 120, multiplying it with wheelScrollLines and step will very often give a value over 120, menaing we can scroll much earlier and _much more_ fined grained. This also fixes some auto tests that was ifdeffed out because of specialised mac code written inside this function from before. (NB: we still plan to introduce a new event for pixel scrolling, perhaps for Qt-4.7) Rev-By: Andreas Rev-By: denis
Diffstat (limited to 'src/gui/kernel/qapplication_mac.mm')
-rw-r--r--src/gui/kernel/qapplication_mac.mm37
1 files changed, 6 insertions, 31 deletions
diff --git a/src/gui/kernel/qapplication_mac.mm b/src/gui/kernel/qapplication_mac.mm
index 771cddc..84e0d50 100644
--- a/src/gui/kernel/qapplication_mac.mm
+++ b/src/gui/kernel/qapplication_mac.mm
@@ -1697,15 +1697,14 @@ QApplicationPrivate::globalEventProcessor(EventHandlerCallRef er, EventRef event
// (actually two events; one for horizontal and one for vertical).
// As a results of this, and to make sure we dont't receive duplicate events,
// we try to detect when this happend by checking the 'compatibilityEvent'.
- const int scrollFactor = 4 * 8;
SInt32 mdelt = 0;
GetEventParameter(event, kEventParamMouseWheelSmoothHorizontalDelta, typeSInt32, 0,
sizeof(mdelt), 0, &mdelt);
- wheel_deltaX = mdelt * scrollFactor;
+ wheel_deltaX = mdelt;
mdelt = 0;
GetEventParameter(event, kEventParamMouseWheelSmoothVerticalDelta, typeSInt32, 0,
sizeof(mdelt), 0, &mdelt);
- wheel_deltaY = mdelt * scrollFactor;
+ wheel_deltaY = mdelt;
GetEventParameter(event, kEventParamEventRef, typeEventRef, 0,
sizeof(compatibilityEvent), 0, &compatibilityEvent);
} else if (ekind == kEventMouseWheelMoved) {
@@ -1718,31 +1717,11 @@ QApplicationPrivate::globalEventProcessor(EventHandlerCallRef er, EventRef event
GetEventParameter(event, kEventParamMouseWheelAxis, typeMouseWheelAxis, 0,
sizeof(axis), 0, &axis);
- // The 'new' event has acceleration applied by the OS, while the old (on
- // Carbon only), has not. So we introduce acceleration here to be consistent.
- // The acceleration is trying to respect both pixel based and line scrolling,
- // which turns out to be rather difficult.
- int linesToScroll = mdelt > 0 ? 1 : -1;
- static QTime t;
- int elapsed = t.elapsed();
- t.restart();
- if (elapsed < 20)
- linesToScroll *= 120;
- else if (elapsed < 30)
- linesToScroll *= 60;
- else if (elapsed < 50)
- linesToScroll *= 30;
- else if (elapsed < 100)
- linesToScroll *= 6;
- else if (elapsed < 200)
- linesToScroll *= 3;
- else if (elapsed < 300)
- linesToScroll *= 2;
-
+ // Remove acceleration, and use either -120 or 120 as delta:
if (axis == kEventMouseWheelAxisX)
- wheel_deltaX = linesToScroll * 120;
+ wheel_deltaX = qBound(-120, int(mdelt * 10000), 120);
else
- wheel_deltaY = linesToScroll * 120;
+ wheel_deltaY = qBound(-120, int(mdelt * 10000), 120);
}
}
@@ -2695,11 +2674,7 @@ int QApplication::keyboardInputInterval()
void QApplication::setWheelScrollLines(int n)
{
- Q_UNUSED(n);
- // On Mac, acceleration is handled by the OS. Multiplying wheel scroll
- // deltas with n will not be as cross platform as one might think! So
- // we choose to go native in this case (and let wheel_scroll_lines == 1).
- // QApplicationPrivate::wheel_scroll_lines = n;
+ QApplicationPrivate::wheel_scroll_lines = n;
}
int QApplication::wheelScrollLines()