1 /* $XFree86$ */ 2 #ifndef __XTRAPDI__ 3 #define __XTRAPDI__ 4 5 /***************************************************************************** 6 Copyright 1987, 1988, 1989, 1990, 1991, 1992, 1994 by Digital Equipment Corp., 7 Maynard, MA 8 9 Permission to use, copy, modify, and distribute this software and its 10 documentation for any purpose and without fee is hereby granted, 11 provided that the above copyright notice appear in all copies and that 12 both that copyright notice and this permission notice appear in 13 supporting documentation, and that the name of Digital not be 14 used in advertising or publicity pertaining to distribution of the 15 software without specific, written prior permission. 16 17 DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING 18 ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL 19 DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR 20 ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, 21 WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, 22 ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS 23 SOFTWARE. 24 25 *****************************************************************************/ 26 /* 27 * 28 * CONTRIBUTORS: 29 * 30 * Dick Annicchiarico 31 * Robert Chesler 32 * Dan Coutu 33 * Gene Durso 34 * Marc Evans 35 * Alan Jamison 36 * Mark Henry 37 * Ken Miller 38 * 39 * DESCRIPTION: 40 * This header file defines the common structures/constants 41 * between the XTrap extension and clients. All protocol 42 * definitions between XTrap extension/clients can be found 43 * here. 44 */ 45 46 #define NEED_REPLIES 47 #define NEED_EVENTS 48 #include <X11/X.h> 49 #include <X11/Xmd.h> 50 #ifdef SMT 51 #define NEED_EVENTS 52 #define NEED_REPLIES 53 #endif 54 #include <X11/Xproto.h> 55 #include <X11/extensions/xtrapbits.h> 56 #define XTrapExtName "DEC-XTRAP" 57 /* Current Release, Version, and Revision of the XTrap Extension */ 58 #define XETrapRelease 3L 59 #define XETrapVersion 4L 60 #ifndef XETrapRevision /* Changed from the Makefile by users */ 61 # define XETrapRevision 0L 62 #endif /* XETrapRevision */ 63 #define XETrapProtocol 32L 64 65 #ifndef SIZEOF 66 # ifdef __STDC__ 67 # define SIZEOF(x) sz_##x 68 # else 69 # define SIZEOF(x) sz_/**/x 70 # endif /* if ANSI C compiler else not */ 71 #endif 72 #ifndef sz_CARD32 73 #define sz_CARD32 4L 74 #endif 75 #ifndef sz_CARD8 76 #define sz_CARD8 1L 77 #endif 78 #ifndef True 79 # define True 1L 80 # define False 0L 81 #endif 82 83 /* This is used as flags to indicate desired request traps 84 * Note: This has been padded to a CARD32 to keep structure aligned 85 */ 86 #define XETrapMaxRequest (((SIZEOF(CARD32)+((256L-1L) / \ 87 (BitsInByte*SIZEOF(CARD8))))/SIZEOF(CARD32))*SIZEOF(CARD32)) 88 typedef CARD8 ReqFlags[XETrapMaxRequest]; 89 90 /* This is used as flags to indicate desired event traps 91 * Until events become *fully vectored*, we'll have to fake it 92 * by defining an array of 5 events (KeyPress, KeyRelease, 93 * ButtonPress, ButtonRelease, and MotionNotify. The extra 2 94 * are required as the event types start with "2" (errors and 95 * replies are 0 & 1). The event type is the index into the 96 * bits. 97 * Note: This has been padded to a longword to keep structure aligned 98 */ 99 #ifndef VECTORED_EVENTS 100 #define XETrapCoreEvents (2L+5L) 101 #else 102 #define XETrapCoreEvents 128L 103 #endif 104 #define XETrapMaxEvent (((SIZEOF(CARD32)+((XETrapCoreEvents-1L) / \ 105 (BitsInByte*SIZEOF(CARD8))))/SIZEOF(CARD32))*SIZEOF(CARD32)) 106 typedef CARD8 EventFlags[XETrapMaxEvent]; 107 108 /* This structure is used in a request to specify the types of 109 * configuration information that should be changed or updated. 110 */ 111 typedef struct 112 { 113 CARD8 valid[4L]; /* Bits TRUE indicates data field is used */ 114 CARD8 data[4L]; /* Bits looked at if corresponding valid bit set */ 115 ReqFlags req; /* Bits correspond to core requests */ 116 EventFlags event; /* Bits correspond to core events */ 117 } XETrapFlags; 118 119 /* Bit definitions for the above XETrapFlags structure. */ 120 #define XETrapTimestamp 0L /* hdr timestamps desired */ 121 #define XETrapCmd 1L /* command key specified */ 122 #define XETrapCmdKeyMod 2L /* cmd key is a modifier */ 123 #define XETrapRequest 3L /* output requests array */ 124 #define XETrapEvent 4L /* future output events array */ 125 #define XETrapMaxPacket 5L /* Maximum packet length set */ 126 #define XETrapTransOut 6L /* obsolete */ 127 #define XETrapStatistics 7L /* collect counts on requests */ 128 #define XETrapWinXY 8L /* Fill in Window (X,Y) in hdr */ 129 #define XETrapTransIn 9L /* obsolete */ 130 #define XETrapCursor 10L /* Trap cursor state changes */ 131 #define XETrapXInput 11L /* Use XInput extension */ 132 #define XETrapVectorEvents 12L /* Use Vectored Events (128) */ 133 #define XETrapColorReplies 13L /* Return replies with Color Req's */ 134 #define XETrapGrabServer 14L /* Disables client GrabServers */ 135 136 typedef struct /* used by XEConfigRequest */ 137 { 138 XETrapFlags flags; /* Flags to specify what should be chg'd */ 139 CARD16 max_pkt_size; /* Maximum number of bytes in a packet */ 140 CARD8 cmd_key; /* Keyboard command_key (KeyCode) */ 141 /* 142 * cmd_key is intentionally *not* defined KeyCode since it's definition is 143 * ambiguous (int in Intrinsic.h and unsigned char in X.h. 144 */ 145 CARD8 pad[1L]; /* pad out to a quadword */ 146 } XETrapCfg; 147 148 /* These structures are used within the Xtrap request structure for 149 * the various types of xtrap request 150 */ 151 #ifndef _XINPUT 152 /* (see the definition of XEvent as a reference) */ 153 typedef struct /* used by XESimulateXEventRequest for synthesizing core evts */ 154 { 155 CARD8 type; /* (must be first) as in XEvent */ 156 CARD8 detail; /* Detail keycode/button as in XEvent */ 157 CARD8 screen; /* screen number (0 to n) */ 158 CARD8 pad; /* pad to longword */ 159 INT16 x; /* X & Y coord as in XEvent */ 160 INT16 y; 161 } XETrapInputReq; 162 #endif 163 164 /* These are constants that refer to the extension request vector table. 165 * A request will use these values as minor opcodes. 166 */ 167 #define XETrap_Reset 0L /* set to steady state */ 168 #define XETrap_GetAvailable 1L /* get available funct from ext */ 169 #define XETrap_Config 2L /* configure extension */ 170 #define XETrap_StartTrap 3L /* use Trapping */ 171 #define XETrap_StopTrap 4L /* stop using Trapping */ 172 #define XETrap_GetCurrent 5L /* get current info from ext */ 173 #define XETrap_GetStatistics 6L /* get count statistics from ext */ 174 #ifndef _XINPUT 175 #define XETrap_SimulateXEvent 7L /* async input simulation */ 176 #endif 177 #define XETrap_GetVersion 8L /* Get (Just) Version */ 178 #define XETrap_GetLastInpTime 9L /* Get Timestamp of last client input */ 179 180 /* The following are formats of a request to the XTRAP 181 * extension. The data-less XTrap requests all use xXTrapReq 182 */ 183 typedef struct 184 { 185 CARD8 reqType; 186 CARD8 minor_opcode; 187 CARD16 length; 188 CARD32 pad; /* Maintain quadword alignment */ 189 } xXTrapReq; 190 /* the following works because all fields are defined as bit (Bnn) fields */ 191 #define sz_xXTrapReq (sizeof(xXTrapReq)) 192 /* For retrieving version/available info (passes lib-side protocol number) */ 193 typedef struct 194 { 195 CARD8 reqType; 196 CARD8 minor_opcode; 197 CARD16 length; 198 CARD16 protocol; /* The xtrap extension protocol number */ 199 CARD16 pad; /* Maintain quadword alignment */ 200 } xXTrapGetReq; 201 /* the following works because all fields are defined as bit (Bnn) fields */ 202 #define sz_xXTrapGetReq (sizeof(xXTrapGetReq)) 203 204 typedef struct 205 { 206 CARD8 reqType; 207 CARD8 minor_opcode; 208 CARD16 length; 209 /* 210 * The following is done so that structure padding wont be 211 * a problem. The request structure contains a shadow for 212 * the XETrapCfg structure. Since the XETrapCfg also has a 213 * substructure (XETrapFlags) this structure is also shadowed. 214 * 215 * The following are a shadow of the XETrapFlags 216 * structure. 217 */ 218 CARD8 config_flags_valid[4L]; 219 CARD8 config_flags_data[4L]; 220 ReqFlags config_flags_req; 221 EventFlags config_flags_event; 222 /* End Shadow (XETrapFlags)*/ 223 CARD16 config_max_pkt_size; /* Max number of bytes in a packet */ 224 CARD8 config_cmd_key; /* Keyboard command_key (KeyCode) */ 225 /* 226 * cmd_key is intentionally *not* defined KeyCode since it's definition is 227 * ambiguous (int in Intrinsic.h and unsigned char in X.h. 228 */ 229 CARD8 config_pad[1L]; /* pad out to a quadword */ 230 /* End Shadow (XETrapCfg) */ 231 CARD32 pad; /* Maintain quadword alignment */ 232 } xXTrapConfigReq; 233 /* the following works because all fields are defined as bit (Bnn) fields */ 234 #define sz_xXTrapConfigReq (sizeof(xXTrapConfigReq)) 235 236 #ifndef _XINPUT 237 typedef struct 238 { 239 CARD8 reqType; 240 CARD8 minor_opcode; 241 CARD16 length; 242 CARD32 pad; /* Maintain quadword alignment */ 243 XETrapInputReq input; 244 } xXTrapInputReq; 245 /* the following works because all fields are defined as bit (Bnn) fields */ 246 #define sz_xXTrapInputReq (sizeof(xXTrapInputReq)) 247 #endif 248 249 250 /* The following structures are used by the server extension to send 251 * information and replies to the client. 252 */ 253 254 /* header for all X replies */ 255 typedef struct 256 { 257 CARD8 type; 258 CARD8 detail; 259 CARD16 sequenceNumber; 260 CARD32 length; 261 } XETrapRepHdr; 262 263 /* Structure of Get Available Functionality reply */ 264 typedef struct 265 { 266 CARD32 pf_ident; /* Contains constant identifying the platform */ 267 CARD16 xtrap_release; /* The xtrap extension release number */ 268 CARD16 xtrap_version; /* The xtrap extension version number */ 269 CARD16 xtrap_revision; /* The xtrap extension revision number */ 270 CARD16 max_pkt_size; /* Maximum number of bytes in a packet */ 271 CARD8 valid[4]; /* What specific configuration flags are valid */ 272 CARD32 major_opcode; /* The major opcode identifying xtrap */ 273 CARD32 event_base; /* The event value we start at */ 274 CARD32 pad0; /* obsolete field */ 275 CARD16 pad1, pad2, pad3; /* obsolete field */ 276 CARD16 xtrap_protocol; /* The xtrap extension protocol number */ 277 INT16 cur_x; /* Current X & Y coord for relative motion */ 278 INT16 cur_y; 279 } XETrapGetAvailRep; 280 281 typedef struct 282 { 283 CARD16 xtrap_release; /* The xtrap extension release number */ 284 CARD16 xtrap_version; /* The xtrap extension version number */ 285 CARD16 xtrap_revision; /* The xtrap extension revision number */ 286 CARD16 xtrap_protocol; /* The xtrap extension protocol number */ 287 } XETrapGetVersRep; 288 289 typedef struct 290 { 291 CARD32 last_time; /* Timestamp of last input time */ 292 } XETrapGetLastInpTimeRep; 293 294 /* Structure of Get Current Configuration Information reply */ 295 typedef struct 296 { 297 CARD8 state_flags[2]; /* Miscellaneous flags, see below #define's */ 298 CARD16 pad0; /* Assure quadword alignment */ 299 XETrapCfg config; /* Current Config information */ 300 CARD32 pad1; 301 } XETrapGetCurRep; 302 303 /* Mask definitions for the above flags. */ 304 #define XETrapTrapActive 0L /* If sending/receiving between client/ext */ 305 306 /* Structure of Get Statistics Information reply */ 307 typedef struct 308 { 309 CARD32 requests[256L]; /* Array containing request counts if trapped */ 310 CARD32 events[XETrapCoreEvents]; /* Array containing event stats */ 311 #ifndef VECTORED_EVENTS 312 CARD32 pad; /* Pad out to a quadword */ 313 #endif 314 } XETrapGetStatsRep; 315 316 #define PF_Other 0L /* server not one of the below */ 317 #define PF_Apollo 10L /* server on Apollo system */ 318 #define PF_ATT 20L /* server on AT&T system */ 319 #define PF_Cray1 30L /* server on Cray 1 system */ 320 #define PF_Cray2 31L /* server on Cray 2 system */ 321 #define PF_DECUltrix 40L /* server on DEC ULTRIX system */ 322 #define PF_DECVMS 41L /* server on DEC VMS system */ 323 #define PF_DECVT1000 42L /* server on DEC-VT1000-terminal */ 324 #define PF_DECXTerm 43L /* server on DEC-X-terminal */ 325 #define PF_DECELN 44L /* server on DEC VAXELN X terminal */ 326 #define PF_DECOSF1 45L /* server on DEC's OSF/1 system */ 327 #define PF_HP9000s800 50L /* server on HP 9000/800 system */ 328 #define PF_HP9000s300 51L /* server on HP 9000/300 system */ 329 #define PF_IBMAT 60L /* server on IBM/AT system */ 330 #define PF_IBMRT 61L /* server on IBM/RT system */ 331 #define PF_IBMPS2 62L /* server on IBM/PS2 system */ 332 #define PF_IBMRS 63L /* server on IBM/RS system */ 333 #define PF_MacII 70L /* server on Mac II system */ 334 #define PF_Pegasus 80L /* server on Tektronix Pegasus system */ 335 #define PF_SGI 90L /* server on Silicon Graphcis system */ 336 #define PF_Sony 100L /* server on Sony system */ 337 #define PF_Sun3 110L /* server on Sun 3 system */ 338 #define PF_Sun386i 111L /* server on Sun 386i system */ 339 #define PF_SunSparc 112L /* server on Sun Sparc system */ 340 341 /* reply sent back by XETrapGetAvailable request */ 342 typedef struct 343 { 344 XETrapRepHdr hdr; 345 XETrapGetAvailRep data; 346 } xXTrapGetAvailReply; 347 /* the following works because all fields are defined as bit (Bnn) fields */ 348 #define sz_xXTrapGetAvailReply sizeof(xXTrapGetAvailReply) 349 350 /* reply sent back by XETrapGetVersion request */ 351 typedef struct 352 { 353 XETrapRepHdr hdr; 354 XETrapGetVersRep data; 355 CARD32 pad0; /* pad out to 32 bytes */ 356 CARD32 pad1; 357 CARD32 pad2; 358 CARD32 pad3; 359 } xXTrapGetVersReply; 360 /* the following works because all fields are defined as bit (Bnn) fields */ 361 #define sz_xXTrapGetVersReply sizeof(xXTrapGetVersReply) 362 363 /* reply sent back by XETrapGetLastInpTime request */ 364 typedef struct 365 { 366 XETrapRepHdr hdr; 367 /* 368 * The following is a shadow of the XETrapGetLastInpTimeRep 369 * structure. This is done to avoid structure padding. 370 */ 371 CARD32 data_last_time; /* Timestamp of last input time */ 372 CARD32 pad0; /* pad out to 32 bytes */ 373 CARD32 pad1; 374 CARD32 pad2; 375 CARD32 pad3; 376 CARD32 pad4; 377 } xXTrapGetLITimReply; 378 /* the following works because all fields are defined as bit (Bnn) fields */ 379 #define sz_xXTrapGetLITimReply sizeof(xXTrapGetLITimReply) 380 381 /* reply sent back by XETrapGetCurrent request */ 382 typedef struct 383 { 384 XETrapRepHdr hdr; 385 /* 386 * The following is a shadow of the XETrapGetCurRep 387 * structure. This is done to avoid structure padding. 388 * Since the XETrapGetCurRep structure contains a sub-structure 389 * (XETrapCfg) there is a shadow for that as well.*/ 390 CARD8 data_state_flags[2]; /* Misc flags, see below #define's */ 391 CARD16 data_pad0; /* Assure quadword alignment */ 392 /* XETrapCfg Shadow Starts */ 393 CARD8 data_config_flags_valid[4L]; 394 CARD8 data_config_flags_data[4L]; 395 ReqFlags data_config_flags_req; 396 EventFlags data_config_flags_event; 397 CARD16 data_config_max_pkt_size; /* Max num of bytes in a pkt */ 398 CARD8 data_config_cmd_key; /* Keyboard cmd_key (KeyCode) */ 399 /* 400 * cmd_key is intentionally *not* defined KeyCode since it's definition is 401 * ambiguous (int in Intrinsic.h and unsigned char in X.h. 402 */ 403 CARD8 data_config_pad[1L]; /* pad out to a quadword */ 404 /* End Shadow (XETrapCfg) */ 405 CARD32 pad1; 406 } xXTrapGetCurReply; 407 /* the following works because all fields are defined as bit (Bnn) fields */ 408 #define sz_xXTrapGetCurReply sizeof(xXTrapGetCurReply) 409 410 /* reply sent back by XETrapGetStatistics request */ 411 /* Note: 412 * The following does *not* use the standard XETrapRepHdr, but instead 413 * one which is padded out to 32-bytes. This is because Cray's have a problem 414 * reading arrays of CARD32s without using the _Read32 macro (see XERqsts.c). 415 * This requires that none of the data be in the _Reply area. 416 */ 417 typedef struct 418 { 419 CARD8 type; 420 CARD8 detail; 421 CARD16 sequenceNumber; 422 CARD32 length; 423 CARD32 pad0; 424 CARD32 pad1; 425 CARD32 pad2; 426 CARD32 pad3; 427 CARD32 pad4; 428 CARD32 pad5; 429 XETrapGetStatsRep data; 430 } xXTrapGetStatsReply; 431 #define sz_xXTrapGetStatsReply 1088 432 433 typedef struct /* the XTrap Output header (for output from ext to client) */ 434 { /* this must be quadword aligned for portability */ 435 CARD32 count; /* Length including this header */ 436 CARD32 timestamp; /* timestamp if desired */ 437 CARD8 type; /* event id, request id, special id */ 438 CARD8 screen; /* screen number (0 to n) */ 439 INT16 win_x; /* X coord of drawable, if any */ 440 INT16 win_y; /* X coord of drawable, if any */ 441 CARD16 client; /* to distinguish requests */ 442 } XETrapHeader; 443 /* the following works because all fields are defined as bit (Bnn) fields */ 444 #define sz_XETrapHeader sizeof(XETrapHeader) 445 446 #define XETrapHeaderIsEvent(phdr) (XETrapGetHeaderType(phdr) == 0x1L) 447 #define XETrapHeaderIsRequest(phdr) (XETrapGetHeaderType(phdr) == 0x2L) 448 #define XETrapHeaderIsSpecial(phdr) (XETrapGetHeaderType(phdr) == 0x3L) 449 #define XETrapHeaderIsCursor(phdr) (XETrapGetHeaderType(phdr) == 0x4L) 450 #define XETrapHeaderIsReply(phdr) (XETrapGetHeaderType(phdr) == 0x5L) 451 452 /* Define a structure used for reading/writing datum of type XTrap */ 453 typedef struct 454 { 455 XETrapHeader hdr; 456 union 457 { 458 xEvent event; 459 xResourceReq req; 460 xGenericReply reply; 461 /* special? */ 462 } u; 463 } XETrapDatum; 464 465 /* this doesn't get picked up for VMS server builds (different Xproto.h) */ 466 #ifndef sz_xEvent 467 #define sz_xEvent 32 468 #endif 469 /* Minimum size of a packet from the server extension */ 470 #define XETrapMinPktSize (SIZEOF(XETrapHeader) + SIZEOF(xEvent)) 471 472 /* Constants used with the XLIB transport */ 473 #define XETrapDataStart 0L /* Used in the detail field */ 474 #define XETrapDataContinued 1L /* Used in the detail field */ 475 #define XETrapDataLast 2L /* Used in the detail field */ 476 #define XETrapData 0L /* Used in the type field */ 477 #define XETrapNumberEvents 1L 478 /* This is the representation on the wire(see also XLib.h) */ 479 #define sz_EventData 24L /* 32 bytes - type, detail, seq, index */ 480 typedef struct { 481 CARD8 type; 482 CARD8 detail; 483 CARD16 sequenceNumber; 484 CARD32 idx; 485 CARD8 data[sz_EventData]; 486 } xETrapDataEvent; 487 488 /* Error message indexes added to X for extension */ 489 #define BadIO 2L /* Can't read/write */ 490 #define BadStatistics 4L /* Stat's not avail. */ 491 #define BadDevices 5L /* Devices not vectored */ 492 #define BadScreen 7L /* Can't send event to given screen */ 493 #define BadSwapReq 8L /* Can't send swapped extension requests */ 494 #define XETrapNumErrors (BadSwapReq + 1) 495 496 497 #define XEKeyIsClear 0 498 #define XEKeyIsEcho 1 499 #define XEKeyIsOther 2 500 501 #endif /* __XTRAPDI__ */ 502