On snapshot image restart, restore the priority
authorStefan Vogel <sv@exept.de>
Mon, 04 Apr 2005 12:32:49 +0200
changeset 4375 d16dc7e26e38
parent 4374 284f319c979b
child 4376 6374d66a262a
On snapshot image restart, restore the priority of window group processes.
WindowGroup.st
--- a/WindowGroup.st	Fri Apr 01 14:56:29 2005 +0200
+++ b/WindowGroup.st	Mon Apr 04 12:32:49 2005 +0200
@@ -17,7 +17,7 @@
 		previousGroup focusView focusSequence preEventHook postEventHook
 		pointerView isForModalSubview focusByTab groupHasFocus busyHook
 		busyHookTimeout inModalLoop preEventHooks postEventHooks
-		creatingProcess traceEvents'
+		creatingProcess traceEvents processPriority'
 	classVariableNames:'LastActiveGroup LastActiveProcess LeaveSignal
 		WindowGroupQuerySignal LastEventQuerySignal BusyHookTime'
 	poolDictionaries:''
@@ -594,6 +594,17 @@
     "Modified: / 17.8.1998 / 10:21:29 / cg"
 !
 
+processPriority
+    ^ processPriority
+!
+
+processPriority:anInteger
+    processPriority := anInteger.
+    myProcess notNil ifTrue:[
+        myProcess priority:anInteger.
+    ].
+!
+
 sensor
     "return the windowGroups sensor.
      All events for any of the groups views is handled by that sensor."
@@ -928,6 +939,26 @@
     "Created: / 6.5.1999 / 09:46:33 / cg"
 !
 
+shutDown
+    "shutdown the window group; close all views and
+     terminate the process"
+
+    self closeDownViews.
+    self shutDownProcess.
+!
+
+shutDownProcess
+    "shutdown the window group process"
+
+    |p|
+
+    myProcess notNil ifTrue:[
+        p := myProcess.
+        myProcess := nil.
+        p terminate.
+    ]
+!
+
 startupModal:checkBlock
     "startup the window-group in a modal loop 
      (i.e. under the currently running process);
@@ -1098,26 +1129,8 @@
             ]
         ] newProcess.
 
-        (topViews size > 0) ifTrue:[
-            "/
-            "/ give the windowGroup process a user friendly name
-            "/ ask its topView for the processName, and
-            "/ optionally append the displayName (if its not the default)
-            "/
-            top := topViews first.
-            nm := top processName.
-
-            (dev := top graphicsDevice) notNil ifTrue:[
-                devNm := dev displayName.
-                (devNm notNil and:[Display isNil or:[devNm ~= Display displayName]]) ifTrue:[
-                    nm := nm , ' (' , devNm , ')'
-                ]
-            ]
-        ] ifFalse:[
-            nm := 'window handler'.
-        ].
-        myProcess name:nm;
-                  priority:(Processor userSchedulingPriority);
+        self setProcessNameWithRedirectIndicator:''.
+        myProcess priority:processPriority;
                   beGroupLeader;
                   beGUIProcess.
 
@@ -1151,28 +1164,6 @@
     "Modified: / 4.12.1997 / 14:13:35 / cg"
 ! !
 
-!WindowGroup methodsFor:'activation / deactivation'!
-
-shutDown
-    "shutdown the window group; close all views and
-     terminate the process"
-
-    self closeDownViews.
-    self shutDownProcess.
-!
-
-shutDownProcess
-    "shutdown the window group process"
-
-    |p|
-
-    myProcess notNil ifTrue:[
-        p := myProcess.
-        myProcess := nil.
-        p terminate.
-    ]
-! !
-
 !WindowGroup methodsFor:'enumerating'!
 
 allNonTopViewsDo:aBlock
@@ -2316,6 +2307,7 @@
 
     mySensor := WindowSensor new.
     mySensor eventSemaphore:(Semaphore new name:'WGroup eventSema').
+    processPriority := Processor userSchedulingPriority.
     isModal := false.
     isForModalSubview := false.
 
@@ -2333,6 +2325,7 @@
 
 "/        myProcess removeAllExitActions.
         myProcess removeAllSuspendActions.
+        processPriority := myProcess priority. "save old priority"
         myProcess := nil.
     ].
 
@@ -2341,6 +2334,33 @@
 
     "Modified: 13.12.1995 / 13:45:35 / stefan"
     "Modified: 12.1.1997 / 00:45:01 / cg"
+!
+
+setProcessNameWithRedirectIndicator:redirectString
+    "give the windowGroup process a user friendly name.
+     This name shows up in the ProcessMonitor"
+
+    |top nm dev devNm defaultDisplay|
+
+    "ask my topView for the processName, and
+     optionally append the displayName (if its not the default)"
+
+    topViews size ~~ 0 ifTrue:[
+        top := topViews first.
+        nm := top processName.
+
+        dev := top graphicsDevice.
+        defaultDisplay := Screen default.
+        (dev notNil and:[dev ~~ defaultDisplay]) ifTrue:[
+            devNm := dev displayName.
+            (devNm notNil and:[defaultDisplay isNil or:[devNm ~= defaultDisplay displayName]]) ifTrue:[
+                nm := nm , ' (' , redirectString , devNm , ')'
+            ]
+        ]
+    ] ifFalse:[
+        nm := 'window handler'.
+    ].
+    myProcess name:nm.
 ! !
 
 !WindowGroup methodsFor:'keyboard control'!
@@ -2422,7 +2442,7 @@
 migrateTo:anotherDisplay
     "migrate all of my views to some other display device"
 
-    |myDevice top nm dev devNm previouslyRealized|
+    |myDevice previouslyRealized|
 
     self isModal ifTrue:[
         "/ cannot migrate a modal box away from its owner ...
@@ -2471,23 +2491,10 @@
     anotherDisplay sync.
     myDevice sync.
 
-    "/
-    "/ change the name of my process
-    "/
-    (topViews size > 0) ifTrue:[
-        top := topViews first.
-        nm := top processName.
-
-        (dev := top graphicsDevice) notNil ifTrue:[
-            devNm := dev displayName.
-            (devNm notNil and:[Display isNil or:[devNm ~= Display displayName]]) ifTrue:[
-                nm := nm , ' (->' , devNm , ')'
-            ]
-        ]
-    ] ifFalse:[
-        nm := 'window handler'.
-    ].
-    myProcess name:nm.
+
+    "change the name of my process"
+    self setProcessNameWithRedirectIndicator:'->'.
+
 
     "
      |anotherDisplay v host|
@@ -2762,7 +2769,7 @@
 !WindowGroup class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libview/WindowGroup.st,v 1.273 2005-02-16 14:32:42 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libview/WindowGroup.st,v 1.274 2005-04-04 10:32:49 stefan Exp $'
 ! !
 
 WindowGroup initialize!