2 /*****************************************************************************
3 Copyright 1987, 1988, 1989, 1990, 1991 by Digital Equipment Corp., Maynard, MA
5 Permission to use, copy, modify, and distribute this software and its
6 documentation for any purpose and without fee is hereby granted,
7 provided that the above copyright notice appear in all copies and that
8 both that copyright notice and this permission notice appear in
9 supporting documentation, and that the name of Digital not be
10 used in advertising or publicity pertaining to distribution of the
11 software without specific, written prior permission.
13 DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
14 ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
15 DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
16 ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
17 WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
18 ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
21 *****************************************************************************/
37 * This file contains XETrap Callback initilization routines.
38 * The callback data hang off of the TC and are freed as part of the
43 #include <X11/extensions/xtraplib.h>
44 #include <X11/extensions/xtraplibp.h>
46 int XEAddRequestCB(XETC *tc, CARD8 req, void_function func, BYTE *data)
48 if (!tc->values.req_cb)
49 { /* This is the first time for this particular TC, need to malloc */
50 if ((tc->values.req_cb =
51 (XETrapCB *)XtCalloc(256L,sizeof(XETrapCB))) == NULL)
53 /* XtCalloc already reported the error */
57 tc->values.req_cb[req].func = func;
58 tc->values.req_cb[req].data = data;
63 int XEAddRequestCBs(XETC *tc, ReqFlags req_flags, void_function func,
69 for (i=0; i<=255L; i++)
71 if (BitIsTrue(req_flags, i))
73 status = XEAddRequestCB(tc, (CARD8)i, func, data);
79 int XEAddEventCB(XETC *tc, CARD8 evt, void_function func, BYTE *data)
81 if (!tc->values.evt_cb)
82 { /* This is the first time for this particular TC, need to malloc */
83 if ((tc->values.evt_cb =
84 (XETrapCB *)XtCalloc(XETrapCoreEvents,sizeof(XETrapCB))) == NULL)
86 /* XtCalloc already reported the error */
90 tc->values.evt_cb[evt].func = func;
91 tc->values.evt_cb[evt].data = data;
96 int XEAddEventCBs(XETC *tc, EventFlags evt_flags, void_function func,
102 for (i=KeyPress; i<=MotionNotify; i++)
104 if (BitIsTrue(evt_flags, i))
106 status = XEAddEventCB(tc, (CARD8)i, func, data);
112 void XERemoveRequestCB(XETC *tc, CARD8 req)
114 if (!tc->values.req_cb)
115 { /* We gotta problem! CB struct not allocated! */
118 tc->values.req_cb[req].func = (void_function)NULL;
119 tc->values.req_cb[req].data = (BYTE *)NULL;
122 void XERemoveRequestCBs(XETC *tc, ReqFlags req_flags)
126 for (i=0; i<=255L; i++)
128 if (BitIsTrue(req_flags, i))
130 XERemoveRequestCB(tc, (CARD8)i);
135 void XERemoveAllRequestCBs(XETC *tc)
137 if (!tc->values.req_cb)
138 { /* We gotta problem! CB struct not allocated! */
141 XtFree((XtPointer)tc->values.req_cb);
144 void XERemoveEventCB(XETC *tc, CARD8 evt)
146 if (!tc->values.evt_cb)
147 { /* We gotta problem! CB struct not allocated! */
150 tc->values.evt_cb[evt].func = (void_function)NULL;
151 tc->values.evt_cb[evt].data = (BYTE *)NULL;
155 void XERemoveEventCBs(XETC *tc, EventFlags evt_flags)
159 for (i=KeyPress; i<=MotionNotify; i++)
161 if (BitIsTrue(evt_flags, i))
163 XERemoveEventCB(tc, (CARD8)i);
168 void XERemoveAllEventCBs(XETC *tc)
170 if (!tc->values.evt_cb)
171 { /* We gotta problem! CB struct not allocated! */
174 XtFree((XtPointer)tc->values.evt_cb);