68 ^ self new setWindowID:anAlienWindowID |
68 ^ self new setWindowID:anAlienWindowID |
69 ! ! |
69 ! ! |
70 |
70 |
71 !ExternalTopView methodsFor:'private'! |
71 !ExternalTopView methodsFor:'private'! |
72 |
72 |
|
73 alienViewHasBeenDestroyed |
|
74 'alienViewHasBeenDestroyed' printCR. |
|
75 self sensor notNil ifTrue:[ |
|
76 self sensor destroyedView:self |
|
77 ] ifFalse:[ |
|
78 self destroyed |
|
79 ] |
|
80 ! |
|
81 |
73 checkWindowStillAlive |
82 checkWindowStillAlive |
74 "check for a destroyed topView |
83 "check for a destroyed topView |
75 (must poll, since we do not get any events from X)" |
84 (must poll, since we do not get any events from X for the alien topView)" |
76 |
85 |
77 |prevHandler ok| |
86 |prevHandler stillAlive prevErrorPrintingFlag| |
78 |
87 |
79 "/ Transcript showCR:'check ...'. |
88 prevErrorPrintingFlag := device class errorPrinting. |
80 |
89 device class errorPrinting:true. |
81 ok := device isValidWindowId:drawableId. |
90 |
82 |
91 drawableId notNil ifTrue:[ |
83 ok ifFalse:[ |
92 stillAlive := device isValidWindowId:drawableId. |
84 "/ Transcript showCR:'no ...'. |
93 ] ifFalse:[ |
85 self destroyed. |
94 stillAlive := false |
86 ] ifTrue:[ |
95 ]. |
87 Processor |
96 device flush. |
88 addTimedBlock:[self checkWindowStillAlive] |
97 |
89 for:nil |
98 device class errorPrinting:prevErrorPrintingFlag. |
90 afterMilliseconds:1000 |
99 |
91 ] |
100 ^ stillAlive. |
|
101 ! |
|
102 |
|
103 checkWindowStillAliveLoop |
|
104 [self checkWindowStillAlive] whileTrue:[ |
|
105 Delay waitForSeconds:0.5. |
|
106 ]. |
|
107 |
|
108 self alienViewHasBeenDestroyed |
|
109 ! |
|
110 |
|
111 startWindowClosedPollProcess |
|
112 windowClosedPollProcess isNil ifTrue:[ |
|
113 windowClosedPollProcess := |
|
114 [ |
|
115 [ |
|
116 self checkWindowStillAliveLoop |
|
117 ] valueNowOrOnUnwindDo:[ |
|
118 windowClosedPollProcess := nil. |
|
119 ] |
|
120 ] fork. |
|
121 ]. |
|
122 ! |
|
123 |
|
124 stopWindowClosedPollProcess |
|
125 windowClosedPollProcess notNil ifTrue:[ |
|
126 windowClosedPollProcess terminate. |
|
127 windowClosedPollProcess waitUntilTerminated |
|
128 ]. |
92 ! ! |
129 ! ! |
93 |
130 |
94 !ExternalTopView methodsFor:'private accessing'! |
131 !ExternalTopView methodsFor:'private accessing'! |
95 |
132 |
96 setWindowID:aWindowID |
133 setWindowID:aWindowID |
110 |
147 |
111 destroyView |
148 destroyView |
112 "never destroyed by ST/X - instead, the view is under |
149 "never destroyed by ST/X - instead, the view is under |
113 control of the host application ..." |
150 control of the host application ..." |
114 |
151 |
|
152 self stopWindowClosedPollProcess. |
115 realized := false. |
153 realized := false. |
116 drawableId := nil. |
154 drawableId := nil. |
|
155 |
117 ! |
156 ! |
118 |
157 |
119 open |
158 open |
120 "redefined to start a watch timeout for closed windows; |
159 "redefined to start a watch timeout for closed windows; |
121 this is required, since we wont get any closeRequest event for |
160 this is required, since we wont get any closeRequest event for |
122 external windows (as all of its events are handled by the alien |
161 external windows (as all of its events are handled by the alien |
123 application)" |
162 application)" |
124 |
163 |
125 super open. |
164 super open. |
126 self checkWindowStillAlive |
165 "/ self checkWindowStillAlive |
|
166 self startWindowClosedPollProcess. |
127 ! |
167 ! |
128 |
168 |
129 unmap |
169 unmap |
130 "redefined as a noop; |
170 "redefined as a noop; |
131 ExternalTopViews are never unmapped by ST/X - instead, the view is under |
171 ExternalTopViews are never unmapped by ST/X - instead, the view is under |
135 ! ! |
175 ! ! |
136 |
176 |
137 !ExternalTopView methodsFor:'special'! |
177 !ExternalTopView methodsFor:'special'! |
138 |
178 |
139 becomeParentOf:anSTXWindow |
179 becomeParentOf:anSTXWindow |
|
180 "add myself to the windowGroup of anSTXWindow ... |
|
181 and reparent anSTXWindow to be the (only) child of myself" |
|
182 |
|
183 self old_becomeParentOf:anSTXWindow |
|
184 ! |
|
185 |
|
186 new_becomeParentOf:anSTXWindow |
|
187 "add myself to the windowGroup of anSTXWindow ... |
|
188 and reparent anSTXWindow to be the (only) child of myself" |
|
189 |
|
190 |wg oldTopView retryCount deviceErrorOccured| |
|
191 |
|
192 anSTXWindow borderWidth:0. anSTXWindow forceBorderWidth. |
|
193 self borderWidth:0. self forceBorderWidth. |
|
194 self borderColor:Color red. |
|
195 |
|
196 anSTXWindow createWithAllSubViews. |
|
197 oldTopView := anSTXWindow topView. |
|
198 |
|
199 wg := anSTXWindow windowGroup. |
|
200 wg notNil ifTrue:[ |
|
201 windowGroup notNil ifTrue:[ |
|
202 self halt. |
|
203 windowGroup removeTopView:self. |
|
204 ]. |
|
205 wg addTopView:self. |
|
206 windowGroup := wg. |
|
207 ]. |
|
208 |
|
209 oldTopView == anSTXWindow ifTrue:[ |
|
210 oldTopView container:self. |
|
211 ]. |
|
212 |
|
213 self open. "/ not really an open; however it starts its event handler |
|
214 wg isNil ifTrue:[ |
|
215 oldTopView windowGroup:self windowGroup. |
|
216 ] ifFalse:[ |
|
217 windowGroup ~~ anSTXWindow windowGroup ifTrue:[self halt]. |
|
218 ]. |
|
219 |
|
220 "/'childID: ' print. anSTXWindow id displayString printCR. |
|
221 "/'parentID: ' print. self id displayString printCR. |
|
222 self addSubView:anSTXWindow. |
|
223 |
|
224 self checkWindowStillAlive ifFalse:[ Transcript showCR:'x1'. ^ true]. |
|
225 |
|
226 |
|
227 anSTXWindow device |
|
228 reparentWindow:anSTXWindow id |
|
229 to:self id. |
|
230 anSTXWindow device unBuffered. |
|
231 retryCount := 0. |
|
232 deviceErrorOccured := false. |
|
233 [ |
|
234 |
|
235 GLXWorkstation deviceErrorSignal handle:[:ex| |
|
236 'DeviceErrorSignal raised in becomeParentOf: ' printNL. |
|
237 deviceErrorOccured := true. |
|
238 "/ (Delay waitForSeconds: 1). |
|
239 "/ retryCount := retryCount + 1. |
|
240 "/ retryCount > 5 ifTrue:[ |
|
241 "/ ex proceed |
|
242 "/ ]. |
|
243 ex proceed |
|
244 ] do:[ |
|
245 deviceErrorOccured := false. |
|
246 anSTXWindow enableEvent:#structureNotify. |
|
247 ]. |
|
248 ] ensure:[ |
|
249 anSTXWindow device buffered. |
|
250 ]. |
|
251 deviceErrorOccured ifTrue:[^false]. |
|
252 |
|
253 |
|
254 self checkWindowStillAlive ifFalse:[ Transcript showCR:'x2'. ^ true]. |
|
255 |
|
256 anSTXWindow realize. |
|
257 anSTXWindow map. |
|
258 ^true |
|
259 |
|
260 "/ wg notNil ifTrue:[ |
|
261 "/ wg removeView:oldTopView. |
|
262 "/ wg addView:oldTopView. |
|
263 "/ ]. |
|
264 |
|
265 "/ anSTXWindow origin:0.0 @ 0.0 corner:1.0 @ 1.0. |
|
266 ! |
|
267 |
|
268 old_becomeParentOf:anSTXWindow |
140 "add myself to the windowGroup of anSTXWindow ... |
269 "add myself to the windowGroup of anSTXWindow ... |
141 and reparent anSTXWindow to be the (only) child of myself" |
270 and reparent anSTXWindow to be the (only) child of myself" |
142 |
271 |
143 |wg oldTopView| |
272 |wg oldTopView| |
144 |
273 |
174 wg removeView:oldTopView. |
303 wg removeView:oldTopView. |
175 wg addView:oldTopView. |
304 wg addView:oldTopView. |
176 ]. |
305 ]. |
177 |
306 |
178 anSTXWindow origin:0.0 @ 0.0 corner:1.0 @ 1.0. |
307 anSTXWindow origin:0.0 @ 0.0 corner:1.0 @ 1.0. |
179 |
|
180 |
|
181 ! ! |
308 ! ! |
182 |
309 |
183 !ExternalTopView class methodsFor:'documentation'! |
310 !ExternalTopView class methodsFor:'documentation'! |
184 |
311 |
185 version |
312 version |
186 ^ '$Header: /cvs/stx/stx/libview2/ExternalTopView.st,v 1.11 2002-05-07 11:33:59 cg Exp $' |
313 ^ '$Header: /cvs/stx/stx/libview2/ExternalTopView.st,v 1.12 2004-04-02 16:52:16 werner Exp $' |
187 ! ! |
314 ! ! |