WindowGroup.st
changeset 7825 07ea44507793
parent 7709 653b97047e4d
child 7827 1e4843632745
--- a/WindowGroup.st	Tue Jan 31 16:17:37 2017 +0100
+++ b/WindowGroup.st	Tue Jan 31 17:06:55 2017 +0100
@@ -1649,229 +1649,223 @@
     self processExposeEvents.
 
     [
-        LastEventQuerySignal handle:[:ex |
-            ex proceedWith:event
-        ] do:[
-            [mySensor notNil
-             and:[(event := mySensor nextEvent) notNil]] whileTrue:[
-                ignore := false.
-                focus := focusView.
-                modalDelegate := false.
-                modalTop := nil.
-
-                modalGroup notNil ifTrue:[
-                    "/ an incoming event for a masterView, 
-                    "/ while being blocked by some other modalView.
-
-                    modalTops := modalGroup topViews.
-                    modalTops size > 0 ifTrue:[
-                        modalTop := modalTops first.
+        [mySensor notNil
+         and:[(event := mySensor nextEvent) notNil]] whileTrue:[
+            ignore := false.
+            focus := focusView.
+            modalDelegate := false.
+            modalTop := nil.
+
+            modalGroup notNil ifTrue:[
+                "/ an incoming event for a masterView, 
+                "/ while being blocked by some other modalView.
+
+                modalTops := modalGroup topViews.
+                modalTops notEmptyOrNil ifTrue:[
+                    modalTop := modalTops first.
+                ].
+
+                event isKeyEvent ifTrue:[
+                    "/ forward keyboard events to my modal
+                    "/ groups first topView ...
+                    modalTop notNil ifTrue:[
+                        focus := modalTop.
+                        modalDelegate := true.
+                    ].
+                    modalGroup focusView notNil ifTrue:[
+                        focus := modalGroup focusView
                     ].
-
-                    event isKeyEvent ifTrue:[
-                        "/ forward keyboard events to my modal
-                        "/ groups first topView ...
-                        modalTop notNil ifTrue:[
-                            focus := modalTop.
-                            modalDelegate := true.
+                ] ifFalse:[
+                    event isFocusEvent ifTrue:[
+                        event isFocusInEvent ifTrue:[
+                            "/ move focus over to modalBox
+                            modalTop notNil ifTrue:[
+                                modalTop getKeyboardFocus.
+                                "/ focusIn is forwarded to the modalGroup
+                                "/ (since keyboard is forwarded)
+                                event view:modalTop.
+                                focus := modalTop.
+                            ]
+                        ] ifFalse:[
+                            "/ focusOut goes to both the modal and
+                            "/ the blocked main-group
+                            "/ (actually, only the very first focusOut
+                            "/  is needed in the mainGroup (to turn off the cursor)
+                            "/  all others are only needed in the modalGroup)
+
+"/                            syntheticEvent := event copy.
+"/                            syntheticEvent view:modalTop.
+"/                            LastEventQuerySignal handle:[:ex |
+"/                                ex proceedWith:syntheticEvent
+"/                            ] do:[
+"/                                syntheticEvent sendEventWithFocusOn:nil.
+"/                            ].
+
+                            "/ event view:modalTop.
                         ].
-                        modalGroup focusView notNil ifTrue:[
-                            focus := modalGroup focusView
-                        ].
+                        modalDelegate := true.
                     ] ifFalse:[
-                        event isFocusEvent ifTrue:[
-                            event isFocusInEvent ifTrue:[
-                                "/ move focus over to modalBox
-                                modalTop notNil ifTrue:[
-                                    modalTop getKeyboardFocus.
-                                    "/ focusIn is forwarded to the modalGroup
-                                    "/ (since keyboard is forwarded)
-                                    event view:modalTop.
-                                    focus := modalTop.
-                                ]
-                            ] ifFalse:[
-                                "/ focusOut goes to both the modal and
-                                "/ the blocked main-group
-                                "/ (actually, only the very first focusOut
-                                "/  is needed in the mainGroup (to turn off the cursor)
-                                "/  all others are only needed in the modalGroup)
-
-    "/                            syntheticEvent := event copy.
-    "/                            syntheticEvent view:modalTop.
-    "/                            LastEventQuerySignal handle:[:ex |
-    "/                                ex proceedWith:syntheticEvent
-    "/                            ] do:[
-    "/                                syntheticEvent sendEventWithFocusOn:nil.
-    "/                            ].
-
-                                "/ event view:modalTop.
-                            ].
-                            modalDelegate := true.
+                        event isPointerLeaveEvent ifTrue:[
                         ] ifFalse:[
-                            event isPointerLeaveEvent ifTrue:[
-                            ] ifFalse:[
-                                event isUserEvent ifTrue:[
-                                    ignore := true.
-
-                                    event isButtonPressEvent ifTrue:[
-                                        "/ raise the modalTop and beep 
-                                        event view device beep.
-                                        modalTop notNil ifTrue:[ modalTop raise ].
-                                    ]
+                            event isUserEvent ifTrue:[
+                                ignore := true.
+
+                                event isButtonPressEvent ifTrue:[
+                                    "/ raise the modalTop and beep 
+                                    event view device beep.
+                                    modalTop notNil ifTrue:[ modalTop raise ].
                                 ]
                             ]
                         ]
-                    ].
-                    "/ also update the slave-sensor's modifier state from the master-sensor's
-                    "/ state. This is needed for a popUpView to see the correct shift-, ctrl- and alt states
-                    "/ in its own sensor.
-
-                    "/ cg: disabled 15-jun-2014
-                    "/ mhmh - something seems to have changed on a lower level,
-                    "/ so now the modal sensor already has the correct sensor state
-                    "/ (as opposed to previous versions, where this was not true).
-                    "/ Now, enabling the following line leads to a confirmation dialog to NOT
-                    "/ behave correctly w.r.t. Shift-CursorRight.
-                    "/ I wonder, what is responsible for that fixing side effect... (sigh)
-                    "/ modalGroup sensor updateModifierStatesFrom:mySensor
+                    ]
                 ].
-
-                ignore ifFalse:[
-                    (views notNil or:[topViews notNil]) ifTrue:[
-
-                        "/ give eventRecorders, catchers etc. 
-                        "/ a chance to eat or modify that event
-
-                        modalGroup notNil ifTrue:[
-                            ignore := (modalGroup executePreEventHooksFor:event).
-                        ] ifFalse:[
-                            ignore := false
-                        ].
+                "/ also update the slave-sensor's modifier state from the master-sensor's
+                "/ state. This is needed for a popUpView to see the correct shift-, ctrl- and alt states
+                "/ in its own sensor.
+
+                "/ cg: disabled 15-jun-2014
+                "/ mhmh - something seems to have changed on a lower level,
+                "/ so now the modal sensor already has the correct sensor state
+                "/ (as opposed to previous versions, where this was not true).
+                "/ Now, enabling the following line leads to a confirmation dialog to NOT
+                "/ behave correctly w.r.t. Shift-CursorRight.
+                "/ I wonder, what is responsible for that fixing side effect... (sigh)
+                "/ modalGroup sensor updateModifierStatesFrom:mySensor
+            ].
+
+            ignore ifFalse:[
+                (views notNil or:[topViews notNil]) ifTrue:[
+                    "/ give eventRecorders, catchers etc. 
+                    "/ a chance to eat or modify that event
+                    modalGroup notNil ifTrue:[
+                        ignore := modalGroup executePreEventHooksFor:event.
+                    ] ifFalse:[
+                        ignore := false
+                    ].
+                    ignore ifFalse:[
+                        ignore := self executePreEventHooksFor:event.
                         ignore ifFalse:[
-                            ignore := (self executePreEventHooksFor:event).
+                            evView := event view.
+
+                            (event isKeyEvent 
+                            and:[(keyboardProcessor := (modalTop ? evView topView) keyboardProcessor) notNil]) ifTrue:[
+                                ignore := keyboardProcessor processEvent:event forModalView:modalTop
+                            ].
+
                             ignore ifFalse:[
-                                evView := event view.
-
-                                (event isKeyEvent 
-                                and:[(keyboardProcessor := (modalTop ? evView topView) keyboardProcessor) notNil]) ifTrue:[
-                                    ignore := keyboardProcessor processEvent:event forModalView:modalTop
-                                ].
-
-                                ignore ifFalse:[
-                                    "/ event handling below will vanish ...
-                                    "/ (keyboardProcessor will do it eventually)
-
-                                    event isKeyPressEvent ifTrue:[
-                                        event key == #Escape ifTrue:[
-                                            modalDelegate ifTrue:[
-                                                top := modalTop.
-                                            ] ifFalse:[
-                                                (isModal and:[topViews size > 0]) ifTrue:[
-                                                    top := topViews first.
+                                "/ event handling below will vanish ...
+                                "/ (keyboardProcessor will do it eventually)
+
+                                event isKeyPressEvent ifTrue:[
+                                    event key == #Escape ifTrue:[
+                                        modalDelegate ifTrue:[
+                                            top := modalTop.
+                                        ] ifFalse:[
+                                            (isModal and:[topViews notEmptyOrNil]) ifTrue:[
+                                                top := topViews first.
+                                            ]
+                                        ].
+                                        top notNil ifTrue:[
+                                            "/ a popUpView does it himself (only closing one submenu)
+                                            (top isPopUpView not
+                                             or:[UserPreferences current closePopUpMenuChainOnEscape]) ifTrue:[
+                                                top escapeIsCancel ifTrue:[
+                                                    top closeCancel.
+                                                    "/ top hideRequest. 
+                                                    top realized ifFalse:[ ignore := true ].
                                                 ]
-                                            ].
-                                            top notNil ifTrue:[
-                                                "/ a popUpView does it himself (only closing one submenu)
-                                                (top isPopUpView not
-                                                or:[ UserPreferences current closePopUpMenuChainOnEscape ]) ifTrue:[
-                                                    top escapeIsCancel ifTrue:[
-                                                        top closeCancel.
-                                                        "/ top hideRequest. 
-                                                        top realized ifFalse:[ ignore := true ].
-                                                    ]
-                                                ]
-                                            ].
-                                        ]
-                                    ] ifFalse:[
-                                        "/
-                                        "/ keep track of which view has the pointer
-                                        "/
-                                        event isPointerEnterEvent ifTrue:[
-                                            pointerView := evView
-                                        ] ifFalse:[
-                                            event isPointerLeaveEvent ifTrue:[
-                                                pointerView := nil
                                             ]
-                                        ]
-                                    ].
+                                        ].
+                                    ]
+                                ] ifFalse:[
+                                    "/
+                                    "/ keep track of which view has the pointer
+                                    "/
+                                    event isPointerEnterEvent ifTrue:[
+                                        pointerView := evView
+                                    ] ifFalse:[event isPointerLeaveEvent ifTrue:[
+                                        pointerView := nil
+                                    ]].
                                 ].
                             ].
                         ].
-
-                        ignore ifFalse:[
-                            "/
-                            "/ buttonPress events turn off explicit focus, and reverts
-                            "/ to implicit focus control
-                            "/ This used to be done for every click -
-                            "/ but behaved ugly if clicking in a scrollbar ...
-
-                            "/ XXX: move to dispatchEvent
-                            event isButtonPressEvent ifTrue:[
-                                (evView wantsFocusWithButtonPress) ifTrue:[
-                                    "/ cannot use 'evView requestFocus' here,
-                                    "/ since we want to enforce it without giving the
-                                    "/ view a chance to circumvent this.
-
-                                    "/ evView requestFocus.
-                                    self focusView:evView.
-                                ].
+                    ].
+
+                    ignore ifFalse:[
+                        "/
+                        "/ buttonPress events turn off explicit focus, and reverts
+                        "/ to implicit focus control
+                        "/ This used to be done for every click -
+                        "/ but behaved ugly if clicking in a scrollbar ...
+
+                        "/ XXX: move to dispatchEvent
+                        event isButtonPressEvent ifTrue:[
+                            (evView wantsFocusWithButtonPress) ifTrue:[
+                                "/ cannot use 'evView requestFocus' here,
+                                "/ since we want to enforce it without giving the
+                                "/ view a chance to circumvent this.
+
+                                "/ evView requestFocus.
+                                self focusView:evView.
                             ].
-
-                            (busyHook notNil and:[busyHookBlock isNil]) ifTrue:[
-                                (event isKeyEvent or:[event isButtonPressEvent]) ifTrue:[
-                                    "/ start a timeout action - to invoke the busyHook after some time
-                                    busyHookCalled := false.
-                                    busyHookBlock := [ 
-                                                        (inModalLoop ~~ true and:[busyHookCalled not]) ifTrue:[ 
-                                                            busyHook value:true. 
-                                                            busyHookCalled := true 
-                                                        ] 
-                                                     ].
-                                    Processor 
-                                        addTimedBlock:busyHookBlock 
-                                        for:Processor timeoutHandlerProcess
-                                        afterMilliseconds:(busyHookTimeout ? BusyHookTime ? 150).
-                                ].
+                        ].
+
+                        (busyHook notNil and:[busyHookBlock isNil]) ifTrue:[
+                            (event isKeyEvent or:[event isButtonPressEvent]) ifTrue:[
+                                "/ start a timeout action - to invoke the busyHook after some time
+                                busyHookCalled := false.
+                                busyHookBlock := [ 
+                                                    (inModalLoop ~~ true and:[busyHookCalled not]) ifTrue:[ 
+                                                        busyHook value:true. 
+                                                        busyHookCalled := true 
+                                                    ] 
+                                                 ].
+                                Processor 
+                                    addTimedBlock:busyHookBlock 
+                                    for:Processor timeoutHandlerProcess
+                                    afterMilliseconds:(busyHookTimeout ? BusyHookTime ? 150).
                             ].
-                            event isMessageSendEvent ifTrue:[
-                                "/ a synthetic event (delayed message)
+                        ].
+                        event isMessageSendEvent ifTrue:[
+                            "/ a synthetic event (delayed message)
 "/ cg: seems to not be a good idea (see modalLoopStarts):
 "/ if in a modal-loop, do not process now, but repush onto the queue
 "/                                modalGroup notNil ifTrue:[
 "/                                    mySensor pushEvent:event
 "/                                ] ifFalse:[
-                                    event value 
+                                event value 
 "/                                ]
+                        ] ifFalse:[
+                            "
+                             if there is no view information in the event,
+                             it must have been sent directly to the sensor.
+                             Send it to the first topView.
+                            "
+                            (evReceiver := evView) isNil ifTrue:[
+                                (firstTop := topViews first) notNil ifTrue:[
+                                    event isApplicationEvent ifTrue:[
+                                        evReceiver := firstTop application ? firstTop
+                                    ] ifFalse:[
+                                        evReceiver := firstTop.
+                                    ]. 
+                                ]
+                            ].
+                            evReceiver isNil ifTrue:[
+                                ('WindowGroup [warning]: no receiver to dispatch ' , event type asString , '-event to. Ignored.') infoPrintCR.
                             ] ifFalse:[
-                                "
-                                 if there is no view information in the event,
-                                 it must have been sent directly to the sensor.
-                                 Send it to the first topView.
-                                "
-                                (evReceiver := evView) isNil ifTrue:[
-                                    (firstTop := topViews first) notNil ifTrue:[
-                                        event isApplicationEvent ifTrue:[
-                                            evReceiver := firstTop application ? firstTop
-                                        ] ifFalse:[
-                                            evReceiver := firstTop.
-                                        ]. 
-                                    ]
-                                ].
-                                evReceiver isNil ifTrue:[
-                                    ('WindowGroup [warning]: no receiver to dispatch ' , event type asString , '-event to. Ignored.') infoPrintCR.
-                                ] ifFalse:[
-                                    evReceiver dispatchEvent:event withFocusOn:focus delegate:true
-                                ].
+                                evReceiver dispatchEvent:event withFocusOn:focus delegate:true
                             ].
                         ].
-
-                        "/ give eventRecorders, postProcessors 
-                        "/ a chance to see that event
-                        self executePostEventHooksFor:event
-                    ]
-                ].
+                    ].
+
+                    "/ give eventRecorders, postProcessors 
+                    "/ a chance to see that event
+                    self executePostEventHooksFor:event
+                ]
             ].
-        ]
+        ] "end while".
+    ] on:LastEventQuerySignal do:[:ex |
+        ex proceedWith:event
     ] ensure:[
         busyHookBlock notNil ifTrue:[
             Processor removeTimedBlock:busyHookBlock.
@@ -1883,8 +1877,9 @@
         ].
     ].
 
-    "Created: / 5.3.1997 / 11:33:11 / cg"
-    "Modified: / 4.8.1998 / 18:18:55 / cg"
+    "Created: / 05-03-1997 / 11:33:11 / cg"
+    "Modified: / 04-08-1998 / 18:18:55 / cg"
+    "Modified: / 31-01-2017 / 16:48:45 / stefan"
 !
 
 processExposeEvents