asm.h: use only .asciz sections of the .s file
[AROS.git] / rom / intuition / wbtasktalk.c
blob0c633af9431d37a768392597ea85a81dfab2bfbf
1 /*
2 Copyright © 1995-2003, The AROS Development Team. All rights reserved.
3 Copyright © 2001-2003, The MorphOS Development Team. All Rights Reserved.
4 $Id$
6 Tell Workbench task that it shall open/close its windows.
7 */
9 /******************************************************************************/
11 #include <proto/exec.h>
12 #include <proto/intuition.h>
13 #include <string.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,
40 &imsg->ExecMessage);
42 DEBUG_WORKBENCH(dprintf("TellWBTaskToOpenWindows: done\n"));
43 return(TRUE);
45 else
47 DEBUG_WORKBENCH(dprintf("TellWBTaskToOpenWindows: no memory\n"));
50 else
52 DEBUG_WORKBENCH(dprintf("TellWBTaskToOpenWindows: no Workbench port\n"));
54 return(FALSE);
57 #if 1
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 );
96 WaitPort( &replymp );
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"));
101 return(TRUE);
103 else
105 DEBUG_WORKBENCH(dprintf("TellWBTaskToCloseWindows: no Workbench port\n"));
107 return(FALSE);
110 /******************************************************************************/
112 #else
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,
134 &imsg->ExecMessage);
135 DEBUG_WORKBENCH(dprintf("TellWBTaskToCloseWindows: done\n"));
136 return(TRUE);
138 else
140 DEBUG_WORKBENCH(dprintf("TellWBTaskToCloseWindows: no memory\n"));
143 else
145 DEBUG_WORKBENCH(dprintf("TellWBTaskToCloseWindows: no Workbench port\n"));
147 return(FALSE);
150 /******************************************************************************/
151 #endif