ViewerProcessesImpl.mesa; written by S. McGregor
Edited by McGregor on May 24, 1983 4:40 pm
Last Edited by: Maxwell, May 24, 1983 8:06 am
Last Edited by: Paul Rovner, June 16, 1983 10:06 am
Last Edited by: Doug Wyatt, December 15, 1983 5:06 pm
DIRECTORY
Booting USING [CheckpointProc, RegisterProcs, RollbackProc],
Buttons USING [ButtonProc, Create],
ClassIncreek USING [ActionBody, GetAction, Increek, IncreekError, NewStdIncreek, SetAtLatest],
Cursors USING [CursorType, SetCursor],
Idle USING [Sleep],
Interminal USING [terminal],
Process USING [Abort, Detach, Pause, priorityForeground, Seconds, SecondsToTicks, SetPriority],
Rope USING [ROPE],
UserProfile USING [Number],
Terminal USING [GetKeys],
ViewerClasses USING [Viewer],
ViewerOps USING [EnumerateViewers, EnumProc, FindViewer, PaintViewer, SaveAllEdits],
VirtualDesktops USING [VirtualDesktop];
ViewerProcessesImpl: CEDAR MONITOR
IMPORTS Booting, Buttons, ClassIncreek, Cursors, Process, Idle, Interminal, UserProfile, Terminal, ViewerOps
EXPORTS VirtualDesktops =
BEGIN
EnumerateViewers:
PUBLIC
PROC [enum: ViewerOps.EnumProc] =
BEGIN
ViewerOps.EnumerateViewers[enum];
END;
FindViewer:
PUBLIC
PROC [name: Rope.
ROPE]
RETURNS [viewer: ViewerClasses.Viewer, desktop: VirtualDesktops.VirtualDesktop] = BEGIN
RETURN[ViewerOps.FindViewer[name], 0];
END;
EmergencySaveAllEdits:
PROC =
TRUSTED
BEGIN
PaintCaption: ViewerOps.EnumProc =
TRUSTED
BEGIN
ViewerOps.PaintViewer[v, caption];
END;
Process.SetPriority[Process.priorityForeground];
DO
-- forever
Process.Pause[Process.SecondsToTicks[1]];
IF Interminal.terminal.GetKeys[][LeftShift]=down
AND Interminal.terminal.GetKeys[][RightShift]=down
AND Interminal.terminal.GetKeys[][Spare3]=down
THEN BEGIN
Cursors.SetCursor[activate];
ViewerOps.SaveAllEdits[];
Cursors.SetCursor[textPointer];
ViewerOps.EnumerateViewers[PaintCaption]; -- ok if this doesn't finish
END;
ENDLOOP;
END;
idleProcess: PROCESS ← NIL;
AutoIdle:
PROC =
TRUSTED
BEGIN
ENABLE ANY => GOTO Punt; -- punt if bad number or ABORTED
increek: ClassIncreek.Increek;
action: ClassIncreek.ActionBody;
idleTime: Process.Seconds;
idleTime ← 60 * UserProfile.Number["AutoIdleTimeout", 20];
IF idleTime<=0 THEN RETURN;
increek ← ClassIncreek.NewStdIncreek[];
DO
-- forever
ClassIncreek.SetAtLatest[increek];
Process.Pause[Process.SecondsToTicks[idleTime]];
action ← ClassIncreek.GetAction[increek, dontWait,
----, clicksAndMotion
! ClassIncreek.IncreekError => LOOP];
WITH a: action
SELECT
FROM
timedOut => Idle.Sleep[];
ENDCASE;
ENDLOOP;
EXITS Punt => NULL;
END;
IdleOn: Booting.RollbackProc =
BEGIN
idleProcess ← FORK AutoIdle[];
END;
IdleOff: Booting.CheckpointProc =
TRUSTED
BEGIN
Process.Abort[idleProcess];
JOIN idleProcess;
idleProcess ← NIL;
END;
IdleProc: Buttons.ButtonProc = { Idle.Sleep[] };
[] ← Buttons.Create[info: [name: "Idle"], proc: IdleProc, fork:
TRUE,
documentation: "Hide desktop pending user login"];
TRUSTED {Process.Detach[FORK EmergencySaveAllEdits[]]};
Booting.RegisterProcs[c: IdleOff, r: IdleOn]; IdleOn[NIL];
END.