Check for SYS/GL during library init. Reason is that
[AROS.git] / rom / intuition / activategadget.c
blob479e0d3eac317197ffe0a51de1a6ce8f4548cef1
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$
5 */
7 #include "intuition_intern.h"
8 #include "inputhandler_actions.h"
9 #include "inputhandler.h"
10 #include "gadgets.h"
12 #include <proto/exec.h>
14 struct ActivateGadgetActionMsg
16 struct IntuiActionMsg msg;
17 struct Window *window;
18 struct Requester *requester;
19 struct Gadget *gadget;
20 BOOL success;
23 #define DEBUG_ACTIVATEGADGET(x) ;
25 static VOID int_activategadget(struct ActivateGadgetActionMsg *msg,
26 struct IntuitionBase *IntuitionBase);
28 /*****************************************************************************
30 NAME */
31 #include <proto/intuition.h>
33 AROS_LH3(BOOL, ActivateGadget,
35 /* SYNOPSIS */
36 AROS_LHA(struct Gadget * , gadget, A0),
37 AROS_LHA(struct Window * , window, A1),
38 AROS_LHA(struct Requester *, requester, A2),
40 /* LOCATION */
41 struct IntuitionBase *, IntuitionBase, 77, Intuition)
43 /* FUNCTION
44 Activates the specified gadget.
46 INPUTS
47 gadget - The gadget to activate
48 window - The window which contains the gadget
49 requester - The requester which contains the gadget or
50 NULL if it is not a requester gadget
52 RESULT
54 NOTES
56 EXAMPLE
58 BUGS
60 SEE ALSO
62 INTERNALS
64 *****************************************************************************/
66 AROS_LIBFUNC_INIT
68 BOOL success = FALSE;
70 DEBUG_ACTIVATEGADGET(dprintf("ActivateGadget: Gadget 0x%lx Window 0x%lx Req 0x%lx\n",
71 gadget, window, requester));
73 if (gadget && (window || requester))
75 if (1)
77 if ((((gadget->GadgetType & GTYP_GTYPEMASK) == GTYP_CUSTOMGADGET) && (!(gadget->Activation & GACT_ACTIVEGADGET))) ||
78 ((gadget->GadgetType & GTYP_GTYPEMASK) == GTYP_STRGADGET))
80 struct ActivateGadgetActionMsg msg;
82 msg.window = window;
83 msg.requester = requester;
84 msg.gadget = gadget;
86 DEBUG_ACTIVATEGADGET(dprintf("ActivateGadget: send gadget activation msg\n"));
88 DoSyncAction((APTR)int_activategadget, &msg.msg, IntuitionBase);
90 success = msg.success;
92 else
94 DEBUG_ACTIVATEGADGET(dprintf("ActivateGadget: no Custom/Stringgadget\n"));
97 } /* if (!(gadget->Activation & GACT_ACTIVEGADGET)) */
98 else
100 DEBUG_ACTIVATEGADGET(dprintf("ActivateGadget: Gadget Activation bit already set\n"));
101 success = TRUE;
104 } /* if (gadget && (window || requester)) */
105 else
107 DEBUG_ACTIVATEGADGET(dprintf("ActivateGadget: No Gadget/Window/Requester\n"));
109 DEBUG_ACTIVATEGADGET(dprintf("ActivateGadget: Success %d\n",
110 success));
112 return success;
114 AROS_LIBFUNC_EXIT
116 } /* ActivateGadget */
119 static VOID int_activategadget(struct ActivateGadgetActionMsg *msg,
120 struct IntuitionBase *IntuitionBase)
122 struct IIHData *iihdata = (struct IIHData *)GetPrivIBase(IntuitionBase)->InputHandler->is_Data;
123 struct Window *window = msg->window;
124 struct Requester *req = msg->requester;
125 struct Gadget *gadget = msg->gadget;
127 DEBUG_ACTIVATEGADGET(dprintf("int_ActivateGadget: Gadget 0x%lx Window 0x%lx Req 0x%lx\n",
128 gadget,
129 window,
130 req));
132 msg->success = FALSE;
134 /* Activate gadget only if no other gadget is
135 actually active and the gadget to be
136 activated is in the actual active window
137 and the gadget is not disabled */
139 DEBUG_ACTIVATEGADGET(dprintf("int_ActivateGadget: activeGadget 0x%lx\n",
140 iihdata->ActiveGadget));
142 if ((iihdata->ActiveGadget == NULL) &&
143 (IntuitionBase->ActiveWindow == window) &&
144 ((gadget->Flags & GFLG_DISABLED) == 0))
146 msg->success = (DoActivateGadget(window, req, gadget, IntuitionBase) != NULL);