Add processor (an ApplicationModel), which processes the lock/unlock
authorStefan Vogel <sv@exept.de>
Mon, 02 Oct 2000 16:47:03 +0200
changeset 1416 79f3aee2d64c
parent 1415 fd8738cc4733
child 1417 810fdd94d742
Add processor (an ApplicationModel), which processes the lock/unlock operation.
ScreenLock.st
--- a/ScreenLock.st	Mon Oct 02 16:07:15 2000 +0200
+++ b/ScreenLock.st	Mon Oct 02 16:47:03 2000 +0200
@@ -2,7 +2,7 @@
 
 EventListener subclass:#ScreenLock
 	instanceVariableNames:'workstation lastInactiveTime lockAfterSeconds lockChannel
-		lockChannelOut lockedViews hiddenViews'
+		lockChannelOut processor lockedViews hiddenViews'
 	classVariableNames:''
 	poolDictionaries:''
 	category:'Interface-Support'
@@ -96,26 +96,46 @@
     lockAfterSeconds := something.!
 
 lockChannel
-    "return the value of the instance variable 'lockChannel' (automatically generated)"
 
-    ^ lockChannel!
+    lockChannel isNil ifTrue:[
+        self lockChannel:false asValue.
+    ].
+    ^ lockChannel
+!
 
 lockChannel:something
 
+    lockChannel notNil ifTrue:[ 
+        lockChannel removeDependent:self.
+    ].
+
     lockChannel := something.
     lockChannel addDependent:self.
 !
 
 lockChannelOut
-    "return the value of the instance variable 'lockChannelOut' (automatically generated)"
 
-    ^ lockChannelOut!
+    lockChannelOut isNil ifTrue:[
+        lockChannelOut := false asValue.
+    ].
+    ^ lockChannelOut
+!
 
 lockChannelOut:something
     "set the value of the instance variable 'lockChannelOut' (automatically generated)"
 
     lockChannelOut := something.!
 
+processor
+    "return the value of the instance variable 'processor' (automatically generated)"
+
+    ^ processor!
+
+processor:something
+    "set the value of the instance variable 'processor' (automatically generated)"
+
+    processor := something.!
+
 workstation
     "return the value of the instance variable 'workstation' (automatically generated)"
 
@@ -140,10 +160,23 @@
             "/ lockChannel is a block or something else
             lock := param.
         ].
+
+        "lock or unlock the screen
+         If a processor is defined, let the processor perform the unlock,
+         so that posssible Display errors do not affect the sender"
+
         lock == true ifTrue:[
-            self lockScreen.
+            processor isNil ifTrue:[
+                self lockScreen.
+            ] ifFalse:[
+                processor enqueueMessage:#lockScreen for:self arguments:#().
+            ].
         ] ifFalse:[
-            self unlockScreen.
+            processor isNil ifTrue:[
+                self unlockScreen.
+            ] ifFalse:[
+                processor enqueueMessage:#unlockScreen for:self arguments:#().
+            ].
         ]
     ].
 ! !
@@ -204,22 +237,23 @@
 !
 
 lock
+   "trigger locking of screen"
 
-    lockChannel isNil ifTrue:[
-        self lockChannel:ValueHolder new.
-    ].
-
-    lockChannel value:true.
+    self lockChannel value:true.
 !
 
 unlisten
+    "do not listen for events any longer.
+     This must be called when a screen lock is detached from a
+     screen."
 
     workstation removeEventListener:self
 !
 
 unlock
+   "trigger unlocking of screen"
 
-    lockChannel value:false.
+    self lockChannel value:false.
 ! !
 
 !ScreenLock methodsFor:'private'!
@@ -245,6 +279,7 @@
 !
 
 lockScreen
+    "lock the screen"
 
     lockedViews := workstation allViews.
     hiddenViews := lockedViews select:[:v|
@@ -288,5 +323,5 @@
 !ScreenLock class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libview2/ScreenLock.st,v 1.4 2000-10-02 14:07:15 stefan Exp $'
+    ^ '$Header: /cvs/stx/stx/libview2/ScreenLock.st,v 1.5 2000-10-02 14:47:03 stefan Exp $'
 ! !