WindowGroup.st
changeset 2126 1f108c76dfdb
parent 2116 b389262e58b1
child 2154 4b2a478e59b8
--- a/WindowGroup.st	Wed May 20 21:56:14 1998 +0200
+++ b/WindowGroup.st	Thu May 21 01:58:25 1998 +0200
@@ -1060,46 +1060,47 @@
 
     <resource: #keyboard (#Escape )>
 
-    |event ignore key focus modalTops modalTop modalDelegate syntheticEvent|
+    |event ignore key focus firstTop evView evType evArgs
+     modalTops modalTop modalDelegate syntheticEvent|
 
     self processExposeEvents.
 
     [mySensor hasEvents] whileTrue:[
-	event := mySensor nextEvent.
-	event notNil ifTrue:[
-	    ignore := false.
-	    focus := focusView.
-	    modalDelegate := false.
+        event := mySensor nextEvent.
+        event notNil ifTrue:[
+            ignore := false.
+            focus := focusView.
+            modalDelegate := false.
 
-	    modalGroup notNil ifTrue:[
-		"/ an incoming event for a masterView, 
-		"/ while being blocked by some other modalView.
+            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.
-		].
+                modalTops := modalGroup topViews.
+                modalTops size > 0 ifTrue:[
+                    modalTop := modalTops first.
+                ].
 
-		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:[
-			    "/ 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)
+                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:[
+                            "/ 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 |
@@ -1107,93 +1108,103 @@
 "/                            ] do:[
 "/                                syntheticEvent sendEventWithFocusOn:nil.
 "/                            ].
-			    event view:modalTop.
-			].
-			modalDelegate := true.
-		    ] ifFalse:[
-			event isPointerLeaveEvent ifTrue:[
-			] ifFalse:[
-			    event isUserEvent ifTrue:[
-				ignore := true
-			    ]
-			]
-		    ]
-		]
-	    ].
+                            event view:modalTop.
+                        ].
+                        modalDelegate := true.
+                    ] ifFalse:[
+                        event isPointerLeaveEvent ifTrue:[
+                        ] ifFalse:[
+                            event isUserEvent ifTrue:[
+                                ignore := true
+                            ]
+                        ]
+                    ]
+                ]
+            ].
 
-	    ignore ifFalse:[
-		(views notNil or:[topViews notNil]) ifTrue:[
-		    LastEventQuerySignal handle:[:ex |
-			ex proceedWith:event
-		    ] do:[
-			(preEventHook  notNil 
-			and:[preEventHook processEvent:event]) ifTrue:[
-			    ignore := true.
-			].
+            ignore ifFalse:[
+                (views notNil or:[topViews notNil]) ifTrue:[
+                    LastEventQuerySignal handle:[:ex |
+                        ex proceedWith:event
+                    ] do:[
+                        (preEventHook  notNil 
+                        and:[preEventHook processEvent:event]) ifTrue:[
+                            ignore := true.
+                        ].
 
-			ignore ifFalse:[
-			    event isKeyPressEvent ifTrue:[
-				key := event key.
+                        ignore ifFalse:[
+                            evView := event view.
+
+                            event isKeyPressEvent ifTrue:[
+                                key := event key.
 
-				key == #Escape ifTrue:[
-				    modalDelegate ifTrue:[
-					modalTop hideRequest
-				    ] ifFalse:[
-					isModal ifTrue:[
-					    topViews first hideRequest
-					]
-				    ]
-				]
-			    ].
-			    event isPointerEnterEvent ifTrue:[
-				pointerView := event view
-			    ].
-			    event isPointerLeaveEvent ifTrue:[
-				pointerView := nil
-			    ].
+                                key == #Escape ifTrue:[
+                                    modalDelegate ifTrue:[
+                                        modalTop hideRequest
+                                    ] ifFalse:[
+                                        isModal ifTrue:[
+                                            topViews first hideRequest
+                                        ]
+                                    ]
+                                ]
+                            ] ifFalse:[
+                                "/
+                                "/ keep track of which view has the pointer
+                                "/
+                                event isPointerEnterEvent ifTrue:[
+                                    pointerView := evView
+                                ] ifFalse:[
+                                    event isPointerLeaveEvent ifTrue:[
+                                        pointerView := nil
+                                    ]
+                                ]
+                            ].
+
+                            "/
+                            "/  buttonPress events turn off explicit focus, and revert
+                            "/  to implicit focus control
+                            "/
+                            (focusView notNil
+                            and:[event isButtonPressEvent]) ifTrue:[
+                                self focusView:nil
+                            ].
 
-			    ignore ifFalse:[
-				"/
-				"/  buttonPress events turn off explicit focus, and revert
-				"/  to implicit focus control
-				"/
-				(focusView notNil
-				and:[event isButtonPressEvent]) ifTrue:[
-				    self focusView:nil
-				].
-				"/
-				"/ let the event forward itself
-				"/
-				LastActiveGroup := self.
-				LastActiveProcess := Processor activeProcess.
+                            LastActiveGroup := self.
+                            LastActiveProcess := Processor activeProcess.
+
+                            "
+                             if there is no view information in the event,
+                             it must have been sent directly to the sensor.
+                             Send it to the first topView.
+                            "
+                            evType := event type.
+                            evArgs := event arguments.
 
-				"
-				 if there is no view information in the event,
-				 it must have been sent directly to the sensor.
-				 Send it to the first topView.
-				"
-				event view isNil ifTrue:[
-				    topViews first notNil ifTrue:[
-					topViews first perform:event type withArguments:event arguments
-				    ]
-				] ifFalse:[
-				    event sendEventWithFocusOn:focus.
-				]
-			    ]
-			].
+                            evView isNil ifTrue:[
+                                (firstTop := topViews first) notNil ifTrue:[
+                                    firstTop perform:evType withArguments:evArgs
+                                ]
+                            ] ifFalse:[
+                                evView
+                                    dispatchEvent:evType 
+                                    arguments:evArgs 
+                                    withFocusOn:focus 
+                                    delegate:true
+                            ]
+                        ].
 
-			postEventHook notNil ifTrue:[
-			    postEventHook processEvent:event
-			].
-		    ]
-		]
-	    ].
-	    event := nil.
-	].
+                        postEventHook notNil ifTrue:[
+                            postEventHook processEvent:event
+                        ].
+                    ]
+                ]
+            ].
+            event := nil.
+        ].
     ]
 
