9 #include <exec/types.h>
10 #include <exec/nodes.h>
11 #include <intuition/classes.h>
12 #include <intuition/intuitionbase.h>
13 #include <intuition/gadgetclass.h>
14 #include <datatypes/iconobject.h>
16 #include <dos/dosextens.h>
17 #include <dos/dostags.h>
18 #include <scalos/scalos.h>
19 #include <scalos/preferences.h>
20 #include <workbench/workbench.h>
21 #include <workbench/startup.h>
22 #include <workbench/icon.h>
23 #include <libraries/iffparse.h>
25 #include <clib/alib_protos.h>
27 #include <proto/iconobject.h>
28 #include <proto/utility.h>
29 #include <proto/dos.h>
30 #include <proto/exec.h>
31 #include <proto/scalos.h>
32 #include <proto/intuition.h>
33 #include <proto/layers.h>
34 #include <proto/icon.h>
35 #include <proto/iffparse.h>
36 #include <proto/preferences.h>
45 #include "wb39proto.h"
46 #include "volumegauge.h"
48 // moved revision history to file "History"
53 State of WB3.5/3.9 API emulation
54 ================================
56 AddAppIconA - partially supported :
57 WBAPPICONA_SupportsOpen - native support by Scalos ver >= 40
58 WBAPPICONA_SupportsCopy - native support by Scalos ver >= 40
59 WBAPPICONA_SupportsRename - native support by Scalos ver >= 40
60 WBAPPICONA_SupportsInformation - native support by Scalos ver >= 40
61 WBAPPICONA_SupportsSnapshot - native support by Scalos ver >= 40
62 WBAPPICONA_SupportsUnSnapshot - native support by Scalos ver >= 40
63 WBAPPICONA_SupportsLeaveOut - native support by Scalos ver >= 40
64 WBAPPICONA_SupportsPutAway - native support by Scalos ver >= 40
65 WBAPPICONA_SupportsDelete - native support by Scalos ver >= 40
66 WBAPPICONA_SupportsFormatDisk - native support by Scalos ver >= 40
67 WBAPPICONA_SupportsEmptyTrash - native support by Scalos ver >= 40
68 WBAPPICONA_PropagatePosition - supported, only works with Scalos ver >= 40
69 WBAPPICONA_RenderHook - supported, only works with Scalos ver >= 40
70 WBAPPICONA_NotifySelectState - ./.
71 AddAppMenuItemA - full native support by Scalos ver >= 40
72 AddAppWindowA - supported
73 AddAppWindowDropZoneA - supported
74 ChangeWorkbenchSelectionA - supported
75 CloseWorkbenchObjectA - supported
76 MakeWorkbenchObjectVisibleA - supported
77 OpenWorkbenchObjectA - supported
78 RemoveAppIcon - partially supported
79 RemoveAppMenuItem - ./. unchanged
80 RemoveAppWindow - supported
81 RemoveAppWindowDropZone - supported
82 WBInfo - ./. unchanged
83 WorkbenchControlA - fully supported :
84 WBCTRLA_IsOpen - supported
85 WBCTRLA_DuplicateSearchPath - supported
86 WBCTRLA_FreeSearchPath - supported
87 WBCTRLA_GetDefaultStackSize - supported with Scalos ver >= 40
88 WBCTRLA_SetDefaultStackSize - supported with Scalos ver >= 40
89 WBCTRLA_RedrawAppIcon - does Icon Redraw, only works with Scalos ver >= 40
90 WBCTRLA_GetProgramList - supported with Scalos ver >= 40
91 WBCTRLA_FreeProgramList - supported
92 WBCTRLA_GetSelectedIconList - supported
93 WBCTRLA_FreeSelectedIconList - supported
94 WBCTRLA_GetOpenDrawerList - supported
95 WBCTRLA_FreeOpenDrawerList - supported
96 WBCTRLA_AddHiddenDeviceName - supported
97 WBCTRLA_RemoveHiddenDeviceName - supported
98 WBCTRLA_GetHiddenDeviceList - supported
99 WBCTRLA_FreeHiddenDeviceList - supported
100 WBCTRLA_GetTypeRestartTime - supported, with Scalos ver >= 40
101 WBCTRLA_SetTypeRestartTime - supported, with Scalos ver >= 40
105 #if !defined(__amigaos4__) && !defined(__AROS__)
106 extern int _STI_240_InitMemFunctions(void);
107 extern void _STD_240_TerminateMemFunctions(void);
110 static BOOL
LateInit(void);
111 static BOOL
OpenLibraries(void);
112 static void CloseLibraries(void);
113 static LIBFUNC_P3_PROTO(BOOL
, myOpenWorkbenchObjectA
,
115 A1
, struct TagItem
*, tags
,
116 A6
, struct Library
*, WorkbenchBase
);
117 static struct WBArg
*BuildWBArg(struct TagItem
*Tags
, ULONG
*ArgCount
);
118 static void FreeWBArg(struct WBArg
*ArgList
, ULONG ArgCount
, BOOL FreeLocks
);
119 static LIBFUNC_P3_PROTO(BOOL
, myCloseWorkbenchObjectA
,
121 A1
, struct TagItem
*, tags
,
122 A6
, struct Library
*, WorkbenchBase
);
123 static LIBFUNC_P3_PROTO(ULONG
, myWbprivate1
,
126 A6
, struct Library
*, WorkbenchBase
);
127 static LIBFUNC_P3_PROTO(BOOL
, myMakeWorkbenchObjectVisibleA
,
129 A1
, struct TagItem
*, tags
,
130 A6
, struct Library
*, WorkbenchBase
);
131 static void UpdateVolumeGauge(struct Gadget
*gad
, struct Window
*win
, BPTR iLock
);
132 static LIBFUNC_P4_PROTO(BOOL
, myChangeWorkbenchSelectionA
,
134 A1
, struct Hook
*, hook
,
135 A2
, struct TagItem
*, tags
,
136 A6
, struct Library
*, WorkbenchBase
);
137 static void FreeAllNodes(struct List
*pl
); // +dm+ 20010518
140 static LIBFUNC_P2VA_PROTO(BOOL
, myOpenWorkbenchObject
,
142 A6
, struct Library
*, WorkbenchBase
);
143 static LIBFUNC_P2VA_PROTO(BOOL
, myCloseWorkbenchObject
,
145 A6
, struct Library
*, WorkbenchBase
);
146 static LIBFUNC_P2VA_PROTO(BOOL
, myMakeWorkbenchObjectVisible
,
148 A6
, struct Library
*, WorkbenchBase
);
149 static LIBFUNC_P3VA_PROTO(BOOL
, myChangeWorkbenchSelection
,
151 A1
, struct Hook
*, hook
,
152 A6
, struct Library
*, WorkbenchBase
);
155 struct DosLibrary
*DOSBase
= NULL
;
156 struct Library
*IconobjectBase
= NULL
;
157 struct Library
*WorkbenchBase
= NULL
;
158 T_UTILITYBASE UtilityBase
= NULL
;
159 struct ScalosBase
*ScalosBase
= NULL
;
160 struct IntuitionBase
*IntuitionBase
= NULL
;
161 struct Library
*LayersBase
= NULL
;
162 struct Library
*GfxBase
= NULL
;
163 struct Library
*IconBase
= NULL
;
164 struct Library
*IFFParseBase
= NULL
;
166 struct Library
*NewlibBase
= NULL
;
168 struct DOSIFace
*IDOS
= NULL
;
169 struct IconobjectIFace
*IIconobject
= NULL
;
170 struct WorkbenchIFace
*IWorkbench
= NULL
;
171 struct UtilityIFace
*IUtility
= NULL
;
172 struct ScalosIFace
*IScalos
= NULL
;
173 struct IntuitionIFace
*IIntuition
= NULL
;
174 struct LayersIFace
*ILayers
= NULL
;
175 struct GraphicsIFace
*IGraphics
= NULL
;
176 struct IconIFace
*IIcon
= NULL
;
177 struct IFFParseIFace
*IIFFParse
= NULL
;
178 struct Interface
*INewlib
= NULL
;
181 #if defined(__GNUC__) && !defined(__MORPHOS__) && !defined(__amigaos4__) && !defined(__AROS__)
182 extern T_UTILITYBASE __UtilityBase
;
183 #endif /* defined(__GNUC__) && !defined(__MORPHOS__) */
185 APTR origOpenWorkbenchObjectA
= NULL
;
186 APTR origCloseWorkbenchObjectA
= NULL
;
187 APTR origAddAppWindowDropZoneA
= NULL
;
188 APTR origRemoveAppWindowDropZone
= NULL
;
189 APTR origWbprivate1
= NULL
;
190 APTR origMakeWorkbenchObjectVisibleA
= NULL
;
191 APTR origChangeWorkbenchSelectionA
= NULL
;
194 /*LIBFUNC_P6_DPROTO(struct ScaAppObjNode *, (*origAddAppWindowA),
197 A0, struct Window *, window,
198 A1, struct MsgPort *, msgport,
199 A2, struct TagItem *, taglist,
200 A6, struct Library *, WorkbenchBase);
201 LIBFUNC_P2_DPROTO(BOOL, (*origRemoveAppWindow),
202 A0, struct ScaAppObjNode *, appWindow,
203 A6, struct Library *, WorkbenchBase);
204 LIBFUNC_P5_DPROTO(void, (*origSCA_DrawDrag),
205 A0, struct DragHandle *, draghandle,
209 A6, struct Library *, ScalosBase);
210 static LIBFUNC_P3_DPROTO(BOOL, (*origWorkbenchControlA),
212 A1, struct TagItem *, tags,
213 A6, struct Library *, WorkbenchBase);
215 APTR origAddAppWindowA
= NULL
;
216 APTR origRemoveAppWindow
= NULL
;
217 APTR origSCA_DrawDrag
= NULL
;
218 APTR origWorkbenchControlA
= NULL
;
221 APTR origOpenWorkbenchObject
= NULL
;
222 APTR origCloseWorkbenchObject
= NULL
;
223 APTR origAddAppWindowDropZone
= NULL
;
224 APTR origMakeWorkbenchObjectVisible
= NULL
;
225 APTR origChangeWorkbenchSelection
= NULL
;
226 APTR origAddAppWindow
= NULL
;
227 APTR origWorkbenchControl
= NULL
;
230 static BOOL fInit
= FALSE
;
232 STRPTR DefIconsPath
= "ENV:sys/def_";
234 struct List AppWindowList
; // list of all AppWindows
235 struct SignalSemaphore AppWindowSema
;
237 ULONG DefaultStackSize
= 4096; // +dm+ 20010518 changed to 4096 (was 4095???)
238 ULONG fVolumeGauge
= TRUE
;
239 ULONG fTitleBar
= TRUE
;
240 ULONG TypeRestartTime
= 3; // Keyboard restart delay in s
241 BOOL NewIconsSupport
= TRUE
;
242 BOOL ColorIconsSupport
= TRUE
;
245 WORD ScalosPrefs_IconOffsets
[4] = { 1, 1, 1, 1 };
247 struct ScaRootList
*rList
= NULL
;
249 struct List HiddenDeviceList
; // +dm+ 20010518 for storing names of hidden devices
250 struct SignalSemaphore HiddenDevListSema
; // +jl+ 20010523 Semaphore to protect HiddenDeviceList
253 M68KFUNC_P3(ULONG
, myHookFunc
,
258 struct ScaRootList
*rootList
;
259 struct ScaWindowStruct
*sWin
= NULL
;
263 rList
= rootList
= (struct ScaRootList
*) obj
;
265 d1(kprintf("%s/%s/%ld: MethodID=%08lx\n"__FILE__
, __FUNC__
, __LINE__
, msg
->MethodID
));
267 if (rootList
&& rootList
->rl_WindowTask
)
268 sWin
= rootList
->rl_WindowTask
->mt_WindowStruct
;
270 switch (msg
->MethodID
)
272 case OM_NEW
: /* First, pass up to superclass */
275 obj
= (Object
*) DoSuperMethodA(cl
, obj
, msg
);
278 struct WB39inst
*inst
= INST_DATA(cl
, obj
);
280 inst
->wb39i_VolumeGaugeObject
= NULL
;
282 Result
= (ULONG
) obj
;
288 case SCCM_Window_Open
:
289 d1(kprintf("%s/%s/%ld: instOffset=%lu instSize=%lu\n"__FILE__
, __FUNC__
, __LINE__
, cl
->cl_InstOffset
, cl
->cl_InstSize
));
291 Scalos4014
= ScalosBase
->scb_LibNode
.lib_Version
>= 40 && ScalosBase
->scb_LibNode
.lib_Revision
>= 14;
293 if (sWin
&& (sWin
->ws_Flags
& WSV_FlagF_RootWindow
)
294 && cl
->cl_InstSize
>= sizeof(struct WB39inst
))
296 if (Scalos4014
&& fVolumeGauge
)
299 struct WB39inst
*inst
= INST_DATA(cl
, obj
);
301 inst
->wb39i_VolumeGaugeObject
= NewObject(VOLUMEGAUGE_GetClass(), NULL
,
302 GA_DrawInfo
, (ULONG
) rootList
->rl_internInfos
->ii_DrawInfo
,
305 VOLUMEGAUGE_Ticks
, 5,
306 VOLUMEGAUGE_ShortTicks
, TRUE
,
307 VOLUMEGAUGE_TickSize
, 3,
309 VOLUMEGAUGE_Max
, 1000,
310 VOLUMEGAUGE_Level
, 500,
313 gg
= (struct Gadget
*) inst
->wb39i_VolumeGaugeObject
;
316 // insert volume gauge in front of other window gadgets
317 DoMethod(sWin
->ws_WindowTask
->mt_MainObject
,
318 SCCM_IconWin_AddGadget
, gg
);
320 UpdateVolumeGauge(gg
, NULL
, sWin
->ws_Lock
);
325 Result
= DoSuperMethodA(cl
, obj
, msg
);
327 d1(kprintf("%s/%s/%ld: RootList=%08lx InternInfos=%08lx\n"__FILE__
, __FUNC__
, __LINE__
, \
328 rootList
, rootList
->rl_internInfos
));
330 if (sWin
&& (sWin
->ws_Flags
& WSV_FlagF_RootWindow
)
331 && cl
->cl_InstSize
>= sizeof(struct WB39inst
)
334 struct Window
*win
= rootList
->rl_WindowTask
->wt_Window
;
336 if (win
&& fVolumeGauge
)
338 struct WB39inst
*inst
= INST_DATA(cl
, obj
);
341 if (win
->BorderLeft
< 14)
342 win
->BorderLeft
= 14;
343 if (win
->BorderLeft
< win
->BorderRight
)
344 win
->BorderLeft
= win
->BorderRight
;
346 inst
->wb39i_VolumeGaugeObject
= NewObject(VOLUMEGAUGE_GetClass(), NULL
,
347 GA_Top
, win
->BorderTop
+ 2,
349 GA_Width
, win
->BorderLeft
- 4 - 4,
350 GA_RelHeight
, - (win
->BorderTop
+ 2) - win
->BorderBottom
,
351 GA_DrawInfo
, (ULONG
) rootList
->rl_internInfos
->ii_DrawInfo
,
354 VOLUMEGAUGE_Ticks
, 5,
355 VOLUMEGAUGE_ShortTicks
, TRUE
,
356 VOLUMEGAUGE_TickSize
, 3,
358 VOLUMEGAUGE_Max
, 1000,
359 VOLUMEGAUGE_Level
, 500,
362 gad
= (struct Gadget
*) inst
->wb39i_VolumeGaugeObject
;
365 AddGadget(win
, gad
, ~0);
366 RefreshGList(gad
, win
, NULL
, 1);
368 UpdateVolumeGauge(gad
, win
, sWin
->ws_Lock
);
370 RefreshWindowFrame(win
);
372 DoMethod(sWin
->ws_WindowTask
->mt_WindowObject
, SCCM_Window_SetInnerSize
);
374 d1(kprintf("%s/%s/%ld: Lock=%08lx\n"__FILE__
, __FUNC__
, __LINE__
, sWin
->ws_Lock
));
376 d1(KPrintF("%s/%s/%ld: Window=%08lx bLeft=%ld bRight=%ld wb39i_VolumeGaugeObject=%08lx\n"__FILE__
, __FUNC__
, __LINE__
, \
377 win
, win
->BorderLeft
, win
->BorderRight
, inst
->wb39i_VolumeGaugeObject
));
381 case SCCM_Window_Close
:
382 if (sWin
&& (sWin
->ws_Flags
& WSV_FlagF_RootWindow
) && cl
->cl_InstSize
>= sizeof(struct WB39inst
))
384 struct WB39inst
*inst
= INST_DATA(cl
, obj
);
385 struct Window
*win
= rootList
->rl_WindowTask
->wt_Window
;
386 struct Gadget
*gad
= (struct Gadget
*) inst
->wb39i_VolumeGaugeObject
;
388 d1(kprintf("%s/%s/%ld: Window=%08lx gad=%08lx\n"__FILE__
, __FUNC__
, __LINE__
, \
393 RemoveGadget(win
, gad
);
394 DisposeObject((Object
*) gad
);
397 Result
= DoSuperMethodA(cl
, obj
, msg
);
400 case SCCM_Window_SetTitle
:
401 if (sWin
&& (sWin
->ws_Flags
& WSV_FlagF_RootWindow
) && cl
->cl_InstSize
>= sizeof(struct WB39inst
))
403 struct WB39inst
*inst
= INST_DATA(cl
, obj
);
404 struct Window
*win
= rootList
->rl_WindowTask
->wt_Window
;
405 struct Gadget
*gad
= (struct Gadget
*) inst
->wb39i_VolumeGaugeObject
;
407 d1(kprintf("%s/%s/%ld: Window=%08lx gad=%08lx\n"__FILE__
, __FUNC__
, __LINE__
, \
411 UpdateVolumeGauge(gad
, win
, sWin
->ws_Lock
);
413 Result
= DoSuperMethodA(cl
, obj
, msg
);
417 d1(kprintf("%s/%s/%ld: MethodID=%08lx\n"__FILE__
, __FUNC__
, __LINE__
, msg
->MethodID
));
418 Result
= DoSuperMethodA(cl
, obj
, msg
);
427 static BOOL
LateInit(void)
429 static BOOL First
= TRUE
;
431 d1(KPrintF("/%s/%ld: First=%ld\n", __FUNC__
, __FILE__
, __FUNC__
, __LINE__
, First
));
435 ULONG EmulationMode
= TRUE
;
437 rList
= GetScalosRootList();
438 d1(kprintf("%s/%s/%ld: ScaRootList=%08lx\n"__FILE__
, __FUNC__
, __LINE__
, rList
));
441 // Set Flag "Workbench open"
443 UBYTE
* wbb
= (UBYTE
*) WorkbenchBase
;
448 if (ScalosBase
->scb_LibNode
.lib_Version
>= 40)
450 SCA_ScalosControl(NULL
,
451 SCALOSCTRLA_GetEmulationMode
, (ULONG
) &EmulationMode
,
455 NewList(&AppWindowList
);
456 NewList(&HiddenDeviceList
); // +dm+ 20010518
458 InitSemaphore(&AppWindowSema
);
459 InitSemaphore(&HiddenDevListSema
); // +jl+ 20010523
464 STATIC_PATCHFUNC(myOpenWorkbenchObjectA
)
465 STATIC_PATCHFUNC(myCloseWorkbenchObjectA
)
466 STATIC_PATCHFUNC(myMakeWorkbenchObjectVisibleA
)
467 STATIC_PATCHFUNC(myChangeWorkbenchSelectionA
)
469 STATIC_PATCHFUNC(myAddAppWindowDropZoneA
)
470 STATIC_PATCHFUNC(myRemoveAppWindowDropZone
)
471 STATIC_PATCHFUNC(myAddAppWindowA
)
472 STATIC_PATCHFUNC(myRemoveAppWindow
)
474 STATIC_PATCHFUNC(myWorkbenchControlA
)
476 STATIC_PATCHFUNC(myWbprivate1
)
477 STATIC_PATCHFUNC(mySCA_DrawDrag
)
483 #if defined(__amigaos4__)
484 origOpenWorkbenchObjectA
= SetMethod((struct Interface
*)IWorkbench
,
485 offsetof(struct WorkbenchIFace
, OpenWorkbenchObjectA
),
486 (APTR
)myOpenWorkbenchObjectA
);
487 origOpenWorkbenchObject
= SetMethod((struct Interface
*)IWorkbench
,
488 offsetof(struct WorkbenchIFace
, OpenWorkbenchObject
),
489 (APTR
)myOpenWorkbenchObject
);
490 origCloseWorkbenchObjectA
= SetMethod((struct Interface
*)IWorkbench
,
491 offsetof(struct WorkbenchIFace
, CloseWorkbenchObjectA
),
492 (APTR
)myCloseWorkbenchObjectA
);
493 origCloseWorkbenchObject
= SetMethod((struct Interface
*)IWorkbench
,
494 offsetof(struct WorkbenchIFace
, CloseWorkbenchObject
),
495 (APTR
)myCloseWorkbenchObject
);
496 origMakeWorkbenchObjectVisibleA
= SetMethod((struct Interface
*)IWorkbench
,
497 offsetof(struct WorkbenchIFace
, MakeWorkbenchObjectVisibleA
),
498 (APTR
)myMakeWorkbenchObjectVisibleA
);
499 origMakeWorkbenchObjectVisible
= SetMethod((struct Interface
*)IWorkbench
,
500 offsetof(struct WorkbenchIFace
, MakeWorkbenchObjectVisible
),
501 (APTR
)myMakeWorkbenchObjectVisible
);
502 origChangeWorkbenchSelectionA
= SetMethod((struct Interface
*)IWorkbench
,
503 offsetof(struct WorkbenchIFace
, ChangeWorkbenchSelectionA
),
504 (APTR
)myChangeWorkbenchSelectionA
);
505 origChangeWorkbenchSelection
= SetMethod((struct Interface
*)IWorkbench
,
506 offsetof(struct WorkbenchIFace
, ChangeWorkbenchSelection
),
507 (APTR
)myChangeWorkbenchSelection
);
509 origAddAppWindowDropZoneA
= SetMethod((struct Interface
*)IWorkbench
,
510 offsetof(struct WorkbenchIFace
, AddAppWindowDropZoneA
),
511 (APTR
)myAddAppWindowDropZoneA
);
512 origAddAppWindowDropZone
= SetMethod((struct Interface
*)IWorkbench
,
513 offsetof(struct WorkbenchIFace
, AddAppWindowDropZone
),
514 (APTR
)myAddAppWindowDropZone
);
515 origRemoveAppWindowDropZone
= SetMethod((struct Interface
*)IWorkbench
,
516 offsetof(struct WorkbenchIFace
, RemoveAppWindowDropZone
),
517 (APTR
)myRemoveAppWindowDropZone
);
518 origAddAppWindowA
= SetMethod((struct Interface
*)IWorkbench
,
519 offsetof(struct WorkbenchIFace
, AddAppWindowA
),
520 (APTR
)myAddAppWindowA
);
521 origAddAppWindow
= SetMethod((struct Interface
*)IWorkbench
,
522 offsetof(struct WorkbenchIFace
, AddAppWindow
),
523 (APTR
)myAddAppWindow
);
524 origRemoveAppWindow
= SetMethod((struct Interface
*)IWorkbench
,
525 offsetof(struct WorkbenchIFace
, RemoveAppWindow
),
526 (APTR
)myRemoveAppWindow
);
528 origWorkbenchControlA
= SetMethod((struct Interface
*)IWorkbench
,
529 offsetof(struct WorkbenchIFace
, WorkbenchControlA
),
530 (APTR
)myWorkbenchControlA
);
531 origWorkbenchControl
= SetMethod((struct Interface
*)IWorkbench
,
532 offsetof(struct WorkbenchIFace
, WorkbenchControl
),
533 (APTR
)myWorkbenchControl
);
535 origWbprivate1
= SetMethod((struct Interface
*)IWorkbench
,
536 offsetof(struct WorkbenchIFace
, Private1
),
539 origSCA_DrawDrag
= SetMethod((struct Interface
*)IScalos
,
540 offsetof(struct ScalosIFace
, SCA_DrawDrag
),
541 (APTR
)mySCA_DrawDrag
);
542 #elif defined(__AROS__)
543 origOpenWorkbenchObjectA
= SetFunction(WorkbenchBase
,
544 -16 * LIB_VECTSIZE
, AROS_SLIB_ENTRY(myOpenWorkbenchObjectA
, WorkbenchBase
, 0));
545 origCloseWorkbenchObjectA
= SetFunction(WorkbenchBase
,
546 -17 * LIB_VECTSIZE
, AROS_SLIB_ENTRY(myCloseWorkbenchObjectA
, WorkbenchBase
, 0));
547 origMakeWorkbenchObjectVisibleA
= SetFunction(WorkbenchBase
,
548 -22 * LIB_VECTSIZE
, AROS_SLIB_ENTRY(myMakeWorkbenchObjectVisibleA
, WorkbenchBase
, 0));
549 origChangeWorkbenchSelectionA
= SetFunction(WorkbenchBase
,
550 -21 * LIB_VECTSIZE
, AROS_SLIB_ENTRY(myChangeWorkbenchSelectionA
, WorkbenchBase
, 0));
552 origAddAppWindowDropZoneA
= SetFunction(WorkbenchBase
,
553 -19 * LIB_VECTSIZE
, AROS_SLIB_ENTRY(myAddAppWindowDropZoneA
, WorkbenchBase
, 0));
554 origRemoveAppWindowDropZone
= SetFunction(WorkbenchBase
,
555 -20 * LIB_VECTSIZE
, AROS_SLIB_ENTRY(myRemoveAppWindowDropZone
, WorkbenchBase
, 0));
556 origAddAppWindowA
= SetFunction(WorkbenchBase
,
557 -8 * LIB_VECTSIZE
, AROS_SLIB_ENTRY(myAddAppWindowA
, WorkbenchBase
, 0));
558 origRemoveAppWindow
= SetFunction(WorkbenchBase
,
559 -9 * LIB_VECTSIZE
, AROS_SLIB_ENTRY(myRemoveAppWindow
, WorkbenchBase
, 0));
561 origWorkbenchControlA
= SetFunction(WorkbenchBase
,
562 -18 * LIB_VECTSIZE
, AROS_SLIB_ENTRY(myWorkbenchControlA
, WorkbenchBase
, 0));
564 origWbprivate1
= SetFunction(WorkbenchBase
,
565 -5 * LIB_VECTSIZE
, AROS_SLIB_ENTRY(myWbprivate1
, WorkbenchBase
, 0));
567 origSCA_DrawDrag
= SetFunction(&ScalosBase
->scb_LibNode
,
568 -25 * LIB_VECTSIZE
, AROS_SLIB_ENTRY(mySCA_DrawDrag
, ScalosBase
, 0));
570 origOpenWorkbenchObjectA
= SetFunction(WorkbenchBase
,
571 -96, PATCH_NEWFUNC(myOpenWorkbenchObjectA
));
572 origCloseWorkbenchObjectA
= SetFunction(WorkbenchBase
,
573 -102, PATCH_NEWFUNC(myCloseWorkbenchObjectA
));
574 origMakeWorkbenchObjectVisibleA
= SetFunction(WorkbenchBase
,
575 -132, PATCH_NEWFUNC(myMakeWorkbenchObjectVisibleA
));
576 origChangeWorkbenchSelectionA
= SetFunction(WorkbenchBase
,
577 -126, PATCH_NEWFUNC(myChangeWorkbenchSelectionA
));
579 origAddAppWindowDropZoneA
= SetFunction(WorkbenchBase
,
580 -114, PATCH_NEWFUNC(myAddAppWindowDropZoneA
));
581 origRemoveAppWindowDropZone
= SetFunction(WorkbenchBase
,
582 -120, PATCH_NEWFUNC(myRemoveAppWindowDropZone
));
583 origAddAppWindowA
= SetFunction(WorkbenchBase
,
584 -48, PATCH_NEWFUNC(myAddAppWindowA
));
585 origRemoveAppWindow
= SetFunction(WorkbenchBase
,
586 -54, PATCH_NEWFUNC(myRemoveAppWindow
));
588 origWorkbenchControlA
= SetFunction(WorkbenchBase
,
589 -108, PATCH_NEWFUNC(myWorkbenchControlA
));
591 origWbprivate1
= SetFunction(WorkbenchBase
,
592 -30, PATCH_NEWFUNC(myWbprivate1
));
594 origSCA_DrawDrag
= SetFunction(&ScalosBase
->scb_LibNode
,
595 -150, PATCH_NEWFUNC(mySCA_DrawDrag
));
600 // try to use current WB settings
601 ParseWBPrefs("ENV:sys/Workbench.prefs");
603 // Read some Scalos preferences settings
613 BOOL
initPlugin(struct Library
*libbase
)
615 d1(KPrintF("%s/%s/%ld: Start.\n"__FILE__
, __FUNC__
, __LINE__
));
620 if (!OpenLibraries())
623 d1(KPrintF("%s/%s/%ld: IconobjectBase=%08lx WorkbenchBase=%08lx UtilityBase=%08lx\n", \
624 __FILE__
, __FUNC__
, __LINE__
, \
625 IconobjectBase
, WorkbenchBase
, UtilityBase
));
627 #if !defined(__amigaos4__) && !defined(__AROS__)
628 _STI_240_InitMemFunctions();
631 fInit
= TRUE
; // +dm+ 20010520 Added
634 d1(KPrintF("%s/%s/%ld: End.\n"__FILE__
, __FUNC__
, __LINE__
));
640 VOID
closePlugin(struct Library
*libbase
)
644 d1(kprintf("%s/%s/%ld: \n"__FILE__
, __FUNC__
, __LINE__
));
648 #if defined(__amigaos4__)
651 SetMethod((struct Interface
*)IWorkbench
, offsetof(struct WorkbenchIFace
, Private1
),
652 (APTR
) origWbprivate1
);
653 origWbprivate1
= NULL
;
655 if (origWorkbenchControlA
)
657 SetMethod((struct Interface
*)IWorkbench
, offsetof(struct WorkbenchIFace
, WorkbenchControlA
),
658 (APTR
) origWorkbenchControlA
);
659 origWorkbenchControlA
= NULL
;
661 if (origRemoveAppWindow
)
663 SetMethod((struct Interface
*)IWorkbench
, offsetof(struct WorkbenchIFace
, RemoveAppWindow
),
664 (APTR
) origRemoveAppWindow
);
665 origRemoveAppWindow
= NULL
;
667 if (origAddAppWindowA
)
669 SetMethod((struct Interface
*)IWorkbench
, offsetof(struct WorkbenchIFace
, AddAppWindowA
),
670 (APTR
) origAddAppWindowA
);
671 origAddAppWindowA
= NULL
;
673 if (origRemoveAppWindowDropZone
)
675 SetMethod((struct Interface
*)IWorkbench
, offsetof(struct WorkbenchIFace
, RemoveAppWindowDropZone
),
676 (APTR
) origRemoveAppWindowDropZone
);
677 origRemoveAppWindowDropZone
= NULL
;
679 if (origAddAppWindowDropZoneA
)
681 SetMethod((struct Interface
*)IWorkbench
, offsetof(struct WorkbenchIFace
, AddAppWindowDropZoneA
),
682 (APTR
) origAddAppWindowDropZoneA
);
683 origAddAppWindowDropZoneA
= NULL
;
685 if (origMakeWorkbenchObjectVisibleA
)
687 SetMethod((struct Interface
*)IWorkbench
, offsetof(struct WorkbenchIFace
, MakeWorkbenchObjectVisibleA
),
688 (APTR
) origMakeWorkbenchObjectVisibleA
);
689 origMakeWorkbenchObjectVisibleA
= NULL
;
691 if (origOpenWorkbenchObjectA
)
693 SetMethod((struct Interface
*)IWorkbench
, offsetof(struct WorkbenchIFace
, OpenWorkbenchObjectA
),
694 (APTR
) origOpenWorkbenchObjectA
);
695 origOpenWorkbenchObjectA
= NULL
;
697 if (origOpenWorkbenchObject
)
699 SetMethod((struct Interface
*)IWorkbench
, offsetof(struct WorkbenchIFace
, OpenWorkbenchObject
),
700 (APTR
) origOpenWorkbenchObject
);
701 origOpenWorkbenchObject
= NULL
;
703 if (origSCA_DrawDrag
)
705 SetMethod((struct Interface
*)IScalos
, offsetof(struct ScalosIFace
, SCA_DrawDrag
),
706 (APTR
) origSCA_DrawDrag
);
707 origSCA_DrawDrag
= NULL
;
709 #elif defined(__AROS__)
712 SetFunction(WorkbenchBase
, -5 * LIB_VECTSIZE
, (ULONG (* const )()) origWbprivate1
);
713 origWbprivate1
= NULL
;
715 if (origWorkbenchControlA
)
717 SetFunction(WorkbenchBase
, -18 * LIB_VECTSIZE
, (ULONG (* const )()) origWorkbenchControlA
);
718 origWorkbenchControlA
= NULL
;
720 if (origRemoveAppWindow
)
722 SetFunction(WorkbenchBase
, -9 * LIB_VECTSIZE
, (ULONG (* const )()) origRemoveAppWindow
);
723 origRemoveAppWindow
= NULL
;
725 if (origAddAppWindowA
)
727 SetFunction(WorkbenchBase
, -8 * LIB_VECTSIZE
, (ULONG (* const )()) origAddAppWindowA
);
728 origAddAppWindowA
= NULL
;
730 if (origRemoveAppWindowDropZone
)
732 SetFunction(WorkbenchBase
, -20 * LIB_VECTSIZE
, (ULONG (* const )()) origRemoveAppWindowDropZone
);
733 origRemoveAppWindowDropZone
= NULL
;
735 if (origAddAppWindowDropZoneA
)
737 SetFunction(WorkbenchBase
, -19 * LIB_VECTSIZE
, (ULONG (* const )()) origAddAppWindowDropZoneA
);
738 origAddAppWindowDropZoneA
= NULL
;
740 if (origMakeWorkbenchObjectVisibleA
)
742 SetFunction(WorkbenchBase
, -22 * LIB_VECTSIZE
, (ULONG (* const )()) origMakeWorkbenchObjectVisibleA
);
743 origMakeWorkbenchObjectVisibleA
= NULL
;
745 if (origOpenWorkbenchObjectA
)
747 SetFunction(WorkbenchBase
, -16 * LIB_VECTSIZE
, (ULONG (* const )()) origOpenWorkbenchObjectA
);
748 origOpenWorkbenchObjectA
= NULL
;
750 if (origSCA_DrawDrag
)
752 SetFunction(&ScalosBase
->scb_LibNode
, -25 * LIB_VECTSIZE
, (ULONG (* const )()) origSCA_DrawDrag
);
753 origSCA_DrawDrag
= NULL
;
758 SetFunction(WorkbenchBase
, -30, (ULONG (* const )()) origWbprivate1
);
759 origWbprivate1
= NULL
;
761 if (origWorkbenchControlA
)
763 SetFunction(WorkbenchBase
, -108, (ULONG (* const )()) origWorkbenchControlA
);
764 origWorkbenchControlA
= NULL
;
766 if (origRemoveAppWindow
)
768 SetFunction(WorkbenchBase
, -54, (ULONG (* const )()) origRemoveAppWindow
);
769 origRemoveAppWindow
= NULL
;
771 if (origAddAppWindowA
)
773 SetFunction(WorkbenchBase
, -48, (ULONG (* const )()) origAddAppWindowA
);
774 origAddAppWindowA
= NULL
;
776 if (origRemoveAppWindowDropZone
)
778 SetFunction(WorkbenchBase
, -120, (ULONG (* const )()) origRemoveAppWindowDropZone
);
779 origRemoveAppWindowDropZone
= NULL
;
781 if (origAddAppWindowDropZoneA
)
783 SetFunction(WorkbenchBase
, -114, (ULONG (* const )()) origAddAppWindowDropZoneA
);
784 origAddAppWindowDropZoneA
= NULL
;
786 if (origMakeWorkbenchObjectVisibleA
)
788 SetFunction(WorkbenchBase
, -132, (ULONG (* const )()) origMakeWorkbenchObjectVisibleA
);
789 origMakeWorkbenchObjectVisibleA
= NULL
;
791 if (origOpenWorkbenchObjectA
)
793 SetFunction(WorkbenchBase
, -96, (ULONG (* const )()) origOpenWorkbenchObjectA
);
794 origOpenWorkbenchObjectA
= NULL
;
796 if (origSCA_DrawDrag
)
798 SetFunction(&ScalosBase
->scb_LibNode
, -150, (ULONG (* const )()) origSCA_DrawDrag
);
799 origSCA_DrawDrag
= NULL
;
803 FreeAllNodes(&HiddenDeviceList
); // +dm+ 20010518
806 #if !defined(__amigaos4__) && !defined(__AROS__)
807 _STD_240_TerminateMemFunctions();
810 d1(kprintf("%s/%s/%ld: \n"__FILE__
, __FUNC__
, __LINE__
));
815 static BOOL
OpenLibraries(void)
817 DOSBase
= (struct DosLibrary
*) OpenLibrary(DOSNAME
, 39);
821 IDOS
= (struct DOSIFace
*)GetInterface((struct Library
*)DOSBase
, "main", 1, NULL
);
826 IconobjectBase
= OpenLibrary("iconobject.library", 39);
827 if (NULL
== IconobjectBase
)
830 IIconobject
= (struct IconobjectIFace
*)GetInterface((struct Library
*)IconobjectBase
, "main", 1, NULL
);
831 if (NULL
== IIconobject
)
835 WorkbenchBase
= OpenLibrary(WORKBENCH_NAME
, 44);
836 if (NULL
== WorkbenchBase
)
839 IWorkbench
= (struct WorkbenchIFace
*)GetInterface((struct Library
*)WorkbenchBase
, "main", 1, NULL
);
840 if (NULL
== IWorkbench
)
844 UtilityBase
= (T_UTILITYBASE
) OpenLibrary("utility.library", 40);
845 if (NULL
== UtilityBase
)
848 IUtility
= (struct UtilityIFace
*)GetInterface((struct Library
*)UtilityBase
, "main", 1, NULL
);
849 if (NULL
== IUtility
)
853 #if defined(__GNUC__) && !defined(__MORPHOS__) && !defined(__amigaos4__) && !defined(__AROS__)
854 __UtilityBase
= UtilityBase
;
855 #endif /* defined(__GNUC__) && !defined(__MORPHOS__) */
857 ScalosBase
= (struct ScalosBase
*) OpenLibrary(SCALOSNAME
, 41);
858 if (NULL
== ScalosBase
)
861 IScalos
= (struct ScalosIFace
*)GetInterface((struct Library
*)ScalosBase
, "main", 1, NULL
);
866 IntuitionBase
= (struct IntuitionBase
*) OpenLibrary("intuition.library", 40);
867 if (NULL
== IntuitionBase
)
870 IIntuition
= (struct IntuitionIFace
*)GetInterface((struct Library
*)IntuitionBase
, "main", 1, NULL
);
871 if (NULL
== IIntuition
)
875 LayersBase
= OpenLibrary("layers.library", 40);
876 if (NULL
== LayersBase
)
879 ILayers
= (struct LayersIFace
*)GetInterface((struct Library
*)LayersBase
, "main", 1, NULL
);
884 GfxBase
= OpenLibrary("graphics.library", 40);
888 IGraphics
= (struct GraphicsIFace
*)GetInterface((struct Library
*)GfxBase
, "main", 1, NULL
);
889 if (NULL
== IGraphics
)
893 IconBase
= OpenLibrary("icon.library", 41);
894 if (NULL
== IconBase
)
897 IIcon
= (struct IconIFace
*)GetInterface((struct Library
*)IconBase
, "main", 1, NULL
);
902 IFFParseBase
= OpenLibrary("iffparse.library", 39);
903 if (NULL
== IFFParseBase
)
906 IIFFParse
= (struct IFFParseIFace
*)GetInterface((struct Library
*)IFFParseBase
, "main", 1, NULL
);
907 if (NULL
== IIFFParse
)
910 NewlibBase
= OpenLibrary("newlib.library", 0);
911 if (NULL
== NewlibBase
)
913 INewlib
= GetInterface(NewlibBase
, "main", 1, NULL
);
922 static void CloseLibraries(void)
927 DropInterface((struct Interface
*)IIFFParse
);
933 CloseLibrary(IFFParseBase
);
939 DropInterface((struct Interface
*)IIcon
);
945 CloseLibrary(IconBase
);
951 DropInterface((struct Interface
*)IGraphics
);
957 CloseLibrary(GfxBase
);
963 DropInterface((struct Interface
*)IDOS
);
969 CloseLibrary((struct Library
*) DOSBase
);
975 DropInterface((struct Interface
*)IIconobject
);
981 CloseLibrary(IconobjectBase
);
982 IconobjectBase
= NULL
;
987 DropInterface((struct Interface
*)IWorkbench
);
993 CloseLibrary(WorkbenchBase
);
994 WorkbenchBase
= NULL
;
999 DropInterface((struct Interface
*)IUtility
);
1005 CloseLibrary((struct Library
*) UtilityBase
);
1011 DropInterface((struct Interface
*)IScalos
);
1017 CloseLibrary((struct Library
*) ScalosBase
);
1023 DropInterface((struct Interface
*)IIntuition
);
1029 CloseLibrary((struct Library
*) IntuitionBase
);
1030 IntuitionBase
= NULL
;
1035 DropInterface((struct Interface
*)ILayers
);
1041 CloseLibrary(LayersBase
);
1047 // OpenWorkbenchObjectA emulation
1048 static LIBFUNC_P3(BOOL
, myOpenWorkbenchObjectA
,
1050 A1
, struct TagItem
*, tags
,
1051 A6
, struct Library
*, WorkbenchBase
)
1053 struct WBArg
*ArgList
;
1054 struct Process
*myProc
;
1055 Object
*IconObj
= NULL
;
1056 struct DiskObject
*diskObj
= NULL
;
1057 struct TagItem TagList
[5];
1059 BPTR fLock
, dLock
= (BPTR
)NULL
;
1060 BOOL Result
= FALSE
;
1062 /* Suppress warning */
1063 (void)WorkbenchBase
;
1065 d1(KPrintF("%s/%ld\n", __FUNC__
, __FILE__
, __FUNC__
, __LINE__
));
1067 myProc
= (struct Process
*) FindTask(NULL
);
1068 if (NT_PROCESS
== myProc
->pr_Task
.tc_Node
.ln_Type
)
1070 dLock
= myProc
->pr_CurrentDir
;
1073 fLock
= Lock(name
, ACCESS_READ
);
1077 struct FileInfoBlock
*fib
;
1079 NameFromLock(fLock
, Buffer
, sizeof(Buffer
));
1081 fib
= AllocDosObject(DOS_FIB
, TAG_END
);
1085 BOOL ShowAllFiles
= FALSE
;
1086 ULONG ViewByMode
= SCAV_ViewModes_Icon
;
1087 struct TagItem
*tiShowAll
, *tiViewBy
;
1089 Examine(fLock
, fib
);
1092 d1(KPrintF("%s/%s/%ld: name=<%s> \n"__FILE__
, __FUNC__
, __LINE__
, fib
->fib_FileName
));
1094 DirEntryType
= fib
->fib_DirEntryType
;
1096 FreeDosObject(DOS_FIB
, fib
);
1098 d1(KPrintF(__FUNC__
"/%ld\n"__FILE__
, __FUNC__
, __LINE__
));
1100 tiShowAll
= FindTagItem(WBOPENA_Show
, tags
);
1103 switch (tiShowAll
->ti_Data
)
1105 case DDFLAGS_SHOWICONS
:
1106 ShowAllFiles
= FALSE
;
1108 case DDFLAGS_SHOWALL
:
1109 ShowAllFiles
= TRUE
;
1117 tiViewBy
= FindTagItem(WBOPENA_ViewBy
, tags
);
1120 switch (tiViewBy
->ti_Data
)
1123 ViewByMode
= SCAV_ViewModes_Icon
;
1126 ViewByMode
= SCAV_ViewModes_Name
;
1129 ViewByMode
= SCAV_ViewModes_Date
;
1132 ViewByMode
= SCAV_ViewModes_Size
;
1141 d1(KPrintF(__FUNC__
"/%ld DirEntryType=%ld\n"__FILE__
, __FUNC__
, __LINE__
, DirEntryType
));
1143 switch (DirEntryType
)
1148 // Volume or Directory : open Icon Window
1149 d1(KPrintF(__FUNC__
"/%ld Buffer=<%s>\n"__FILE__
, __FUNC__
, __LINE__
, Buffer
));
1150 Result
= NULL
!= SCA_OpenDrawerByNameTags(Buffer
,
1151 tiShowAll
? SCA_ShowAllFiles
: TAG_IGNORE
, ShowAllFiles
,
1152 tiViewBy
? SCA_ViewModes
: TAG_IGNORE
, ViewByMode
,
1155 d1(KPrintF(__FUNC__
"/%ld Result=%08lx\n"__FILE__
, __FUNC__
, __LINE__
, Result
));
1162 diskObj
= GetDiskObjectNew(Buffer
);
1165 IconObj
= Convert2IconObjectA(diskObj
, NULL
);
1168 d1(kprintf("%s/%s/%ld: FILE diskobj=%08lx iconobj=%08lx\n", \
1169 __LINE__
, diskObj
, IconObj
));
1173 d1(kprintf(__FUNC__
"/%ld\n"__FILE__
, __FUNC__
, __LINE__
));
1179 d1(kprintf(__FUNC__
"/%ld\n"__FILE__
, __FUNC__
, __LINE__
));
1181 ArgList
= BuildWBArg(tags
, &ArgCount
);
1182 if (NULL
== ArgList
)
1185 DisposeIconObject(IconObj
);
1187 FreeDiskObject(diskObj
);
1191 d1(kprintf("%s/%s/%ld: diskobj=%08lx iconobj=%08lx\n", \
1192 __LINE__
, diskObj
, IconObj
));
1194 if (NULL
== IconObj
)
1196 IconObj
= NewIconObjectTags(name
, TAG_END
);
1197 d1(kprintf("%s/%s/%ld: diskobj=%08lx iconobj=%08lx\n", \
1198 __LINE__
, diskObj
, IconObj
));
1202 ArgList
[0].wa_Lock
= DupLock(dLock
);
1203 ArgList
[0].wa_Name
= name
;
1205 TagList
[0].ti_Tag
= SCA_IconObject
;
1206 TagList
[0].ti_Data
= (ULONG
) IconObj
;
1207 TagList
[1].ti_Tag
= SCA_Stacksize
;
1208 TagList
[1].ti_Data
= DefaultStackSize
;
1209 TagList
[2].ti_Tag
= SCA_Flags
;
1210 TagList
[2].ti_Data
= SCAV_WBStart_PathSearch
;
1211 TagList
[3].ti_Tag
= TAG_END
;
1212 TagList
[3].ti_Data
= 0;
1214 Result
= SCA_WBStart(ArgList
, TagList
, ArgCount
);
1216 FreeWBArg(ArgList
, ArgCount
, FALSE
);
1219 FreeWBArg(ArgList
, ArgCount
, TRUE
);
1221 d1(kprintf(__FUNC__
"/%ld\n"__FILE__
, __FUNC__
, __LINE__
));
1223 DisposeIconObject(IconObj
);
1224 d1(kprintf(__FUNC__
"/%ld\n"__FILE__
, __FUNC__
, __LINE__
));
1226 FreeDiskObject(diskObj
);
1228 d1(kprintf("%s/%s/%ld: Result=%ld\n"__FILE__
, __FUNC__
, __LINE__
, Result
));
1235 static struct WBArg
*BuildWBArg(struct TagItem
*tags
, ULONG
*ArgCount
)
1237 struct WBArg
*ArgList
;
1239 struct TagItem
*tag
;
1244 // Count arguments (program itself is argument #0)
1246 d1(kprintf("%s/%s/%ld: tags=%08lx tp=%08lx\n", \
1247 __LINE__
, tags
, tp
));
1249 while (tag
= NextTagItem(&tp
))
1251 if (WBOPENA_ArgName
== tag
->ti_Tag
)
1254 d1(kprintf("%s/%s/%ld: ArgCount=%ld\n", \
1255 __LINE__
, *ArgCount
));
1259 d1(kprintf("%s/%s/%ld: tags=%08lx ArgCount=%ld\n", \
1260 __LINE__
, tags
, *ArgCount
));
1262 // build Program's ArgList
1263 ArgList
= calloc(sizeof(struct WBArg
), *ArgCount
);
1264 if (NULL
== ArgList
)
1269 while (tag
= NextTagItem(&tp
))
1271 switch (tag
->ti_Tag
)
1273 case WBOPENA_ArgLock
:
1274 if (ArgList
[n
].wa_Lock
)
1276 ArgList
[n
].wa_Lock
= DupLock((BPTR
)tag
->ti_Data
);
1281 NameFromLock(tag
->ti_Data
, Path
, sizeof(Path
));
1282 kprintf("%s/%s/%ld: Arg[%ld] ArgLock=<%s>\n", \
1287 case WBOPENA_ArgName
:
1288 if (ArgList
[n
].wa_Name
)
1290 ArgList
[n
].wa_Name
= (STRPTR
) tag
->ti_Data
;
1291 d1(kprintf("%s/%s/%ld: Arg[%ld] ArgName=<%s>\n", \
1292 __LINE__
, n
, tag
->ti_Data
));
1296 d1(kprintf("%s/%s/%ld: tag=%08lx data=%08lx\n", \
1297 __LINE__
, tag
->ti_Tag
, tag
->ti_Data
));
1306 static void FreeWBArg(struct WBArg
*ArgList
, ULONG ArgCount
, BOOL FreeLocks
)
1310 if (NULL
== ArgList
)
1315 for (n
=0; n
<ArgCount
; n
++)
1317 if (ArgList
[n
].wa_Lock
)
1318 UnLock(ArgList
[n
].wa_Lock
);
1322 d1(KPrintF("%s/%s/%ld: diskobj=%08lx iconobj=%08lx\n", \
1323 __LINE__
, diskObj
, IconObj
));
1329 // CloseWorkbenchObjectA emulation
1330 static LIBFUNC_P3(BOOL
, myCloseWorkbenchObjectA
,
1332 A1
, struct TagItem
*, tags
,
1333 A6
, struct Library
*, WorkbenchBase
)
1336 struct ScaWindowList
*swList
= SCA_LockWindowList(SCA_LockWindowList_Shared
);
1339 /* Suppress warning */
1340 (void)WorkbenchBase
;
1346 nLock
= Lock(name
, ACCESS_READ
);
1347 if ((BPTR
)NULL
== nLock
)
1352 struct ScaWindowStruct
*swi
;
1354 for (swi
=swList
->wl_WindowStruct
; !Found
&& swi
; swi
= (struct ScaWindowStruct
*) swi
->ws_Node
.mln_Succ
)
1356 d1(kprintf("%s/%s/%ld: swi=%08lx Lock=%08lx nLock=%08lx\n"__FILE__
, __FUNC__
, __LINE__
, \
1357 swi
, swi
->ws_Lock
, nLock
));
1359 if (swi
->ws_Lock
&& LOCK_SAME
== SameLock(swi
->ws_Lock
, nLock
))
1361 CloseScalosWindow(swi
);
1362 // swi is now invalid
1370 SCA_UnLockWindowList();
1375 d1(kprintf("%s/%s/%ld: Found=%ld\n"__FILE__
, __FUNC__
, __LINE__
, Found
));
1383 static LIBFUNC_P3(ULONG
, myWbprivate1
,
1386 A6
, struct Library
*, WorkbenchBase
)
1388 struct Task
*myTask
= FindTask(NULL
);
1390 /* Suppress warning */
1391 (void)WorkbenchBase
;
1393 d1(kprintf("%s/%s/%ld: Lock=%08lx Name=<%s>\n"__FILE__
, __FUNC__
, __LINE__
, iLock
, Name
));
1395 if (myTask
->tc_Node
.ln_Name
)
1397 d1(kprintf("%s/%s/%ld: Task=<%s>\n"__FILE__
, __FUNC__
, __LINE__
, myTask
->tc_Node
.ln_Name
));
1399 if (0 != Stricmp(myTask
->tc_Node
.ln_Name
, "Scalos_Window_Task") &&
1400 0 != Stricmp(myTask
->tc_Node
.ln_Name
, "Scalos_Drag&Drop"))
1402 struct ScaUpdateIcon_IW Upd
;
1404 Upd
.ui_iw_Lock
= iLock
;
1405 Upd
.ui_iw_Name
= Name
;
1407 d1(kprintf("%s/%s/%ld: Lock=%08lx Name=<%s>\n"__FILE__
, __FUNC__
, __LINE__
, iLock
, Name
));
1409 SCA_UpdateIcon(WSV_Type_IconWindow
, &Upd
, sizeof(Upd
));
1417 /* ====================================================== */
1419 static void UpdateVolumeGauge(struct Gadget
*gad
, struct Window
*win
, BPTR iLock
)
1421 struct InfoData
*id
= AllocVec(sizeof(struct InfoData
), MEMF_PUBLIC
);
1427 d1(kprintf("%s/%s/%ld: NumBlocks=%lu NumBlocksUsed=%lu\n"__FILE__
, __FUNC__
, __LINE__
, \
1428 id
->id_NumBlocks
, id
->id_NumBlocksUsed
));
1430 SetGadgetAttrs(gad
, win
, NULL
,
1431 VOLUMEGAUGE_Level
, id
->id_NumBlocksUsed
,
1432 VOLUMEGAUGE_Max
, id
->id_NumBlocks
,
1440 void _XCEXIT(long x
)
1445 static LIBFUNC_P3(BOOL
, myMakeWorkbenchObjectVisibleA
,
1447 A1
, struct TagItem
*, tags
,
1448 A6
, struct Library
*, WorkbenchBase
)
1450 struct Process
*myProc
;
1452 // dLock = (BPTR)NULL; // unused
1453 BOOL Result
= FALSE
;
1455 /* Suppress warning */
1456 (void)WorkbenchBase
;
1459 myProc
= (struct Process
*) FindTask(NULL
);
1460 if (NT_PROCESS
== myProc
->pr_Task
.tc_Node
.ln_Type
)
1462 // dLock = myProc->pr_CurrentDir;
1465 fLock
= Lock(name
, ACCESS_READ
);
1468 struct ScaWindowStruct
*swi
;
1469 BPTR parentLock
= ParentDir(fLock
);
1471 swi
= FindWindowByLock(parentLock
);
1474 struct ScaIconNode
*sIcon
= GetIconByName(swi
, FilePart(name
));
1480 MakeIconVisible(swi
, sIcon
);
1481 ReleaseSemaphore(swi
->ws_WindowTask
->wt_IconSemaphore
);
1484 SCA_UnLockWindowList();
1496 // ChangeWorkbenchSelectionA()
1497 static LIBFUNC_P4(BOOL
, myChangeWorkbenchSelectionA
,
1499 A1
, struct Hook
*, hook
,
1500 A2
, struct TagItem
*, tags
,
1501 A6
, struct Library
*, WorkbenchBase
)
1503 struct ScaWindowStruct
*swi
= NULL
;
1504 BOOL Result
= FALSE
;
1506 /* Suppress warning */
1507 (void)WorkbenchBase
;
1509 d1(kprintf("%s/%s/%ld: name=%08lx hook=%08lx tags=%08lx\n"__FILE__
, __FUNC__
, __LINE__
, name
, hook
, tags
));
1510 d1(kprintf("%s/%s/%ld: name=<%s>\n"__FILE__
, __FUNC__
, __LINE__
, name
? name
: (STRPTR
) ""));
1514 BPTR fLock
= Lock(name
, ACCESS_READ
);
1516 d1(kprintf("%s/%s/%ld: fLock=%08lx\n"__FILE__
, __FUNC__
, __LINE__
, fLock
));
1519 swi
= FindWindowByLock(fLock
);
1521 d1(kprintf("%s/%s/%ld: swi=%08lx\n"__FILE__
, __FUNC__
, __LINE__
, swi
));
1525 SCA_UnLockWindowList();
1530 // get Workbench Backdrop window
1531 swi
= FindWindowByName("root");
1534 d1(kprintf("%s/%s/%ld: swi=%08lx\n"__FILE__
, __FUNC__
, __LINE__
, swi
));
1538 struct ScaWindowTask
*wt
= swi
->ws_WindowTask
;
1539 struct ScaIconNode
*icon
;
1544 ObtainSemaphore(wt
->wt_IconSemaphore
);
1546 for (icon
=wt
->wt_IconList
; GoOn
&& icon
; icon
= (struct ScaIconNode
*) icon
->in_Node
.mln_Succ
)
1548 struct ExtGadget
*gg
= (struct ExtGadget
*) icon
->in_Icon
;
1549 struct IconSelectMsg ism
;
1551 WORD iconLeft
, iconTop
;
1552 struct ScaWindowStruct
*swiDrawer
= GetIconNodeOpenWindow(swi
->ws_Lock
, icon
);
1554 ism
.ism_Name
= NULL
;
1556 GetAttr(IDTA_Text
, icon
->in_Icon
, (ULONG
*) &ism
.ism_Name
);
1557 GetAttr(IDTA_Type
, icon
->in_Icon
, (ULONG
*) &IconType
);
1559 d1(kprintf("%s/%s/%ld: icon=%08lx <%s> IconType=%ld swiDrawer=%08lx\n", \
1560 __LINE__
, icon
, ism
.ism_Name
, IconType
, swiDrawer
));
1562 // Translate Scalos-specific icon types
1565 case WB_TEXTICON_TOOL
:
1568 case WB_TEXTICON_DRAWER
:
1569 IconType
= WBDRAWER
;
1575 iconLeft
= gg
->BoundsLeftEdge
+ swi
->ws_Window
->BorderLeft
- swi
->ws_xoffset
;
1576 iconTop
= gg
->BoundsTopEdge
+ swi
->ws_Window
->BorderTop
- swi
->ws_yoffset
;
1578 ism
.ism_Length
= sizeof(ism
);
1579 ism
.ism_Drawer
= swi
->ws_Lock
;
1580 ism
.ism_Type
= IconType
;
1581 ism
.ism_Selected
= (gg
->Flags
& GFLG_SELECTED
) ? TRUE
: FALSE
;
1582 ism
.ism_Tags
= tags
;
1583 ism
.ism_DrawerWindow
= swiDrawer
? swiDrawer
->ws_Window
: NULL
;
1584 ism
.ism_ParentWindow
= swi
->ws_Window
;
1585 ism
.ism_Left
= iconLeft
;
1586 ism
.ism_Top
= iconTop
;
1587 ism
.ism_Width
= gg
->BoundsWidth
;
1588 ism
.ism_Height
= gg
->BoundsHeight
;
1590 switch (CallHookPkt(hook
, NULL
, &ism
))
1592 case ISMACTION_Unselect
:
1593 d1(kprintf("%s/%s/%ld: ISMACTION_Unselect\n"__FILE__
, __FUNC__
, __LINE__
));
1594 SelectIcon(swi
, icon
, FALSE
);
1596 case ISMACTION_Select
:
1597 d1(kprintf("%s/%s/%ld: ISMACTION_Select\n"__FILE__
, __FUNC__
, __LINE__
));
1598 SelectIcon(swi
, icon
, TRUE
);
1600 case ISMACTION_Ignore
:
1601 d1(kprintf("%s/%s/%ld: ISMACTION_Ignore\n"__FILE__
, __FUNC__
, __LINE__
));
1603 case ISMACTION_Stop
:
1604 d1(kprintf("%s/%s/%ld: ISMACTION_Stop\n"__FILE__
, __FUNC__
, __LINE__
));
1610 SCA_UnLockWindowList();
1612 if (ism
.ism_Left
!= iconLeft
|| ism
.ism_Top
!= iconTop
)
1614 d1(kprintf("%s/%s/%ld: oldLeft=%ld Left=%ld\n"__FILE__
, __FUNC__
, __LINE__
, ism
.ism_Left
, iconLeft
));
1615 d1(kprintf("%s/%s/%ld: oldTop=%ld Top=%ld\n"__FILE__
, __FUNC__
, __LINE__
, ism
.ism_Top
, iconTop
));
1618 ism
.ism_Left
- swi
->ws_Window
->BorderLeft
+ swi
->ws_xoffset
,
1619 ism
.ism_Top
- swi
->ws_Window
->BorderTop
+ swi
->ws_yoffset
);
1623 ReleaseSemaphore(wt
->wt_IconSemaphore
);
1626 d1(kprintf("%s/%s/%ld: Result=%ld\n"__FILE__
, __FUNC__
, __LINE__
, Result
)); // +dm+ 20010518 Added another %ld
1633 // +dm+ 20010518 start
1634 // Needed for not having to free the list structure also
1635 static void FreeAllNodes(struct List
*pl
)
1639 d1(kprintf("%s/%s/%ld: List=%08lx\n"__FILE__
, __FUNC__
, __LINE__
, pl
));
1642 while(xNode
= RemHead(pl
))
1644 d1(kprintf("%s/%s/%ld: Node=%08lx Name=%08lx Succ=%08lx\n"__FILE__
, __FUNC__
, __LINE__
, xNode
, xNode
->ln_Name
, xNode
->ln_Succ
));
1645 if(xNode
->ln_Name
) free(xNode
->ln_Name
);
1650 // +dm+ 20010518 end
1653 static LIBFUNC_P2VA(BOOL
, myOpenWorkbenchObject
,
1655 A6
, struct Library
*, WorkbenchBase
)
1658 struct WorkbenchIFace
*IWorkbench
= (struct WorkbenchIFace
*)self
;
1660 va_startlinear(args
, name
);
1662 (void)WorkbenchBase
;
1664 ret
= OpenWorkbenchObjectA(name
, va_getlinearva(args
, const struct TagItem
*));
1672 static LIBFUNC_P2VA(BOOL
, myCloseWorkbenchObject
,
1674 A6
, struct Library
*, WorkbenchBase
)
1677 struct WorkbenchIFace
*IWorkbench
= (struct WorkbenchIFace
*)self
;
1679 va_startlinear(args
, name
);
1681 (void)WorkbenchBase
;
1683 ret
= CloseWorkbenchObjectA(name
, va_getlinearva(args
, const struct TagItem
*));
1691 static LIBFUNC_P2VA(BOOL
, myMakeWorkbenchObjectVisible
,
1693 A6
, struct Library
*, WorkbenchBase
)
1696 struct WorkbenchIFace
*IWorkbench
= (struct WorkbenchIFace
*)self
;
1698 va_startlinear(args
, name
);
1700 (void)WorkbenchBase
;
1702 ret
= MakeWorkbenchObjectVisibleA(name
, va_getlinearva(args
, const struct TagItem
*));
1710 static LIBFUNC_P3VA(BOOL
, myChangeWorkbenchSelection
,
1712 A1
, struct Hook
*, hook
,
1713 A6
, struct Library
*, WorkbenchBase
)
1716 struct WorkbenchIFace
*IWorkbench
= (struct WorkbenchIFace
*)self
;
1718 va_startlinear(args
, hook
);
1720 (void)WorkbenchBase
;
1722 ret
= ChangeWorkbenchSelectionA(name
, hook
, va_getlinearva(args
, const struct TagItem
*));
1733 #elif !defined(__amigaos4__) /* __SASC */