1966bf024Smrg/* $XFree86$ */
2966bf024Smrg/*****************************************************************************
3966bf024SmrgCopyright 1987, 1988, 1989, 1990, 1991 by Digital Equipment Corp., Maynard, MA
4966bf024Smrg
5966bf024SmrgPermission to use, copy, modify, and distribute this software and its
6966bf024Smrgdocumentation for any purpose and without fee is hereby granted,
7966bf024Smrgprovided that the above copyright notice appear in all copies and that
8966bf024Smrgboth that copyright notice and this permission notice appear in
9966bf024Smrgsupporting documentation, and that the name of Digital not be
10966bf024Smrgused in advertising or publicity pertaining to distribution of the
11966bf024Smrgsoftware without specific, written prior permission.
12966bf024Smrg
13966bf024SmrgDIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
14966bf024SmrgALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
15966bf024SmrgDIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
16966bf024SmrgANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
17966bf024SmrgWHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
18966bf024SmrgARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
19966bf024SmrgSOFTWARE.
20966bf024Smrg
21966bf024Smrg*****************************************************************************/
22966bf024Smrg#ifndef NO_DEC_ADDED_VALUE
23966bf024Smrg#ifdef SMT
24966bf024Smrg#define NEED_EVENTS
25966bf024Smrg#define NEED_REPLIES
26966bf024Smrg#endif
27966bf024Smrg#include <X11/Xlib.h>
28966bf024Smrg#define NEED_REPLIES
29966bf024Smrg#define NEED_EVENTS
30966bf024Smrg#include <X11/Xproto.h>
31966bf024Smrg#else /* NO_DEC_BUG_FIX */
32966bf024Smrg#include <X11/Xlib.h>
33966bf024Smrg#define NEED_REPLIES
34966bf024Smrg#define NEED_EVENTS
35966bf024Smrg#include <X11/Xproto.h>
36966bf024Smrg#endif /* NO_DEC_BUG_FIX */
37966bf024Smrg/* the following's a hack to support V3.1 protocol */
38966bf024Smrg#if defined(__STDC__) && !defined(UNIXCPP)
39966bf024Smrg#define GetOldReq(name, req, old_length) \
40966bf024Smrg        WORD64ALIGN\
41966bf024Smrg        if ((dpy->bufptr + SIZEOF(x##name##Req)) > dpy->bufmax)\
42966bf024Smrg                _XFlush(dpy);\
43966bf024Smrg        req = (x##name##Req *)(dpy->last_req = dpy->bufptr);\
44966bf024Smrg        req->reqType = X_##name;\
45966bf024Smrg        req->length = old_length>>2;\
46966bf024Smrg        dpy->bufptr += old_length;\
47966bf024Smrg        dpy->request++
48966bf024Smrg
49966bf024Smrg#else  /* non-ANSI C uses empty comment instead of "##" for token concat */
50966bf024Smrg#define GetOldReq(name, req, old_length) \
51966bf024Smrg        WORD64ALIGN\
52966bf024Smrg        if ((dpy->bufptr + SIZEOF(x/**/name/**/Req)) > dpy->bufmax)\
53966bf024Smrg                _XFlush(dpy);\
54966bf024Smrg        req = (x/**/name/**/Req *)(dpy->last_req = dpy->bufptr);\
55966bf024Smrg        req->reqType = X_/**/name;\
56966bf024Smrg        req->length = old_length>>2;\
57966bf024Smrg        dpy->bufptr += old_length;\
58966bf024Smrg        dpy->request++
59966bf024Smrg#endif
60966bf024Smrg
61966bf024Smrg#ifndef vms
62966bf024Smrg#include <X11/Xlibint.h>
63966bf024Smrg#else   /* vms */
64966bf024Smrg#define SyncHandle() \
65966bf024Smrg    if (dpy->synchandler) (*dpy->synchandler)(dpy)
66966bf024Smrg/*
67966bf024Smrg * LockDisplay uses an undocumented feature in V5 of VMS that allows
68966bf024Smrg * disabling ASTs without calling $SETAST.  A bit is set in P1 space
69966bf024Smrg * that disables a user mode AST from being delivered to this process.
70966bf024Smrg *
71966bf024Smrg */
72966bf024Smrg#define LockDisplay(dis)             \
73966bf024Smrg{   globalref char ctl$gb_soft_ast_disable;    \
74966bf024Smrg    globalref char ctl$gb_lib_lock;        \
75966bf024Smrg    globalref short ctl$gw_soft_ast_lock_depth;    \
76966bf024Smrg    if ( ctl$gb_soft_ast_disable == 0 ) {    \
77966bf024Smrg    ctl$gb_soft_ast_disable = 1;        \
78966bf024Smrg    ctl$gb_lib_lock = 1;            \
79966bf024Smrg    ctl$gw_soft_ast_lock_depth = 1;        \
80966bf024Smrg    }                        \
81966bf024Smrg    else ctl$gw_soft_ast_lock_depth++;        \
82966bf024Smrg}
83966bf024Smrg
84966bf024Smrg/*
85966bf024Smrg * UnlockDisplay clears the AST disable bit, then checks to see if an
86966bf024Smrg * AST delivery attempt was made during the critical section.  If so,
87966bf024Smrg * reenable_ASTs is set, and $SETAST must be called to turn AST delivery
88966bf024Smrg * back on.
89966bf024Smrg *
90966bf024Smrg * Note that it assumed that LockDisplay and UnlockDisplay appear in
91966bf024Smrg * matched sets within a single routine.
92966bf024Smrg */
93966bf024Smrg#define UnlockDisplay(dis)             \
94966bf024Smrg{   globalref char ctl$gb_reenable_asts;    \
95966bf024Smrg    globalref char ctl$gb_soft_ast_disable;    \
96966bf024Smrg    globalref char ctl$gb_lib_lock;        \
97966bf024Smrg    globalref short ctl$gw_soft_ast_lock_depth;    \
98966bf024Smrg    if (!--ctl$gw_soft_ast_lock_depth)         \
99966bf024Smrg    if ( ctl$gb_lib_lock ) {        \
100966bf024Smrg        ctl$gb_lib_lock = 0;        \
101966bf024Smrg            ctl$gb_soft_ast_disable = 0;    \
102966bf024Smrg        if (ctl$gb_reenable_asts != 0)    \
103966bf024Smrg        sys$setast(1);            \
104966bf024Smrg        }                    \
105966bf024Smrg}
106966bf024Smrg
107966bf024Smrg#define WORD64ALIGN
108966bf024Smrg#if defined(__STDC__) && !defined(UNIXCPP)
109966bf024Smrg#define GetReq(name, req) \
110966bf024Smrg        WORD64ALIGN\
111966bf024Smrg        if ((dpy->bufptr + SIZEOF(x##name##Req)) > dpy->bufmax)\
112966bf024Smrg                _XFlush(dpy);\
113966bf024Smrg        req = (x##name##Req *)(dpy->last_req = dpy->bufptr);\
114966bf024Smrg        req->reqType = X_##name;\
115966bf024Smrg        req->length = (SIZEOF(x##name##Req))>>2;\
116966bf024Smrg        dpy->bufptr += SIZEOF(x##name##Req);\
117966bf024Smrg        dpy->request++
118966bf024Smrg
119966bf024Smrg#else  /* non-ANSI C uses empty comment instead of "##" for token concat */
120966bf024Smrg#define GetReq(name, req) \
121966bf024Smrg        WORD64ALIGN\
122966bf024Smrg        if ((dpy->bufptr + SIZEOF(x/**/name/**/Req)) > dpy->bufmax)\
123966bf024Smrg                _XFlush(dpy);\
124966bf024Smrg        req = (x/**/name/**/Req *)(dpy->last_req = dpy->bufptr);\
125966bf024Smrg        req->reqType = X_/**/name;\
126966bf024Smrg        req->length = (SIZEOF(x/**/name/**/Req))>>2;\
127966bf024Smrg        dpy->bufptr += SIZEOF(x/**/name/**/Req);\
128966bf024Smrg        dpy->request++
129966bf024Smrg#endif
130966bf024Smrg#endif /* vms */
131966bf024Smrg
132966bf024Smrg#include <X11/extensions/xtraplib.h>
133966bf024Smrg#include <X11/extensions/xtraplibp.h>
134966bf024Smrg
135966bf024Smrg/* Returns the all important protocol number to be used.
136966bf024Smrg * The only request guaranteed to be of the same request/reply
137966bf024Smrg * size is XEGetVersionRequest.  All others need the protocol
138966bf024Smrg * number to determine how to communicate.
139966bf024Smrg * Unfortunately, this was broken for V3.1 so GetAvailable will
140966bf024Smrg * have to be used to determine the protocol version.
141966bf024Smrg */
142966bf024Smrgint XEGetVersionRequest(XETC *tc, XETrapGetVersRep *ret)
143966bf024Smrg{
144966bf024Smrg    int status = True;
145966bf024Smrg    Display *dpy = tc->dpy;
146966bf024Smrg    CARD32 X_XTrapGet = tc->extOpcode;
147966bf024Smrg    xXTrapGetReq *reqptr;
148966bf024Smrg    xXTrapGetVersReply rep;
149966bf024Smrg    int numlongs = (SIZEOF(xXTrapGetVersReply) -
150966bf024Smrg        SIZEOF(xReply) + SIZEOF(CARD32) -1 ) / SIZEOF(CARD32);
151966bf024Smrg    LockDisplay(dpy);
152966bf024Smrg    GetReq(XTrapGet,reqptr);
153966bf024Smrg    reqptr->minor_opcode = XETrap_GetVersion;
154966bf024Smrg    reqptr->protocol = XETrapProtocol;
155966bf024Smrg    status = _XReply(dpy,(xReply *)&rep,numlongs,xTrue);
156966bf024Smrg    UnlockDisplay(dpy);
1579384b2f3Smrg    SyncHandle();
158966bf024Smrg    memcpy((char *)ret,&(rep.data),sizeof(XETrapGetVersRep));
159966bf024Smrg    return(status);
160966bf024Smrg}
161966bf024Smrg
162966bf024Smrgint XEGetAvailableRequest(XETC *tc, XETrapGetAvailRep *ret)
163966bf024Smrg{
164966bf024Smrg    int status = True;
165966bf024Smrg    Display *dpy = tc->dpy;
166966bf024Smrg    CARD32 X_XTrapGet = tc->extOpcode;
167966bf024Smrg    xXTrapGetReq *reqptr;
168966bf024Smrg    xXTrapGetAvailReply rep;
169966bf024Smrg    int numlongs = (SIZEOF(xXTrapGetAvailReply) -
170966bf024Smrg        SIZEOF(xReply) + SIZEOF(CARD32) -1 ) / SIZEOF(CARD32);
171966bf024Smrg    LockDisplay(dpy);
172966bf024Smrg    GetReq(XTrapGet,reqptr);
173966bf024Smrg    reqptr->minor_opcode = XETrap_GetAvailable;
174966bf024Smrg    reqptr->protocol = XETrapProtocol;
175966bf024Smrg    status = _XReply(dpy,(xReply *)&rep,numlongs,xTrue);
176966bf024Smrg    UnlockDisplay(dpy);
1779384b2f3Smrg    SyncHandle();
178966bf024Smrg    memcpy((char *)ret,&(rep.data),sizeof(XETrapGetAvailRep));
179966bf024Smrg    return(status);
180966bf024Smrg}
181966bf024Smrg
182966bf024Smrg/* should not be called directly by clients */
183966bf024Smrgstatic int XEConfigRequest(XETC *tc)
184966bf024Smrg{   /* protocol changed between V3.1 and V3.2! */
185966bf024Smrg    int status = True;
186966bf024Smrg    Display *dpy = tc->dpy;
187966bf024Smrg    CARD32 X_XTrapConfig = tc->extOpcode;
188966bf024Smrg    xXTrapConfigReq *reqptr;
189966bf024Smrg    if (tc->protocol == 31)
190966bf024Smrg    {   /* hack to allocate the old request length */
191966bf024Smrg        GetOldReq(XTrapConfig,reqptr,276);
192966bf024Smrg    }
193966bf024Smrg    else
194966bf024Smrg    {
195966bf024Smrg        GetReq(XTrapConfig,reqptr);
196966bf024Smrg    }
197966bf024Smrg    reqptr->minor_opcode = XETrap_Config;
198966bf024Smrg
199966bf024Smrg    memcpy((char *)reqptr->config_flags_valid,
200966bf024Smrg        (char *)tc->values.v.flags.valid,4);
201966bf024Smrg    memcpy((char *)reqptr->config_flags_data,
202966bf024Smrg        (char *)tc->values.v.flags.data,4);
203966bf024Smrg    memcpy((char *)reqptr->config_flags_req,
204966bf024Smrg        (char *)tc->values.v.flags.req,XETrapMaxRequest);
205966bf024Smrg    memcpy((char *)reqptr->config_flags_event,
206966bf024Smrg        (char *)tc->values.v.flags.event,XETrapMaxEvent);
207966bf024Smrg    reqptr->config_max_pkt_size=tc->values.v.max_pkt_size;
208966bf024Smrg    reqptr->config_cmd_key=tc->values.v.cmd_key;
209966bf024Smrg
210966bf024Smrg    XFlush(dpy);
211966bf024Smrg    SyncHandle();
212966bf024Smrg    tc->dirty = 0L; /* Configuration is no longer dirty */
213966bf024Smrg    return(status);
214966bf024Smrg}
215966bf024Smrg
216966bf024Smrg/* Flush out any pending configuration */
217966bf024Smrgint XEFlushConfig(XETC *tc)
218966bf024Smrg{
219966bf024Smrg    return((tc->dirty) ? XEConfigRequest(tc) : True);
220966bf024Smrg}
221966bf024Smrgint XEResetRequest(XETC *tc)
222966bf024Smrg{
223966bf024Smrg    int status = True;
224966bf024Smrg    Display *dpy = tc->dpy;
225966bf024Smrg    CARD32 X_XTrap = tc->extOpcode;
226966bf024Smrg    xXTrapReq *reqptr;
227966bf024Smrg    status = XEFlushConfig(tc); /* Flushout any pending configuration first */
228966bf024Smrg    if (status == True)
229966bf024Smrg    {
230966bf024Smrg        GetReq(XTrap,reqptr);
231966bf024Smrg        reqptr->minor_opcode = XETrap_Reset;
232966bf024Smrg        XFlush(dpy);
233966bf024Smrg        SyncHandle();
234966bf024Smrg    }
235966bf024Smrg    return(status);
236966bf024Smrg}
237966bf024Smrg
238966bf024Smrg
239966bf024Smrgint XEGetLastInpTimeRequest(XETC *tc, XETrapGetLastInpTimeRep *ret)
240966bf024Smrg{   /* this was broken in V3.1! */
241966bf024Smrg    int status = True;
242966bf024Smrg    Display *dpy = tc->dpy;
243966bf024Smrg    CARD32 X_XTrap = tc->extOpcode;
244966bf024Smrg    xXTrapReq *reqptr;
245966bf024Smrg    xXTrapGetLITimReply rep;
246966bf024Smrg    int numlongs = (SIZEOF(xXTrapGetLITimReply) -
247966bf024Smrg        SIZEOF(xReply) + SIZEOF(CARD32) - 1) / SIZEOF(CARD32);
248966bf024Smrg    LockDisplay(dpy);
249966bf024Smrg    GetReq(XTrap,reqptr);
250966bf024Smrg    reqptr->minor_opcode = XETrap_GetLastInpTime;
251966bf024Smrg    status = _XReply(dpy,(xReply *)&rep,numlongs,xTrue);
252966bf024Smrg    UnlockDisplay(dpy);
2539384b2f3Smrg    SyncHandle();
254966bf024Smrg
255966bf024Smrg    ret->last_time=rep.data_last_time;
256966bf024Smrg
257966bf024Smrg    return(status);
258966bf024Smrg}
259966bf024Smrg
260966bf024Smrgint XEStartTrapRequest(XETC *tc)
261966bf024Smrg{
262966bf024Smrg    int status = True;
263966bf024Smrg    Display *dpy = tc->dpy;
264966bf024Smrg    CARD32 X_XTrap = tc->extOpcode;
265966bf024Smrg    xXTrapReq *reqptr;
266966bf024Smrg    status = XEFlushConfig(tc); /* Flushout any pending configuration first */
267966bf024Smrg    if (status == True)
268966bf024Smrg    {
269966bf024Smrg        /* Add our event handler for the XLib transport */
270966bf024Smrg        XETrapSetEventHandler(tc, XETrapData, XETrapDispatchXLib);
271966bf024Smrg        GetReq(XTrap,reqptr);
272966bf024Smrg        reqptr->minor_opcode = XETrap_StartTrap;
273966bf024Smrg        XFlush(dpy);
274966bf024Smrg        SyncHandle();
275966bf024Smrg        BitTrue(tc->values.tc_flags, XETCTrapActive);
276966bf024Smrg    }
277966bf024Smrg    return(status);
278966bf024Smrg}
279966bf024Smrgint XEStopTrapRequest(XETC *tc)
280966bf024Smrg{
281966bf024Smrg    int status = True;
282966bf024Smrg    Display *dpy = tc->dpy;
283966bf024Smrg    CARD32 X_XTrap = tc->extOpcode;
284966bf024Smrg    xXTrapReq *reqptr;
285966bf024Smrg    status = XEFlushConfig(tc); /* Flushout any pending configuration first */
286966bf024Smrg    if (status == True)
287966bf024Smrg    {
288966bf024Smrg        GetReq(XTrap,reqptr);
289966bf024Smrg        reqptr->minor_opcode = XETrap_StopTrap;
290966bf024Smrg        XFlush(dpy);
291966bf024Smrg        SyncHandle();
292966bf024Smrg        BitFalse(tc->values.tc_flags, XETCTrapActive);
293966bf024Smrg        /* Remove our event handler for the XLib transport */
294966bf024Smrg	XETrapSetEventHandler(tc, XETrapData, NULL);
295966bf024Smrg    }
296966bf024Smrg
297966bf024Smrg    return(status);
298966bf024Smrg}
299966bf024Smrg
300966bf024Smrg#ifndef _XINPUT
301966bf024Smrgint XESimulateXEventRequest(XETC *tc, CARD8 type, CARD8 detail,
302966bf024Smrg    CARD16 x, CARD16 y, CARD8 screen)
303966bf024Smrg{
304966bf024Smrg    int status = True;
305966bf024Smrg    Display *dpy = tc->dpy;
306966bf024Smrg    CARD32 X_XTrapInput = tc->extOpcode;
307966bf024Smrg    xXTrapInputReq *reqptr;
308966bf024Smrg    status = XEFlushConfig(tc); /* Flushout any pending configuration first */
309966bf024Smrg    if (status == True)
310966bf024Smrg    {   /* write out the input event */
311966bf024Smrg        GetReq(XTrapInput,reqptr);
312966bf024Smrg        reqptr->minor_opcode = XETrap_SimulateXEvent;
313966bf024Smrg        reqptr->input.type   = type;
314966bf024Smrg        reqptr->input.detail = detail;
315966bf024Smrg        reqptr->input.x      = x;
316966bf024Smrg        reqptr->input.y      = y;
317966bf024Smrg        reqptr->input.screen = screen;
318966bf024Smrg        XFlush(dpy);
319966bf024Smrg    }
320966bf024Smrg    return(status);
321966bf024Smrg}
322966bf024Smrg#endif
323966bf024Smrgint XEGetCurrentRequest(XETC *tc, XETrapGetCurRep *ret)
324966bf024Smrg{
325966bf024Smrg    int status = True;
326966bf024Smrg    Display *dpy = tc->dpy;
327966bf024Smrg    CARD32 X_XTrap = tc->extOpcode;
328966bf024Smrg    xXTrapReq *reqptr;
329966bf024Smrg    xXTrapGetCurReply rep;
330966bf024Smrg    int numlongs = (SIZEOF(xXTrapGetCurReply) -
331966bf024Smrg        SIZEOF(xReply) + SIZEOF(CARD32) -1 ) / SIZEOF(CARD32);
332966bf024Smrg    status = XEFlushConfig(tc); /* Flushout any pending configuration first */
333966bf024Smrg    if (status == True)
334966bf024Smrg    {
335966bf024Smrg        LockDisplay(dpy);
336966bf024Smrg        GetReq(XTrap,reqptr);
337966bf024Smrg        reqptr->minor_opcode = XETrap_GetCurrent;
338966bf024Smrg        /* to support comm. w/ V3.1 extensions */
339966bf024Smrg        if (tc->protocol == 31)
340966bf024Smrg        {
341966bf024Smrg            char tmp[284];  /* need space for the big *old* reply */
342966bf024Smrg            numlongs = (284-sizeof(xReply)+sizeof(long)-1)/sizeof(long);
343966bf024Smrg            status = _XReply(dpy,(xReply *)tmp,numlongs,xTrue);
344966bf024Smrg            memcpy(&rep,tmp,sizeof(rep));   /* move just what's needed */
345966bf024Smrg        }
346966bf024Smrg        else
347966bf024Smrg        {
348966bf024Smrg            status = _XReply(dpy,(xReply *)&rep,numlongs,xTrue);
349966bf024Smrg        }
350966bf024Smrg        UnlockDisplay(dpy);
3519384b2f3Smrg        SyncHandle();
352966bf024Smrg
353966bf024Smrg    memcpy((char *)ret->state_flags,rep.data_state_flags,2);
354966bf024Smrg    memcpy((char *)ret->config.flags.valid,rep.data_config_flags_valid,4);
355966bf024Smrg    memcpy((char *)ret->config.flags.data,rep.data_config_flags_data,4);
356966bf024Smrg    memcpy((char *)ret->config.flags.req,rep.data_config_flags_req,
357966bf024Smrg        XETrapMaxRequest);
358966bf024Smrg    memcpy((char *)ret->config.flags.event,rep.data_config_flags_event,
359966bf024Smrg        XETrapMaxEvent);
360966bf024Smrg    ret->config.max_pkt_size=rep.data_config_max_pkt_size;
361966bf024Smrg    ret->config.cmd_key=rep.data_config_cmd_key;
362966bf024Smrg
363966bf024Smrg    }
364966bf024Smrg    return(status);
365966bf024Smrg}
366966bf024Smrg
367966bf024Smrgint XEGetStatisticsRequest(XETC *tc, XETrapGetStatsRep *ret)
368966bf024Smrg{
369966bf024Smrg    int status = True;
370966bf024Smrg    Display *dpy = tc->dpy;
371966bf024Smrg    CARD32 X_XTrap = tc->extOpcode;
372966bf024Smrg    xXTrapReq *reqptr;
373966bf024Smrg    xXTrapGetStatsReply rep;
374966bf024Smrg    status = XEFlushConfig(tc); /* Flushout any pending configuration first */
375966bf024Smrg    if (status == True)
376966bf024Smrg    {
377966bf024Smrg        LockDisplay(dpy);
378966bf024Smrg        GetReq(XTrap,reqptr);
379966bf024Smrg        reqptr->minor_opcode = XETrap_GetStatistics;
380966bf024Smrg        /* to support comm. w/ V3.1 extensions */
381966bf024Smrg#ifndef CRAY
382966bf024Smrg        if (tc->protocol == 31)
383966bf024Smrg        {   /* this is the way we used to do it which breaks Cray's */
384966bf024Smrg#ifndef VECTORED_EVENTS
385966bf024Smrg            int numlongs = (1060-sizeof(xReply)+sizeof(long)-1)/sizeof(long);
386966bf024Smrg#else
387966bf024Smrg            int numlongs = (1544-sizeof(xReply)+sizeof(long)-1)/sizeof(long);
388966bf024Smrg#endif
389966bf024Smrg            status = _XReply(dpy,(xReply *)&rep,numlongs,xTrue);
390966bf024Smrg            if (status == True)
391966bf024Smrg            {   /* need to shift it back into the data struct */
392966bf024Smrg                xXTrapGetStatsReply tmp;
393966bf024Smrg                tmp = rep;
394966bf024Smrg                memcpy(&(rep.data),&(tmp.pad0), sizeof(rep.data));
395966bf024Smrg            }
396966bf024Smrg        }
397966bf024Smrg        else
398966bf024Smrg#endif /* CRAY */
399966bf024Smrg        {   /* this is the way we do it for V3.2 */
400966bf024Smrg            int numbytes = SIZEOF(xXTrapGetStatsReply) - SIZEOF(xReply);
401966bf024Smrg            status = _XReply(dpy, (xReply *)&rep, 0, xFalse);
402966bf024Smrg            if (status == True)
403966bf024Smrg            {
404966bf024Smrg                status = _XRead(dpy, (char *)&rep.data, numbytes);
405966bf024Smrg            }
406966bf024Smrg        }
407966bf024Smrg        UnlockDisplay(dpy);
4089384b2f3Smrg        SyncHandle();
409966bf024Smrg        memcpy(ret,&(rep.data),sizeof(XETrapGetStatsRep));
410966bf024Smrg    }
411966bf024Smrg    return(status);
412966bf024Smrg}
413