-    "Created: 5.3.1997 / 11:33:11 / cg"
-    "Modified: 20.8.1997 / 15:23:31 / cg"
+    "Created: / 5.3.1997 / 11:33:11 / cg"
+    "Modified: / 21.5.1998 / 00:14:59 / cg"
 !
 
 processExposeEvents
@@ -1217,8 +1228,9 @@
                 ] do:[
                     (preEventHook notNil 
                     and:[preEventHook processEvent:event]) ifFalse:[
+                        view := event view.
+
                         event isDamage ifTrue:[
-                            view := event view.
                             "/
                             "/ if the view is no longer shown (iconified or closed),
                             "/ this is a leftover event and ignored.
@@ -1227,21 +1239,13 @@
                                 LastActiveGroup := self.
                                 LastActiveProcess := thisProcess.
 
-"/                                rect := event rectangle.
-"/                                x := rect left.
-"/                                y := rect top.
-"/                                w := rect width.
-"/                                h := rect height.
-"/
-"/                                view transformation notNil ifTrue:[
-"/                                    view deviceExposeX:x y:y width:w height:h
-"/                                ] ifFalse:[
-"/                                    view exposeX:x y:y width:w height:h
-"/                                ]
+                                view
+                                    dispatchEvent:(event type) 
+                                    arguments:(event arguments) 
+                                    withFocusOn:nil 
+                                    delegate:true
 
-                                event sendEventWithFocusOn:nil.
-
-                            ] ifFalse:[
+"/                            ] ifFalse:[
 "/                                ('WGROUP: damage for ' , view displayString , ' ignored') infoPrintCR.
                             ]
                         ] ifFalse:[
@@ -1250,7 +1254,12 @@
                             "
                             LastActiveGroup := self.
                             LastActiveProcess := thisProcess.
-                            event sendEventWithFocusOn:nil.
+                            "/ event sendEventWithFocusOn:nil.
+                            view
+                                dispatchEvent:(event type) 
+                                arguments:(event arguments) 
+                                withFocusOn:nil 
+                                delegate:true
                         ]
                     ].
                     postEventHook notNil ifTrue:[
@@ -1261,7 +1270,7 @@
         ]
     ]
 
-    "Modified: / 5.4.1998 / 11:35:21 / cg"
+    "Modified: / 21.5.1998 / 00:17:18 / cg"
 !
 
 processRealExposeEvents
@@ -1744,6 +1753,6 @@
 !WindowGroup class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libview/WindowGroup.st,v 1.134 1998-05-16 15:35:31 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libview/WindowGroup.st,v 1.135 1998-05-20 23:57:43 cg Exp $'
 ! !
 WindowGroup initialize!