#ifndef NO_DEC_ADDED_VALUE
#ifdef SMT
#define NEED_EVENTS
#define NEED_REPLIES
#endif
#include <X11/Xlib.h>
#define NEED_REPLIES
#define NEED_EVENTS
#include <X11/Xproto.h>
#else
#include <X11/Xlib.h>
#define NEED_REPLIES
#define NEED_EVENTS
#include <X11/Xproto.h>
#endif
#if defined(__STDC__) && !defined(UNIXCPP)
#define GetOldReq(name, req, old_length) \
WORD64ALIGN\
if ((dpy->bufptr + SIZEOF(x##name##Req)) > dpy->bufmax)\
_XFlush(dpy);\
req = (x##name##Req *)(dpy->last_req = dpy->bufptr);\
req->reqType = X_##name;\
req->length = old_length>>2;\
dpy->bufptr += old_length;\
dpy->request++
#else
#define GetOldReq(name, req, old_length) \
WORD64ALIGN\
if ((dpy->bufptr + SIZEOF(xnameReq)) > dpy->bufmax)\
_XFlush(dpy);\
req = (xnameReq *)(dpy->last_req = dpy->bufptr);\
req->reqType = X_name;\
req->length = old_length>>2;\
dpy->bufptr += old_length;\
dpy->request++
#endif
#ifndef vms
#include <X11/Xlibint.h>
#else
#define SyncHandle() \
if (dpy->synchandler) (*dpy->synchandler)(dpy)
#define LockDisplay(dis) \
{ globalref char ctl$gb_soft_ast_disable; \
globalref char ctl$gb_lib_lock; \
globalref short ctl$gw_soft_ast_lock_depth; \
if ( ctl$gb_soft_ast_disable == 0 ) { \
ctl$gb_soft_ast_disable = 1; \
ctl$gb_lib_lock = 1; \
ctl$gw_soft_ast_lock_depth = 1; \
} \
else ctl$gw_soft_ast_lock_depth++; \
}
#define UnlockDisplay(dis) \
{ globalref char ctl$gb_reenable_asts; \
globalref char ctl$gb_soft_ast_disable; \
globalref char ctl$gb_lib_lock; \
globalref short ctl$gw_soft_ast_lock_depth; \
if (!--ctl$gw_soft_ast_lock_depth) \
if ( ctl$gb_lib_lock ) { \
ctl$gb_lib_lock = 0; \
ctl$gb_soft_ast_disable = 0; \
if (ctl$gb_reenable_asts != 0) \
sys$setast(1); \
} \
}
#define WORD64ALIGN
#if defined(__STDC__) && !defined(UNIXCPP)
#define GetReq(name, req) \
WORD64ALIGN\
if ((dpy->bufptr + SIZEOF(x##name##Req)) > dpy->bufmax)\
_XFlush(dpy);\
req = (x##name##Req *)(dpy->last_req = dpy->bufptr);\
req->reqType = X_##name;\
req->length = (SIZEOF(x##name##Req))>>2;\
dpy->bufptr += SIZEOF(x##name##Req);\
dpy->request++
#else
#define GetReq(name, req) \
WORD64ALIGN\
if ((dpy->bufptr + SIZEOF(xnameReq)) > dpy->bufmax)\
_XFlush(dpy);\
req = (xnameReq *)(dpy->last_req = dpy->bufptr);\
req->reqType = X_name;\
req->length = (SIZEOF(xnameReq))>>2;\
dpy->bufptr += SIZEOF(xnameReq);\
dpy->request++
#endif
#endif
#include <X11/extensions/xtraplib.h>
#include <X11/extensions/xtraplibp.h>
int XEGetVersionRequest(XETC *tc, XETrapGetVersRep *ret)
{
int status = True;
Display *dpy = tc->dpy;
CARD32 X_XTrapGet = tc->extOpcode;
xXTrapGetReq *reqptr;
xXTrapGetVersReply rep;
int numlongs = (SIZEOF(xXTrapGetVersReply) -
SIZEOF(xReply) + SIZEOF(CARD32) -1 ) / SIZEOF(CARD32);
LockDisplay(dpy);
GetReq(XTrapGet,reqptr);
reqptr->minor_opcode = XETrap_GetVersion;
reqptr->protocol = XETrapProtocol;
status = _XReply(dpy,(xReply *)&rep,numlongs,xTrue);
SyncHandle();
UnlockDisplay(dpy);
memcpy((char *)ret,&(rep.data),sizeof(XETrapGetVersRep));
return(status);
}
int XEGetAvailableRequest(XETC *tc, XETrapGetAvailRep *ret)
{
int status = True;
Display *dpy = tc->dpy;
CARD32 X_XTrapGet = tc->extOpcode;
xXTrapGetReq *reqptr;
xXTrapGetAvailReply rep;
int numlongs = (SIZEOF(xXTrapGetAvailReply) -
SIZEOF(xReply) + SIZEOF(CARD32) -1 ) / SIZEOF(CARD32);
LockDisplay(dpy);
GetReq(XTrapGet,reqptr);
reqptr->minor_opcode = XETrap_GetAvailable;
reqptr->protocol = XETrapProtocol;
status = _XReply(dpy,(xReply *)&rep,numlongs,xTrue);
SyncHandle();
UnlockDisplay(dpy);
memcpy((char *)ret,&(rep.data),sizeof(XETrapGetAvailRep));
return(status);
}
static int XEConfigRequest(XETC *tc)
{
int status = True;
Display *dpy = tc->dpy;
CARD32 X_XTrapConfig = tc->extOpcode;
xXTrapConfigReq *reqptr;
if (tc->protocol == 31)
{
GetOldReq(XTrapConfig,reqptr,276);
}
else
{
GetReq(XTrapConfig,reqptr);
}
reqptr->minor_opcode = XETrap_Config;
memcpy((char *)reqptr->config_flags_valid,
(char *)tc->values.v.flags.valid,4);
memcpy((char *)reqptr->config_flags_data,
(char *)tc->values.v.flags.data,4);
memcpy((char *)reqptr->config_flags_req,
(char *)tc->values.v.flags.req,XETrapMaxRequest);
memcpy((char *)reqptr->config_flags_event,
(char *)tc->values.v.flags.event,XETrapMaxEvent);
reqptr->config_max_pkt_size=tc->values.v.max_pkt_size;
reqptr->config_cmd_key=tc->values.v.cmd_key;
XFlush(dpy);
SyncHandle();
tc->dirty = 0L;
return(status);
}
int XEFlushConfig(XETC *tc)
{
return((tc->dirty) ? XEConfigRequest(tc) : True);
}
int XEResetRequest(XETC *tc)
{
int status = True;
Display *dpy = tc->dpy;
CARD32 X_XTrap = tc->extOpcode;
xXTrapReq *reqptr;
status = XEFlushConfig(tc);
if (status == True)
{
GetReq(XTrap,reqptr);
reqptr->minor_opcode = XETrap_Reset;
XFlush(dpy);
SyncHandle();
}
return(status);
}
int XEGetLastInpTimeRequest(XETC *tc, XETrapGetLastInpTimeRep *ret)
{
int status = True;
Display *dpy = tc->dpy;
CARD32 X_XTrap = tc->extOpcode;
xXTrapReq *reqptr;
xXTrapGetLITimReply rep;
int numlongs = (SIZEOF(xXTrapGetLITimReply) -
SIZEOF(xReply) + SIZEOF(CARD32) - 1) / SIZEOF(CARD32);
LockDisplay(dpy);
GetReq(XTrap,reqptr);
reqptr->minor_opcode = XETrap_GetLastInpTime;
status = _XReply(dpy,(xReply *)&rep,numlongs,xTrue);
SyncHandle();
UnlockDisplay(dpy);
ret->last_time=rep.data_last_time;
return(status);
}
int XEStartTrapRequest(XETC *tc)
{
int status = True;
Display *dpy = tc->dpy;
CARD32 X_XTrap = tc->extOpcode;
xXTrapReq *reqptr;
status = XEFlushConfig(tc);
if (status == True)
{
XETrapSetEventHandler(tc, XETrapData, XETrapDispatchXLib);
GetReq(XTrap,reqptr);
reqptr->minor_opcode = XETrap_StartTrap;
XFlush(dpy);
SyncHandle();
BitTrue(tc->values.tc_flags, XETCTrapActive);
}
return(status);
}
int XEStopTrapRequest(XETC *tc)
{
int status = True;
Display *dpy = tc->dpy;
CARD32 X_XTrap = tc->extOpcode;
xXTrapReq *reqptr;
status = XEFlushConfig(tc);
if (status == True)
{
GetReq(XTrap,reqptr);
reqptr->minor_opcode = XETrap_StopTrap;
XFlush(dpy);
SyncHandle();
BitFalse(tc->values.tc_flags, XETCTrapActive);
XETrapSetEventHandler(tc, XETrapData, NULL);
}
return(status);
}
#ifndef _XINPUT
int XESimulateXEventRequest(XETC *tc, CARD8 type, CARD8 detail,
CARD16 x, CARD16 y, CARD8 screen)
{
int status = True;
Display *dpy = tc->dpy;
CARD32 X_XTrapInput = tc->extOpcode;
xXTrapInputReq *reqptr;
status = XEFlushConfig(tc);
if (status == True)
{
GetReq(XTrapInput,reqptr);
reqptr->minor_opcode = XETrap_SimulateXEvent;
reqptr->input.type = type;
reqptr->input.detail = detail;
reqptr->input.x = x;
reqptr->input.y = y;
reqptr->input.screen = screen;
XFlush(dpy);
}
return(status);
}
#endif
int XEGetCurrentRequest(XETC *tc, XETrapGetCurRep *ret)
{
int status = True;
Display *dpy = tc->dpy;
CARD32 X_XTrap = tc->extOpcode;
xXTrapReq *reqptr;
xXTrapGetCurReply rep;
int numlongs = (SIZEOF(xXTrapGetCurReply) -
SIZEOF(xReply) + SIZEOF(CARD32) -1 ) / SIZEOF(CARD32);
status = XEFlushConfig(tc);
if (status == True)
{
LockDisplay(dpy);
GetReq(XTrap,reqptr);
reqptr->minor_opcode = XETrap_GetCurrent;
if (tc->protocol == 31)
{
char tmp[284];
numlongs = (284-sizeof(xReply)+sizeof(long)-1)/sizeof(long);
status = _XReply(dpy,(xReply *)tmp,numlongs,xTrue);
memcpy(&rep,tmp,sizeof(rep));
}
else
{
status = _XReply(dpy,(xReply *)&rep,numlongs,xTrue);
}
SyncHandle();
UnlockDisplay(dpy);
memcpy((char *)ret->state_flags,rep.data_state_flags,2);
memcpy((char *)ret->config.flags.valid,rep.data_config_flags_valid,4);
memcpy((char *)ret->config.flags.data,rep.data_config_flags_data,4);
memcpy((char *)ret->config.flags.req,rep.data_config_flags_req,
XETrapMaxRequest);
memcpy((char *)ret->config.flags.event,rep.data_config_flags_event,
XETrapMaxEvent);
ret->config.max_pkt_size=rep.data_config_max_pkt_size;
ret->config.cmd_key=rep.data_config_cmd_key;
}
return(status);
}
int XEGetStatisticsRequest(XETC *tc, XETrapGetStatsRep *ret)
{
int status = True;
Display *dpy = tc->dpy;
CARD32 X_XTrap = tc->extOpcode;
xXTrapReq *reqptr;
xXTrapGetStatsReply rep;
status = XEFlushConfig(tc);
if (status == True)
{
LockDisplay(dpy);
GetReq(XTrap,reqptr);
reqptr->minor_opcode = XETrap_GetStatistics;
#ifndef CRAY
if (tc->protocol == 31)
{
#ifndef VECTORED_EVENTS
int numlongs = (1060-sizeof(xReply)+sizeof(long)-1)/sizeof(long);
#else
int numlongs = (1544-sizeof(xReply)+sizeof(long)-1)/sizeof(long);
#endif
status = _XReply(dpy,(xReply *)&rep,numlongs,xTrue);
if (status == True)
{
xXTrapGetStatsReply tmp;
tmp = rep;
memcpy(&(rep.data),&(tmp.pad0), sizeof(rep.data));
}
}
else
#endif
{
int numbytes = SIZEOF(xXTrapGetStatsReply) - SIZEOF(xReply);
status = _XReply(dpy, (xReply *)&rep, 0, xFalse);
if (status == True)
{
status = _XRead(dpy, (char *)&rep.data, numbytes);
}
}
SyncHandle();
UnlockDisplay(dpy);
memcpy(ret,&(rep.data),sizeof(XETrapGetStatsRep));
}
return(status);
}