2 Copyright © 1995-2006, The AROS Development Team. All rights reserved.
6 #define MUIMASTER_YES_INLINE_STDARG
8 #include <exec/types.h>
9 #include <exec/resident.h>
10 #include <exec/memory.h>
11 #include <proto/exec.h>
12 #include <aros/symbolsets.h>
13 #include <libraries/desktop.h>
14 #include <libraries/mui.h>
16 #include <proto/exec.h>
17 #include <proto/muimaster.h>
19 #include "desktop_intern.h"
20 #include LC_LIBDEFS_FILE
24 #include "presentation.h"
25 #include "iconcontainerclass.h"
26 #include "iconclass.h"
27 #include "diskiconclass.h"
28 #include "drawericonclass.h"
29 #include "tooliconclass.h"
30 #include "projecticonclass.h"
31 #include "trashcaniconclass.h"
32 #include "iconcontainerobserver.h"
33 #include "iconobserver.h"
34 #include "diskiconobserver.h"
35 #include "drawericonobserver.h"
36 #include "tooliconobserver.h"
37 #include "projecticonobserver.h"
38 #include "trashcaniconobserver.h"
39 #include "desktopobserver.h"
40 #include "operationclass.h"
41 #include "internaliconopsclass.h"
42 #include "internalwindowopsclass.h"
43 #include "internaldesktopopsclass.h"
44 #include "desktopclass.h"
45 #include "containericonobserver.h"
46 #include "abstracticon.h"
47 #include "abstracticoncontainer.h"
49 #include "desktop_intern_protos.h"
52 #include <aros/debug.h>
54 struct DesktopBase
*DesktopBase
;
56 static int Init(LIBBASETYPEPTR desktopbase
)
59 This function is single-threaded by exec by calling Forbid. If you break
60 the Forbid() another task may enter this function at the same time. Take
63 DesktopBase
= desktopbase
;
65 InitSemaphore(&DesktopBase
->db_BaseMutex
);
66 InitSemaphore(&DesktopBase
->db_HandlerSafety
);
68 D(bug("*** Entering DesktopBase::init...\n"));
70 DesktopBase
->db_libsOpen
= FALSE
;
71 DesktopBase
->db_HandlerPort
= NULL
;
73 these will be moved into a new DesktopContext area
75 DesktopBase
->db_DefaultWindow
= NULL
;
76 DesktopBase
->db_DefaultWindowArguments
= NULL
;
78 // TEMPORARY! see note in DesktopOperation struct, in desktop_intern.h
79 NEWLIST(&DesktopBase
->db_OperationList
);
82 D(bug("*** Exitiing DesktopBase::init...\n"));
85 You would return NULL here if the init failed.
91 static int Open(LIBBASETYPEPTR LIBBASE
)
93 struct DesktopOperation
*dob
;
97 This function is single-threaded by exec by calling Forbid. If you break
98 the Forbid() another task may enter this function at the same time. Take
102 D(bug("*** Entered DesktopBase::open...\n"));
104 ObtainSemaphore(&DesktopBase
->db_BaseMutex
);
106 if (DesktopBase
->db_libsOpen
== FALSE
)
108 // Any of these could potentially break the Forbid(),
109 // so we have a semaphore
110 DesktopBase
->db_InputIO
=
111 AllocVec(sizeof(struct IORequest
), MEMF_ANY
);
113 ("input.device", NULL
,
114 (struct IORequest
*) DesktopBase
->db_InputIO
, NULL
))
116 DesktopBase
->db_InputBase
=
117 (struct Library
*) DesktopBase
->db_InputIO
->io_Device
;
119 DesktopBase
->db_Presentation
=
120 MUI_CreateCustomClass(NULL
, MUIC_Area
, NULL
,
121 sizeof(struct PresentationClassData
),
122 presentationDispatcher
);
123 if (!DesktopBase
->db_Presentation
)
126 DesktopBase
->db_AbstractIconContainer
=
127 MUI_CreateCustomClass(NULL
, NULL
, DesktopBase
->db_Presentation
,
128 sizeof(struct AbstractIconContainerData
),
129 abstractIconContainerDispatcher
);
130 if (!DesktopBase
->db_AbstractIconContainer
)
135 DesktopBase
->db_IconContainer
=
136 MUI_CreateCustomClass(NULL
, NULL
, DesktopBase
->db_AbstractIconContainer
,
137 sizeof(struct IconContainerClassData
),
138 iconContainerDispatcher
);
139 if (!DesktopBase
->db_IconContainer
)
143 DesktopBase
->db_Observer
=
144 MUI_CreateCustomClass(NULL
, MUIC_Notify
, NULL
,
145 sizeof(struct ObserverClassData
),
147 if (!DesktopBase
->db_Observer
)
150 DesktopBase
->db_IconObserver
=
151 MUI_CreateCustomClass(NULL
, NULL
, DesktopBase
->db_Observer
,
152 sizeof(struct IconObserverClassData
),
153 iconObserverDispatcher
);
154 if (!DesktopBase
->db_IconObserver
)
157 DesktopBase
->db_ContainerIconObserver
=
158 MUI_CreateCustomClass(NULL
, NULL
, DesktopBase
->db_IconObserver
,
160 ContainerIconObserverClassData
),
161 containerIconObserverDispatcher
);
162 if (!DesktopBase
->db_ContainerIconObserver
)
165 DesktopBase
->db_DiskIconObserver
=
166 MUI_CreateCustomClass(NULL
, NULL
,
167 DesktopBase
->db_ContainerIconObserver
,
168 sizeof(struct DiskIconObserverClassData
),
169 diskIconObserverDispatcher
);
170 if (!DesktopBase
->db_DiskIconObserver
)
173 DesktopBase
->db_DrawerIconObserver
=
174 MUI_CreateCustomClass(NULL
, NULL
,
175 DesktopBase
->db_ContainerIconObserver
,
176 sizeof(struct DrawerIconObserverClassData
),
177 drawerIconObserverDispatcher
);
178 if (!DesktopBase
->db_DrawerIconObserver
)
181 DesktopBase
->db_ToolIconObserver
=
182 MUI_CreateCustomClass(NULL
, NULL
, DesktopBase
->db_IconObserver
,
183 sizeof(struct ToolIconObserverClassData
),
184 toolIconObserverDispatcher
);
185 if (!DesktopBase
->db_ToolIconObserver
)
188 DesktopBase
->db_ProjectIconObserver
=
189 MUI_CreateCustomClass(NULL
, NULL
, DesktopBase
->db_IconObserver
,
190 sizeof(struct ProjectIconObserverClassData
),
191 projectIconObserverDispatcher
);
192 if (!DesktopBase
->db_ProjectIconObserver
)
195 DesktopBase
->db_TrashcanIconObserver
=
196 MUI_CreateCustomClass(NULL
, NULL
, DesktopBase
->db_IconObserver
,
198 TrashcanIconObserverClassData
),
199 trashcanIconObserverDispatcher
);
200 if (!DesktopBase
->db_TrashcanIconObserver
)
203 DesktopBase
->db_IconContainerObserver
=
204 MUI_CreateCustomClass(NULL
, NULL
, DesktopBase
->db_Observer
,
206 IconContainerObserverClassData
),
207 iconContainerObserverDispatcher
);
208 if (!DesktopBase
->db_IconContainerObserver
)
211 DesktopBase
->db_DesktopObserver
=
212 MUI_CreateCustomClass(NULL
, NULL
, DesktopBase
->db_Observer
,
213 sizeof(struct DesktopObserverClassData
),
214 desktopObserverDispatcher
);
215 if (!DesktopBase
->db_DesktopObserver
)
218 DesktopBase
->db_AbstractIcon
=MUI_CreateCustomClass(NULL
, NULL
, DesktopBase
->db_Presentation
, sizeof(struct AbstractIconClassData
), abstractIconDispatcher
);
219 if(!DesktopBase
->db_AbstractIcon
)
222 DesktopBase
->db_Icon
=
223 MUI_CreateCustomClass(NULL
, NULL
, DesktopBase
->db_AbstractIcon
,
224 sizeof(struct IconClassData
),
226 if (!DesktopBase
->db_Icon
)
229 DesktopBase
->db_DiskIcon
=
230 MUI_CreateCustomClass(NULL
, NULL
, DesktopBase
->db_Icon
,
231 sizeof(struct DiskIconClassData
),
233 if (!DesktopBase
->db_DiskIcon
)
236 DesktopBase
->db_DrawerIcon
=
237 MUI_CreateCustomClass(NULL
, NULL
, DesktopBase
->db_Icon
,
238 sizeof(struct DrawerIconClassData
),
239 drawerIconDispatcher
);
240 if (!DesktopBase
->db_DrawerIcon
)
243 DesktopBase
->db_TrashcanIcon
=
244 MUI_CreateCustomClass(NULL
, NULL
, DesktopBase
->db_Icon
,
245 sizeof(struct TrashcanIconClassData
),
246 trashcanIconDispatcher
);
247 if (!DesktopBase
->db_TrashcanIcon
)
250 DesktopBase
->db_ToolIcon
=
251 MUI_CreateCustomClass(NULL
, NULL
, DesktopBase
->db_Icon
,
252 sizeof(struct ToolIconClassData
),
254 if (!DesktopBase
->db_ToolIcon
)
257 DesktopBase
->db_ProjectIcon
=
258 MUI_CreateCustomClass(NULL
, NULL
, DesktopBase
->db_Icon
,
259 sizeof(struct ProjectIconClassData
),
260 projectIconDispatcher
);
261 if (!DesktopBase
->db_ProjectIcon
)
264 DesktopBase
->db_Desktop
=
265 MUI_CreateCustomClass(NULL
, NULL
, DesktopBase
->db_IconContainer
,
266 sizeof(struct DesktopClassData
),
268 if (!DesktopBase
->db_Desktop
)
271 // TEMPORARY! see note in DesktopOperation struct, in desktop_intern.h
272 DesktopBase
->db_Operation
=
273 MUI_CreateCustomClass(NULL
, MUIC_Notify
, NULL
,
274 sizeof(struct OperationClassData
),
275 operationDispatcher
);
276 if (!DesktopBase
->db_Operation
)
280 dob
= AllocVec(sizeof(struct DesktopOperation
), MEMF_ANY
);
281 dob
->do_Code
= (DOC_ICONOP
| 1);
282 dob
->do_Name
= "Open...";
283 dob
->do_MutualExclude
= 0;
286 NEWLIST(&dob
->do_SubItems
);
288 MUI_CreateCustomClass(NULL
, NULL
, DesktopBase
->db_Operation
,
289 sizeof(struct InternalIconOpsClassData
),
290 internalIconOpsDispatcher
);
291 AddTail(&DesktopBase
->db_OperationList
, (struct Node
*) dob
);
294 dob
= AllocVec(sizeof(struct DesktopOperation
), MEMF_ANY
);
295 dob
->do_Code
= (DOC_WINDOWOP
| 1);
296 dob
->do_Name
= "Close";
297 dob
->do_MutualExclude
= 0;
300 NEWLIST(&dob
->do_SubItems
);
302 MUI_CreateCustomClass(NULL
, NULL
, DesktopBase
->db_Operation
,
303 sizeof(struct InternalWindowOpsClassData
),
304 internalWindowOpsDispatcher
);
305 AddTail(&DesktopBase
->db_OperationList
, (struct Node
*) dob
);
308 dob
= AllocVec(sizeof(struct DesktopOperation
), MEMF_ANY
);
309 dob
->do_Code
= (DOC_WINDOWOP
| 2);
310 dob
->do_Name
= "View by";
311 dob
->do_MutualExclude
= 0;
314 NEWLIST(&dob
->do_SubItems
);
315 subList
= &dob
->do_SubItems
;
317 MUI_CreateCustomClass(NULL
, NULL
, DesktopBase
->db_Operation
,
318 sizeof(struct InternalWindowOpsClassData
),
319 internalWindowOpsDispatcher
);
320 AddTail(&DesktopBase
->db_OperationList
, (struct Node
*) dob
);
323 dob
= AllocVec(sizeof(struct DesktopOperation
), MEMF_ANY
);
324 dob
->do_Code
= (DOC_WINDOWOP
| 3);
325 dob
->do_Name
= "Large icons";
326 dob
->do_MutualExclude
= (1 << 5) | (1 << 6);
327 dob
->do_Flags
= DOF_CHECKED
| DOF_CHECKABLE
| DOF_MUTUALEXCLUDE
;
329 NEWLIST(&dob
->do_SubItems
);
331 MUI_CreateCustomClass(NULL
, NULL
, DesktopBase
->db_Operation
,
332 sizeof(struct InternalWindowOpsClassData
),
333 internalWindowOpsDispatcher
);
334 AddTail(subList
, (struct Node
*) dob
);
337 dob
= AllocVec(sizeof(struct DesktopOperation
), MEMF_ANY
);
338 dob
->do_Code
= (DOC_WINDOWOP
| 4);
339 dob
->do_Name
= "Small icons";
340 dob
->do_MutualExclude
= (1 << 4) | (1 << 6);
341 dob
->do_Flags
= DOF_CHECKABLE
| DOF_MUTUALEXCLUDE
;
343 NEWLIST(&dob
->do_SubItems
);
345 MUI_CreateCustomClass(NULL
, NULL
, DesktopBase
->db_Operation
,
346 sizeof(struct InternalWindowOpsClassData
),
347 internalWindowOpsDispatcher
);
348 AddTail(subList
, (struct Node
*) dob
);
351 dob
= AllocVec(sizeof(struct DesktopOperation
), MEMF_ANY
);
352 dob
->do_Code
= (DOC_WINDOWOP
| 5);
353 dob
->do_Name
= "Detail";
354 dob
->do_MutualExclude
= (1 << 4) | (1 << 5);
355 dob
->do_Flags
= DOF_CHECKABLE
| DOF_MUTUALEXCLUDE
;
357 NEWLIST(&dob
->do_SubItems
);
359 MUI_CreateCustomClass(NULL
, NULL
, DesktopBase
->db_Operation
,
360 sizeof(struct InternalWindowOpsClassData
),
361 internalWindowOpsDispatcher
);
362 AddTail(subList
, (struct Node
*) dob
);
365 dob
= AllocVec(sizeof(struct DesktopOperation
), MEMF_ANY
);
366 dob
->do_Code
= (DOC_DESKTOPOP
| 1);
367 dob
->do_Name
= "Quit";
368 dob
->do_MutualExclude
= 0;
371 NEWLIST(&dob
->do_SubItems
);
373 MUI_CreateCustomClass(NULL
, NULL
, DesktopBase
->db_Operation
,
374 sizeof(struct InternalDesktopOpsClassData
),
375 internalDesktopOpsDispatcher
);
376 AddTail(&DesktopBase
->db_OperationList
, (struct Node
*) dob
);
379 DesktopBase
->db_libsOpen
= TRUE
;
382 if (!DesktopBase
->db_HandlerPort
)
383 startDesktopHandler();
387 D(bug("*** Exiting DesktopBase::open...\n"));
389 ReleaseSemaphore(&DesktopBase
->db_BaseMutex
);
395 static void Close(LIBBASETYPEPTR LIBBASE
)
398 This function is single-threaded by exec by calling Forbid. If you
399 break the Forbid() another task may enter this function at the same
402 D(bug("*** Entering DesktopBase::close...\n"));
406 D(bug("*** Exiting DesktopBase::close...\n"));
409 static int Expunge(LIBBASETYPEPTR LIBBASE
)
411 struct DesktopOperation
*dob
;
414 This function is single-threaded by exec by calling Forbid. Never break
415 the Forbid() or strange things might happen.
417 D(bug("*** Entering DesktopBase::expunge...\n"));
420 dob
= (struct DesktopOperation
*) DesktopBase
->db_OperationList
.lh_Head
;
421 while (dob
->do_Node
.ln_Succ
)
424 MUI_DeleteCustomClass(dob
->do_Impl
);
425 dob
= (struct DesktopOperation
*) dob
->do_Node
.ln_Succ
;
429 if (DesktopBase
->db_Operation
)
430 MUI_DeleteCustomClass(DesktopBase
->db_Operation
);
433 if (DesktopBase
->db_DiskIconObserver
)
434 MUI_DeleteCustomClass(DesktopBase
->db_DiskIconObserver
);
435 if (DesktopBase
->db_DrawerIconObserver
)
436 MUI_DeleteCustomClass(DesktopBase
->db_DrawerIconObserver
);
437 if (DesktopBase
->db_ToolIconObserver
)
438 MUI_DeleteCustomClass(DesktopBase
->db_ToolIconObserver
);
439 if (DesktopBase
->db_Desktop
)
440 MUI_DeleteCustomClass(DesktopBase
->db_Desktop
);
441 if (DesktopBase
->db_ProjectIconObserver
)
442 MUI_DeleteCustomClass(DesktopBase
->db_ProjectIconObserver
);
443 if (DesktopBase
->db_TrashcanIconObserver
)
444 MUI_DeleteCustomClass(DesktopBase
->db_TrashcanIconObserver
);
445 if (DesktopBase
->db_IconObserver
)
446 MUI_DeleteCustomClass(DesktopBase
->db_IconObserver
);
447 if (DesktopBase
->db_DesktopObserver
)
448 MUI_DeleteCustomClass(DesktopBase
->db_DesktopObserver
);
449 if (DesktopBase
->db_IconContainerObserver
)
450 MUI_DeleteCustomClass(DesktopBase
->db_IconContainerObserver
);
451 if (DesktopBase
->db_ContainerIconObserver
)
452 MUI_DeleteCustomClass(DesktopBase
->db_ContainerIconObserver
);
453 if (DesktopBase
->db_Observer
)
454 MUI_DeleteCustomClass(DesktopBase
->db_Observer
);
455 if (DesktopBase
->db_ToolIcon
)
456 MUI_DeleteCustomClass(DesktopBase
->db_ToolIcon
);
457 if (DesktopBase
->db_DiskIcon
)
458 MUI_DeleteCustomClass(DesktopBase
->db_DiskIcon
);
459 if (DesktopBase
->db_DrawerIcon
)
460 MUI_DeleteCustomClass(DesktopBase
->db_DrawerIcon
);
461 if (DesktopBase
->db_TrashcanIcon
)
462 MUI_DeleteCustomClass(DesktopBase
->db_TrashcanIcon
);
463 if (DesktopBase
->db_ProjectIcon
)
464 MUI_DeleteCustomClass(DesktopBase
->db_ProjectIcon
);
465 if (DesktopBase
->db_Icon
)
466 MUI_DeleteCustomClass(DesktopBase
->db_Icon
);
467 if (DesktopBase
->db_IconContainer
)
468 MUI_DeleteCustomClass(DesktopBase
->db_IconContainer
);
469 if (DesktopBase
->db_Presentation
)
470 MUI_DeleteCustomClass(DesktopBase
->db_Presentation
);
472 if (DesktopBase
->db_InputBase
)
473 CloseDevice(&DesktopBase
->db_InputIO
);
478 ADD2INITLIB(Init
, 0);
479 ADD2OPENLIB(Open
, 0);
480 ADD2CLOSELIB(Close
, 0);
481 ADD2EXPUNGELIB(Expunge
, 0);