2 Copyright © 1995-2003, The AROS Development Team. All rights reserved.
3 Copyright © 2001-2003, The MorphOS Development Team. All Rights Reserved.
6 Tell Workbench task that it shall open/close its windows.
9 /******************************************************************************/
11 #include <proto/exec.h>
12 #include <proto/intuition.h>
14 #include "intuition_intern.h"
16 /******************************************************************************/
18 ULONG
TellWBTaskToOpenWindows(struct IntuitionBase
*IntuitionBase
)
20 DEBUG_WORKBENCH(dprintf("TellWBTaskToOpenWindows: currenttask <%s>\n",
21 FindTask(NULL
)->tc_Node
.ln_Name
));
24 GetPrivIBase(IntuitionBase
)->WorkBenchMP
!= NULL
25 && GetPrivIBase(IntuitionBase
)->WorkBenchMP
->mp_SigTask
!= FindTask(NULL
)
28 struct IntuiMessage
*imsg
;
30 if ((imsg
= AllocIntuiMessage(NULL
)))
32 /* Setup our message. */
33 imsg
->ExecMessage
.mn_ReplyPort
= GetPrivIBase(IntuitionBase
)->IntuiReplyPort
;
34 imsg
->Class
= IDCMP_WBENCHMESSAGE
;
35 imsg
->Code
= WBENCHOPEN
;
37 DEBUG_WORKBENCH(dprintf("TellWBTaskToOpenWindows: Send Msg\n"));
38 /* Sends it to the handler asynchron */
39 PutMsg( GetPrivIBase(IntuitionBase
)->WorkBenchMP
,
42 DEBUG_WORKBENCH(dprintf("TellWBTaskToOpenWindows: done\n"));
47 DEBUG_WORKBENCH(dprintf("TellWBTaskToOpenWindows: no memory\n"));
52 DEBUG_WORKBENCH(dprintf("TellWBTaskToOpenWindows: no Workbench port\n"));
59 /******************************************************************************/
61 ULONG
TellWBTaskToCloseWindows(struct IntuitionBase
*IntuitionBase
)
63 DEBUG_WORKBENCH(dprintf("TellWBTaskToCloseWindows: currenttask <%s>\n",
64 FindTask(NULL
)->tc_Node
.ln_Name
));
68 GetPrivIBase(IntuitionBase
)->WorkBenchMP
!= NULL
69 && GetPrivIBase(IntuitionBase
)->WorkBenchMP
->mp_SigTask
!= FindTask(NULL
)
72 struct MsgPort replymp
;
73 struct IntuiMessage imsg
;
75 /* Setup our reply port. By doing this manually, we can use SIGB_SINGLE
76 * and thus avoid allocating a signal (which may fail). */
77 memset( &replymp
, 0, sizeof( replymp
) );
79 replymp
.mp_Node
.ln_Type
= NT_MSGPORT
;
80 replymp
.mp_Flags
= PA_SIGNAL
;
81 replymp
.mp_SigBit
= SIGB_SINGLE
;
82 replymp
.mp_SigTask
= FindTask( NULL
);
83 NEWLIST( &replymp
.mp_MsgList
);
85 /* Setup our message */
86 imsg
.ExecMessage
.mn_ReplyPort
= &replymp
;
87 imsg
.Class
= IDCMP_WBENCHMESSAGE
;
88 imsg
.Code
= WBENCHCLOSE
;
90 SetSignal(0, SIGF_SINGLE
);
92 DEBUG_WORKBENCH(dprintf("TellWBTaskToCloseWindows: Send Msg\n"));
93 /* Sends it to the handler and wait for the reply */
94 PutMsg( GetPrivIBase(IntuitionBase
)->WorkBenchMP
,
95 (struct Message
*) &imsg
);
98 /* After leaving this block imsg and repymp will be automagically freed,
99 * so we don't have to deallocate them ourselves. */
100 DEBUG_WORKBENCH(dprintf("TellWBTaskToCloseWindows: done\n"));
105 DEBUG_WORKBENCH(dprintf("TellWBTaskToCloseWindows: no Workbench port\n"));
110 /******************************************************************************/
113 /******************************************************************************/
115 ULONG
TellWBTaskToCloseWindows(struct IntuitionBase
*IntuitionBase
)
117 DEBUG_WORKBENCH(dprintf("TellWBTaskToCloseWindows: currenttask <%s>\n",
118 FindTask(NULL
)->tc_Node
.ln_Name
));
120 if( GetPrivIBase(IntuitionBase
)->WorkBenchMP
!= NULL
)
122 struct IntuiMessage
*imsg
;
124 if ((imsg
= AllocIntuiMessage(NULL
)))
126 /* Setup our message */
127 imsg
->ExecMessage
.mn_ReplyPort
= GetPrivIBase(IntuitionBase
)->IntuiReplyPort
;
128 imsg
->Class
= IDCMP_WBENCHMESSAGE
;
129 imsg
->Code
= WBENCHCLOSE
;
131 DEBUG_WORKBENCH(dprintf("TellWBTaskToCloseWindows: Send Msg\n"));
132 /* Sends it to the handler asynchron */
133 PutMsg( GetPrivIBase(IntuitionBase
)->WorkBenchMP
,
135 DEBUG_WORKBENCH(dprintf("TellWBTaskToCloseWindows: done\n"));
140 DEBUG_WORKBENCH(dprintf("TellWBTaskToCloseWindows: no memory\n"));
145 DEBUG_WORKBENCH(dprintf("TellWBTaskToCloseWindows: no Workbench port\n"));
150 /******************************************************************************/