4 ** Copyright (C) 1994,95,96,97,98 Bernardo Innocenti
6 ** Commodity support functions
10 #include <exec/memory.h>
11 #include <libraries/commodities.h>
13 #include <proto/exec.h>
14 #include <proto/dos.h>
15 #include <proto/intuition.h>
16 #include <proto/commodities.h>
18 #include "XModulePriv.h"
22 #define CX_POPKEY 'POP!'
26 XDEF UBYTE CxPopKey[32] = "control alt x";
27 XDEF BOOL CxPopup = TRUE;
30 XDEF struct MsgPort *CxPort = NULL;
31 XDEF CxObj *MyBroker = NULL;
34 static struct NewBroker MyNewBroker =
39 "Module Processing Utility",
49 GLOBALCALL void HandleCx (void)
55 while (cxm = (CxMsg *) GetMsg (CxPort))
57 type = CxMsgType (cxm);
63 if (id == CX_POPKEY) DeIconify();
70 ActivateCxObj (MyBroker, FALSE);
74 ActivateCxObj (MyBroker, TRUE);
87 GuiSwitches.AskExit = FALSE;
93 } /* End Switch (id) */
98 } /* End Switch (type) */
100 ReplyMsg ((struct Message *) cxm);
102 } /* End While (GetMsg()) */
107 GLOBALCALL LONG SetupCx (void)
109 CxObj *filter, *sender;
111 if (!CxPopKey[0]) return RETURN_FAIL;
113 if (!(CxBase = OpenLibrary ("commodities.library", 37L)))
116 if (!(CxPort = CreateMsgPort ()))
119 return ERROR_NO_FREE_STORE;
122 CxSig = 1 << CxPort->mp_SigBit;
125 MyNewBroker.nb_Pri = CxPri;
126 MyNewBroker.nb_Port = CxPort;
128 if (!(MyBroker = CxBroker (&MyNewBroker, NULL)))
134 /* Create PopKey Filter/Sender */
136 if (filter = CxFilter (CxPopKey))
138 if (CxObjError (filter) & COERR_BADFILTER)
139 ShowMessage (MSG_BAD_HOTKEY);
141 AttachCxObj (MyBroker, filter);
143 if (sender = CxSender (CxPort, CX_POPKEY))
144 AttachCxObj (filter, sender);
147 ActivateCxObj (MyBroker, TRUE);
154 GLOBALCALL void CleanupCx (void)
159 { DeleteCxObjAll (MyBroker); MyBroker = NULL; }
163 KillMsgPort (CxPort);
169 CloseLibrary (CxBase); CxBase = NULL;