WindowGroup.st
changeset 4375 d16dc7e26e38
parent 4348 26cf51169d4c
child 4378 29da8415352c
equal deleted inserted replaced
4374:284f319c979b 4375:d16dc7e26e38
    15 Object subclass:#WindowGroup
    15 Object subclass:#WindowGroup
    16 	instanceVariableNames:'graphicsDevice views topViews myProcess mySensor isModal
    16 	instanceVariableNames:'graphicsDevice views topViews myProcess mySensor isModal
    17 		previousGroup focusView focusSequence preEventHook postEventHook
    17 		previousGroup focusView focusSequence preEventHook postEventHook
    18 		pointerView isForModalSubview focusByTab groupHasFocus busyHook
    18 		pointerView isForModalSubview focusByTab groupHasFocus busyHook
    19 		busyHookTimeout inModalLoop preEventHooks postEventHooks
    19 		busyHookTimeout inModalLoop preEventHooks postEventHooks
    20 		creatingProcess traceEvents'
    20 		creatingProcess traceEvents processPriority'
    21 	classVariableNames:'LastActiveGroup LastActiveProcess LeaveSignal
    21 	classVariableNames:'LastActiveGroup LastActiveProcess LeaveSignal
    22 		WindowGroupQuerySignal LastEventQuerySignal BusyHookTime'
    22 		WindowGroupQuerySignal LastEventQuerySignal BusyHookTime'
    23 	poolDictionaries:''
    23 	poolDictionaries:''
    24 	category:'Interface-Support'
    24 	category:'Interface-Support'
    25 !
    25 !
   592     ^ myProcess
   592     ^ myProcess
   593 
   593 
   594     "Modified: / 17.8.1998 / 10:21:29 / cg"
   594     "Modified: / 17.8.1998 / 10:21:29 / cg"
   595 !
   595 !
   596 
   596 
       
   597 processPriority
       
   598     ^ processPriority
       
   599 !
       
   600 
       
   601 processPriority:anInteger
       
   602     processPriority := anInteger.
       
   603     myProcess notNil ifTrue:[
       
   604         myProcess priority:anInteger.
       
   605     ].
       
   606 !
       
   607 
   597 sensor
   608 sensor
   598     "return the windowGroups sensor.
   609     "return the windowGroups sensor.
   599      All events for any of the groups views is handled by that sensor."
   610      All events for any of the groups views is handled by that sensor."
   600 
   611 
   601     ^ mySensor
   612     ^ mySensor
   924 	].
   935 	].
   925     ].
   936     ].
   926 
   937 
   927     "Modified: / 6.5.1999 / 09:42:37 / cg"
   938     "Modified: / 6.5.1999 / 09:42:37 / cg"
   928     "Created: / 6.5.1999 / 09:46:33 / cg"
   939     "Created: / 6.5.1999 / 09:46:33 / cg"
       
   940 !
       
   941 
       
   942 shutDown
       
   943     "shutdown the window group; close all views and
       
   944      terminate the process"
       
   945 
       
   946     self closeDownViews.
       
   947     self shutDownProcess.
       
   948 !
       
   949 
       
   950 shutDownProcess
       
   951     "shutdown the window group process"
       
   952 
       
   953     |p|
       
   954 
       
   955     myProcess notNil ifTrue:[
       
   956         p := myProcess.
       
   957         myProcess := nil.
       
   958         p terminate.
       
   959     ]
   929 !
   960 !
   930 
   961 
   931 startupModal:checkBlock
   962 startupModal:checkBlock
   932     "startup the window-group in a modal loop 
   963     "startup the window-group in a modal loop 
   933      (i.e. under the currently running process);
   964      (i.e. under the currently running process);
  1096                     ]
  1127                     ]
  1097                 ]
  1128                 ]
  1098             ]
  1129             ]
  1099         ] newProcess.
  1130         ] newProcess.
  1100 
  1131 
  1101         (topViews size > 0) ifTrue:[
  1132         self setProcessNameWithRedirectIndicator:''.
  1102             "/
  1133         myProcess priority:processPriority;
  1103             "/ give the windowGroup process a user friendly name
       
  1104             "/ ask its topView for the processName, and
       
  1105             "/ optionally append the displayName (if its not the default)
       
  1106             "/
       
  1107             top := topViews first.
       
  1108             nm := top processName.
       
  1109 
       
  1110             (dev := top graphicsDevice) notNil ifTrue:[
       
  1111                 devNm := dev displayName.
       
  1112                 (devNm notNil and:[Display isNil or:[devNm ~= Display displayName]]) ifTrue:[
       
  1113                     nm := nm , ' (' , devNm , ')'
       
  1114                 ]
       
  1115             ]
       
  1116         ] ifFalse:[
       
  1117             nm := 'window handler'.
       
  1118         ].
       
  1119         myProcess name:nm;
       
  1120                   priority:(Processor userSchedulingPriority);
       
  1121                   beGroupLeader;
  1134                   beGroupLeader;
  1122                   beGUIProcess.
  1135                   beGUIProcess.
  1123 
  1136 
  1124         "/
  1137         "/
  1125         "/ when the process gets suspended, 
  1138         "/ when the process gets suspended, 
  1147     ]
  1160     ]
  1148 
  1161 
  1149     "Modified: / 13.12.1995 / 14:04:53 / stefan"
  1162     "Modified: / 13.12.1995 / 14:04:53 / stefan"
  1150     "Created: / 24.7.1997 / 12:52:04 / cg"
  1163     "Created: / 24.7.1997 / 12:52:04 / cg"
  1151     "Modified: / 4.12.1997 / 14:13:35 / cg"
  1164     "Modified: / 4.12.1997 / 14:13:35 / cg"
  1152 ! !
       
  1153 
       
  1154 !WindowGroup methodsFor:'activation / deactivation'!
       
  1155 
       
  1156 shutDown
       
  1157     "shutdown the window group; close all views and
       
  1158      terminate the process"
       
  1159 
       
  1160     self closeDownViews.
       
  1161     self shutDownProcess.
       
  1162 !
       
  1163 
       
  1164 shutDownProcess
       
  1165     "shutdown the window group process"
       
  1166 
       
  1167     |p|
       
  1168 
       
  1169     myProcess notNil ifTrue:[
       
  1170         p := myProcess.
       
  1171         myProcess := nil.
       
  1172         p terminate.
       
  1173     ]
       
  1174 ! !
  1165 ! !
  1175 
  1166 
  1176 !WindowGroup methodsFor:'enumerating'!
  1167 !WindowGroup methodsFor:'enumerating'!
  1177 
  1168 
  1178 allNonTopViewsDo:aBlock
  1169 allNonTopViewsDo:aBlock
  2314     "setup the windowgroup, by creating a new sensor
  2305     "setup the windowgroup, by creating a new sensor
  2315      and an event semaphore"
  2306      and an event semaphore"
  2316 
  2307 
  2317     mySensor := WindowSensor new.
  2308     mySensor := WindowSensor new.
  2318     mySensor eventSemaphore:(Semaphore new name:'WGroup eventSema').
  2309     mySensor eventSemaphore:(Semaphore new name:'WGroup eventSema').
       
  2310     processPriority := Processor userSchedulingPriority.
  2319     isModal := false.
  2311     isModal := false.
  2320     isForModalSubview := false.
  2312     isForModalSubview := false.
  2321 
  2313 
  2322     "Modified: 25.1.1997 / 00:20:19 / cg"
  2314     "Modified: 25.1.1997 / 00:20:19 / cg"
  2323 !
  2315 !
  2331         "/ otherwise, it might do destroy or other actions when it
  2323         "/ otherwise, it might do destroy or other actions when it
  2332         "/ gets finalized ...
  2324         "/ gets finalized ...
  2333 
  2325 
  2334 "/        myProcess removeAllExitActions.
  2326 "/        myProcess removeAllExitActions.
  2335         myProcess removeAllSuspendActions.
  2327         myProcess removeAllSuspendActions.
       
  2328         processPriority := myProcess priority. "save old priority"
  2336         myProcess := nil.
  2329         myProcess := nil.
  2337     ].
  2330     ].
  2338 
  2331 
  2339     "throw away old events"
  2332     "throw away old events"
  2340     mySensor notNil ifTrue:[mySensor reinitialize]
  2333     mySensor notNil ifTrue:[mySensor reinitialize]
  2341 
  2334 
  2342     "Modified: 13.12.1995 / 13:45:35 / stefan"
  2335     "Modified: 13.12.1995 / 13:45:35 / stefan"
  2343     "Modified: 12.1.1997 / 00:45:01 / cg"
  2336     "Modified: 12.1.1997 / 00:45:01 / cg"
       
  2337 !
       
  2338 
       
  2339 setProcessNameWithRedirectIndicator:redirectString
       
  2340     "give the windowGroup process a user friendly name.
       
  2341      This name shows up in the ProcessMonitor"
       
  2342 
       
  2343     |top nm dev devNm defaultDisplay|
       
  2344 
       
  2345     "ask my topView for the processName, and
       
  2346      optionally append the displayName (if its not the default)"
       
  2347 
       
  2348     topViews size ~~ 0 ifTrue:[
       
  2349         top := topViews first.
       
  2350         nm := top processName.
       
  2351 
       
  2352         dev := top graphicsDevice.
       
  2353         defaultDisplay := Screen default.
       
  2354         (dev notNil and:[dev ~~ defaultDisplay]) ifTrue:[
       
  2355             devNm := dev displayName.
       
  2356             (devNm notNil and:[defaultDisplay isNil or:[devNm ~= defaultDisplay displayName]]) ifTrue:[
       
  2357                 nm := nm , ' (' , redirectString , devNm , ')'
       
  2358             ]
       
  2359         ]
       
  2360     ] ifFalse:[
       
  2361         nm := 'window handler'.
       
  2362     ].
       
  2363     myProcess name:nm.
  2344 ! !
  2364 ! !
  2345 
  2365 
  2346 !WindowGroup methodsFor:'keyboard control'!
  2366 !WindowGroup methodsFor:'keyboard control'!
  2347 
  2367 
  2348 processMnemonic:aKeyEvent
  2368 processMnemonic:aKeyEvent
  2420 !WindowGroup methodsFor:'special'!
  2440 !WindowGroup methodsFor:'special'!
  2421 
  2441 
  2422 migrateTo:anotherDisplay
  2442 migrateTo:anotherDisplay
  2423     "migrate all of my views to some other display device"
  2443     "migrate all of my views to some other display device"
  2424 
  2444 
  2425     |myDevice top nm dev devNm previouslyRealized|
  2445     |myDevice previouslyRealized|
  2426 
  2446 
  2427     self isModal ifTrue:[
  2447     self isModal ifTrue:[
  2428         "/ cannot migrate a modal box away from its owner ...
  2448         "/ cannot migrate a modal box away from its owner ...
  2429         "/ (need a separate process and views may not be owned)
  2449         "/ (need a separate process and views may not be owned)
  2430         Transcript showCR:'Modal windogroup cannot be migrated.'.
  2450         Transcript showCR:'Modal windogroup cannot be migrated.'.
  2469     graphicsDevice := anotherDisplay.
  2489     graphicsDevice := anotherDisplay.
  2470 
  2490 
  2471     anotherDisplay sync.
  2491     anotherDisplay sync.
  2472     myDevice sync.
  2492     myDevice sync.
  2473 
  2493 
  2474     "/
  2494 
  2475     "/ change the name of my process
  2495     "change the name of my process"
  2476     "/
  2496     self setProcessNameWithRedirectIndicator:'->'.
  2477     (topViews size > 0) ifTrue:[
  2497 
  2478         top := topViews first.
       
  2479         nm := top processName.
       
  2480 
       
  2481         (dev := top graphicsDevice) notNil ifTrue:[
       
  2482             devNm := dev displayName.
       
  2483             (devNm notNil and:[Display isNil or:[devNm ~= Display displayName]]) ifTrue:[
       
  2484                 nm := nm , ' (->' , devNm , ')'
       
  2485             ]
       
  2486         ]
       
  2487     ] ifFalse:[
       
  2488         nm := 'window handler'.
       
  2489     ].
       
  2490     myProcess name:nm.
       
  2491 
  2498 
  2492     "
  2499     "
  2493      |anotherDisplay v host|
  2500      |anotherDisplay v host|
  2494 
  2501 
  2495      v := StandardSystemView new.
  2502      v := StandardSystemView new.
  2760 ! !
  2767 ! !
  2761 
  2768 
  2762 !WindowGroup class methodsFor:'documentation'!
  2769 !WindowGroup class methodsFor:'documentation'!
  2763 
  2770 
  2764 version
  2771 version
  2765     ^ '$Header: /cvs/stx/stx/libview/WindowGroup.st,v 1.273 2005-02-16 14:32:42 cg Exp $'
  2772     ^ '$Header: /cvs/stx/stx/libview/WindowGroup.st,v 1.274 2005-04-04 10:32:49 stefan Exp $'
  2766 ! !
  2773 ! !
  2767 
  2774 
  2768 WindowGroup initialize!
  2775 WindowGroup initialize!