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], SystemVersion USING [machineType], UserProfile USING [Number], Terminal USING [GetKeys], ViewerClasses USING [Viewer], ViewerOps USING [EnumerateViewers, EnumProc, FindViewer, PaintEverything, PaintViewer, SaveAllEdits], VirtualDesktops USING [VirtualDesktop]; ViewerProcessesImpl: CEDAR MONITOR IMPORTS Booting, Buttons, ClassIncreek, Cursors, Process, Idle, Interminal, SystemVersion, UserProfile, Terminal, ViewerOps EXPORTS VirtualDesktops = BEGIN EnumerateViewers: PUBLIC PROC [enum: ViewerOps.EnumProc] = { ViewerOps.EnumerateViewers[enum]; }; FindViewer: PUBLIC PROC [name: Rope.ROPE] RETURNS [viewer: ViewerClasses.Viewer, desktop: VirtualDesktops.VirtualDesktop] = { RETURN[ViewerOps.FindViewer[name], 0]; }; EmergencySaveAllEdits: PROC = TRUSTED { 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; }; idleProcess: PROCESS _ NIL; AutoIdle: PROC = TRUSTED { 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 => IdleProc[NIL]; ENDCASE; ENDLOOP; EXITS Punt => NULL; }; IdleOn: Booting.RollbackProc = { idleProcess _ FORK AutoIdle[]; RefreshIfNecessary[]; }; IdleOff: Booting.CheckpointProc = TRUSTED { Process.Abort[idleProcess]; JOIN idleProcess; idleProcess _ NIL; }; useIdleCrock: BOOL _ TRUE; -- can be set to FALSE to provoke the bug IdleProc: Buttons.ButtonProc = { Idle.Sleep[]; RefreshIfNecessary[]; }; RefreshIfNecessary: PROC = { IF useIdleCrock AND SystemVersion.machineType = dandelion THEN ViewerOps.PaintEverything[]; }; [] _ 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. ViewerProcessesImpl.mesa Copyright c 1983, 1984 Xerox Corporation. All rights reserved. written by S. McGregor McGregor on May 24, 1983 4:40 pm Maxwell, May 24, 1983 8:06 am Paul Rovner, June 16, 1983 10:06 am Russ Atkinson, February 24, 1984 12:45:17 pm PST Doug Wyatt, September 4, 1984 4:52:40 pm PDT RRA: February 24, 1984 12:44:23 pm PST This crock is here to get around a bug that is probably in VM. If we do not repaint everything, trash gets left on the screen after Idle comes back. This is tied up with the special memory used for the terminal on DLions, and nowhere else. Luckily, the bug appears benign except for the screen trash. Κ– "Mesa" style˜šΟc™Jšœ Οmœ4™?Jš™Jš ™ J™J™#J™0J™,—J™šΟk ˜ JšœŸœ/˜šœ&™&Jšœ―™―—Jšœ˜—J˜—J˜šœ˜Jšœ,Ÿœ˜1J˜2—J˜JšŸœŸœ˜7J˜Jšœ5Ÿœ˜:J˜JšŸœ˜J˜J˜—…— μ