6 #include <exec/types.h>
7 #include <dos/dostags.h>
8 #include <workbench/startup.h>
9 #include <intuition/gadgetclass.h>
10 #include <datatypes/pictureclass.h>
11 #include <utility/tagitem.h>
15 #include <proto/asl.h>
16 #include <proto/dos.h>
17 #include <proto/exec.h>
18 #include <proto/intuition.h>
19 #include <proto/graphics.h>
20 #include <proto/iconobject.h>
22 #include <proto/scalos.h>
24 #include <clib/alib_protos.h>
27 #include <scalos/scalos.h>
28 #include <scalos/GadgetBar.h>
36 #include "scalos_structures.h"
39 #include "functions.h"
40 #include "Variables.h"
43 //----------------------------------------------------------------------------
45 // local data structures
47 //----------------------------------------------------------------------------
51 static SAVEDS(ULONG
) INTERRUPT
DefaultColumnWidthChangeHookFunc(struct Hook
*hook
, Object
*o
, Msg msg
);
53 //----------------------------------------------------------------------------
57 #define MIN_WINDOW_WIDTH 92
58 #define MIN_WINDOW_HEIGHT 65
60 //----------------------------------------------------------------------------
62 static SAVEDS(ULONG
) INTERRUPT
DefaultColumnWidthChangeHookFunc(struct Hook
*hook
, Object
*o
, Msg msg
)
72 SAVEDS(void) INTERRUPT
WindowTask(void)
75 struct internalScaWindowTask
*iwt
;
76 struct SM_StartWindow
*msgStart
= NULL
;
77 BOOL WinSemaLocked
= FALSE
;
78 BOOL wasMainWindow
= FALSE
;
79 struct ScaWindowStruct
*dummyList
= NULL
;
81 ScalosObtainSemaphoreShared(&QuitSemaphore
);
83 d1(kprintf("%s/%s/%ld: Offset iwt_LastIconUpdateTime=%ld\n", __FILE__
, __FUNC__
, __LINE__
, offsetof(struct internalScaWindowTask
, iwt_LastIconUpdateTime
)));
84 d1(kprintf("%s/%s/%ld: Offset iwt_UpdateSemaphore=%ld\n", __FILE__
, __FUNC__
, __LINE__
, offsetof(struct internalScaWindowTask
, iwt_UpdateSemaphore
)));
87 struct ScaWindowStruct
*ws
;
88 BOOL Finished
= FALSE
;
89 enum ScanDirResult sdResult
;
91 iwt
= ScalosAlloc(sizeof(struct internalScaWindowTask
));
95 d1(kprintf("%s/%s/%ld: iwt=%08lx\n", __FILE__
, __FUNC__
, __LINE__
, iwt
));
96 d1(kprintf("%s/%s/%ld: MainMenu=%08lx\n", __FILE__
, __FUNC__
, __LINE__
, MainMenu
));
98 memset(iwt
, 0, sizeof(struct internalScaWindowTask
));
100 ScalosInitSemaphore(&iwt
->iwt_ThumbnailIconSemaphore
);
101 ScalosInitSemaphore(&iwt
->iwt_ThumbGenerateSemaphore
);
102 ScalosInitSemaphore(&iwt
->iwt_PopChildListSemaphore
);
103 ScalosInitSemaphore(&iwt
->iwt_WindowHistoryListSemaphore
);
105 iwt
->iwt_WindowTask
.wt_PatternInfo
.ptinf_BgPen
= NO_PEN
;
107 NewList(&iwt
->iwt_ThumbnailIconList
);
108 NewList(&iwt
->iwt_IconDropMarkInfoList
);
109 NewList(&iwt
->iwt_ControlBarMemberList
);
110 NewList(&iwt
->iwt_HistoryList
);
111 NewList(&iwt
->iwt_PopChildList
);
113 iwt
->iwt_BottomScrollerScale
= iwt
->iwt_SideScrollerScale
= 0;
115 iwt
->iwt_OldFileSys
= (struct MsgPort
*) ~0;
117 iwt
->iwt_IDCMPFlags
= IDCMP_REFRESHWINDOW
| IDCMP_MOUSEBUTTONS
| IDCMP_GADGETDOWN
118 | IDCMP_GADGETUP
| IDCMP_MENUPICK
| IDCMP_CLOSEWINDOW
| IDCMP_ACTIVEWINDOW
119 | IDCMP_RAWKEY
| IDCMP_CHANGEWINDOW
| IDCMP_GADGETHELP
| IDCMP_IDCMPUPDATE
120 | IDCMP_INACTIVEWINDOW
;
122 #if defined(IDCMP_EXTENDEDMOUSE)
123 iwt
->iwt_IDCMPFlags
|= IDCMP_EXTENDEDMOUSE
;
124 #endif //defined(IDCMP_EXTENDEDMOUSE)
125 #if defined(__MORPHOS__)
126 // enable IDCMP events during dynamic window resizing
127 iwt
->iwt_IDCMPFlags
|= IDCMP_NEWSIZE
;
130 iwt
->iwt_WindowProcess
= (struct Process
*) FindTask(NULL
);
132 while (NULL
== (msgStart
= (struct SM_StartWindow
*) GetMsg(&iwt
->iwt_WindowProcess
->pr_MsgPort
)))
133 WaitPort(&iwt
->iwt_WindowProcess
->pr_MsgPort
);
135 d1(kprintf("%s/%s/%ld: iwt=%08lx msgStart=%08lx ReplyPort=%08lx\n", \
136 __FILE__
, __FUNC__
, __LINE__
, iwt
, msgStart
, msgStart
->ScalosMessage
.sm_Message
.mn_ReplyPort
));
138 iwt
->iwt_WindowTask
.mt_WindowStruct
= dummyList
= ws
= msgStart
->WindowStruct
;
140 iwt
->iwt_ColumnWidthChangeHook
.h_Data
= iwt
;
141 SETHOOKFUNC(iwt
->iwt_ColumnWidthChangeHook
, DefaultColumnWidthChangeHookFunc
);
143 iwt
->iwt_WindowTask
.wt_IconSemaphore
= ScalosCreateSemaphore();
144 if (NULL
== iwt
->iwt_WindowTask
.wt_IconSemaphore
)
147 iwt
->iwt_AppListSemaphore
= ScalosCreateSemaphore();
148 if (NULL
== iwt
->iwt_AppListSemaphore
)
151 iwt
->iwt_WindowTask
.wt_WindowSemaphore
= ScalosCreateSemaphore();
152 if (NULL
== iwt
->iwt_WindowTask
.wt_WindowSemaphore
)
155 ScalosInitSemaphore(&iwt
->iwt_UpdateSemaphore
);
156 ScalosInitSemaphore(&iwt
->iwt_ScanDirSemaphore
);
157 ScalosInitSemaphore(&iwt
->iwt_ChildProcessSemaphore
);
159 ws
->ws_WindowTask
= (struct ScaWindowTask
*) iwt
;
161 iwt
->iwt_WinScreen
= iwt
->iwt_OrigWinScreen
= iInfos
.xii_iinfos
.ii_Screen
;
162 iwt
->iwt_WinDrawInfo
= iInfos
.xii_iinfos
.ii_DrawInfo
;
164 iwt
->iwt_CheckOverlappingIcons
= (ws
->ws_Flags
& WSV_FlagF_CheckOverlappingIcons
) != 0;
166 d1(KPrintF("%s/%s/%ld: ws_Flags=%08lx\n", __FILE__
, __FUNC__
, __LINE__
, ws
->ws_Flags
));
167 d1(KPrintF("%s/%s/%ld: iwt_CheckOverlappingIcons=%ld\n", __FILE__
, __FUNC__
, __LINE__
, iwt
->iwt_CheckOverlappingIcons
));
169 iwt
->iwt_WindowTask
.wt_IconPort
= ws
->ws_MessagePort
= CreateMsgPort();
170 if (NULL
== iwt
->iwt_WindowTask
.wt_IconPort
)
173 if (WSV_Type_DeviceWindow
!= ws
->ws_WindowType
)
175 struct FileLock
*fLock
= BADDR(ws
->ws_Lock
);
177 ScalosObtainSemaphore(&iwt
->iwt_WindowHistoryListSemaphore
);
178 iwt
->iwt_CurrentHistoryEntry
= WindowAddHistoryEntry(iwt
, ws
->ws_Lock
);
179 ScalosReleaseSemaphore(&iwt
->iwt_WindowHistoryListSemaphore
);
181 iwt
->iwt_OldFileSys
= SetFileSysTask(fLock
->fl_Task
);
183 iwt
->iwt_ReadOnly
= !ClassIsDiskWritable(ws
->ws_Lock
);
185 UndoWindowSignalOpening(iwt
);
188 if (ws
->ws_Width
< MIN_WINDOW_WIDTH
)
189 ws
->ws_Width
= MIN_WINDOW_WIDTH
;
190 if (ws
->ws_Height
< MIN_WINDOW_HEIGHT
)
191 ws
->ws_Height
= MIN_WINDOW_HEIGHT
;
193 iwt
->iwt_WindowTask
.wt_PatternInfo
.ptinf_width
= ws
->ws_Width
;
194 iwt
->iwt_WindowTask
.wt_PatternInfo
.ptinf_height
= ws
->ws_Height
;
196 if (ws
->ws_Flags
& WSV_FlagF_Backdrop
)
199 iwt
->iwt_WindowTask
.wt_PatternInfo
.ptinf_width
= iwt
->iwt_WinScreen
->Width
;
200 iwt
->iwt_WindowTask
.wt_PatternInfo
.ptinf_height
= iwt
->iwt_WinScreen
->Height
;
202 iwt
->iwt_WindowTask
.wt_XOffset
= ws
->ws_xoffset
= 0;
203 iwt
->iwt_WindowTask
.wt_YOffset
= ws
->ws_yoffset
= 0;
205 if (!CurrentPrefs
.pref_FullBenchFlag
)
206 iwt
->iwt_WindowTask
.wt_PatternInfo
.ptinf_height
-= iwt
->iwt_WinScreen
->BarHeight
+ 1;
208 SetBackFill(iwt
, ws
->ws_PatternNode
, &iwt
->iwt_WindowTask
.wt_PatternInfo
, 0, iwt
->iwt_WinScreen
);
210 iwt
->iwt_TitleObject
= SCA_NewScalosObjectTags("Title.sca",
211 SCCA_Title_Type
, SCCV_Title_Type_Window
,
212 SCCA_Title_Format
, (IPTR
) (ws
->ws_Title
? ws
->ws_Title
: (STRPTR
) "Scalos"),
213 SCCA_WindowTask
, (IPTR
) iwt
,
215 d1(kprintf("%s/%s/%ld: TitleObject=%08lx\n", __FILE__
, __FUNC__
, __LINE__
, iwt
->iwt_TitleObject
));
216 if (NULL
== iwt
->iwt_TitleObject
)
219 if (DoMethod(iwt
->iwt_TitleObject
, SCCM_Title_QueryTitle
))
221 iwt
->iwt_IDCMPFlags
|= IDCMP_DISKINSERTED
| IDCMP_DISKREMOVED
;
222 iwt
->iwt_NeedsTimerFlag
= TRUE
;
223 ws
->ws_Flags
|= WSV_FlagF_NeedsTimerMsg
;
225 iwt
->iwt_WinTitle
= (STRPTR
) DoMethod(iwt
->iwt_TitleObject
, SCCM_Title_Generate
);
227 if (IsIwtViewByIcon(iwt
))
229 iwt
->iwt_WindowTask
.wt_XOffset
= ws
->ws_xoffset
;
230 iwt
->iwt_WindowTask
.wt_YOffset
= ws
->ws_yoffset
;
233 iwt
->iwt_WindowTask
.mt_WindowObject
= SCA_NewScalosObjectTags("Window.sca",
234 SCCA_WindowTask
, (IPTR
) iwt
,
236 d1(kprintf("%s/%s/%ld: WindowObject=%08lx\n", __FILE__
, __FUNC__
, __LINE__
, iwt
->iwt_WindowTask
.mt_WindowObject
));
237 if (NULL
== iwt
->iwt_WindowTask
.mt_WindowObject
)
240 iwt
->iwt_WindowTask
.mt_MainObject
= SCA_NewScalosObjectTags(ws
->ms_ClassName
,
241 SCCA_WindowTask
, (IPTR
) iwt
,
243 d1(kprintf("%s/%s/%ld: MainObject=%08lx\n", __FILE__
, __FUNC__
, __LINE__
, iwt
->iwt_WindowTask
.mt_MainObject
));
244 if (NULL
== iwt
->iwt_WindowTask
.mt_MainObject
)
247 if (CurrentPrefs
.pref_DisplayStatusBar
&& (CurrentPrefs
.pref_iCandy
> 1) && !(ws
->ws_Flags
& (WSV_FlagF_NoStatusBar
| WSV_FlagF_Backdrop
)))
249 if (!StatusBarAdd(iwt
))
253 if (!(ws
->ws_Flags
& WSV_FlagF_Backdrop
) && !(ws
->ws_MoreFlags
& WSV_MoreFlagF_NoControlBar
))
255 if (!ControlBarAdd(iwt
))
257 // Disable browser mode if control bar creation failed.
258 ws
->ws_Flags
&= ~WSV_FlagF_BrowserMode
;
262 d1(KPrintF("%s/%s/%ld: ws_ThumbnailView=%ld\n", __FILE__
, __FUNC__
, __LINE__
, ws
->ws_ThumbnailView
));
264 SetAttrs(iwt
->iwt_WindowTask
.mt_MainObject
,
265 SCCA_IconWin_ShowType
, ws
->ws_ViewAll
,
266 SCCA_IconWin_ThumbnailView
, ws
->ws_ThumbnailView
,
269 iwt
->iwt_ThumbnailsLifetimeDays
= ws
->ws_ThumbnailsLifetimeDays
;
271 SetIconWindowReadOnly(iwt
, iwt
->iwt_ReadOnly
);
273 d1(kprintf("%s/%s/%ld: \n", __FILE__
, __FUNC__
, __LINE__
));
275 if (ws
->ws_Flags
& WSV_FlagF_Iconify
)
277 d1(kprintf("%s/%s/%ld: \n", __FILE__
, __FUNC__
, __LINE__
));
279 // Reply task startup message
280 ReplyMsg(&msgStart
->ScalosMessage
.sm_Message
);
283 if (!DoMethod(iwt
->iwt_WindowTask
.mt_WindowObject
, SCCM_Window_Iconify
))
285 ws
->ws_Flags
&= ~WSV_FlagF_Iconify
;
286 iwt
->iwt_IconifyFlag
= FALSE
;
288 if (!DoMethod(iwt
->iwt_WindowTask
.mt_WindowObject
, SCCM_Window_Open
))
290 d1(kprintf("%s/%s/%ld: SCCM_Window_Open failed.\n", __FILE__
, __FUNC__
, __LINE__
));
294 d1(kprintf("%s/%s/%ld: wt_Window=%08lx\n", __FILE__
, __FUNC__
, __LINE__
, iwt
->iwt_WindowTask
.wt_Window
));
296 ws
->ws_Window
= iwt
->iwt_WindowTask
.wt_Window
;
301 d1(kprintf("%s/%s/%ld: \n", __FILE__
, __FUNC__
, __LINE__
));
303 if (!DoMethod(iwt
->iwt_WindowTask
.mt_WindowObject
, SCCM_Window_Open
))
305 d1(kprintf("%s/%s/%ld: SCCM_Window_Open failed.\n", __FILE__
, __FUNC__
, __LINE__
));
309 d1(kprintf("%s/%s/%ld: wt_Window=%08lx\n", __FILE__
, __FUNC__
, __LINE__
, iwt
->iwt_WindowTask
.wt_Window
));
311 ws
->ws_Window
= iwt
->iwt_WindowTask
.wt_Window
;
313 ReplyMsg(&msgStart
->ScalosMessage
.sm_Message
);
317 // move <ws> into official window list
318 SCA_LockWindowList(SCA_LockWindowList_Exclusiv
);
319 SCA_MoveWSNode(&dummyList
, &winlist
.wl_WindowStruct
, iwt
->iwt_WindowTask
.mt_WindowStruct
);
320 SCA_UnLockWindowList();
322 d1(kprintf("%s/%s/%ld: wt_Window=%08lx\n", __FILE__
, __FUNC__
, __LINE__
, iwt
->iwt_WindowTask
.wt_Window
));
324 DoMethod(iwt
->iwt_WindowTask
.mt_WindowObject
, SCCM_Window_SetInnerSize
);
326 d1(kprintf("%s/%s/%ld: \n", __FILE__
, __FUNC__
, __LINE__
));
328 if (iwt
->iwt_WindowTask
.wt_Window
)
330 Scalos_SetFont(iwt
->iwt_WindowTask
.wt_Window
->RPort
, iwt
->iwt_IconFont
, &iwt
->iwt_IconTTFont
);
332 SetABPenDrMd(iwt
->iwt_WindowTask
.wt_Window
->RPort
,
333 FontPrefs
.fprf_FontFrontPen
, FontPrefs
.fprf_FontBackPen
,
334 FontPrefs
.fprf_TextDrawMode
);
336 d1(kprintf("%s/%s/%ld: MainMenu=%08lx\n", __FILE__
, __FUNC__
, __LINE__
, MainMenu
));
338 SafeSetMenuStrip(iwt
->iwt_WindowTask
.wt_Window
);
341 d1(kprintf("%s/%s/%ld: \n", __FILE__
, __FUNC__
, __LINE__
));
345 d1(kprintf("%s/%s/%ld: \n", __FILE__
, __FUNC__
, __LINE__
));
347 iwt
->iwt_RemRegion
= (struct Region
*) DoMethod(iwt
->iwt_WindowTask
.mt_WindowObject
, SCCM_Window_InitClipRegion
);
348 d1(kprintf("%s/%s/%ld: iwt_RemRegion=%08lx\n", __FILE__
, __FUNC__
, __LINE__
, iwt
->iwt_RemRegion
));
350 d1(KPrintF("%s/%s/%ld: iwt=%08lx ws=%08lx\n", \
351 __FILE__
, __FUNC__
, __LINE__
, iwt
, iwt
->iwt_WindowTask
.mt_WindowStruct
));
353 sdResult
= DoMethod(iwt
->iwt_WindowTask
.mt_MainObject
, SCCM_IconWin_Update
);
355 d1(KPrintF("%s/%s/%ld: SCCM_IconWin_Update Result = %08lx\n", __FILE__
, __FUNC__
, __LINE__
, sdResult
));
356 if (ScanDirIsError(sdResult
))
357 break; // error or user abort reading icons
359 d1(kprintf("%s/%s/%ld: \n", __FILE__
, __FUNC__
, __LINE__
));
361 UpdateIconCount(iwt
);
365 DoMethod(iwt
->iwt_WindowTask
.mt_MainObject
, SCCM_WindowStartComplete
);
368 d1(KPrintF("%s/%s/%ld: iwt=%08lx Finished=%ld iwt_CloseWindow=%ld\n", __FILE__
, __FUNC__
, __LINE__
, iwt
, Finished
, iwt
->iwt_CloseWindow
));
370 if (iwt
->iwt_CloseWindow
)
373 WaitPort(iwt
->iwt_WindowTask
.wt_IconPort
);
375 if (DoMethod(iwt
->iwt_WindowTask
.mt_MainObject
, SCCM_HandleMessages
))
377 // Window is going to be closed
380 d1(KPrintF("%s/%s/%ld: \n", __FILE__
, __FUNC__
, __LINE__
));
382 FlushThumbnailEntries(iwt
);
384 d1(KPrintF("%s/%s/%ld: \n", __FILE__
, __FUNC__
, __LINE__
));
386 if (iwt
->iwt_PopupMenuPending
)
388 if (iwt
->iwt_PopupMenuPending
->mpm_Flags
& SHOWPOPUPFLGF_WinListLocked
)
389 SCA_UnLockWindowList();
390 if (iwt
->iwt_PopupMenuPending
->mpm_Flags
& SHOWPOPUPFLGF_IconSemaLocked
)
391 ScalosUnLockIconList(iwt
);
393 ScalosFree(iwt
->iwt_PopupMenuPending
);
396 d1(KPrintF("%s/%s/%ld: \n", __FILE__
, __FUNC__
, __LINE__
));
398 if (ScaAttemptSemaphoreList(SCA_SemaphoreExclusive
, (IPTR
) iwt
->iwt_WindowTask
.wt_WindowSemaphore
,
399 SCA_SemaphoreExclusive
, (IPTR
) &iwt
->iwt_ChildProcessSemaphore
,
402 WinSemaLocked
= TRUE
;
404 d1(KPrintF("%s/%s/%ld: mt_WindowStruct=%08lx ii_MainWindowStruct=%08lx\n", \
405 __FILE__
, __FUNC__
, __LINE__
, iwt
->iwt_WindowTask
.mt_WindowStruct
, iInfos
.xii_iinfos
.ii_MainWindowStruct
));
407 if (iwt
->iwt_WindowTask
.mt_WindowStruct
== iInfos
.xii_iinfos
.ii_MainWindowStruct
)
409 // "Quit Scalos" requested
411 if (MainWindowTask
->emulation
)
413 UseAsyncRequestArgs(iwt
,
414 MSGID_CANNOT_QUIT_WBREPLACEMENT
,
418 ScalosReleaseSemaphore(&iwt
->iwt_ChildProcessSemaphore
);
419 ScalosReleaseSemaphore(iwt
->iwt_WindowTask
.wt_WindowSemaphore
);
420 WinSemaLocked
= FALSE
;
422 iwt
->iwt_CloseWindow
= FALSE
;
426 d1(KPrintF("%s/%s/%ld: OpenCnt=%ld\n", __FILE__
, __FUNC__
, __LINE__
, ScalosBase
->scb_LibNode
.lib_OpenCnt
));
428 // force flushing of all libraries/devices
429 (void) AllocMem(INT_MAX
, MEMF_ANY
);
431 d1(KPrintF("%s/%s/%ld: OpenCnt=%ld\n", __FILE__
, __FUNC__
, __LINE__
, ScalosBase
->scb_LibNode
.lib_OpenCnt
));
433 // Add 1 to ScaLibPluginOpenCount because Scalos itself opens the library once!
434 while (Finished
&& (ScalosBase
->scb_LibNode
.lib_OpenCnt
> (1 + ScaLibPluginOpenCount
)))
436 d1(KPrintF("%s/%s/%ld: \n", __FILE__
, __FUNC__
, __LINE__
));
438 UseAsyncRequestArgs(iwt
,
439 MSGID_CANNOT_QUIT_LIBOPEN
,
441 1, (ScalosBase
->scb_LibNode
.lib_OpenCnt
- 1) << 16);
443 d1(kprintf("%s/%s/%ld: \n", __FILE__
, __FUNC__
, __LINE__
));
445 if (0 == WaitReply(iwt
->iwt_WindowTask
.wt_IconPort
, iwt
, MTYP_Requester
))
447 d1(kprintf("%s/%s/%ld: \n", __FILE__
, __FUNC__
, __LINE__
));
449 ScalosReleaseSemaphore(&iwt
->iwt_ChildProcessSemaphore
);
450 ScalosReleaseSemaphore(iwt
->iwt_WindowTask
.wt_WindowSemaphore
);
451 WinSemaLocked
= FALSE
;
453 iwt
->iwt_CloseWindow
= FALSE
;
455 d1(kprintf("%s/%s/%ld: \n", __FILE__
, __FUNC__
, __LINE__
));
458 d1(KPrintF("%s/%s/%ld: OpenCnt=%ld\n", __FILE__
, __FUNC__
, __LINE__
, ScalosBase
->scb_LibNode
.lib_OpenCnt
));
464 // Cannot lock semaphores - perhaps some child process is still running
465 // defer quit until child process has finished!
468 d1(KPrintF("%s/%s/%ld: iwt_IconPortOutstanding=%ld iwt_AsyncLayoutPending=%ld\n", __FILE__
, __FUNC__
, __LINE__
, iwt
->iwt_IconPortOutstanding
, iwt
->iwt_AsyncLayoutPending
));
470 if (Finished
&& (iwt
->iwt_IconPortOutstanding
|| iwt
->iwt_AsyncLayoutPending
))
472 ScalosReleaseSemaphore(&iwt
->iwt_ChildProcessSemaphore
);
473 ScalosReleaseSemaphore(iwt
->iwt_WindowTask
.wt_WindowSemaphore
);
476 } while ((!WinSemaLocked
&& !Finished
) || iwt
->iwt_IconPortOutstanding
|| iwt
->iwt_AsyncLayoutPending
);
479 d1(kprintf("%s/%s/%ld: \n", __FILE__
, __FUNC__
, __LINE__
));
483 struct WindowHistoryEntry
*whe
;
484 struct ScaPopChildWindow
*spcw
;
487 UndoWindowSignalClosing(iwt
);
489 d1(kprintf("%s/%s/%ld: iwt_AsyncLayoutPending=%ld\n", __FILE__
, __FUNC__
, __LINE__
, iwt
->iwt_AsyncLayoutPending
));
491 InvalidateLastIwtUnderPointer(iwt
);
493 while (iwt
->iwt_AsyncLayoutPending
)
495 // we need to continue handling messages because iwt_AsyncLayoutPending
496 // is cleared within message reply handler
497 (void) DoMethod(iwt
->iwt_WindowTask
.mt_MainObject
, SCCM_CheckForMessages
);
501 d1(kprintf("%s/%s/%ld: iwt_AsyncLayoutPending=%ld\n", __FILE__
, __FUNC__
, __LINE__
, iwt
->iwt_AsyncLayoutPending
));
503 ScalosObtainSemaphore(&iwt
->iwt_ChildProcessSemaphore
);
504 ScalosReleaseSemaphore(&iwt
->iwt_ChildProcessSemaphore
);
506 // make sure whe_IconList is not freed twice
507 if (iwt
->iwt_CurrentHistoryEntry
)
508 iwt
->iwt_CurrentHistoryEntry
->whe_IconList
= NULL
;
510 DoMethod(iwt
->iwt_WindowTask
.mt_WindowObject
, SCCM_Window_RemClipRegion
, iwt
->iwt_RemRegion
);
511 iwt
->iwt_RemRegion
= NULL
;
512 d1(kprintf("%s/%s/%ld: iwt_RemRegion=%08lx\n", __FILE__
, __FUNC__
, __LINE__
, iwt
->iwt_RemRegion
));
514 d1(kprintf("%s/%s/%ld: \n", __FILE__
, __FUNC__
, __LINE__
));
516 if (iInfos
.xii_GlobalGadgetUnderPointer
.ggd_iwt
== iwt
)
518 iInfos
.xii_GlobalGadgetUnderPointer
.ggd_iwt
= NULL
;
519 iInfos
.xii_GlobalGadgetUnderPointer
.ggd_Gadget
= NULL
;
520 iInfos
.xii_GlobalGadgetUnderPointer
.ggd_GadgetID
= SGTT_GADGETID_unknown
;
523 // Dispose icon overlays
524 for (n
= 0; n
< Sizeof(iwt
->iwt_IconOverlays
); n
++)
526 DisposeDatatypesImage(&iwt
->iwt_IconOverlays
[n
]);
528 if (iwt
->iwt_PopupMenuPending
)
529 ScalosFree(iwt
->iwt_PopupMenuPending
);
530 if (iwt
->iwt_myAppObj
)
532 SCA_RemoveAppObject(iwt
->iwt_myAppObj
);
533 DisposeIconObject(iwt
->iwt_myAppIcon
);
537 ScalosReleaseSemaphore(iwt
->iwt_WindowTask
.wt_WindowSemaphore
);
538 ScalosReleaseSemaphore(&iwt
->iwt_ChildProcessSemaphore
);
541 // Dispose all entries in window history list
542 while ((whe
= (struct WindowHistoryEntry
*) RemHead(&iwt
->iwt_HistoryList
)))
544 WindowHistoryEntryDispose(iwt
, whe
);
546 iwt
->iwt_CurrentHistoryEntry
= NULL
;
548 // Dispose all entries in iwt_PopChildList
549 while ((spcw
= (struct ScaPopChildWindow
*) RemHead(&iwt
->iwt_PopChildList
)))
551 d1(KPrintF("%s/%s/%ld: spcw=%08lx\n", __FILE__
, __FUNC__
, __LINE__
, spcw
));
552 PopChildWindowDispose(iwt
, spcw
);
555 if (iwt
->iwt_WindowTask
.mt_WindowObject
)
556 DoMethod(iwt
->iwt_WindowTask
.mt_WindowObject
, SCCM_Window_Close
);
558 d1(kprintf("%s/%s/%ld: \n", __FILE__
, __FUNC__
, __LINE__
));
560 wasMainWindow
= DisposeScalosWindow(iwt
, dummyList
? &dummyList
: &winlist
.wl_WindowStruct
); // frees ScaWindowStruct !!
561 iwt
->iwt_WindowTask
.mt_WindowStruct
= NULL
;
563 d1(kprintf("%s/%s/%ld: \n", __FILE__
, __FUNC__
, __LINE__
));
565 if (iwt
->iwt_WindowTask
.mt_WindowObject
)
567 SCA_DisposeScalosObject(iwt
->iwt_WindowTask
.mt_WindowObject
);
570 FreeBackFill(&iwt
->iwt_WindowTask
.wt_PatternInfo
);
572 if (iwt
->iwt_WindowTask
.wt_IconSemaphore
)
574 ScalosLockIconListExclusive(iwt
);
576 FreeIconList(iwt
, &iwt
->iwt_WindowTask
.wt_IconList
);
577 FreeIconList(iwt
, &iwt
->iwt_WindowTask
.wt_LateIconList
);
579 ScalosUnLockIconList(iwt
);
582 StatusBarRemove(iwt
);
583 ControlBarRemove(iwt
);
585 if (iwt
->iwt_WindowTask
.mt_MainObject
)
587 SCA_DisposeScalosObject(iwt
->iwt_WindowTask
.mt_MainObject
);
588 iwt
->iwt_WindowTask
.mt_MainObject
= NULL
;
591 if (iwt
->iwt_WindowTask
.wt_IconPort
)
593 struct MsgPort
*iconPort
= iwt
->iwt_WindowTask
.wt_IconPort
;
597 iwt
->iwt_WindowTask
.wt_IconPort
= NULL
;
598 if (iwt
->iwt_WindowTask
.mt_WindowStruct
)
599 iwt
->iwt_WindowTask
.mt_WindowStruct
->ws_MessagePort
= NULL
;
601 ClearMsgPort(iconPort
);
602 DeleteMsgPort(iconPort
);
606 if (iwt
->iwt_WindowTask
.wt_IconSemaphore
)
608 ScalosDeleteSemaphore(iwt
->iwt_WindowTask
.wt_IconSemaphore
);
609 iwt
->iwt_WindowTask
.wt_IconSemaphore
= NULL
;
611 if (iwt
->iwt_AppListSemaphore
)
613 ScalosDeleteSemaphore(iwt
->iwt_AppListSemaphore
);
614 iwt
->iwt_AppListSemaphore
= NULL
;
616 if (iwt
->iwt_WindowTask
.wt_WindowSemaphore
)
618 ScalosDeleteSemaphore(iwt
->iwt_WindowTask
.wt_WindowSemaphore
);
619 iwt
->iwt_WindowTask
.wt_WindowSemaphore
= NULL
;
622 if (((struct MsgPort
*) ~0) != iwt
->iwt_OldFileSys
)
623 SetFileSysTask(iwt
->iwt_OldFileSys
);
625 if (iwt
->iwt_TitleObject
)
627 SCA_DisposeScalosObject(iwt
->iwt_TitleObject
);
628 iwt
->iwt_TitleObject
= NULL
;
630 if (iwt
->iwt_AslFileRequest
)
632 FreeAslRequest(iwt
->iwt_AslFileRequest
);
633 iwt
->iwt_AslFileRequest
= NULL
;
635 if (iwt
->iwt_WindowTask
.mt_WindowStruct
)
636 iwt
->iwt_WindowTask
.mt_WindowStruct
->ws_WindowTask
= NULL
;
638 CleanupDropMarkInfo(&iwt
->iwt_WindowDropMarkInfo
);
639 CleanupDropMarkInfoList(&iwt
->iwt_IconDropMarkInfoList
);
641 d1(kprintf("%s/%s/%ld: iwt=%08lx\n", __FILE__
, __FUNC__
, __LINE__
, iwt
));
646 d1(KPrintF("%s/%s/%ld: wasMainWindow=%ld\n", __FILE__
, __FUNC__
, __LINE__
, wasMainWindow
));
650 struct SM_AsyncRoutine
*msg
= (struct SM_AsyncRoutine
*) SCA_AllocMessage(MTYP_AsyncRoutine
, 0);
652 d1(KPrintF("%s/%s/%ld: msg=%08lx\n", __FILE__
, __FUNC__
, __LINE__
, msg
));
656 msg
->smar_EntryPoint
= (ASYNCROUTINEFUNC
) CloseWindowMsg
;
658 PutMsg(iInfos
.xii_iinfos
.ii_MainMsgPort
, &msg
->ScalosMessage
.sm_Message
);
662 d1(KPrintF("%s/%s/%ld: \n", __FILE__
, __FUNC__
, __LINE__
));
665 ReplyMsg(&msgStart
->ScalosMessage
.sm_Message
);
667 d1(KPrintF("%s/%s/%ld: \n", __FILE__
, __FUNC__
, __LINE__
));
669 SCA_FreeAllNodes((struct ScalosNodeList
*)(APTR
) &dummyList
);
671 d1(KPrintF("%s/%s/%ld: \n", __FILE__
, __FUNC__
, __LINE__
));
673 ScalosReleaseSemaphore(&QuitSemaphore
);
675 d1(KPrintF("%s/%s/%ld: END\n", __FILE__
, __FUNC__
, __LINE__
));