2 Copyright © 1995-2003, The AROS Development Team. All rights reserved.
6 #define MUIMASTER_YES_INLINE_STDARG
8 #include <exec/types.h>
9 #include <exec/memory.h>
10 #include <exec/nodes.h>
12 #include <dos/dostags.h>
13 #include <dos/dosextens.h>
14 #include <intuition/classes.h>
15 #include <libraries/desktop.h>
16 #include <libraries/gadtools.h>
17 #include <utility/tagitem.h>
19 #include <proto/dos.h>
20 #include <proto/exec.h>
21 #include <proto/intuition.h>
23 #include "desktop_intern.h"
26 #include "desktop_intern_protos.h"
29 #include <aros/debug.h>
31 BOOL
startDesktopHandler(void)
34 NOTE: the OPEN vector (the only caller of this function)
35 already has a mutex on the library base at this point
37 struct Process
*process
= NULL
;
38 struct Message
*msg
= NULL
;
39 struct MsgPort
*port
= (struct MsgPort
*) CreateMsgPort();
43 D(bug("[desktop handler starter] ERROR: Could not create message port!\n"));
47 D(bug("*** Starting desktop handler\n"));
48 process
= CreateNewProcTags
50 NP_Entry
, (IPTR
) desktopHandler
,
51 NP_Name
, (IPTR
) "Desktop Handler",
53 NP_UserData
, (IPTR
) port
,
60 // FIXME: deallocate msgport??
61 D(bug("[desktop handler starter] ERROR: Could not start desktop handler process!\n"));
69 D(bug("*** Desktop Handler started OK\n"));
74 BOOL
handlerAddUser(void)
77 struct DesktopInternMsg msg
;
79 kprintf("/// Attempting to obtain semaphore\n");
80 if (!AttemptSemaphoreShared(&DesktopBase
->db_HandlerSafety
))
83 port
= CreateMsgPort();
86 msg
.di_Message
.mn_Node
.ln_Type
= NT_MESSAGE
;
87 msg
.di_Message
.mn_ReplyPort
= port
;
88 msg
.di_Message
.mn_Length
= sizeof(struct DesktopInternMsg
);
89 msg
.di_Command
= DIMC_ADDUSER
;
91 PutMsg(DesktopBase
->db_HandlerPort
, (struct Message
*) &msg
);
93 kprintf("/// addmsg: awaitng reply from handler\n");
97 kprintf("/// addmsg: got reply, releasing semaphore\n");
99 ReleaseSemaphore(&DesktopBase
->db_HandlerSafety
);
104 BOOL
handlerSubUser(void)
106 struct MsgPort
*port
;
107 struct DesktopInternMsg msg
;
109 port
= CreateMsgPort();
112 msg
.di_Message
.mn_Node
.ln_Type
= NT_MESSAGE
;
113 msg
.di_Message
.mn_ReplyPort
= port
;
114 msg
.di_Message
.mn_Length
= sizeof(struct DesktopInternMsg
);
115 msg
.di_Command
= DIMC_SUBUSER
;
117 PutMsg(DesktopBase
->db_HandlerPort
, (struct Message
*) &msg
);
126 struct HandlerScanRequest
*createScanMessage(ULONG command
,
127 struct MsgPort
*replyPort
,
128 BPTR dirLock
, Object
* callback
,
131 struct HandlerScanRequest
*hsr
;
134 (struct HandlerScanRequest
*)
135 AllocVec(sizeof(struct HandlerScanRequest
), MEMF_ANY
);
136 hsr
->hsr_Message
.di_Message
.mn_Length
= sizeof(struct HandlerScanRequest
);
137 hsr
->hsr_Message
.di_Message
.mn_Node
.ln_Type
= NT_MESSAGE
;
138 hsr
->hsr_Message
.di_Message
.mn_ReplyPort
= replyPort
;
139 hsr
->hsr_Message
.di_Command
= command
;
140 hsr
->hsr_CallBack
= callback
;
141 hsr
->hsr_DirLock
= dirLock
;
142 hsr
->hsr_Application
= app
;
147 struct HandlerTopLevelRequest
*createTLScanMessage(ULONG command
,
148 struct MsgPort
*replyPort
,
153 struct HandlerTopLevelRequest
*htl
;
156 (struct HandlerTopLevelRequest
*)
157 AllocVec(sizeof(struct HandlerTopLevelRequest
), MEMF_ANY
);
158 htl
->htl_Message
.di_Message
.mn_Length
= sizeof(struct HandlerScanRequest
);
159 htl
->htl_Message
.di_Message
.mn_Node
.ln_Type
= NT_MESSAGE
;
160 htl
->htl_Message
.di_Message
.mn_ReplyPort
= replyPort
;
161 htl
->htl_Message
.di_Command
= command
;
162 htl
->htl_Types
= types
;
163 htl
->htl_CallBack
= callback
;
164 htl
->htl_Application
= app
;
170 struct WorkingMessageNode
*findWorkedMessage(struct MinList
*list
, ULONG id
)
172 struct WorkingMessageNode
*wmn
;
175 wmn
= (struct WorkingMessageNode
*)list
->mlh_Head
;
176 while (!found
&& wmn
->wm_Node
.mln_Succ
)
178 if (wmn
->wm_ID
== id
)
181 wmn
= (struct WorkingMessageNode
*)wmn
->wm_Node
.mln_Succ
;
188 BOOL
findOperationItem(LONG menuNumber
, struct DesktopOperationItem
* doi
,
189 struct NewMenu
* menuDat
, LONG
* i
)
196 while (!found
&& doi
[j
].doi_Code
!= 0)
198 // find menu number in doi
199 if (doi
[j
].doi_Number
== menuNumber
)
201 // find matching entry in menudat
203 while (!found
&& menuDat
[k
].nm_Type
!= NM_END
)
205 if (menuDat
[k
].nm_UserData
== doi
[j
].doi_Code
)
207 // kprintf("found mutex to exclude : %s\n", doi[j].doi_Name);
215 if (doi
[j
].doi_SubItems
)
219 while (!found
&& doi
[j
].doi_SubItems
[m
].doi_Code
!= 0)
221 if (doi
[j
].doi_SubItems
[m
].doi_Number
== menuNumber
)
223 // find matching entry in menudat
225 while (!found
&& menuDat
[k
].nm_Type
!= NM_END
)
227 if (menuDat
[k
].nm_UserData
==
228 doi
[j
].doi_SubItems
[m
].doi_Code
)
246 LONG
getItemPosition(struct NewMenu
* menuDat
, LONG i
)
251 while (menuDat
[j
].nm_Type
== menuDat
[i
].nm_Type
)
257 void doExclude(struct DesktopOperationItem
*doi
, struct NewMenu
*menuDat
,
264 while (doi
[j
].doi_Code
!= 0)
266 if (doi
[j
].doi_MutualExclude
)
271 if (bitNum
& doi
[j
].doi_MutualExclude
)
273 if (findOperationItem(bitNum
, doi
, menuDat
, &i
))
274 menuDat
[n
].nm_MutualExclude
|=
275 (1 << getItemPosition(menuDat
, i
));
283 if (doi
[j
].doi_SubItems
)
287 while (doi
[j
].doi_SubItems
[k
].doi_Code
!= 0)
289 if (doi
[j
].doi_SubItems
[k
].doi_MutualExclude
)
294 if ((1 << bitNum
) & doi
[j
].doi_SubItems
[k
].
297 if (findOperationItem(bitNum
, doi
, menuDat
, &i
))
298 menuDat
[n
].nm_MutualExclude
|=
299 (1 << getItemPosition(menuDat
, i
));
315 void processOperationItem(LONG
* reali
, LONG
* realj
,
316 struct DesktopOperationItem
*doi
,
317 struct NewMenu
*menuDat
)
322 menuDat
[i
].nm_Type
= NM_ITEM
;
323 menuDat
[i
].nm_Label
= doi
[j
].doi_Name
;
324 menuDat
[i
].nm_CommKey
= 0;
325 menuDat
[i
].nm_Flags
= 0;
326 menuDat
[i
].nm_MutualExclude
= 0;
328 if (doi
[j
].doi_Flags
& DOIF_CHECKABLE
)
330 menuDat
[i
].nm_Flags
|= CHECKIT
;
331 if (doi
[j
].doi_Flags
& DOIF_CHECKED
)
332 menuDat
[i
].nm_Flags
|= CHECKED
;
335 menuDat
[i
].nm_UserData
= doi
[j
].doi_Code
;
338 if (doi
[j
].doi_SubItems
)
342 while (doi
[j
].doi_SubItems
[k
].doi_Code
!= 0
343 && doi
[j
].doi_SubItems
[k
].doi_Name
!= NULL
)
345 menuDat
[i
].nm_Type
= NM_SUB
;
346 menuDat
[i
].nm_Label
= doi
[j
].doi_SubItems
[k
].doi_Name
;
347 menuDat
[i
].nm_CommKey
= 0;
348 menuDat
[i
].nm_Flags
= 0;
349 menuDat
[i
].nm_MutualExclude
= 0;
351 if (doi
[j
].doi_SubItems
[k
].doi_Flags
& DOIF_CHECKABLE
)
353 menuDat
[i
].nm_Flags
|= CHECKIT
;
354 if (doi
[j
].doi_SubItems
[k
].doi_Flags
& DOIF_CHECKED
)
355 menuDat
[i
].nm_Flags
|= CHECKED
;
358 menuDat
[i
].nm_UserData
= doi
[j
].doi_SubItems
[k
].doi_Code
;