#TUNING by stefan
authorStefan Vogel <sv@exept.de>
Tue, 21 Feb 2017 10:28:59 +0100
changeset 7919 65494793e281
parent 7918 ad5373d62245
child 7920 522478f29bab
#TUNING by stefan class: SimpleView changed: #openModal:inGroup: refactoring #showBusyWhile: do not create lots of Delays
SimpleView.st
--- a/SimpleView.st	Tue Feb 21 02:03:45 2017 +0100
+++ b/SimpleView.st	Tue Feb 21 10:28:59 2017 +0100
@@ -4948,50 +4948,53 @@
 
     ok := true.
     bitmaps := #('wheel1' 'wheel2' 'wheel3' 'wheel4')
-	       collect:[:name |
-		   |f|
-
-		   f := Smalltalk imageFromFileNamed:(name , '.xbm') forClass:self class.
-		   f isNil ifTrue:[
-			('SimpleView [warning]: no bitmap file: ' , name , '.xbm') errorPrintCR.
-			ok := false
-		   ].
-		   f
-	       ].
+               collect:[:name |
+                   |f|
+
+                   f := Smalltalk imageFromFileNamed:(name , '.xbm') forClass:self class.
+                   f isNil ifTrue:[
+                        ('SimpleView [warning]: no bitmap file: ' , name , '.xbm') errorPrintCR.
+                        ok := false
+                   ].
+                   f
+               ].
 
     ok ifTrue:[
-	maskForm := Smalltalk imageFromFileNamed:'wheelm.xbm' forClass:self class.
-	maskForm isNil ifTrue:[
-	    ('SimpleView [warning]: no bitmap file: wheelm.xbm') errorPrintCR.
-	    ok := false
-	].
+        maskForm := Smalltalk imageFromFileNamed:'wheelm.xbm' forClass:self class.
+        maskForm isNil ifTrue:[
+            ('SimpleView [warning]: no bitmap file: wheelm.xbm') errorPrintCR.
+            ok := false
+        ].
     ].
 
     ok ifFalse:[
-	self cursor:Cursor wait.
-	aBlock ensure:[
-	    self cursor:oldCursor
-	]
+        self cursor:Cursor wait.
+        aBlock ensure:[
+            self cursor:oldCursor
+        ]
     ] ifTrue:[
-	cursors := bitmaps collect:[:form | (Cursor sourceForm:form
-						      maskForm:maskForm
-							  hotX:8
-							  hotY:8) onDevice:device].
-
-	process := [
-		    Delay waitForSeconds:0.25.
-		    [
-			cursors do:[:curs |
-			    self cursor:curs.
-			    Delay waitForSeconds:0.05.
-			]
-		    ] loop.
-	   ] forkAt:(Processor activeProcess priority + 1).
-
-	aBlock ensure:[
-	    process terminate.
-	    self cursor:oldCursor
-	]
+        cursors := bitmaps collect:[:form | (Cursor sourceForm:form
+                                                      maskForm:maskForm
+                                                          hotX:8
+                                                          hotY:8) onDevice:device].
+
+        process := [
+                    |shortDelay|
+
+                    Delay waitForSeconds:0.25.
+                    shortDelay := Delay forSeconds:0.05.
+                    [
+                        cursors do:[:curs |
+                            self cursor:curs.
+                            shortDelay wait.
+                        ]
+                    ] loop.
+           ] forkAt:(Processor activeProcess priority + 1).
+
+        aBlock ensure:[
+            process terminate.
+            self cursor:oldCursor
+        ]
     ].
 
     "
@@ -4999,7 +5002,8 @@
      Transcript showBusyWhile:[ Delay waitForSeconds:5 ]
     "
 
-    "Modified: / 31.10.1997 / 19:59:49 / cg"
+    "Modified: / 31-10-1997 / 19:59:49 / cg"
+    "Modified: / 20-02-2017 / 17:15:54 / stefan"
 ! !
 
 !SimpleView methodsFor:'dependents access'!
