_screen is only valid between show/hide.
[AROS.git] / rom / intuition / donotify.c
blobb46b4825dc56226a749c8365bf9dc4eb9ee6d5c1
1 /*
2 Copyright © 1995-2013, The AROS Development Team. All rights reserved.
3 Copyright © 2001-2003, The MorphOS Development Team. All Rights Reserved.
4 $Id$
6 ICClass notification support routines.
7 */
9 #include <exec/types.h>
10 #include <exec/memory.h>
11 #include <intuition/classes.h>
12 #include <intuition/cghooks.h>
13 #include <intuition/icclass.h>
14 #include <proto/exec.h>
15 #include <proto/utility.h>
16 #include <proto/intuition.h>
18 #include "intuition_intern.h"
20 #define DEBUG_NOTIFY(x) ;
23 Note: This file is essentially the contents of the file
24 rom/intuition/notify.c which contained code used by the icclass
25 and gadgetclass in caldi's first implementation. It was split
26 by iaint for the new boopsi.library.
31 This will hopefully allow us to send an IDCMP message from a boopsi
32 gadget method.
35 static struct IntuiMessage *SendIDCMPUpdate(Class *cl, Object *o, struct opUpdate *msg,
36 ULONG class, UWORD code, APTR IAddress,
37 struct IntuitionBase *IntuitionBase)
39 struct IntuiMessage *imsg;
41 DEBUG_NOTIFY(dprintf("SendIDCMPUpdate:\n"));
43 imsg = AllocIntuiMessage(msg->opu_GInfo->gi_Window);
45 if( imsg )
47 imsg->Class = class;
48 imsg->Code = code;
49 imsg->Qualifier = (msg->opu_Flags & OPUF_INTERIM) ? IEQUALIFIER_REPEAT : 0; //tells SendIntuiMessage if the message is OK to be dropped
50 imsg->IAddress = IAddress;
51 imsg->MouseX = msg->opu_GInfo->gi_Window->MouseX;
52 imsg->MouseY = msg->opu_GInfo->gi_Window->MouseY;
53 imsg->Seconds = IntuitionBase->Seconds;
54 imsg->Micros = IntuitionBase->Micros;
56 /* done by AllocIntuiMessage
57 imsg->IDCMPWindow = msg->opu_GInfo->gi_Window;
60 SendIntuiMessage(msg->opu_GInfo->gi_Window , imsg);
64 return imsg;
67 /*****i***********************************************************************
69 NAME */
70 AROS_LH4(IPTR, DoNotify,
72 /* SYNOPSIS */
73 AROS_LHA(Class *, cl, A0),
74 AROS_LHA(Object *, o, A1),
75 AROS_LHA(struct ICData *, ic, A2),
76 AROS_LHA(struct opUpdate *, msg, A3),
78 /* LOCATION */
79 struct IntuitionBase *, IntuitionBase, 145, Intuition)
81 /* FUNCTION
82 This function provides a way for icclass objects to notify
83 their listeners when they are notifying. It is mainly
84 provided as an external function for intuition.library's
85 gadgetclass implementation, which contains an inbuilt
86 icclass.
88 INPUTS
89 cl - my class
90 o - this object
91 icdata - interconnection information
92 msg - the message given to the OM_NOTIFY method
94 RESULT
95 The objects listening to this object will be notified.
97 Note: Return value not clear.
99 NOTES
100 This function is also present in MorphOS v50; however it is
101 considered private there.
103 EXAMPLE
105 BUGS
107 SEE ALSO
109 INTERNALS
111 ******************************************************************************/
113 AROS_LIBFUNC_INIT
115 struct Library *UtilityBase = GetPrivIBase(IntuitionBase)->UtilityBase;
117 DEBUG_NOTIFY(dprintf("DoNotify: cl 0x%lx o 0x%lx ICData 0x%lx opUpdate 0x%lx\n",cl,o,ic,msg));
119 SANITY_CHECKR(o,1UL)
120 SANITY_CHECKR(cl,1UL)
121 SANITY_CHECKR(msg,1UL)
122 SANITY_CHECKR(ic,1UL)
124 if( ic->ic_Target != NULL )
126 if( msg->opu_AttrList) /* stegerg: ??? checked also "&& msg->opu_GInfo" ) */
128 ic->ic_LoopCounter += 1UL;
130 DEBUG_NOTIFY(dprintf("DoNotify: Loop counter %ld\n",ic->ic_LoopCounter));
131 /* Don't get into a circular notify target loop */
132 if( ic->ic_LoopCounter == 1UL )
134 if(( ic->ic_CloneTags = CloneTagItems(msg->opu_AttrList)))
136 DEBUG_NOTIFY(dprintf("DoNotify: CloneTags 0x%lx\n",ic->ic_CloneTags));
137 if( ic->ic_Mapping != NULL )
139 MapTags(ic->ic_CloneTags, ic->ic_Mapping, MAP_KEEP_NOT_FOUND);
142 if( ic->ic_Target != (Object *)ICTARGET_IDCMP)
144 struct opUpdate opu;
146 opu.MethodID = OM_UPDATE;
147 opu.opu_AttrList = ic->ic_CloneTags;
148 opu.opu_GInfo = msg->opu_GInfo;
149 opu.opu_Flags = msg->opu_Flags;
151 DEBUG_NOTIFY(dprintf("DoNotify: Send OM_UPDATA to 0x%lx\n",ic->ic_Target));
152 DoMethodA( ic->ic_Target, (Msg)&opu );
154 else
156 if (msg->opu_GInfo)
158 struct Window *win;
160 if ((win = msg->opu_GInfo->gi_Window))
162 if (win->UserPort)
164 if (win->IDCMPFlags & IDCMP_IDCMPUPDATE)
166 struct TagItem *ti;
167 UWORD code = 0;
169 if ((ti = FindTagItem(ICSPECIAL_CODE, ic->ic_CloneTags)))
171 code = ti->ti_Data & 0xFFFF;
174 #if !USE_IDCMPUPDATE_MESSAGECACHE
175 if (!(msg->opu_Flags & OPUF_INTERIM) ||
176 (IW(win)->num_repeatevents < IW(win)->repeatqueue))
178 #endif
180 SendIDCMPUpdate( cl, o, msg, IDCMP_IDCMPUPDATE,
181 code, ic->ic_CloneTags, IntuitionBase );
183 /* in this case the cloned tagitems will be freed in the Intuition
184 InputHandler when the app has replied the IntuiMessage */
186 ic->ic_CloneTags = NULL;
188 #if !USE_IDCMPUPDATE_MESSAGECACHE
190 #endif
198 FreeTagItems(ic->ic_CloneTags);
200 ic->ic_CloneTags = NULL;
202 } /* CloneTagItems() */
204 } /* LoopCounter == 1UL */
205 else
207 DEBUG_NOTIFY(dprintf("DoNotify: skip..circular\n"));
210 ic->ic_LoopCounter -= 1UL;
212 } /* valid parameters */
213 else
215 DEBUG_NOTIFY(dprintf("DoNotify: no AttrList\n"));
217 } /* valid target */
218 else
220 DEBUG_NOTIFY(dprintf("DoNotify: No Target\n"));
222 return 1UL;
224 AROS_LIBFUNC_EXIT
225 } /* DoNotify() */