aboutsummaryrefslogtreecommitdiff
path: root/nx-X11/lib/XTrap/XECallBcks.c
diff options
context:
space:
mode:
authorReinhard Tartler <siretart@tauware.de>2011-10-10 17:43:39 +0200
committerReinhard Tartler <siretart@tauware.de>2011-10-10 17:43:39 +0200
commitf4092abdf94af6a99aff944d6264bc1284e8bdd4 (patch)
tree2ac1c9cc16ceb93edb2c4382c088dac5aeafdf0f /nx-X11/lib/XTrap/XECallBcks.c
parenta840692edc9c6d19cd7c057f68e39c7d95eb767d (diff)
downloadnx-libs-f4092abdf94af6a99aff944d6264bc1284e8bdd4.tar.gz
nx-libs-f4092abdf94af6a99aff944d6264bc1284e8bdd4.tar.bz2
nx-libs-f4092abdf94af6a99aff944d6264bc1284e8bdd4.zip
Imported nx-X11-3.1.0-1.tar.gznx-X11/3.1.0-1
Summary: Imported nx-X11-3.1.0-1.tar.gz Keywords: Imported nx-X11-3.1.0-1.tar.gz into Git repository
Diffstat (limited to 'nx-X11/lib/XTrap/XECallBcks.c')
-rw-r--r--nx-X11/lib/XTrap/XECallBcks.c175
1 files changed, 175 insertions, 0 deletions
diff --git a/nx-X11/lib/XTrap/XECallBcks.c b/nx-X11/lib/XTrap/XECallBcks.c
new file mode 100644
index 000000000..fb1e0893e
--- /dev/null
+++ b/nx-X11/lib/XTrap/XECallBcks.c
@@ -0,0 +1,175 @@
+/* $XFree86$ */
+/*****************************************************************************
+Copyright 1987, 1988, 1989, 1990, 1991 by Digital Equipment Corp., Maynard, MA
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of Digital not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+SOFTWARE.
+
+*****************************************************************************/
+/*
+ *
+ * CONTRIBUTORS:
+ *
+ * Dick Annicchiarico
+ * Robert Chesler
+ * Dan Coutu
+ * Gene Durso
+ * Marc Evans
+ * Alan Jamison
+ * Mark Henry
+ * Ken Miller
+ *
+ */
+/*
+ * This file contains XETrap Callback initilization routines.
+ * The callback data hang off of the TC and are freed as part of the
+ * XEFreeTC routine.
+ */
+
+#include <X11/Xos.h>
+#include <X11/extensions/xtraplib.h>
+#include <X11/extensions/xtraplibp.h>
+
+int XEAddRequestCB(XETC *tc, CARD8 req, void_function func, BYTE *data)
+{
+ if (!tc->values.req_cb)
+ { /* This is the first time for this particular TC, need to malloc */
+ if ((tc->values.req_cb =
+ (XETrapCB *)XtCalloc(256L,sizeof(XETrapCB))) == NULL)
+ {
+ /* XtCalloc already reported the error */
+ return(False);
+ }
+ }
+ tc->values.req_cb[req].func = func;
+ tc->values.req_cb[req].data = data;
+
+ return(True);
+}
+
+int XEAddRequestCBs(XETC *tc, ReqFlags req_flags, void_function func,
+ BYTE *data)
+{
+ int i;
+ int status = True;
+
+ for (i=0; i<=255L; i++)
+ {
+ if (BitIsTrue(req_flags, i))
+ {
+ status = XEAddRequestCB(tc, (CARD8)i, func, data);
+ }
+ }
+ return(status);
+}
+
+int XEAddEventCB(XETC *tc, CARD8 evt, void_function func, BYTE *data)
+{
+ if (!tc->values.evt_cb)
+ { /* This is the first time for this particular TC, need to malloc */
+ if ((tc->values.evt_cb =
+ (XETrapCB *)XtCalloc(XETrapCoreEvents,sizeof(XETrapCB))) == NULL)
+ {
+ /* XtCalloc already reported the error */
+ return(False);
+ }
+ }
+ tc->values.evt_cb[evt].func = func;
+ tc->values.evt_cb[evt].data = data;
+
+ return(True);
+}
+
+int XEAddEventCBs(XETC *tc, EventFlags evt_flags, void_function func,
+ BYTE *data)
+{
+ int i;
+ int status = True;
+
+ for (i=KeyPress; i<=MotionNotify; i++)
+ {
+ if (BitIsTrue(evt_flags, i))
+ {
+ status = XEAddEventCB(tc, (CARD8)i, func, data);
+ }
+ }
+ return(status);
+}
+
+void XERemoveRequestCB(XETC *tc, CARD8 req)
+{
+ if (!tc->values.req_cb)
+ { /* We gotta problem! CB struct not allocated! */
+ return;
+ }
+ tc->values.req_cb[req].func = (void_function)NULL;
+ tc->values.req_cb[req].data = (BYTE *)NULL;
+ return;
+}
+void XERemoveRequestCBs(XETC *tc, ReqFlags req_flags)
+{
+ int i;
+
+ for (i=0; i<=255L; i++)
+ {
+ if (BitIsTrue(req_flags, i))
+ {
+ XERemoveRequestCB(tc, (CARD8)i);
+ }
+ }
+}
+
+void XERemoveAllRequestCBs(XETC *tc)
+{
+ if (!tc->values.req_cb)
+ { /* We gotta problem! CB struct not allocated! */
+ return;
+ }
+ XtFree((XtPointer)tc->values.req_cb);
+}
+
+void XERemoveEventCB(XETC *tc, CARD8 evt)
+{
+ if (!tc->values.evt_cb)
+ { /* We gotta problem! CB struct not allocated! */
+ return;
+ }
+ tc->values.evt_cb[evt].func = (void_function)NULL;
+ tc->values.evt_cb[evt].data = (BYTE *)NULL;
+ return;
+}
+
+void XERemoveEventCBs(XETC *tc, EventFlags evt_flags)
+{
+ int i;
+
+ for (i=KeyPress; i<=MotionNotify; i++)
+ {
+ if (BitIsTrue(evt_flags, i))
+ {
+ XERemoveEventCB(tc, (CARD8)i);
+ }
+ }
+}
+
+void XERemoveAllEventCBs(XETC *tc)
+{
+ if (!tc->values.evt_cb)
+ { /* We gotta problem! CB struct not allocated! */
+ return;
+ }
+ XtFree((XtPointer)tc->values.evt_cb);
+}