break non-windowGroup expose-poll loop after a while (10 seconds)
authorClaus Gittinger <cg@exept.de>
Tue, 19 Aug 1997 17:36:39 +0200
changeset 1873 a67649816bc8
parent 1872 2a10e693d93f
child 1874 a46a8c065050
break non-windowGroup expose-poll loop after a while (10 seconds) to avoid blocking forever.
WSensor.st
WindowSensor.st
--- a/WSensor.st	Tue Aug 19 17:28:51 1997 +0200
+++ b/WSensor.st	Tue Aug 19 17:36:39 1997 +0200
@@ -2284,10 +2284,14 @@
      in future versions. (or the new device may simulate the arrival of
      such an event)"
 
-    |blocked lostExpose|
+    |blocked lostExpose device stopPoll endPollTime|
+
+    device := aView graphicsDevice.
 
     "/ this is only needed for X ...
-    aView device scrollsAsynchronous ifFalse:[
+    device scrollsAsynchronous ifFalse:[
+        gotExpose remove:aView ifAbsent:nil.
+        catchExpose remove:aView ifAbsent:nil.
         ^ self
     ].
 
@@ -2295,11 +2299,18 @@
     [
         aView flush.
         Processor activeProcessIsSystemProcess ifTrue:[
-            "
-             cannot really suspend, if its a systemProcess
-            "
-            [ (gotExpose includes:aView) or:[lostExpose > 2] ] whileFalse:[
-                aView graphicsDevice dispatchExposeEventFor:aView id.
+            endPollTime := AbsoluteTime now addSeconds:10.
+            stopPoll := false.
+
+            "/
+            "/ cannot really suspend, if its a systemProcess
+            "/ must poll for the event
+            "/
+            [(gotExpose includes:aView) or:[stopPoll]] whileFalse:[
+                (device exposeEventPendingFor:aView id withSync:true) ifTrue:[
+                    device dispatchExposeEventFor:aView id.
+                ].
+                stopPoll := (AbsoluteTime now > endPollTime).
                 Processor yield.
             ]
         ] ifFalse:[
@@ -2319,7 +2330,7 @@
                  if the event does not arrive after 15 seconds.
                 "
                 (exposeEventSemaphore waitWithTimeout:(1 * lostExpose)) isNil ifTrue:[
-                    aView graphicsDevice flush.         "/ we are paranoid
+                    device flush.         "/ we are paranoid
                     lostExpose == 1 ifTrue:[
                         "
                          you can put a comment around the following line, 
@@ -2350,8 +2361,8 @@
         eventSemaphore signalOnce
     ].
 
-    "Modified: 23.1.1997 / 22:29:16 / cg"
     "Modified: 20.2.1997 / 09:24:31 / stefan"
+    "Modified: 19.8.1997 / 17:36:20 / cg"
 !
 
 waitNoButton
@@ -2369,6 +2380,6 @@
 !WindowSensor class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libview/Attic/WSensor.st,v 1.110 1997-08-13 21:05:00 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libview/Attic/WSensor.st,v 1.111 1997-08-19 15:36:39 cg Exp $'
 ! !
 WindowSensor initialize!
--- a/WindowSensor.st	Tue Aug 19 17:28:51 1997 +0200
+++ b/WindowSensor.st	Tue Aug 19 17:36:39 1997 +0200
@@ -2284,10 +2284,14 @@
      in future versions. (or the new device may simulate the arrival of
      such an event)"
 
-    |blocked lostExpose|
+    |blocked lostExpose device stopPoll endPollTime|
+
+    device := aView graphicsDevice.
 
     "/ this is only needed for X ...
-    aView device scrollsAsynchronous ifFalse:[
+    device scrollsAsynchronous ifFalse:[
+        gotExpose remove:aView ifAbsent:nil.
+        catchExpose remove:aView ifAbsent:nil.
         ^ self
     ].
 
@@ -2295,11 +2299,18 @@
     [
         aView flush.
         Processor activeProcessIsSystemProcess ifTrue:[
-            "
-             cannot really suspend, if its a systemProcess
-            "
-            [ (gotExpose includes:aView) or:[lostExpose > 2] ] whileFalse:[
-                aView graphicsDevice dispatchExposeEventFor:aView id.
+            endPollTime := AbsoluteTime now addSeconds:10.
+            stopPoll := false.
+
+            "/
+            "/ cannot really suspend, if its a systemProcess
+            "/ must poll for the event
+            "/
+            [(gotExpose includes:aView) or:[stopPoll]] whileFalse:[
+                (device exposeEventPendingFor:aView id withSync:true) ifTrue:[
+                    device dispatchExposeEventFor:aView id.
+                ].
+                stopPoll := (AbsoluteTime now > endPollTime).
                 Processor yield.
             ]
         ] ifFalse:[
@@ -2319,7 +2330,7 @@
                  if the event does not arrive after 15 seconds.
                 "
                 (exposeEventSemaphore waitWithTimeout:(1 * lostExpose)) isNil ifTrue:[
-                    aView graphicsDevice flush.         "/ we are paranoid
+                    device flush.         "/ we are paranoid
                     lostExpose == 1 ifTrue:[
                         "
                          you can put a comment around the following line, 
@@ -2350,8 +2361,8 @@
         eventSemaphore signalOnce
     ].
 
-    "Modified: 23.1.1997 / 22:29:16 / cg"
     "Modified: 20.2.1997 / 09:24:31 / stefan"
+    "Modified: 19.8.1997 / 17:36:20 / cg"
 !
 
 waitNoButton
@@ -2369,6 +2380,6 @@
 !WindowSensor class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libview/WindowSensor.st,v 1.110 1997-08-13 21:05:00 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libview/WindowSensor.st,v 1.111 1997-08-19 15:36:39 cg Exp $'
 ! !
 WindowSensor initialize!