2 Copyright © 1995-2013, The AROS Development Team. All rights reserved.
3 Copyright © 2001-2003, The MorphOS Development Team. All Rights Reserved.
7 #include <exec/memory.h>
8 #include <intuition/classusr.h>
9 #include <intuition/gadgetclass.h>
10 #include <intuition/cghooks.h>
11 #include <proto/alib.h>
12 #include <proto/exec.h>
13 #include <proto/graphics.h>
14 #include <proto/layers.h>
15 #include <proto/intuition.h>
16 #include "intuition_intern.h"
19 /*****************************************************************************
22 #include <intuition/intuition.h>
23 #include <proto/intuition.h>
25 AROS_LH4(IPTR
, DoGadgetMethodA
,
28 AROS_LHA(struct Gadget
*, gad
, A0
),
29 AROS_LHA(struct Window
*, win
, A1
),
30 AROS_LHA(struct Requester
*, req
, A2
),
31 AROS_LHA(Msg
, msg
, A3
),
34 struct IntuitionBase
*, IntuitionBase
, 135, Intuition
)
37 Invokes a BOOPSI method on an object with a GadgetInfo derived from
38 the supplied window or requester parameter.
41 gad - The gadget to work on
42 win - The window which contains the gadget or the requester with
44 req - If the gadget is in a requester, you must specify that one,
46 message - Send this message to the gadget.
49 The result depends on the contents of the message sent to the
61 I have derived from a simular function from ClassAct where I have
62 to "fake" the function which is not implemented under OS 2.04.
63 There are likely a few differences between this routine and the
64 real code, but this gets the job done.
66 One thing to note, the Amiga Rom routine causes some form of
67 (layer?) locking. I presume the point of the lock is to avoid
68 removing the gadget from the window during a refresh, or to avoid
69 resizing the window during refresh, etc.
71 This locking is fairly obvious within Workbench itself. When
72 refreshing most any boopsi gadget(s) via RefreshGList() and you try
73 to drag a Workbench icon you will get stuck in a layer lock.
74 Workbench has a deadlock timer and is smart enough to release the
75 lock and abort the drag. With this routine below this locking does
76 not occur. Some might call it a good thing, however the issue
77 should be revisited once more of Intuition has been implemented -
78 if it hasn't been already?!. :)
80 *****************************************************************************/
84 struct GfxBase
*GfxBase
= GetPrivIBase(IntuitionBase
)->GfxBase
;
85 struct GadgetInfo
*gi
= &GetPrivIBase(IntuitionBase
)->DoGadgetMethodGI
;
86 struct RastPort
*rp
= &GetPrivIBase(IntuitionBase
)->DoGadgetMethodRP
;
89 DEBUG_DOGADGETMETHOD(dprintf("DoGadgetMethod[%x]: Gad %p Win %p Req %p Method %ld (0x%lx)\n",
90 gi
, gad
, win
, req
, msg
->MethodID
, msg
->MethodID
));
92 if (!win
&& req
) win
= req
->RWindow
;
94 if (gad
&& (((gad
->GadgetType
& GTYP_GTYPEMASK
) == GTYP_CUSTOMGADGET
) || (gad
->GadgetType
& 0x100))) /* OS routines work with NULL objects */
97 /* Protect DoMethodA against race conditions between app task
98 and input.device task (which executes Intuitions Inputhandler) */
100 ObtainSemaphore(&GetPrivIBase(IntuitionBase
)->GadgetLock
);
102 //jDc: SetupGInfo fails when there's no window (but it also clears gadgetinfo!)
103 SetupGInfo(gi
, win
, req
, gad
, IntuitionBase
);
108 rp
->Layer
= gi
->gi_RastPort
->Layer
;
109 rp
->BitMap
= gi
->gi_RastPort
->BitMap
;
110 gi
->gi_RastPort
= rp
;
111 SetFont(rp
, gi
->gi_DrInfo
->dri_Font
);
114 switch (msg
->MethodID
)
120 ((struct opSet
*)msg
)->ops_GInfo
= gi
;
121 ret
= Custom_DoMethodA(IntuitionBase
, gad
, msg
);
125 ((struct gpLayout
*)msg
)->gpl_GInfo
= gi
;
126 ret
= Custom_DoMethodA(IntuitionBase
, gad
, msg
);
131 struct RastPort
*rport
;
133 /* Allocate a clone rastport derived from the GadgetInfo
134 * whose layer clipping information has been nulled out...
136 rport
= ObtainGIRPort(gi
);
140 #if 0 /* stegerg: CHECKME!!!! */
141 //init intuition's global dogadmethod rp with obtained data
142 CopyMem(rport
,rp
,sizeof (struct RastPort
));
146 SetFont(rp
, gi
->gi_DrInfo
->dri_Font
);
149 ((struct gpRender
*)msg
)->gpr_RPort
= rp
;
150 ((struct gpRender
*)msg
)->gpr_GInfo
= gi
;
154 SetFont(rport
, gi
->gi_DrInfo
->dri_Font
);
157 ((struct gpRender
*)msg
)->gpr_RPort
= rport
;
158 ((struct gpRender
*)msg
)->gpr_GInfo
= gi
;
162 ret
= Custom_DoMethodA(IntuitionBase
, gad
, msg
);
164 ReleaseGIRPort(rport
);
170 ((struct gpRender
*)msg
)->gpr_GInfo
= gi
;
171 ret
= Custom_DoMethodA (IntuitionBase
, gad
, msg
);
174 } /* switch (msg->MethodID) */
176 if (gi
->gi_DrInfo
) FreeScreenDrawInfo (gi
->gi_Screen
, gi
->gi_DrInfo
);
178 ReleaseSemaphore(&GetPrivIBase(IntuitionBase
)->GadgetLock
);
182 DEBUG_DOGADGETMETHOD(dprintf("DoGadgetMethod[%x]: Return 0x%lx\n", gi
, ret
));
184 return( (ULONG
)ret
);
188 } /* DoGadgetMethodA */