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 *****************************************************************************/
39 #include <X11/extensions/xtraplib.h>
40 #include <X11/extensions/xtraplibp.h>
42 static void XETrapDispatchCB(XETC *tc, XETrapDatum *pdatum)
44 void_function pfunc = NULL;
47 /* Need to deal with Delta Timestamps here before calling client CB */
48 if (XETrapGetTCFlagDeltaTimes(tc))
50 CARD32 last_time = XETrapGetTCTime(tc);
51 if (XETrapHeaderIsEvent(&pdatum->hdr))
52 { /* then we can play with the timestamps */
53 pdatum->hdr.timestamp =
54 pdatum->u.event.u.keyButtonPointer.time;
58 * the current one from GetTimeInMillis is worthless
59 * as it's only updated during event instances (e.g. not
62 pdatum->hdr.timestamp = last_time;
64 if (!pdatum->hdr.timestamp)
65 { /* for dual monitor bug */
66 pdatum->hdr.timestamp = last_time;
69 { /* first one! Prime it! */
70 last_time = pdatum->hdr.timestamp;
72 tc->values.last_time = pdatum->hdr.timestamp; /* no macro! */
73 if (pdatum->hdr.timestamp < last_time)
74 { /* for clock rollover */
75 pdatum->hdr.timestamp = 0;
78 { /* the real delta */
79 pdatum->hdr.timestamp = pdatum->hdr.timestamp - last_time;
82 /* Get the user supplied callback function */
83 if (XETrapHeaderIsEvent(&pdatum->hdr))
85 pfunc = tc->values.evt_cb[pdatum->u.event.u.u.type].func;
86 userp = tc->values.evt_cb[pdatum->u.event.u.u.type].data;
88 else if (XETrapHeaderIsRequest(&pdatum->hdr) ||
89 XETrapHeaderIsReply(&pdatum->hdr))
91 pfunc = tc->values.req_cb[pdatum->u.req.reqType].func;
92 userp = tc->values.req_cb[pdatum->u.req.reqType].data;
95 /* If there is a callback then call it with the data */
98 (*pfunc)(tc,pdatum,userp);
102 Boolean XETrapDispatchXLib(XETrapDataEvent *event, XETC *tc)
104 memcpy(&tc->xbuff[event->idx*sz_EventData], event->data, sz_EventData);
106 if (event->detail == XETrapDataLast)
108 XETrapDispatchCB(tc, (XETrapDatum *)tc->xbuff);