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. |