muimaster.library: when changing an active page, only redraw where the children are...
[AROS.git] / workbench / libs / commodities / eventfuncs.c
bloba35c1fb639a492c00f1e3cb9b9b24178a3822c6a
1 /*
2 Copyright © 1995-2001, The AROS Development Team. All rights reserved.
3 $Id$
5 Desc: Commodities initialization code.
6 Lang: English.
7 */
10 #ifndef COMMODITIES_BASE_H
11 #include "cxintern.h"
12 #endif
13 #ifndef PROTO_EXEC_H
14 #include <proto/exec.h>
15 #endif
16 #ifndef EXEC_MEMORY_H
17 #include <exec/memory.h>
18 #endif
19 #ifndef DEVICES_INPUTEVENT_H
20 #include <devices/inputevent.h>
21 #endif
24 static ULONG Extensions[] =
26 0, /* CX_INVALID */
27 sizeof(struct InputXpression), /* CX_FILTER */
28 0, /* CX_TYPEFILTER */
29 sizeof(struct SendExt), /* CX_SENDER */
30 sizeof(struct SignalExt), /* CX_SIGNAL */
31 0, /* CX_TRANSLATE */
32 sizeof(struct BrokerExt), /* CX_BROKER */
33 0, /* CX_DEBUG */
34 sizeof(struct CustomExt), /* CX_CUSTOM */
35 0 /* CX_ZERO */
39 VOID FreeCxStructure(APTR obj, int type, struct Library *CxBase)
41 if (obj == NULL)
43 return;
46 switch (type)
48 case CX_OBJECT:
49 FreeVec(obj);
50 break;
52 case CX_MESSAGE:
53 FreeCxStructure(((CxMsg *)obj)->cxm_Data, CX_INPUTEVENT, CxBase);
54 FreeVec(obj);
55 break;
57 case CX_INPUTEVENT:
58 if(((struct InputEvent *)obj)->ie_Class == IECLASS_NEWPOINTERPOS &&
59 (((struct InputEvent *)obj)->ie_SubClass == IESUBCLASS_TABLET ||
60 ((struct InputEvent *)obj)->ie_SubClass == IESUBCLASS_NEWTABLET ||
61 ((struct InputEvent *)obj)->ie_SubClass == IESUBCLASS_PIXEL))
63 FreeVec(((struct InputEvent *)obj)->ie_EventAddress);
66 FreeMem(obj, sizeof(struct GeneratedInputEvent));
67 break;
72 APTR AllocCxStructure(LONG type, LONG objtype, struct Library *CxBase)
74 APTR temp = NULL;
75 CxObj *tempObj;
76 CxMsg *tempMsg;
78 switch (type)
80 case CX_OBJECT:
81 tempObj = (CxObj *)AllocVec(sizeof(CxObj) + Extensions[objtype],
82 MEMF_CLEAR | MEMF_PUBLIC);
84 tempObj->co_Ext.co_FilterIX = (APTR)(tempObj + 1);
86 NEWLIST(&tempObj->co_ObjList);
88 /* This is done to make it easy for Exchange */
89 if (objtype == CX_BROKER)
91 tempObj->co_Node.ln_Name = (char *)&tempObj->co_Ext.co_BExt->bext_Name;
94 temp = (APTR)tempObj;
95 break;
97 case CX_MESSAGE:
99 switch (objtype)
101 case CXM_SINGLE:
102 tempMsg = AllocVec(sizeof(CxMsg), MEMF_CLEAR | MEMF_PUBLIC);
104 if (tempMsg != NULL)
106 tempMsg->cxm_Data = NULL;
107 tempMsg->cxm_Type = CXM_COMMAND;
108 tempMsg->cxm_Message.mn_ReplyPort = &GPB(CxBase)->cx_MsgPort;
109 tempMsg->cxm_Message.mn_Length = sizeof(CxMsg);
110 temp = (APTR)tempMsg;
113 break;
115 case CXM_DOUBLE:
116 tempMsg = AllocVec(sizeof(CxMsg), MEMF_CLEAR | MEMF_PUBLIC);
118 if (tempMsg != NULL)
120 tempMsg->cxm_Type = CXM_IEVENT;
121 tempMsg->cxm_Data = AllocCxStructure(CX_INPUTEVENT, 0, CxBase);
122 tempMsg->cxm_Message.mn_ReplyPort = &GPB(CxBase)->cx_MsgPort;
123 tempMsg->cxm_Message.mn_Length = sizeof(CxMsg);
125 if (tempMsg->cxm_Data == NULL)
127 FreeVec(tempMsg);
128 tempMsg = NULL;
131 temp = (APTR)tempMsg;
134 break;
137 break;
139 case CX_INPUTEVENT:
141 temp = AllocMem(sizeof(struct GeneratedInputEvent), MEMF_CLEAR | MEMF_PUBLIC);
142 break;
145 return temp;