Autoscrolling on drag, part 2: Why does scrolling go faster if I wiggle the mouse?

Raymond Chen

Last time, we implemented a basic autoscroller. But you may have noticed an odd side effect: Wiggling the mouse speeds up the scrolling.

This happens because each wiggle of the mouse generates a new WM_MOUSE­MOVE message, and that in turn triggers the “activate autoscroll” code, which causes an autoscroll to happen ahead of its normal schedule. As a result, wiggling the mouse makes autoscrolling go faster.

If you wanted to remove this effect, you would have to reduce the amount of scrolling based on how much time has elapsed since the most recent autoscroll. The autoscroll timer runs at 100ms (assuming a default double-click speed of 500ms), and if the mouse move message is generated after, say, 25ms, then the autoscroll should move only a quarter of its usual distance, rather than the full distance. That way, the all the intermediate adjustments have a cumulative distance equivalent to the single adjustment at the end of the tick.

Another way of fixing this is simply to ignore mouse motion once the autoscroll timer is active. The timer is firing every tenth of a second. That’s plenty fast enough to fall below a human being’s response perception for something that isn’t a click or keypress.

But I suspect this behavior, even though technically incorrect, is something developer leave in because users like it. Wiggling the mouse to make something scroll faster makes it feel like the computer is responding to your impatience by hurrying. And users like that.

A discovered bug is now a feature. (obXKCD.)

Next time, we’ll look at a different autoscrolling algorithm.