WindowSensor.st
branchjv
changeset 7541 39940e2446a5
parent 7395 11ad4a5661c8
parent 7468 6cc4f99397af
child 7542 9e125aa140f9
--- a/WindowSensor.st	Thu Sep 01 23:27:10 2016 +0100
+++ b/WindowSensor.st	Mon Aug 01 23:30:02 2016 +0100
@@ -1684,7 +1684,7 @@
     "an noexpose event arrived - this is sent from the device (Display)"
 
     (catchExpose includes:aView) ifFalse:[
-        'WSensor [warning]: got noExpose for non-catching view:' infoPrint. aView infoPrintCR.
+        Logger info:'noExpose but not catching: %1' with:aView.
         ^ self.
     ].
     gotExpose add:aView.
@@ -2018,7 +2018,7 @@
 
     "/ per device listeners
     "/ KLUDGE: change this as soon as DeviceWorkstation creates WindowEvents.
-    (v := anEvent view) notNil ifTrue:[
+    ((v := anEvent view) notNil and:[v device notNil]) ifTrue:[
         (v device notifyEventListenersAbout:anEvent) == true ifTrue:[
             anyListenerReturnedTrue := true
         ]
@@ -3211,16 +3211,16 @@
      to prepare for the exposeEventSemaphore to be signalled when 
      the noExpose event arrives)."
 
-    "/ this is only needed for X ...
-    aView device scrollsAsynchronous ifFalse:[
-        ^ self
-    ].
+"/ we never come here - this is already checked by the sender
+"/    aView device scrollsAsynchronous ifFalse:[
+"/        ^ self
+"/    ].
 
     (catchExpose includes:aView) ifTrue:[
-        ('WSensor [warning]: already catching (for ' , aView printString , ')') errorPrintCR.
+        Logger warning:'already catching (for %1)' with:aView.
         Delay waitForMilliseconds:100.
         (catchExpose includes:aView) ifTrue:[
-            ('WSensor [warning]: still catching (for ' , aView printString , ')') errorPrintCR.
+            Logger warning:'still catching after 100ms (for %1)' with:aView.
             "/ wake the other one
             gotExpose add:aView.
             exposeEventSemaphore notNil ifTrue:[
@@ -3243,6 +3243,7 @@
 !
 
 pollForActivity
+    <resource: #obsolete>
     "ST-80 compatibility: wait for some activity (i.e. poll for an event) "
 
     "/ should add a buttonStateChangeSemaphore and wait on this ...
@@ -3253,6 +3254,7 @@
 !
 
 waitButton
+    <resource: #obsolete>
     "ST-80 compatibility: wait until any mouse button is pressed.
      Do not use this in your applications; polling the sensor is
      bad style."
@@ -3265,6 +3267,7 @@
 !
 
 waitClickButton
+    <resource: #obsolete>
     "ST-80 compatibility: wait until any mouse button is pressed & released again.
      Do not use this in your applications; polling the sensor is
      bad style."
@@ -3286,13 +3289,14 @@
 
     viewsDevice := aView graphicsDevice.
 
-    viewsDevice scrollsAsynchronous ifFalse:[
-        gotExpose remove:aView ifAbsent:nil.
-        catchExpose remove:aView ifAbsent:nil.
-        ^ self
-    ].
+"/ we never come here - this is already checked by the sender
+"/    viewsDevice scrollsAsynchronous ifFalse:[
+"/        gotExpose remove:aView ifAbsent:nil.
+"/        catchExpose remove:aView ifAbsent:nil.
+"/        ^ self
+"/    ].
     (exposeSema := exposeEventSemaphore) isNil ifTrue:[
-        ('WindowSensor [warning]: expose wait, but no catchExpose done before') errorPrintCR.
+        Logger warning:'expose wait, but no catchExpose done before: %1' with:aView.
         gotExpose remove:aView ifAbsent:nil.
         catchExpose remove:aView ifAbsent:nil.
         ^ self
@@ -3306,15 +3310,15 @@
             "/ since this is definitely a local display,
             "/ there is no need for a long timeOut
             "/ (it should arrive fast)
-            pollDelay := 0.05.
-            pollDelay2 := 0.05.
+            pollDelay := 50.
+            pollDelay2 := 50.
         ] ifFalse:[
-            pollDelay := 3.
-            pollDelay2 := 1.
+            pollDelay := 3000.
+            pollDelay2 := 1000.
         ].
 
         Processor activeProcessIsSystemProcess ifTrue:[
-            endPollTime := Timestamp now addSeconds:pollDelay.
+            endPollTime := Timestamp now addMilliseconds:pollDelay.
             stopPoll := false.
 
             "/
@@ -3347,13 +3351,13 @@
                 exposeSema isNil ifTrue:[
                     lostExpose := 999.
                 ].
-                (exposeSema waitWithTimeout:(pollDelay2 * lostExpose)) isNil ifTrue:[
+                (exposeSema waitWithTimeoutMs:(pollDelay2 * lostExpose)) isNil ifTrue:[
                     viewsDevice flush.         "/ we are paranoid
                     lostExpose := lostExpose + 1.
                 ].
             ].
             (gotExpose includes:aView) ifFalse:[
-                ('WindowSensor [warning]: lost expose event (' , aView printString , ')') errorPrintCR.
+                Logger warning:'lost expose event: %1' with:aView.
             ] ifTrue:[
 "/                lostExpose > 1 ifTrue:[
 "/                    ('WindowSensor [info]: late expose event (' , aView printString , ')') infoPrintCR.
@@ -3374,8 +3378,10 @@
         "/
         "/ other incoming events have been ignored during the wait.
         "/ Now handle those ...
-        "/
-        eventSemaphore signalOnce
+        "/  
+        eventSemaphore notNil ifTrue:[
+            eventSemaphore signalOnce.
+        ].
     ].
 
     "Modified: / 20-02-1997 / 09:24:31 / stefan"
@@ -3383,6 +3389,7 @@
 !
 
 waitNoButton
+    <resource: #obsolete>
     "ST-80 compatibility: wait until no mouse button is pressed.
      Do not use this in your applications; polling the sensor is
      bad style."