equal
deleted
inserted
replaced
283 SetWindowDirty(v); |
283 SetWindowDirty(v); |
284 |
284 |
285 return v; |
285 return v; |
286 } |
286 } |
287 |
287 |
|
288 /* We have run out of windows, so find a suitable candidate for replacement. |
|
289 * Keep all important windows intact */ |
|
290 static Window *FindDeletableWindow(void) |
|
291 { |
|
292 Window *w; |
|
293 for (w = _windows; w < endof(_windows); w++) { |
|
294 if (w->window_class != WC_MAIN_WINDOW && w->window_class != WC_MAIN_TOOLBAR && |
|
295 w->window_class != WC_STATUS_BAR && w->window_class != WC_NEWS_WINDOW && |
|
296 !(w->flags4 & WF_STICKY) ) |
|
297 return w; |
|
298 } |
|
299 return NULL; |
|
300 } |
|
301 |
|
302 /* A window must be freed, and all are marked as important windows. Ease the |
|
303 * restriction a bit by allowing to delete sticky windows */ |
|
304 static Window *ForceFindDeletableWindow(void) |
|
305 { |
|
306 Window *w; |
|
307 for (w = _windows;; w++) { |
|
308 assert(w < _last_window); |
|
309 |
|
310 if (w->window_class != WC_MAIN_WINDOW && w->window_class != WC_MAIN_TOOLBAR && |
|
311 w->window_class != WC_STATUS_BAR && w->window_class != WC_NEWS_WINDOW) |
|
312 return w; |
|
313 } |
|
314 } |
|
315 |
288 Window *AllocateWindow( |
316 Window *AllocateWindow( |
289 int x, |
317 int x, |
290 int y, |
318 int y, |
291 int width, |
319 int width, |
292 int height, |
320 int height, |
294 WindowClass cls, |
322 WindowClass cls, |
295 const Widget *widget) |
323 const Widget *widget) |
296 { |
324 { |
297 Window *w; |
325 Window *w; |
298 |
326 |
299 restart:; |
|
300 w = _last_window; |
327 w = _last_window; |
301 |
328 |
302 if (w >= endof(_windows)) { |
329 if (w >= endof(_windows)) { |
303 for(w=_windows; ;w++) { |
330 w = FindDeletableWindow(); |
304 assert(w < _last_window); |
331 |
305 |
332 if (w == NULL) // no window found, force it! |
306 if (w->window_class != WC_MAIN_WINDOW && w->window_class != WC_MAIN_TOOLBAR && |
333 w = ForceFindDeletableWindow(); |
307 w->window_class != WC_STATUS_BAR && w->window_class != WC_NEWS_WINDOW && |
334 |
308 !(w->flags4 & WF_STICKY) ) { |
335 DeleteWindow(w); |
309 |
336 w = _last_window; |
310 DeleteWindow(w); |
|
311 goto restart; |
|
312 } |
|
313 } |
|
314 } |
337 } |
315 |
338 |
316 if (w != _windows && cls != WC_NEWS_WINDOW) { |
339 if (w != _windows && cls != WC_NEWS_WINDOW) { |
317 Window *v; |
340 Window *v; |
318 |
341 |
1341 w++; |
1364 w++; |
1342 } |
1365 } |
1343 } |
1366 } |
1344 } |
1367 } |
1345 |
1368 |
|
1369 /* It is possible that a stickied window gets to a position where the |
|
1370 * 'close' button is outside the gaming area. You cannot close it then; except |
|
1371 * with this function. It closes all windows calling the standard function, |
|
1372 * then, does a little hacked loop of closing all stickied windows. Note |
|
1373 * that standard windows (status bar, etc.) are not stickied, so these aren't affected */ |
|
1374 void DeleteAllNonVitalWindows(void) |
|
1375 { |
|
1376 Window *w; |
|
1377 // Delete every window except for stickied ones |
|
1378 DeleteNonVitalWindows(); |
|
1379 // Delete all sticked windows |
|
1380 for (w = _windows; w != _last_window;) { |
|
1381 if (w->flags4 & WF_STICKY) { |
|
1382 DeleteWindow(w); |
|
1383 w = _windows; |
|
1384 } else |
|
1385 w++; |
|
1386 } |
|
1387 } |
|
1388 |
1346 int PositionMainToolbar(Window *w) |
1389 int PositionMainToolbar(Window *w) |
1347 { |
1390 { |
1348 DEBUG(misc, 1) ("Repositioning Main Toolbar..."); |
1391 DEBUG(misc, 1) ("Repositioning Main Toolbar..."); |
1349 |
1392 |
1350 if (w == NULL || w->window_class != WC_MAIN_TOOLBAR) |
1393 if (w == NULL || w->window_class != WC_MAIN_TOOLBAR) |