2 Copyright © 1995-2007, The AROS Development Team. All rights reserved.
3 Copyright © 2001-2003, The MorphOS Development Team. All Rights Reserved.
7 #include <proto/layers.h>
8 #include "intuition_intern.h"
9 #include "inputhandler_actions.h"
10 #include "inputhandler.h"
11 #include <intuition/gadgetclass.h>
13 struct RemoveGListActionMsg
15 struct IntuiActionMsg msg
;
16 struct Window
*window
;
17 struct Gadget
*gadget
;
23 static VOID
int_removeglist(struct RemoveGListActionMsg
*msg
,
24 struct IntuitionBase
*IntuitionBase
);
26 /*****************************************************************************
29 #include <intuition/intuition.h>
30 #include <proto/intuition.h>
32 AROS_LH3(UWORD
, RemoveGList
,
35 AROS_LHA(struct Window
*, remPtr
, A0
),
36 AROS_LHA(struct Gadget
*, gadget
, A1
),
37 AROS_LHA(LONG
, numGad
, D0
),
40 struct IntuitionBase
*, IntuitionBase
, 74, Intuition
)
60 *****************************************************************************/
66 struct IIHData
*iihdata
;
73 DEBUG_REMOVEGLIST(dprintf("RemoveGList: Window 0x%lx Gadgets 0x%lx Num %ld\n",
74 remPtr
, gadget
, numGad
));
76 if (!numGad
) return ~0;
77 if (!gadget
) return ~0;
78 if (!remPtr
) return ~0;
83 LOCKWINDOWLAYERS(remPtr
);
86 iihdata
= (struct IIHData
*)GetPrivIBase(IntuitionBase
)->InputHandler
->is_Data
;
87 pred
= (struct Gadget
*)&remPtr
->FirstGadget
;
91 while (pred
->NextGadget
&& pred
->NextGadget
!= gadget
)
93 pred
= pred
->NextGadget
;
99 /* Check if one of the gadgets to be removed is the active gadget.
100 If it is, then make it inactive! */
103 for (last
= gadget
; last
&& numGad2
--; last
= last
->NextGadget
)
105 if ((iihdata
->ActiveGadget
== last
) || (iihdata
->ActiveSysGadget
== last
))
114 for (last
= gadget
; last
->NextGadget
&& --numGad
; last
= last
->NextGadget
) ;
116 pred
->NextGadget
= last
->NextGadget
;
118 /* stegerg: don't do this. DOpus for example relies on gadget->NextGadget
120 /* Emm: but the autodocs say it is done for V36 ??? */
122 last
->NextGadget
= NULL
;
127 } /* if (pred->NextGadget) */
136 UNLOCKWINDOWLAYERS(remPtr
);
139 /* We tried to remove the active gadget. This must be delayed until LMB
144 struct RemoveGListActionMsg msg
;
152 DEBUG_REMOVEGLIST(dprintf("RemoveGList: trying to remove the active gadget.\n"));
153 DoSyncAction((APTR
)int_removeglist
, &msg
.msg
, IntuitionBase
);
155 while (!msg
.success
);
160 DEBUG_REMOVEGLIST(dprintf("RemoveGList: removed %ld gadgets\n",count
));
168 static VOID
int_removeglist(struct RemoveGListActionMsg
*msg
,
169 struct IntuitionBase
*IntuitionBase
)
171 struct Window
*remPtr
= msg
->window
;
172 struct Gadget
*gadget
= msg
->gadget
;
173 LONG numGad
= msg
->numGad
;
176 struct IIHData
*iihdata
;
180 DEBUG_REMOVEGLIST(dprintf("IntRemoveGList: Window 0x%lx Gadgets 0x%lx Num %ld\n",
181 remPtr
, gadget
, numGad
));
183 iihdata
= (struct IIHData
*)GetPrivIBase(IntuitionBase
)->InputHandler
->is_Data
;
185 /* Don't remove the gadget until the LMB is released. */
186 if (iihdata
->ActQualifier
& IEQUALIFIER_LEFTBUTTON
)
188 DEBUG_REMOVEGLIST(dprintf("IntRemoveGList: LMB down\n"));
189 msg
->success
= FALSE
;
196 LOCKWINDOWLAYERS(remPtr
);
199 pred
= (struct Gadget
*)&remPtr
->FirstGadget
;
204 while (pred
->NextGadget
&& pred
->NextGadget
!= gadget
)
206 pred
= pred
->NextGadget
;
210 if (pred
->NextGadget
)
212 /* Check if one of the gadgets to be removed is the active gadget.
213 If it is, then make it inactive! If we got here, one of them was
214 the active gadget at the time of RemoveGList, but this may have
217 for (last
= gadget
; last
&& numGad2
--; last
= last
->NextGadget
)
219 if ((iihdata
->ActiveGadget
== last
) || (iihdata
->ActiveSysGadget
== last
))
221 switch(last
->GadgetType
& GTYP_GTYPEMASK
)
223 case GTYP_CUSTOMGADGET
:
225 struct gpGoInactive gpgi
;
227 gpgi
.MethodID
= GM_GOINACTIVE
;
228 gpgi
.gpgi_GInfo
= NULL
;
231 DoGadgetMethodA(last
, remPtr
, NULL
, (Msg
)&gpgi
);
233 if (SYSGADGET_ACTIVE
)
235 if (IS_BOOPSI_GADGET(iihdata
->ActiveSysGadget
))
237 DoGadgetMethodA(iihdata
->ActiveSysGadget
, remPtr
, NULL
, (Msg
)&gpgi
);
239 iihdata
->ActiveSysGadget
= NULL
;
246 last
->Activation
&= ~GACT_ACTIVEGADGET
;
247 iihdata
->ActiveGadget
= NULL
;
251 for (last
= gadget
; last
->NextGadget
&& --numGad
; last
= last
->NextGadget
) ;
253 pred
->NextGadget
= last
->NextGadget
;
255 /* stegerg: don't do this. DOpus for example relies on gadget->NextGadget
257 /* Emm: but the autodocs say it is done for V36 ??? */
259 last
->NextGadget
= NULL
;
262 } /* if (pred->NextGadget) */
271 UNLOCKWINDOWLAYERS(remPtr
);
274 DEBUG_REMOVEGLIST(dprintf("IntRemoveGList: done\n"));