SVScratchpadMonitorImpl.mesa
Last edited by Bier on July 2, 1983 2:29 pm
Contents: A flexible setup, suggested by Scott McGregor, for processing mouse input as fast as you can (but no faster). I will use it to synchronize my mouse point processing with the mousepoint. If the processing algorithms become faster, this procedure will still do the right thing.
DIRECTORY
Menus,
Process,
Scratchpad2d,
Scratchpad2dUser,
SV2d,
SVInputMonitor,
SVScratchpadMonitor,
SVViewerTool;
SVScratchpadMonitorImpl: MONITOR
IMPORTS Process, Scratchpad2d
EXPORTS SVScratchpadMonitor =
BEGIN
MouseButton: TYPE = Menus.MouseButton;
Point2d: TYPE = SV2d.Point2d;
ScratchpadData: TYPE = Scratchpad2dUser.ScratchpadData;
globalProcess: PROCESSNIL;
screenCoords: Point2d;
clickAtom: ATOM;
spData: ScratchpadData ← NIL;
globalNew: BOOLFALSE;
NewMotion: PUBLIC ENTRY PROC [pt: Point2d, atom: ATOM, scratchpadData: ScratchpadData] = {
globalNew ← TRUE;
screenCoords ← pt;
spData ← scratchpadData;
clickAtom ← atom;
IF globalProcess = NIL THEN Process.Detach[globalProcess ← FORK Painter];
};
Painter: PROC = {
WHILE New[] DO
Dispatch[screenCoords, clickAtom, spData];
ENDLOOP;
};
New: PUBLIC ENTRY PROC RETURNS [x: BOOL] = {
x ← globalNew;
globalNew ← FALSE;
IF NOT x THEN globalProcess ← NIL; -- no mouse action. Let process die.
};
Dispatch: PROC [controlPoint: Point2d, atom: ATOM, scratchpadData: ScratchpadData] = {
SELECT atom FROM
$MOVE => {
IF scratchpadData.mode = drawLin THEN Scratchpad2d.MoveLinPoint[controlPoint, scratchpadData]
ELSE Scratchpad2d.MoveRevoPoint[controlPoint, scratchpadData];
};
$MOVESTART => {
IF scratchpadData.mode = drawLin THEN Scratchpad2d.MoveLinStart[controlPoint, scratchpadData]
ELSE Scratchpad2d.MoveRevoStart[controlPoint, scratchpadData];
};
ENDCASE;
};
END.