DevWorkst.st
changeset 1185 f72f2a0d97cf
parent 1177 e89408c15bb5
child 1189 061c27183b41
equal deleted inserted replaced
1184:1372bad824af 1185:f72f2a0d97cf
  2846 startDispatch
  2846 startDispatch
  2847     "create the display dispatch process."
  2847     "create the display dispatch process."
  2848 
  2848 
  2849     |inputSema fd p nm|
  2849     |inputSema fd p nm|
  2850 
  2850 
  2851     "
  2851     "/
  2852      only allow one dispatcher process per display
  2852     "/ only allow one dispatcher process per display
  2853     "
  2853     "/
  2854     dispatching ifTrue:[^ self].
  2854     dispatching ifTrue:[^ self].
  2855     dispatching := true.
  2855     dispatching := true.
  2856 
  2856 
  2857     AllScreens isNil ifTrue:[
  2857     AllScreens isNil ifTrue:[
  2858 	AllScreens := Set new:1
  2858         AllScreens := Set new:1
  2859     ].
  2859     ].
  2860     AllScreens add:self.
  2860     AllScreens add:self.
  2861 
  2861 
  2862     fd := self displayFileDescriptor.
  2862     fd := self displayFileDescriptor.
  2863 
  2863 
  2864 "/ non-thread operation is no longer supported
  2864     "/ handle all incoming events from the device, sitting on a semaphore.
  2865 "/    "
  2865     "/ Tell Processor to trigger this semaphore when something arrives
  2866 "/     The code below (still) handles the situation where ST/X was built
  2866     "/ on my filedescriptor. Since a select alone is not enough to
  2867 "/     without lightweight process support. Since there are many other places
  2867     "/ know if events are pending (Xlib reads out event-queue while
  2868 "/     in the system whic depend on lightweight processes to function, this
  2868     "/ doing output), we also have to install a poll-check block.        
  2869 "/     may be a stupid thing to do ... expect it to vanish sooner or later.
  2869 
  2870 "/    "
       
  2871 "/
       
  2872 "/    ProcessorScheduler isPureEventDriven ifTrue:[
       
  2873 "/        "
       
  2874 "/         no threads built in;
       
  2875 "/         handle all events by having processor call a block when something
       
  2876 "/         arrives on my filedescriptor. Dispatch the event in that block.
       
  2877 "/        "
       
  2878 "/        Processor enableIOAction:[
       
  2879 "/                                     dispatching ifTrue:[
       
  2880 "/                                         [self eventPending] whileTrue:[
       
  2881 "/                                             self dispatchPendingEvents.
       
  2882 "/                                             "/ self checkForEndOfDispatch.
       
  2883 "/                                         ].
       
  2884 "/                                         dispatching ifFalse:[
       
  2885 "/                                             Processor disableFd:fd.
       
  2886 "/                                             AllScreens remove:self.
       
  2887 "/                                         ]
       
  2888 "/                                     ]
       
  2889 "/                                 ]
       
  2890 "/                         onInput:fd.
       
  2891 "/
       
  2892 "/        ^ self.
       
  2893 "/    ]
       
  2894     "
       
  2895      handle stuff as a process - sitting on a semaphore.
       
  2896      Tell Processor to trigger this semaphore when something arrives
       
  2897      on my filedescriptor. Since a select alone is not enough to
       
  2898      know if events are pending (Xlib reads out event-queue while
       
  2899      doing output), we also have to install a poll-check block.        
       
  2900     "
       
  2901     OperatingSystem supportsSelect ifTrue:[
  2870     OperatingSystem supportsSelect ifTrue:[
  2902 	inputSema := Semaphore new.
  2871         inputSema := Semaphore new.
  2903     ].
  2872     ].
  2904 
  2873 
  2905     p := [
  2874     p := [
  2906 	[dispatching] whileTrue:[
  2875         [dispatching] whileTrue:[
  2907 	    AbortSignal handle:[:ex |
  2876             AbortSignal handle:[:ex |
  2908 		ex return
  2877                 ex return
  2909 	    ] do:[
  2878             ] do:[
  2910 		self eventPending ifFalse:[
  2879                 self eventPending ifFalse:[
  2911 		    Processor activeProcess setStateTo:#ioWait if:#active.
  2880                     Processor activeProcess setStateTo:#ioWait if:#active.
  2912 		    inputSema notNil ifTrue:[
  2881                     inputSema notNil ifTrue:[
  2913 			inputSema wait.
  2882                         inputSema wait.
  2914 		    ] ifFalse:[
  2883                     ] ifFalse:[
  2915 			Delay waitForMilliseconds:50
  2884                         Delay waitForMilliseconds:50
  2916 		    ]
  2885                     ]
  2917 		].
  2886                 ].
  2918 
  2887 
  2919 		self dispatchPendingEvents.
  2888                 self dispatchPendingEvents.
  2920 		"/ self checkForEndOfDispatch.
  2889             ]
  2921 	    ]
  2890         ].
  2922 	].
  2891         inputSema notNil ifTrue:[
  2923 	inputSema notNil ifTrue:[
  2892             Processor disableSemaphore:inputSema.
  2924 	    Processor disableSemaphore:inputSema.
  2893             inputSema := nil.
  2925 	    inputSema := nil.
  2894         ].
  2926 	].
  2895         AllScreens remove:self.
  2927 	AllScreens remove:self.
  2896         dispatchProcess := nil
  2928 	dispatchProcess := nil
       
  2929     ] newProcess.
  2897     ] newProcess.
  2930     "
  2898 
  2931      give the process a nice name (for the processMonitor)
  2899     "/
  2932     "
  2900     "/ give the process a nice name (for the processMonitor)
       
  2901     "/
  2933     (nm := self displayName) notNil ifTrue:[
  2902     (nm := self displayName) notNil ifTrue:[
  2934 	nm := 'event dispatcher (' ,  nm , ')'.
  2903         nm := 'event dispatcher (' ,  nm , ')'.
  2935     ] ifFalse:[
  2904     ] ifFalse:[
  2936 	nm := 'event dispatcher'.
  2905         nm := 'event dispatcher'.
  2937     ].
  2906     ].
  2938     p name:nm.
  2907     p name:nm.
  2939     p priority:(Processor userInterruptPriority).
  2908     p priority:(Processor userInterruptPriority).
  2940     dispatchProcess := p.
  2909     dispatchProcess := p.
  2941     p resume.
  2910     p resume.
  2942 
  2911 
       
  2912     "/ finally, arrange for the processor to signal that semaphore on input
       
  2913 
  2943     inputSema notNil ifTrue:[
  2914     inputSema notNil ifTrue:[
  2944 	Processor signal:inputSema onInput:fd orCheck:[self eventPending].
  2915         Processor signal:inputSema onInput:fd orCheck:[self eventPending].
  2945     ]
  2916     ]
  2946 
  2917 
  2947     "Modified: 12.12.1995 / 20:52:57 / stefan"
  2918     "Modified: 12.12.1995 / 20:52:57 / stefan"
  2948     "Modified: 18.7.1996 / 17:12:50 / cg"
  2919     "Modified: 12.1.1997 / 00:27:50 / cg"
  2949 ! !
  2920 ! !
  2950 
  2921 
  2951 !DeviceWorkstation methodsFor:'font helpers'!
  2922 !DeviceWorkstation methodsFor:'font helpers'!
  2952 
  2923 
  2953 ascentOf:aFontId
  2924 ascentOf:aFontId
  4821 ! !
  4792 ! !
  4822 
  4793 
  4823 !DeviceWorkstation class methodsFor:'documentation'!
  4794 !DeviceWorkstation class methodsFor:'documentation'!
  4824 
  4795 
  4825 version
  4796 version
  4826     ^ '$Header: /cvs/stx/stx/libview/Attic/DevWorkst.st,v 1.148 1997-01-10 18:02:52 cg Exp $'
  4797     ^ '$Header: /cvs/stx/stx/libview/Attic/DevWorkst.st,v 1.149 1997-01-11 23:28:49 cg Exp $'
  4827 ! !
  4798 ! !
  4828 DeviceWorkstation initialize!
  4799 DeviceWorkstation initialize!