WindowGroup.st
changeset 328 7bbe05da5769
parent 325 b24d9a1c74dc
child 329 8a34deadc4ff
equal deleted inserted replaced
327:4913efd64d60 328:7bbe05da5769
   646     |thisProcess|
   646     |thisProcess|
   647 
   647 
   648     thisProcess := Processor activeProcess.
   648     thisProcess := Processor activeProcess.
   649 
   649 
   650     [
   650     [
   651 	"/
   651         "/
   652 	"/ on leave, exit the event loop
   652         "/ on leave, exit the event loop
   653 	"/
   653         "/
   654 	LeaveSignal handle:[:ex |
   654         LeaveSignal handle:[:ex |
   655 	    ex return
   655             ex return
   656 	] do:[
   656         ] do:[
   657 	    |p g mainGroup mySema waitSema|
   657             |p g mainGroup mySema waitSema|
   658 
   658 
   659 	    waitSema := mySema := mySensor eventSemaphore.
   659             waitSema := mySema := mySensor eventSemaphore.
   660 
   660 
   661 	    isModal ifTrue:[
   661             isModal ifTrue:[
   662 		mainGroup := self mainGroup.
   662                 mainGroup := self mainGroup.
   663 		mainGroup == self ifTrue:[
   663                 mainGroup == self ifTrue:[
   664 		    mainGroup := nil
   664                     mainGroup := nil
   665 		].
   665                 ].
   666 		mainGroup notNil ifTrue:[
   666                 mainGroup notNil ifTrue:[
   667 		    waitSema := SemaphoreSet with:mySema 
   667                     waitSema := SemaphoreSet with:mySema 
   668 					     with:(mainGroup sensor eventSemaphore).
   668                                              with:(mainGroup sensor eventSemaphore).
   669 		].
   669                 ].
   670 	    ].
   670             ].
   671 
   671 
   672 	    aBlock whileTrue:[ 
   672             aBlock whileTrue:[ 
   673 		LastActiveGroup := self.
   673                 LastActiveGroup := self.
   674 		LastActiveProcess := thisProcess.
   674                 LastActiveProcess := thisProcess.
   675 
   675 
   676 		(views isNil and:[topViews isNil]) ifTrue:[
   676                 (views isNil and:[topViews isNil]) ifTrue:[
   677 		    myProcess notNil ifTrue:[
   677                     myProcess notNil ifTrue:[
   678 			p := myProcess.
   678                         p := myProcess.
   679 			myProcess := nil.
   679                         myProcess := nil.
   680 			p terminate.
   680                         p terminate.
   681 			"not reached - there is no life after death"
   681                         "not reached - there is no life after death"
   682 		    ].
   682                     ].
   683 		    "
   683                     "
   684 		     this is the end of a modal loop
   684                      this is the end of a modal loop
   685 		     (not having a private process ...)
   685                      (not having a private process ...)
   686 		    "
   686                     "
   687 		    ^ self
   687                     ^ self
   688 		].
   688                 ].
   689 
   689 
   690 		"/
   690                 "/
   691 		"/ on abort, stay in the event loop
   691                 "/ on abort, stay in the event loop
   692 		"/
   692                 "/
   693 		AbortSignal handle:[:ex |
   693                 AbortSignal handle:[:ex |
   694 		    ex return
   694                     ex return
   695 		] do:[
   695                 ] do:[
   696 		    |dev gotSema|
   696                     ActivityNotificationSignal handle:[:ex |
   697 
   697                         self showActivity:(ex errorString).
   698 		    "/ no more events. Flush device output. This may produce more events.
   698                         ex proceed.
   699 		    dev := self device.
   699                     ] do:[
   700 		    dev notNil ifTrue:[dev flush].
   700                         |dev gotSema|
   701 
   701 
   702 		    thisProcess setStateTo:#eventWait if:#active.
   702                         "/ no more events. Flush device output. This may produce more events.
   703 		    gotSema := waitSema wait.
   703                         dev := self device.
   704 		    LastActiveGroup := self.
   704                         dev notNil ifTrue:[dev flush].
   705 		    LastActiveProcess := thisProcess.
   705 
   706 		    gotSema == mySema ifTrue:[
   706                         thisProcess setStateTo:#eventWait if:#active.
   707 			self processEvents
   707                         gotSema := waitSema wait.
   708 		    ] ifFalse:[
   708                         LastActiveGroup := self.
   709 			"
   709                         LastActiveProcess := thisProcess.
   710 			 if modal, also check for redraw events in my maingroup
   710                         gotSema == mySema ifTrue:[
   711 			 (we arrive here after we woke up on maingroup sensor eventSemaphore)
   711                             self processEvents
   712 			"
   712                         ] ifFalse:[
   713 			mainGroup processExposeEvents
   713                             "
   714 		    ]
   714                              if modal, also check for redraw events in my maingroup
   715 		].
   715                              (we arrive here after we woke up on maingroup sensor eventSemaphore)
   716 	    ].
   716                             "
   717 	].
   717                             mainGroup processExposeEvents
       
   718                         ]
       
   719                     ]
       
   720                 ].
       
   721             ].
       
   722         ].
   718     ] valueNowOrOnUnwindDo:[
   723     ] valueNowOrOnUnwindDo:[
   719 	cleanupActions notNil ifTrue:[cleanupActions value]
   724         cleanupActions notNil ifTrue:[cleanupActions value]
   720     ]
   725     ]
   721 
   726 
   722     "Modified: 14.12.1995 / 11:12:24 / stefan"
   727     "Modified: 14.12.1995 / 11:12:24 / stefan"
       
   728     "Modified: 16.12.1995 / 18:39:03 / cg"
   723 !
   729 !
   724 
   730 
   725 leaveEventLoop
   731 leaveEventLoop
   726     "immediately leave the event loop, returning way back.
   732     "immediately leave the event loop, returning way back.
   727      This can be used to leave (and closedown) a modal group.
   733      This can be used to leave (and closedown) a modal group.
   999 	c := aView cursor on:(aView device).
  1005 	c := aView cursor on:(aView device).
  1000 	aView device setCursor:(c id) in:(aView id).
  1006 	aView device setCursor:(c id) in:(aView id).
  1001     ].
  1007     ].
  1002 !
  1008 !
  1003 
  1009 
       
  1010 showActivity:someMessage
       
  1011     topViews notNil ifTrue:[
       
  1012         topViews first showActivity:someMessage
       
  1013     ]
       
  1014 
       
  1015     "Created: 16.12.1995 / 18:39:40 / cg"
       
  1016 !
       
  1017 
  1004 showCursor:aCursor
  1018 showCursor:aCursor
  1005     "change the cursor to aCursor in all of my views."
  1019     "change the cursor to aCursor in all of my views."
  1006 
  1020 
  1007     |c|
  1021     |c|
  1008 
  1022 
  1079 ! !
  1093 ! !
  1080 
  1094 
  1081 !WindowGroup class methodsFor:'documentation'!
  1095 !WindowGroup class methodsFor:'documentation'!
  1082 
  1096 
  1083 version
  1097 version
  1084     ^ '$Header: /cvs/stx/stx/libview/WindowGroup.st,v 1.50 1995-12-16 01:16:01 cg Exp $'
  1098     ^ '$Header: /cvs/stx/stx/libview/WindowGroup.st,v 1.51 1995-12-16 17:44:01 cg Exp $'
  1085 ! !
  1099 ! !
  1086 WindowGroup initialize!
  1100 WindowGroup initialize!