@@ -11396,83 +11400,87 @@
     self raise.
 
     inSystemProcess ifTrue:[
-        self realize
-    ] ifFalse:[
-        "
-         show a stop-cursor in the suspended window groups
-        "
-        (mainGroup notNil and:[isPopup not]) ifTrue:[
-            mainGroup showCursor:(Cursor stop).
-            previousGroup ~~ mainGroup ifTrue:[
-                previousGroup showCursor:(Cursor stop).
-            ].
-            cursorChanged := true.
+        self realize.
+        ^ self.
+    ].
+
+    "
+     show a stop-cursor in the suspended window groups
+    "
+    (mainGroup notNil and:[isPopup not]) ifTrue:[
+        mainGroup showCursor:(Cursor stop).
+        previousGroup ~~ mainGroup ifTrue:[
+            previousGroup showCursor:(Cursor stop).
         ].
-
-        "
-         go dispatch events in this new group
-         (thus current windowgroup is blocked from interaction)
-        "
-        AbortOperationRequest handle:[:ex |
-            "/ the dialog/popup is aborted - hide it. Care for another abort during the hide.
-            AbortOperationRequest handle:[:ex2 |
-                "/ an aborted hide (possibly due to a cancelled user confirmation or similar)
-                self breakPoint:#cg.
-                ex exit.
-            ] do:[
-                self hide.
-                realized ifTrue:[
-                    "/ self halt. "/ hide handled and closeRequest not wanted:
-                    ex exit.
-                ].
-            ].
+        cursorChanged := true.
+    ].
+
+    "
+     go dispatch events in this new group
+     (thus current windowgroup is blocked from interaction)
+    "
+    AbortOperationRequest handle:[:ex |
+        "/ the dialog/popup is aborted - hide it. Care for another abort during the hide.
+        AbortOperationRequest handle:[:ex2 |
+            "/ an aborted hide (possibly due to a cancelled user confirmation or similar)
+            self breakPoint:#cg.
+            ex proceed.
         ] do:[
-            [
-                [
-                    windowGroup startupModal:[realized and:aBlock] forGroup:activeWindowGroup
-                ] ifCurtailed:[
-                    self hide.
-                ]
-            ] ensure:[
-                activeWindowGroup notNil ifTrue:[
-                    activeWindowGroup graphicsDevice sync.  "that's a round trip - make sure that all drawing has been processed"
-                    "/ ensure that eventListener runs here ...
-                    Delay waitForMilliseconds:50.
-                    activeWindowGroup processExposeEvents.
-
-                    (self isPopUpView or:[ReturnFocusWhenClosingModalBoxes]) ifTrue:[
-                        "
-                         return the input focus to the previously active group's top.
-                         This helps with window managers which need an explicit click
-                         on the view for the focus.
-                         Only do this, if the previous group is still having the focus.
-                         (i.e. no other view was opened in the meantime)
-                        "
-                        activeWindowGroup graphicsDevice focusView isNil ifTrue:[
-                            tops := activeWindowGroup topViews.
-                            (tops notEmptyOrNil) ifTrue:[
-                                tops first getKeyboardFocus
-                            ].
-                        ].
-                    ].
-
+            self hide.
+            realized ifTrue:[
+                "/ self halt. "/ hide handled and closeRequest not wanted:
+                ex proceed.
+            ].
+        ].
+    ] do:[
+        |startupDone|
+
+        [
+            startupDone := windowGroup startupModal:[realized and:aBlock] forGroup:activeWindowGroup
+        ] ensure:[
+            startupDone isNil ifTrue:[
+                "startupModal above has been curtailed"
+                self hide.
+            ].
+            activeWindowGroup notNil ifTrue:[
+                activeWindowGroup graphicsDevice sync.  "that's a round trip - make sure that all drawing has been processed"
+                "/ ensure that eventListener runs here ...
+                Delay waitForMilliseconds:50.
+                activeWindowGroup processExposeEvents.
+
+                (self isPopUpView or:[ReturnFocusWhenClosingModalBoxes]) ifTrue:[
                     "
-                     restore cursors in the changed groups
+                     return the input focus to the previously active group's top.
+                     This helps with window managers which need an explicit click
+                     on the view for the focus.
+                     Only do this, if the previous group is still having the focus.
+                     (i.e. no other view was opened in the meantime)
                     "
-                    cursorChanged notNil ifTrue:[
-                        mainGroup restoreCursors.
-                        previousGroup ~~ mainGroup ifTrue:[
-                            previousGroup restoreCursors.
+                    activeWindowGroup graphicsDevice focusView isNil ifTrue:[
+                        tops := activeWindowGroup topViews.
+                        tops notEmptyOrNil ifTrue:[
+                            tops first getKeyboardFocus
                         ].
                     ].
                 ].
-                Dialog boxClosedNotificationSignal raiseRequestWith:self.
-            ]
+
+                "
+                 restore cursors in the changed groups
+                "
+                cursorChanged notNil ifTrue:[
+                    mainGroup restoreCursors.
+                    previousGroup ~~ mainGroup ifTrue:[
+                        previousGroup restoreCursors.
+                    ].
+                ].
+            ].
+            Dialog boxClosedNotificationSignal raiseRequestWith:self.
         ].
-    ]
+    ].
 
     "Created: / 10-12-1995 / 14:06:14 / cg"
     "Modified: / 29-08-2013 / 16:17:10 / cg"
+    "Modified: / 20-02-2017 / 17:10:34 / stefan"
 !
 
 openModalAt:aPoint