patch to interCyclePause:
lex at cc.gatech.edu
Wed May 19 11:37:30 UTC 1999
Andreas Rauss has pointed out a couple of times that the interCyclePause routine in Morphic can cause mouse clicks to be lost. Here is a patch that causes the pauses to terminate early whenever the system mouse has changed state--thus, it should mean it's harder for clicks to get lost. At least, I think that's how it will work; VM authors might want to read the patch and see if it's true for their VM. (It seems to work fine on the Unix VM).
To see this in action, put up a FrameRateMorph (from the Demos section of "new morph...."). Wiggle the mouse around, and the frame rate should drop down pretty low. Leave it still, and the rate should go up to 20. Before the patch, the rate should stay at 10 normally and hardly ever go below that no matter what you do.
In addition to the smarter pausing, there is a second change to make the calculation more accurate. Before, I had noticed that when you set MinCyclePause to 20 milliseconds, you actually got an average pause of *10* milliseconds. This fixes that.
Enjoy! If this works for other people than me, maybe it should be stuck into the main system.
'From Squeak 2.4b of April 23, 1999 on 18 May 1999 at 6:14:49 pm'!
"Change Set: betterPausing
Date: 18 May 1999
Author: Lex Spoon
Fixes two things in WorldMorph>>interactionPause:
1. The timing is fixed, so that all pauses take effect instead of just every other pause.
2. Uses ioRelinquishProcessorForMicroseconds: instead of Delay>>wait. Thus, mouse events should interrupt the pause.
!WorldMorph methodsFor: 'interaction loop' stamp: 'ls 5/18/1999 18:12'!
"delay enough that the next interaction cycle won't happen too soon after the original; thus, if all the system is doing is polling for interaction, the overall CPU usage of Squeak will be low"
| currentTime wait |
currentTime _ Time millisecondClockValue.
lastCycleTime ifNotNil: [
wait _ lastCycleTime + milliSecs - currentTime.
wait > 0 ifTrue: [
wait < milliSecs "big waits happen after a snapshot"
ifTrue: [ (ProcessorScheduler relinquishProcessorForMicroseconds: wait*1000) ]. ]. ].
lastCycleTime _ Time millisecondClockValue.! !
More information about the Squeak-dev