/*
 *	$Header: Xproto.h,v 1.66 87/06/01 15:53:13 sue Exp $
 */

/* Definitions for the X window system used by server and c bindings */

/*
 * This packet-construction scheme makes the following assumptions:
 *
 * 1. The compiler is able
 * to generate code which addresses one- and two-byte quantities.
 * In the worst case, this would be done with bit-fields.  If bit-fields
 * are used it may be necessary to reorder the request fields in this file,
 * depending on the order in which the machine assigns bit fields to
 * machine words.  There may also be a problem with sign extension,
 * as K+R specify that bitfields are always unsigned.
 *
 * 2. 2- and 4-byte fields in packet structures must be ordered by hand
 * such that they are naturally-aligned, so that no compiler will ever
 * insert padding bytes.
 *
 * 3. All packets are hand-padded to a multiple of 4 bytes, for
 * the same reason.
 */

#ifndef XPROTO←H
#define XPROTO←H

/***********************************************************
Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts,
and the Massachusetts Institute of Technology, Cambridge, Massachusetts.

                        All Rights Reserved

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 names of Digital or MIT 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.

******************************************************************/

#include "Xmd.h"  
#include "Xprotostr.h"

/* For the purpose of the structure definitions in this file,
we must redefine the following types in terms of Xmd.h's types, which may
include bit fields.  All of these are #undef'd at the end of this file,
restoring the definitions in X.h.  */

#ifdef princops
#define CARD8 int
#define INT8 int
#define BYTE int
#define BOOL int
#endif

#define Window CARD32
#define Drawable CARD32
#define Font CARD32
#define Pixmap CARD32
#define Cursor CARD32
#define Colormap CARD32
#define GContext CARD32
#define Atom CARD32
#define VisualID CARD32
#define Time CARD32
#define KeyCode CARD8
#define KeySym CARD32

#define X←TCP←PORT 6000     /* add display number */

#define xTrue        1
#define xFalse       0


typedef CARD16 KeyButMask;

/***************** 
   connection setup structure.  This is followed by
   numRoots xWindowRoot structs.
*****************/

typedef struct {
    CARD8	byteOrder B8;
    BYTE	pad B8;
    CARD16	majorVersion B16, minorVersion B16;
    CARD16	nbytesAuthProto B16;	/* Authorization protocol */
    CARD16	nbytesAuthString B16;	/* Authorization string */
    CARD16	pad2;
} xConnClientPrefix;

typedef struct {
    BOOL           success B8;
    BYTE           pad1 B8;
    CARD16         majorVersion B16, 
                   minorVersion B16;
    CARD16         length B16;  /* 1/4 additional bytes in setup info */
} xConnSetupPrefix;

typedef struct {
    CARD32         release B32;
    CARD32         ridBase B32, 
                   ridMask B32;
    CARD32         motionBufferSize B32;
    CARD16         nbytesVendor B16;  /* number of bytes in vendor string */
    CARD16         maxRequestSize B16;
    CARD8          numRoots B8;          /* number of roots structs to follow */
    CARD8          numFormats B8;        /* number of pixmap formats */
    CARD8          imageByteOrder B8;        /* LSBFirst, MSBFirst */
    CARD8          bitmapBitOrder B8;        /* LeastSignificant, MostSign...*/
    CARD8          bitmapScanlineUnit B8,     /* 8, 16, 32 */
                   bitmapScanlinePad B8;     /* 8, 16, 32 */
    KeyCode	   minKeyCode B8, maxKeyCode B8;
    CARD32	   pad2 B32;
} xConnSetup;

typedef struct {
    CARD8          depth B8;
    CARD8          bitsPerPixel B8;
    CARD8          scanLinePad B8;
    CARD8          pad1 B8;
    CARD32	   pad2 B32;
} xPixmapFormat;

/* window root */

typedef struct {
    CARD8 	depth B8;
    CARD8 	pad1 B8;
    CARD16	nVisuals B16;  /* number of xVisualType structures following */
    CARD32	pad2 B32;
    } xDepth;

typedef struct {
    VisualID visualID B32;
    CARD8 class B8;
    CARD8 bitsPerRGB B8;
    CARD16 colormapEntries B16;
    CARD32 redMask B32, greenMask B32, blueMask B32;
    CARD32 pad B32;
    } xVisualType;

typedef struct {
    Window         windowId B32;
    Colormap       defaultColormap B32;
    CARD32         whitePixel B32, blackPixel B32;
    CARD32         currentInputMask B32;   
    CARD16         pixWidth B16, pixHeight B16;
    CARD16         mmWidth B16, mmHeight B16;
    CARD16         minInstalledMaps B16, maxInstalledMaps B16;
    VisualID       rootVisualID B32;
    CARD8          backingStore B8;
    BOOL           saveUnders B8;
    CARD8          rootDepth B8;
    CARD8          nDepths B8;  /* number of xDepth structures following */
} xWindowRoot;


/*****************************************************************
 * Structure Defns
 *   Structures needed for replies 
 *****************************************************************/

/* Used in GetMotionEvents */

typedef struct {
    CARD32 time B32;
    CARD16 x B16, y B16;
} xTimecoord;

typedef struct {
    CARD8 family B8;
    BYTE pad B8;
    CARD16 length B16;
} xHostEntry;

typedef struct {
    INT16 leftSideBearing B16,
	  rightSideBearing B16,
	  characterWidth B16,
	  ascent B16,
	  descent B16;
    CARD16 attributes B16;
} xCharInfo;

typedef struct {
    Atom name B32;
    CARD32 value B32;
} xFontProp;

/*
 * non-aligned big-endian font ID follows this struct
 */
typedef struct {           /* followed by string */
    INT8 len B8;	/* number of *characters* in string, or FontChange (255)
		   for font change, or 0 if just delta given */
    INT8 delta B8;
} xTextElt;


typedef struct {        
    CARD32 pixel B32;
    CARD16 red B16, green B16, blue B16;
    CARD8 flags B8;  /* DoRed, DoGreen, DoBlue booleans */
    CARD8 pad B8;
} xColorItem;


typedef struct {
    CARD16 red B16, green B16, blue B16, pad B16;
} xrgb;

typedef CARD8 KEYCODE;


/*****************
 * XRep:
 *    meant to be 32 byte quantity 
 *****************/

#ifdef NEED←REPLIES

/* GenericReply is the common format of all replies.  The "data" items
   are specific to each individual reply type. */

typedef struct {	
    BYTE type B8;              /* X←Reply */
    BYTE data1 B8;             /* depends on reply type */
    CARD16 sequenceNumber B16;  /* of last request received by server */
    CARD32 length B32;      /* 4 byte quantities beyond size of GenericReply */
    CARD32 data00 B32;
    CARD32 data01 B32;
    CARD32 data02 B32;
    CARD32 data03 B32;
    CARD32 data04 B32;
    CARD32 data05 B32;
    } xGenericReply;

/* Individual reply formats. */

typedef struct {
    BYTE type B8;  /* X←Reply */
    CARD8 backingStore B8;
    CARD16 sequenceNumber B16;
    CARD32 length B32;	/* NOT 0; this is an extra-large reply */
    VisualID visualID B32;
    CARD16 class B16;
    CARD8 bitGravity B8;
    CARD8 winGravity B8;
    CARD32 backingBitPlanes B32;
    CARD32 backingPixel B32;
    BOOL saveUnder B8;
    BOOL mapInstalled B8;
    CARD8 mapState B8;
    BOOL override B8;
    Colormap colormap B32;
    CARD32 allEventMasks B32;
    CARD32 yourEventMask B32;
    CARD16 doNotPropagateMask B16;
    CARD16 pad B16;
    } xGetWindowAttributesReply;

typedef struct {
    BYTE type B8;   /* X←Reply */
    CARD8 depth B8;
    CARD16 sequenceNumber B16;
    CARD32 length B32;  /* 0 */
    Window root B32;
    INT16 x B16, y B16;
    CARD16 width B16, height B16;
    CARD16 borderWidth B16;
    CARD16 pad1 B16;
    CARD32 pad2 B32;
    CARD32 pad3 B32;
    } xGetGeometryReply;

typedef struct {
    BYTE type B8;  /* X←Reply */
    BYTE pad1 B8;
    CARD16 sequenceNumber B16;
    CARD32 length B32;
    Window root B32, parent B32;
    CARD16 nChildren B16;
    CARD16 pad2 B16;
    CARD32 pad3 B32;
    CARD32 pad4 B32;
    CARD32 pad5 B32;
    } xQueryTreeReply;

typedef struct {
    BYTE type B8;  /* X←Reply */
    BYTE pad1 B8;
    CARD16 sequenceNumber B16;
    CARD32 length B32; /* 0 */
    Atom atom B32;
    CARD32 pad2 B32;
    CARD32 pad3 B32;
    CARD32 pad4 B32;
    CARD32 pad5 B32;
    CARD32 pad6 B32;
    } xInternAtomReply;

typedef struct {
    BYTE type B8;  /* X←Reply */
    BYTE pad1 B8;
    CARD16 sequenceNumber B16;
    CARD32 length B32;  /* of additional bytes */
    CARD16 nameLength B16;  /* # of characters in name */
    CARD16 pad2 B16;
    CARD32 pad3 B32;
    CARD32 pad4 B32;
    CARD32 pad5 B32;
    CARD32 pad6 B32;
    CARD32 pad7 B32;
    } xGetAtomNameReply;

typedef struct {
    BYTE type B8;  /* X←Reply */
    CARD8 format B8;
    CARD16 sequenceNumber B16;
    CARD32 length B32; /* of additional bytes */
    Atom propertyType B32;
    CARD32 bytesAfter B32;
    CARD32 nItems B32; /* # of 8, 16, or 32-bit entities in reply */
    CARD32 pad1 B32;
    CARD32 pad2 B32;
    CARD32 pad3 B32;
    } xGetPropertyReply;

typedef struct {
    BYTE type B8;  /* X←Reply */
    BYTE pad1 B8;
    CARD16 sequenceNumber B16;
    CARD32 length B32;
    CARD16 nProperties B16;
    CARD16 pad2 B16;
    CARD32 pad3 B32;
    CARD32 pad4 B32;
    CARD32 pad5 B32;
    CARD32 pad6 B32;
    CARD32 pad7 B32;
    } xListPropertiesReply;

typedef struct {
    BYTE type B8;  /* X←Reply */
    BYTE pad1 B8;
    CARD16 sequenceNumber B16;
    CARD32 length B32;  /* 0 */
    Window owner B32;
    CARD32 pad2 B32;
    CARD32 pad3 B32;
    CARD32 pad4 B32;
    CARD32 pad5 B32;
    CARD32 pad6 B32;
    } xGetSelectionOwnerReply;

typedef struct {
    BYTE type B8;  /* X←Reply */
    BYTE status B8;
    CARD16 sequenceNumber B16;
    CARD32 length B32;  /* 0 */
    CARD32 pad1 B32;
    CARD32 pad2 B32;
    CARD32 pad3 B32;
    CARD32 pad4 B32;
    CARD32 pad5 B32;
    CARD32 pad6 B32;
    } xGrabPointerReply;

typedef xGrabPointerReply xGrabKeyboardReply;

typedef struct {
    BYTE type B8;  /* X←Reply */
    BOOL sameScreen B8;
    CARD16 sequenceNumber B16;
    CARD32 length B32;  /* 0 */
    Window root B32, child B32;
    INT16 rootX B16, rootY B16, winX B16, winY B16;
    CARD16 mask B16;
    CARD16 pad1 B16;
    CARD32 pad B32;
    } xQueryPointerReply;

typedef struct {
    BYTE type B8;  /* X←Reply */
    BYTE pad1 B8;
    CARD16 sequenceNumber B16;
    CARD32 length B32;
    CARD32 nEvents B32;
    CARD32 pad2 B32;
    CARD32 pad3 B32;
    CARD32 pad4 B32;
    CARD32 pad5 B32;
    CARD32 pad6 B32;
    } xGetMotionEventsReply;

typedef struct {
    BYTE type B8;  /* X←Reply */
    BOOL sameScreen B8;
    CARD16 sequenceNumber B16;
    CARD32 length B32; /* 0 */
    Window child B32;
    INT16 dstX B16, dstY B16;
    CARD32 pad2 B32;
    CARD32 pad3 B32;
    CARD32 pad4 B32;
    CARD32 pad5 B32;
    } xTranslateCoordsReply;

typedef struct {
    BYTE type B8;  /* X←Reply */
    CARD8 revertTo B8;
    CARD16 sequenceNumber B16;
    CARD32 length B32;  /* 0 */
    Window focus B32;
    CARD32 pad1 B32;
    CARD32 pad2 B32;
    CARD32 pad3 B32;
    CARD32 pad4 B32;
    CARD32 pad5 B32;
    } xGetInputFocusReply;

typedef struct {
    BYTE type B8;  /* X←Reply */
    BYTE pad1 B8;
    CARD16 sequenceNumber B16;
    CARD32 length B32;  /* 2, NOT 0; this is an extra-large reply */
    /*BYTE*/char map[32];
    } xQueryKeymapReply;

typedef struct {
    BYTE type B8;  /* X←Reply */
    BYTE pad1 B8;
    CARD16 sequenceNumber B16;
    CARD32 length B32;  /* definitely > 0, even if "nCharInfos" is 0 */
    xCharInfo minBounds; 
#ifndef WORD64
    CARD32 walign1 B32;
#endif
    xCharInfo maxBounds; 
#ifndef WORD64
    CARD32 walign2 B32;
#endif
    CARD16 minCharOrByte2 B16, maxCharOrByte2 B16;
    CARD16 defaultChar B16;
    CARD16 nFontProps B16;  /* followed by this many xFontProp structures */
    CARD8 drawDirection B8;
    CARD8 minByte1 B8, maxByte1 B8;
    BOOL allCharsExist B8;
    INT16 fontAscent B16, fontDescent B16;
    CARD32 nCharInfos B32; /* followed by this many xCharInfo structures */
} xQueryFontReply;

typedef struct {
    BYTE type B8;  /* X←Reply */
    CARD8 drawDirection B8;
    CARD16 sequenceNumber B16;
    CARD32 length B32;  /* 0 */
    INT16 fontAscent B16, fontDescent B16;
    INT16 overallAscent B16, overallDescent B16;
    INT32 overallWidth B32, overallLeft B32, overallRight B32;
    CARD32 pad B32;
    } xQueryTextExtentsReply;

typedef struct {
    BYTE type B8;  /* X←Reply */
    BYTE pad1 B8;
    CARD16 sequenceNumber B16;
    CARD32 length B32;
    CARD16 nFonts B32;
    CARD16 pad2 B16;
    CARD32 pad3 B32;
    CARD32 pad4 B32;
    CARD32 pad5 B32;
    CARD32 pad6 B32;
    CARD32 pad7 B32;
    } xListFontsReply;

typedef xListFontsReply xListFontsWithInfoReply;
   /* what follows reply structure is different,
      but reply structure is identical */

typedef struct {
    BYTE type B8;  /* X←Reply */
    BYTE pad1 B8;
    CARD16 sequenceNumber B16;
    CARD32 length B32;
    CARD16 nPaths B16;
    CARD16 pad2 B16;
    CARD32 pad3 B32;
    CARD32 pad4 B32;
    CARD32 pad5 B32;
    CARD32 pad6 B32;
    CARD32 pad7 B32;
    } xGetFontPathReply;

typedef struct {
    BYTE type B8;  /* X←Reply */
    CARD8 depth B8;
    CARD16 sequenceNumber B16;
    CARD32 length B32;
    VisualID visual B32;
    CARD32 pad3 B32;
    CARD32 pad4 B32;
    CARD32 pad5 B32;
    CARD32 pad6 B32;
    CARD32 pad7 B32;
    } xGetImageReply;

typedef struct {
    BYTE type B8;  /* X←Reply */
    BYTE pad1 B8;
    CARD16 sequenceNumber B16;
    CARD32 length B32;
    CARD16 nColormaps B16;
    CARD16 pad2 B16;
    CARD32 pad3 B32;
    CARD32 pad4 B32;
    CARD32 pad5 B32;
    CARD32 pad6 B32;
    CARD32 pad7 B32;
    } xListInstalledColormapsReply;

typedef struct {
    BYTE type B8; /* X←Reply */
    BYTE pad1 B8;
    CARD16 sequenceNumber B16;
    CARD32 length B32;   /* 0 */
    CARD16 red B16, green B16, blue B16;
    CARD16 pad2 B16;
    CARD32 pixel B32;
    CARD32 pad3 B32;
    CARD32 pad4 B32;
    CARD32 pad5 B32;
    } xAllocColorReply;

typedef struct {
    BYTE type B8; /* X←Reply */
    BYTE pad1 B8;
    CARD16 sequenceNumber B16;
    CARD32 length B32;  /* 0 */
    CARD32 pixel B32;
    CARD16 exactRed B16, exactGreen B16, exactBlue B16;
    CARD16 screenRed B16, screenGreen B16, screenBlue B16;
    CARD32 pad2 B32;
    CARD32 pad3 B32;
    } xAllocNamedColorReply;

typedef struct {
    BYTE type B8;  /* X←Reply */
    BYTE pad1 B8;
    CARD16 sequenceNumber B16;
    CARD32 length B32;
    CARD16 nPixels B16, nMasks B16;
    CARD32 pad3 B32;
    CARD32 pad4 B32;
    CARD32 pad5 B32;
    CARD32 pad6 B32;
    CARD32 pad7 B32;
    } xAllocColorCellsReply;

typedef struct {
    BYTE type B8; /* X←Reply */
    BYTE pad1 B8;
    CARD16 sequenceNumber B16;
    CARD32 length B32;
    CARD16 nPixels B16;
    CARD16 pad2 B16;
    CARD32 redMask B16, greenMask B16, blueMask B16;
    CARD32 pad3 B32;
    CARD32 pad4 B32;
    } xAllocColorPlanesReply;

typedef struct {
    BYTE type B8; /* X←Reply */
    BYTE pad1 B8;
    CARD16 sequenceNumber B16;
    CARD32 length B32;
    CARD16 nColors B16;
    CARD16 pad2 B16;
    CARD32 pad3 B32;
    CARD32 pad4 B32;
    CARD32 pad5 B32;
    CARD32 pad6 B32;
    CARD32 pad7 B32;
    } xQueryColorsReply;

typedef struct {
    BYTE type B8;  /* X←Reply */
    BYTE pad1 B8;
    CARD16 sequenceNumber B16;
    CARD32 length B32;  /* 0 */
    CARD16 exactRed B16, exactGreen B16, exactBlue B16;
    CARD16 screenRed B16, screenGreen B16, screenBlue B16;
    CARD32 pad3 B32;
    CARD32 pad4 B32;
    CARD32 pad5 B32;
    } xLookupColorReply;

typedef struct {
    BYTE type B8;  /* X←Reply */
    BYTE pad1 B8;
    CARD16 sequenceNumber B16;
    CARD32 length B32;  /* 0 */
    CARD16 width B16, height B16;
    CARD32 pad3 B32;
    CARD32 pad4 B32;
    CARD32 pad5 B32;
    CARD32 pad6 B32;
    CARD32 pad7 B32;
    } xQueryBestSizeReply;

typedef struct {
    BYTE type B8;  /* X←Reply */
    BYTE pad1 B8;
    CARD16 sequenceNumber B16;
    CARD32 length B32; /* 0 */
    BOOL  present B8;
    CARD8 major←opcode B8;
    CARD8 first←event B8;
    CARD8 first←error B8;
    CARD32 pad3 B32;
    CARD32 pad4 B32;
    CARD32 pad5 B32;
    CARD32 pad6 B32;
    CARD32 pad7 B32;
    } xQueryExtensionReply;

typedef struct {
    BYTE type B8;  /* X←Reply */
    CARD8 nExtensions B8;
    CARD16 sequenceNumber B16;
    CARD32 length B32;
    CARD32 pad2 B32;
    CARD32 pad3 B32;
    CARD32 pad4 B32;
    CARD32 pad5 B32;
    CARD32 pad6 B32;
    CARD32 pad7 B32;
    } xListExtensionsReply;


typedef struct {
    BYTE   type B8;  /* X←Reply */
    CARD8  success B8;
    CARD16 sequenceNumber B16;
    CARD32 length B32;
    CARD32 pad2 B32;
    CARD32 pad3 B32;
    CARD32 pad4 B32;
    CARD32 pad5 B32;
    CARD32 pad6 B32;
    CARD32 pad7 B32;
    } xSetMappingReply;
typedef xSetMappingReply xSetPointerMappingReply;
typedef xSetMappingReply xSetModifierMappingReply;

typedef struct {
    BYTE type B8;  /* X←Reply */
    CARD8 nElts B8;  /* how many elements does the map have */
    CARD16 sequenceNumber B16;
    CARD32 length B32;
    CARD32 pad2 B32;
    CARD32 pad3 B32;
    CARD32 pad4 B32;
    CARD32 pad5 B32;
    CARD32 pad6 B32;
    CARD32 pad7 B32;
    } xGetPointerMappingReply;

typedef struct {
    BYTE type B8;
    CARD8 keySymsPerKeyCode B8;
    CARD16 sequenceNumber B16;
    CARD32 length B32;
    CARD32 pad2 B32;
    CARD32 pad3 B32;
    CARD32 pad4 B32;
    CARD32 pad5 B32;
    CARD32 pad6 B32;
    CARD32 pad7 B32;
} xGetKeyboardMappingReply;    

typedef struct {
    BYTE type B8;
    KeyCode lock B8;
    CARD16 sequenceNumber B16;
    CARD32 length B32;  /* 0 */
    KeyCode shiftA B8, shiftB B8;
    KeyCode controlA B8, controlB B8;
    KeyCode mod1A B8, mod1B B8;
    KeyCode mod2A B8, mod2B B8;
    KeyCode mod3A B8, mod3B B8;
    KeyCode mod4A B8, mod4B B8;
    KeyCode mod5A B8, mod5B B8;
    CARD16 pad1 B16;
    CARD32 pad2 B32;
    CARD32 pad3 B32;
} xGetModifierMappingReply;

typedef struct {
    BYTE type B8;  /* X←Reply */
    BOOL globalAutoRepeat B8;
    CARD16 sequenceNumber B16;
    CARD32 length B32;  /* 5 */
    CARD32 ledMask B32;
    CARD8 keyClickPercent B8, bellPercent B8;
    CARD16 bellPitch B16, bellDuration B16;
    CARD16 pad B16;
    /*BYTE*/char map[32];  /* bit masks start here */
    } xGetKeyboardControlReply;

typedef struct {
    BYTE type B8;  /* X←Reply */
    BYTE pad1 B8;
    CARD16 sequenceNumber B16;
    CARD32 length B32;  /* 0 */
    CARD16 accelNumerator B16, accelDenominator B16;
    CARD16 threshold B16;
    CARD16 pad2 B16;
    CARD32 pad3 B32;
    CARD32 pad4 B32;
    CARD32 pad5 B32;
    CARD32 pad6 B32;
    } xGetPointerControlReply;

typedef struct {
    BYTE type B8;  /* X←Reply */
    BYTE pad1 B8;
    CARD16 sequenceNumber B16;
    CARD32 length B32;  /* 0 */
    CARD16 timeout B16, interval B16;
    BOOL preferBlanking B8;
    BOOL allowExposures B8;
    CARD16 pad2 B16;
    CARD32 pad3 B32;
    CARD32 pad4 B32;
    CARD32 pad5 B32;
    CARD32 pad6 B32;
    } xGetScreenSaverReply;

typedef struct {
    BYTE type B8;  /* X←Reply */
    BOOL enabled B8;
    CARD16 sequenceNumber B16;
    CARD32 length B32;
    CARD16 nHosts B16;
    CARD16 pad1 B16;
    CARD32 pad3 B32;
    CARD32 pad4 B32;
    CARD32 pad5 B32;
    CARD32 pad6 B32;
    CARD32 pad7 B32;
    } xListHostsReply;

#endif /* NEED←REPLIES */




/*****************************************************************
 * Xerror
 *    All errors  are 32 bytes 
 *****************************************************************/

typedef struct {
    BYTE type B8;                  /* X←Error */
    BYTE errorCode B8;
    CARD16 sequenceNumber B16;       /* the nth request from this client */
    CARD32 resourceID B32;
    CARD16 minorCode B16;
    CARD8 majorCode B8;
    BYTE pad1 B8;
    CARD32 pad3 B32;
    CARD32 pad4 B32;
    CARD32 pad5 B32;
    CARD32 pad6 B32;
    CARD32 pad7 B32;
} xError;

/*****************************************************************
 * xEvent
 *    All events are 32 bytes
 *****************************************************************/

#ifdef NEED←EVENTS                /* this hack is necessary because
				     the symbol table in the library
				     is too big to link */

typedef struct {
    union {
	struct {
	    BYTE type B8;
	    BYTE detail B8;
	    CARD16 sequenceNumber B16;
	    } u;
	struct {
            CARD32 pad00 B32;
	    Time time B32;
	    Window root B32, event B32, child B32;
	    INT16 rootX B16, rootY B16, eventX B16, eventY B16;
	    KeyButMask state B16;
	    BOOL sameScreen B8;		
	    BYTE pad1 B8;
	} keyButtonPointer;
	struct {
            CARD32 pad00 B32;
            Time time B32;
	    Window root B32, event B32, child B32;
	    INT16 rootX B16, rootY B16, eventX B16, eventY B16;
	    KeyButMask state B16;
	    BYTE mode B8; 			/* really XMode */
	    BYTE flags B8;		/* sameScreen and focus booleans, packed together */
#define ELFlagFocus        (1<<0)
#define ELFlagSameScreen   (1<<1)
	} enterLeave;
	struct {
            CARD32 pad00 B32;
	    Window window B32;
	    BYTE mode B8; 			/* really XMode */
	    BYTE pad1 B8, pad2 B8, pad3 B8;
	} focus;
	struct {
            CARD32 pad00 B32;
	    Window window B32;
	    CARD16 x B16, y B16, width B16, height B16;
	    CARD16 count B16;
	    CARD16 pad2 B16;
	} expose;
	struct {
            CARD32 pad00 B32;
	    Drawable drawable B32;
	    CARD16 x B16, y B16, width B16, height B16;
	    CARD16 minorEvent B16;
	    CARD16 count B16;
	    BYTE majorEvent B8;
	    BYTE pad1 B8, pad2 B8, pad3 B8;
	} graphicsExposure;
	struct {
            CARD32 pad00 B32;
	    Drawable drawable B32;
	    CARD16 minorEvent B16;
	    BYTE majorEvent B8;
	    BYTE bpad B8;
	} noExposure;
	struct {
            CARD32 pad00 B32;
	    Window window B32;
	    CARD8 state B8;
	    BYTE pad1 B8, pad2 B8, pad3 B8;
	} visibility;
	struct {
            CARD32 pad00 B32;
	    Window parent B32, window B32;
	    INT16 x B16, y B16;
	    CARD16 width B16, height B16, borderWidth B16;
	    BOOL override B8;
	    BYTE bpad B8;
        } createNotify;
/*
 * The event feilds in the structures for DestroyNotify, UnmapNotify,
 * MapNotify, ReparentNotify, ConfigureNotify, CirclulateNotify, GravityNotify,
 * must be at the same offset because server internal code is depending upon
 * this to patch up the events before they are delivered.
 * Also note that MapRequest, ConfigureRequest and CirculateRequest have
 * the same offset for the event window.
 */
	struct {
            CARD32 pad00 B32;
	    Window event B32, window B32;
	} destroyNotify;
	struct {
            CARD32 pad00 B32;
	    Window event B32, window B32;
	    BOOL fromConfigure B8;
	    BYTE pad1 B8, pad2 B8, pad3 B8;
        } unmapNotify;
	struct {
            CARD32 pad00 B32;
	    Window event B32, window B32;
	    BOOL override B8;
	    BYTE pad1 B8, pad2 B8, pad3 B8;
        } mapNotify;
	struct {
            CARD32 pad00 B32;
	    Window parent B32, window B32;
        } mapRequest;
	struct {
            CARD32 pad00 B32;
	    Window event B32, window B32, parent B32;
	    INT16 x B16, y B16;
	    BOOL override B8;
	    BYTE pad1 B8, pad2 B8, pad3 B8;
	} reparent;
	struct {
            CARD32 pad00 B32;
	    Window event B32, window B32, aboveSibling B32;
	    INT16 x B16, y B16;
	    CARD16 width B16, height B16, borderWidth B16;
	    BOOL override B8;		
	    BYTE bpad B8;
	} configureNotify;
	struct {
            CARD32 pad00 B32;
	    Window parent B32, window B32, aboveSibling B32;
	    INT16 x B16, y B16;
	    CARD16 width B16, height B16, borderWidth B16;
	    CARD16 pad1;
	} configureRequest;
	struct {
            CARD32 pad00 B32;
	    Window event B32, window B32;
	    INT16 x B16, y B16;
	    CARD32 pad1, pad2, pad3, pad4;
	} gravity;
	struct {
            CARD32 pad00 B32;
	    Window window B32;
	    CARD16 width B16, height B16;
	} resizeRequest;
	struct {
/* The event field in the circulate record is really the parent when this
   is used as a CirculateRequest insteaad of a CircluateNotify */
            CARD32 pad00 B32;
	    Window event B32, window B32, parent B32;
	    BYTE place B8;			/* Top or Bottom */
	    BYTE pad1 B8, pad2 B8, pad3 B8;
	} circulate;
	struct {
            CARD32 pad00 B32;
	    Window window B32;
	    Atom atom B32;
	    Time time B32;
	    BYTE state B8;			/* NewValue or Deleted */
	    BYTE pad1 B8;
	    CARD16 pad2 B16;
	} property;
	struct {
            CARD32 pad00 B32;
            Time time B32;     
	    Window window B32;
	    Atom atom B32;
	} selectionClear;
	struct {
            CARD32 pad00 B32;
            Time time B32;    
	    Window owner B32, requestor B32;
	    Atom selection B32, target B32, property B32;
	} selectionRequest;
	struct {
            CARD32 pad00 B32;
            Time time B32;   
	    Window requestor B32;
	    Atom selection B32, target B32, property B32;
	} selectionNotify;
	struct {
            CARD32 pad00 B32;
	    Window window B32;
	    Colormap colormap B32;
	    BOOL new B8;		
	    BYTE state B8;			/* Installed or UnInstalled */
	    BYTE pad1 B8, pad2 B8;
	} colormap;
	struct {
	    CARD32 pad00 B32;
	    CARD8 request B8;
	    KeyCode firstKeyCode B8;
	    CARD8 count B8;
	    BYTE pad1 B8;
	} mappingNotify;
	struct {
            CARD32 pad00 B32;
	    Window window B32;
	    union {
		struct {
		    Atom type B32;
		    INT32 longs0 B32;
		    INT32 longs1 B32;
		    INT32 longs2 B32;
		    INT32 longs3 B32;
		    INT32 longs4 B32;
		} l;
		struct {
		    Atom type B32;
		    INT16 shorts0 B16;
		    INT16 shorts1 B16;
		    INT16 shorts2 B16;
		    INT16 shorts3 B16;
		    INT16 shorts4 B16;
		    INT16 shorts5 B16;
		    INT16 shorts6 B16;
		    INT16 shorts7 B16;
		    INT16 shorts8 B16;
		    INT16 shorts9 B16;
		} s;
		struct {
		    Atom type B32;
		    /*INT8*/ char bytes[20];
		} b;
	    } u; 
	} clientMessage;
    } u;
} xEvent;

/* KeymapNotify events are not included in the above union because they
   are different from all other events: they do not have a "detail"
   or "sequenceNumber", so there is room for a 248-bit key mask. */

typedef struct {
    BYTE type B8;
    /*BYTE*/ char map[31];
    } xKeymapEvent;

#endif /* NEED←EVENTS */

#define XEventSize (sizeof(xEvent))

/* XReply is the union of all the replies above whose "fixed part"
fits in 32 bytes.  It does NOT include GetWindowAttributesReply,
QueryFontReply, QueryKeymapReply, or GetKeyboardControlReply */

#ifdef NEED←REPLIES

typedef union {
    xGenericReply generic;
    xGetGeometryReply geom;
    xQueryTreeReply tree;
    xInternAtomReply atom;
    xGetAtomNameReply atomName;
    xGetPropertyReply property;
    xListPropertiesReply listProperties;
    xGetSelectionOwnerReply selection;
    xGrabPointerReply grabPointer;
    xGrabKeyboardReply grabKeyboard;
    xQueryPointerReply pointer;
    xGetMotionEventsReply motionEvents;
    xTranslateCoordsReply coords;
    xGetInputFocusReply inputFocus;
    xQueryTextExtentsReply textExtents;
    xListFontsReply fonts;
    xListFontsWithInfoReply fontInfos;
    xGetFontPathReply fontPath;
    xGetImageReply image;
    xListInstalledColormapsReply colormaps;
    xAllocColorReply allocColor;
    xAllocNamedColorReply allocNamedColor;
    xAllocColorCellsReply colorCells;
    xAllocColorPlanesReply colorPlanes;
    xQueryColorsReply colors;
    xLookupColorReply lookupColor;
    xQueryBestSizeReply bestSize;
    xQueryExtensionReply extension;
    xListExtensionsReply extensions;
    xSetModifierMappingReply setModifierMapping;
    xGetModifierMappingReply getModifierMapping;
    xSetPointerMappingReply setPointerMapping;
    xGetKeyboardMappingReply getKeyboardMapping;
    xGetPointerMappingReply getPointerMapping;
    xGetPointerControlReply pointerControl;
    xGetScreenSaverReply screenSaver;
    xListHostsReply hosts;
    xError error;
#ifdef NEED←EVENTS
    xEvent event;
#endif /* NEED←EVENTS */
} xReply;

#endif /* NEED←REPLIES */



/*****************************************************************
 * REQUESTS
 *****************************************************************/


/* Request structure */

typedef struct {
	CARD8 reqType B8;
	CARD8 data B8;            /* meaning depends on request type */
	CARD16 length B16;         /* length in 4 bytes quantities 
				  of whole request, including this header */
} xReq;

/*****************************************************************
 *  structures that follow request. 
 *****************************************************************/

/* ResourceReq is used for any request which has a resource ID 
   (or Atom or Time) as its one and only argument.  */

typedef struct {
    CARD8 reqType B8;
    BYTE pad B8;
    CARD16 length B16;
    CARD32 id;  /* a Window, Drawable, Font, GContext, Pixmap, etc. */
    } xResourceReq;

typedef struct {
    CARD8 reqType B8;
    CARD8 depth B8;
    CARD16 length B16;
    Window wid B32, parent B32;
    INT16 x B16, y B16;
    CARD16 width B16, height B16, borderWidth B16;  
    CARD16 class B16;
    VisualID visual B32;
    CARD32 mask B32;
} xCreateWindowReq;

typedef struct {
    CARD8 reqType B8;
    BYTE pad B8;
    CARD16 length B16;
    Window window B32;
    CARD32 valueMask B32; 
} xChangeWindowAttributesReq;

typedef struct {
    CARD8 reqType B8;
    BYTE mode B8;
    CARD16 length B16;
    Window window B32;
} xChangeSaveSetReq;

typedef struct {
    CARD8 reqType B8;
    BYTE pad B8;
    CARD16 length B16;
    Window window B32, parent B32;
    INT16 x B16, y B16;
} xReparentWindowReq;

typedef struct {
    CARD8 reqType B8;
    CARD8 pad B8;
    CARD16 length B16;
    Window window B32;
    CARD16 mask B16;
    CARD16 pad2 B16;
} xConfigureWindowReq;

typedef struct {
    CARD8 reqType B8;
    CARD8 direction B8;
    CARD16 length B16;
    Window window B32;
} xCirculateWindowReq;

typedef struct {    /* followed by padded string */
    CARD8 reqType B8;
    BOOL onlyIfExists B8;
    CARD16 length B16;
    CARD16 nbytes  B16;    /* number of bytes in string */
    CARD16 pad B16;
} xInternAtomReq;

typedef struct {
    CARD8 reqType B8;
    CARD8 mode B8;
    CARD16 length B16;
    Window window B32;
    Atom property B32, type B32;
    CARD8 format B8;
    BYTE pad1 B8, pad2 B8, pad3 B8;
    CARD32 nUnits B32;     /* length of stuff following, depends on format */
} xChangePropertyReq;

typedef struct {
    CARD8 reqType B8;
    BYTE pad B8;
    CARD16 length B16;
    Window window B32;
    Atom property B32;
} xDeletePropertyReq;

typedef struct {
    CARD8 reqType B8;
    BOOL delete B8;
    CARD16 length B16;
    Window window B32;
    Atom property B32, type B32;
    CARD32 longOffset B32;
    CARD32 longLength B32;
} xGetPropertyReq;
 
typedef struct {
    CARD8 reqType B8;
    BYTE pad B8;
    CARD16 length B16;
    Window window B32;
    Atom selection B32;
    Time time B32;
} xSetSelectionOwnerReq;

typedef struct {
    CARD8 reqType B8;
    BYTE pad B8;
    CARD16 length B16;
    Window requestor B32;
    Atom selection B32, target B32, property B32;
    Time time B32;
    } xConvertSelectionReq;

#ifdef NEED←EVENTS

typedef struct {
    CARD8 reqType B8;
    BOOL propagate B8;
    CARD16 length B16;
    Window destination B32;
    CARD32 eventMask B32;
    xEvent event;
} xSendEventReq;

#endif /* NEED←EVENTS */

typedef struct {
    CARD8 reqType B8;
    BOOL ownerEvents B8;
    CARD16 length B16;
    Window grabWindow B32;
    CARD16 eventMask B16;
    BYTE pointerMode B8, keyboardMode B8;
    Window confineTo B32;
    Cursor cursor B32;
    Time time B32;
} xGrabPointerReq;

typedef struct {
    CARD8 reqType B8;
    BOOL ownerEvents B8;
    CARD16 length B16;
    Window grabWindow B32;
    CARD16 eventMask B16;
    BYTE pointerMode B8, keyboardMode B8;
    Window confineTo B32;
    Cursor cursor B32;
    CARD8 button B8;
    BYTE pad B8;
    CARD16 modifiers B16;
} xGrabButtonReq;

typedef struct {
    CARD8 reqType B8;
    CARD8 button B8;
    CARD16 length B16;
    Window grabWindow B32;
    CARD16 modifiers B16;
    CARD16 pad B16;
} xUngrabButtonReq;

typedef struct {
    CARD8 reqType B8;
    BYTE pad B8;
    CARD16 length B16;
    Cursor cursor B32;
    Time time B32;
    CARD16 eventMask B16;
    CARD16 pad2 B16;
} xChangeActivePointerGrabReq;

typedef struct {
    CARD8 reqType B8;
    BOOL ownerEvents B8;
    CARD16 length B16;
    Window grabWindow B32;
    Time time B32;
    BYTE pointerMode B8, keyboardMode B8;  
    CARD16 pad B16;
} xGrabKeyboardReq;

typedef struct {
    CARD8 reqType B8;
    BOOL ownerEvents B8;
    CARD16 length B16;
    Window grabWindow B32;
    CARD16 modifiers B16;
    CARD8 key B8;
    BYTE pointerMode B8, keyboardMode B8;  
    BYTE pad1 B8, pad2 B8, pad3 B8;
} xGrabKeyReq;

typedef struct {
    CARD8 reqType B8;
    CARD8 key B8;
    CARD16 length B16;
    Window grabWindow B32;
    CARD16 modifiers B16;
    CARD16 pad B16;
} xUngrabKeyReq;

typedef struct {
    CARD8 reqType B8;
    CARD8 mode B8;
    CARD16 length B16;
    Time time B32;
} xAllowEventsReq;

typedef struct {
    CARD8 reqType B8;
    BYTE pad B8;
    CARD16 length B16;
    Window window B32;
    Time start B32, stop B32;
} xGetMotionEventsReq;

typedef struct {
    CARD8 reqType B8;
    BYTE pad B8;
    CARD16 length B16;
    Window srcWid B32, dstWid B32;
    INT16 srcX B16, srcY B16;
} xTranslateCoordsReq;

typedef struct {
    CARD8 reqType B8;
    BYTE pad B8;
    CARD16 length B16;
    Window srcWid B32, dstWid B32;
    INT16 srcX B16, srcY B16;
    CARD16 srcWidth B16, srcHeight B16;
    INT16 dstX B16, dstY B16;
} xWarpPointerReq;

typedef struct {
    CARD8 reqType B8;
    CARD8 revertTo B8;
    CARD16 length B16;
    Window focus B32;
    Time time B32;
} xSetInputFocusReq;

typedef struct {
    CARD8 reqType B8;
    BYTE pad B8;
    CARD16 length B16;
    Font fid B32;
    CARD16 nbytes B16;
    BYTE pad1 B8, pad2 B8;	/* string follows on word boundary */
} xOpenFontReq;

typedef struct {
    CARD8 reqType B8;
    BOOL oddLength B8;
    CARD16 length B16;
    Font fid B32;
    } xQueryTextExtentsReq;

typedef struct {
    CARD8 reqType B8;
    BYTE pad B8;
    CARD16 length B16;
    CARD16 maxNames B16;
    CARD16 nbytes B16;  /* followed immediately by string bytes */
} xListFontsReq;

typedef xListFontsReq xListFontsWithInfoReq;

typedef struct {
    CARD8 reqType B8;
    BYTE pad B8;
    CARD16 length B16;
    CARD16 nFonts B16;
    BYTE pad1 B8, pad2 B8;	/* LISTofSTRING8 follows on word boundary */
} xSetFontPathReq;

typedef struct {
    CARD8 reqType B8;
    CARD8 depth B8;
    CARD16 length B16;
    Pixmap pid B32;
    Drawable drawable B32;
    CARD16 width B16, height B16;
} xCreatePixmapReq;

typedef struct {
    CARD8 reqType B8;
    BYTE pad B8;
    CARD16 length B16;
    GContext gc B32;
    Drawable drawable B32;
    CARD32 mask B32;
} xCreateGCReq;

typedef struct {
    CARD8 reqType B8;
    BYTE pad B8;
    CARD16 length B16;
    GContext gc B32;
    CARD32 mask B32;
} xChangeGCReq;    

typedef struct {
    CARD8 reqType B8;
    BYTE pad B8;
    CARD16 length B16;
    GContext srcGC B32, dstGC B32;
    CARD32 mask B32;
} xCopyGCReq;    

typedef struct {
    CARD8 reqType B8;
    BYTE pad B8;
    CARD16 length B16;
    GContext gc B32;
    CARD16 dashOffset B16;
    CARD16 nDashes B16;        /* length LISTofCARD8 of values following */
} xSetDashesReq;    

typedef struct {
    CARD8 reqType B8;
    BYTE ordering B8;
    CARD16 length B16;
    GContext gc B32;
    INT16 xOrigin B16, yOrigin B16;
} xSetClipRectanglesReq;    

typedef struct {
    CARD8 reqType B8;
    BOOL exposures B8;
    CARD16 length B16;
    Window window B32;
    INT16 x B16, y B16;
    CARD16 width B16, height B16;
} xClearAreaReq;

typedef struct {
    CARD8 reqType B8;
    BYTE pad B8;
    CARD16 length B16;
    Drawable srcDrawable B32, dstDrawable B32;
    GContext gc B32;
    INT16 srcX B16, srcY B16, dstX B16, dstY B16;
    CARD16 width B16, height B16;
} xCopyAreaReq;    

typedef struct {
    CARD8 reqType B8;
    BYTE pad B8;
    CARD16 length B16;
    Drawable srcDrawable B32, dstDrawable B32;
    GContext gc B32;
    INT16 srcX B16, srcY B16, dstX B16, dstY B16;
    CARD16 width B16, height B16;
    CARD32 bitPlane B32;
} xCopyPlaneReq;    

typedef struct {
    CARD8 reqType B8;
    BYTE coordMode B8;
    CARD16 length B16;
    Drawable drawable B32;
    GContext gc B32;
} xPolyPointReq;    

typedef xPolyPointReq xPolyLineReq;  /* same request structure */

/* The following used for PolySegment, PolyRectangle, PolyArc, PolyFillRectangle, PolyFillArc */

typedef struct {
    CARD8 reqType B8;
    BYTE pad B8;
    CARD16 length B16;
    Drawable drawable B32;
    GContext gc B32;
} xPolySegmentReq;    

typedef xPolySegmentReq xPolyArcReq;
typedef xPolySegmentReq xPolyRectangleReq;
typedef xPolySegmentReq xPolyFillRectangleReq;
typedef xPolySegmentReq xPolyFillArcReq;

typedef struct ←FillPolyReq {
    CARD8 reqType B8;
    BYTE pad B8;
    CARD16 length B16;
    Drawable drawable B32;
    GContext gc B32;
    BYTE shape B8;
    BYTE coordMode B8;
    CARD16 pad1 B16;
} xFillPolyReq;    


typedef struct ←PutImageReq {
    CARD8 reqType B8;
    CARD8 format B8;
    CARD16 length B16;
    Drawable drawable B32;
    GContext gc B32;
    CARD16 width B16, height B16;
    INT16 dstX B16, dstY B16;
    CARD8 leftPad B8;
    CARD8 depth B8;
    CARD16 pad B16;
} xPutImageReq;    

typedef struct {
    CARD8 reqType B8;
    CARD8 format B8;
    CARD16 length B16;
    Drawable drawable B32;
    INT16 x B16, y B16;
    CARD16 width B16, height B16;
    CARD32 planeMask B32;
} xGetImageReq;    

/* the folloiwng used by PolyText8 and PolyText16 */

typedef struct {
    CARD8 reqType B8;
    CARD8 pad B8;
    CARD16 length B16;
    Drawable drawable B32;
    GContext gc B32;
    INT16 x B16, y B16;		/* items (xTextElt) start after struct */
} xPolyTextReq;    

typedef xPolyTextReq xPolyText8Req;
typedef xPolyTextReq xPolyText16Req;

typedef struct {
    CARD8 reqType B8;
    BYTE nChars B8;
    CARD16 length B16;
    Drawable drawable B32;
    GContext gc B32;
    INT16 x B16, y B16;
} xImageTextReq;    

typedef xImageTextReq xImageText8Req;
typedef xImageTextReq xImageText16Req;

typedef struct {
    CARD8 reqType B8;
    BYTE alloc B8;
    CARD16 length B16;
    Colormap mid B32;
    Window window B32;
    VisualID visual B32;
} xCreateColormapReq;    

typedef struct {
    CARD8 reqType B8;
    BYTE pad B8;
    CARD16 length B16;
    Colormap mid B32;
    Colormap srcCmap B32;
} xCopyColormapAndFreeReq;    

typedef struct {
    CARD8 reqType B8;
    BYTE pad B8;
    CARD16 length B16;
    Colormap cmap B32;
    CARD16 red B16, green B16, blue B16;
    CARD16 pad2 B16;
} xAllocColorReq;    

typedef struct {
    CARD8 reqType B8;
    BYTE pad B8;
    CARD16 length B16;
    Colormap cmap B32;
    CARD16 nbytes B16;  /* followed by structure */
    BYTE pad1 B8, pad2 B8;
} xAllocNamedColorReq;    

typedef struct {
    CARD8 reqType B8;
    BOOL contiguous B8;
    CARD16 length B16;
    Colormap cmap B32;
    CARD16 colors B16, planes B16;
} xAllocColorCellsReq;    

typedef struct {
    CARD8 reqType B8;
    BOOL contiguous B8;
    CARD16 length B16;
    Colormap cmap B32;
    CARD16 colors B16, red B16, green B16, blue B16;
} xAllocColorPlanesReq;    

typedef struct {
    CARD8 reqType B8;
    BYTE pad B8;
    CARD16 length B16;
    Colormap cmap B32;
    CARD32 planeMask B32;
} xFreeColorsReq;    

typedef struct {
    CARD8 reqType B8;
    BYTE pad B8;
    CARD16 length B16;
    Colormap cmap B32;
} xStoreColorsReq;    

typedef struct {
    CARD8 reqType B8;
    CARD8 flags B8;   /* DoRed, DoGreen, DoBlue, as in xColorItem */
    CARD16 length B16;
    Colormap cmap B32;
    CARD32 pixel B32;
    CARD16 nbytes B16;  /* number of name string bytes following structure */
    BYTE pad1 B8, pad2 B8;
    } xStoreNamedColorReq;

typedef struct {
    CARD8 reqType B8;
    BYTE pad B8;
    CARD16 length B16;
    Colormap cmap B32;
} xQueryColorsReq;    

typedef struct {    /* followed  by string of length len */
    CARD8 reqType B8;
    BYTE pad B8;
    CARD16 length B16;
    Colormap cmap B32;
    CARD16 nbytes B16;  /* number of string bytes following structure*/
    BYTE pad1 B8, pad2 B8;
} xLookupColorReq;    

typedef struct {
    CARD8 reqType B8;
    BYTE pad B8;
    CARD16 length B16;
    Cursor cid B32;
    Pixmap source B32, mask B32;
    CARD16 foreRed B16, foreGreen B16, foreBlue B16;
    CARD16 backRed B16, backGreen B16, backBlue B16;
    CARD16 x B16, y B16;
} xCreateCursorReq;    

typedef struct {
    CARD8 reqType B8;
    BYTE pad B8;
    CARD16 length B16;
    Cursor cid B32;
    Font source B32, mask B32;
    CARD16 sourceChar B16, maskChar B16;
    CARD16 foreRed B16, foreGreen B16, foreBlue B16;
    CARD16 backRed B16, backGreen B16, backBlue B16;
} xCreateGlyphCursorReq;    

typedef struct {
    CARD8 reqType B8;
    BYTE pad B8;
    CARD16 length B16;
    Cursor cursor B32;
    CARD16 foreRed B16, foreGreen B16, foreBlue B16;
    CARD16 backRed B16, backGreen B16, backBlue B16;
} xRecolorCursorReq;    

typedef struct {
    CARD8 reqType B8;
    CARD8 class B8;
    CARD16 length B16;
    Drawable drawable B32;
    CARD16 width B16, height B16;
} xQueryBestSizeReq;    

typedef struct {
    CARD8 reqType B8;
    BYTE pad B8;
    CARD16 length B16;
    CARD16 nbytes B16;  /* number of string bytes following structure */
    BYTE pad1 B8, pad2 B8;
} xQueryExtensionReq;

typedef struct {
    CARD8   reqType B8;
    KeyCode lock B8;
    CARD16  length B16;
    KeyCode shiftA B8, shiftB B8;
    KeyCode controlA B8, controlB B8;
    KeyCode mod1A B8, mod1B B8;
    KeyCode mod2A B8, mod2B B8;
    KeyCode mod3A B8, mod3B B8;
    KeyCode mod4A B8, mod4B B8;
    KeyCode mod5A B8, mod5B B8;
    CARD16  pad;
} xSetModifierMappingReq;

typedef struct {
    CARD8 reqType B8;
    CARD8 nElts B8;  /* how many elements in the map */
    CARD16 length B16;
} xSetPointerMappingReq;

typedef struct {
    CARD8 reqType B8;
    BYTE pad B8;
    CARD16 length B16;
    KeyCode firstKeyCode B8;
    CARD8 count B8;
    CARD16 pad1 B16;
} xGetKeyboardMappingReq;    

typedef struct {
    CARD8 reqType B8;
    CARD8 keyCodes B8;
    CARD16 length B16;
    KeyCode firstKeyCode B8;
    CARD8 keySymsPerKeyCode B8;
    CARD16 pad1 B16;
} xChangeKeyboardMappingReq;

typedef struct {
    CARD8 reqType B8;
    BYTE pad B8;
    CARD16 length B16;
    CARD32 mask B32;
} xChangeKeyboardControlReq;    

typedef struct {
    CARD8 reqType B8;
    INT8 percent B8;  /* -100 to 100 */
    CARD16 length B16;
} xBellReq;    

typedef struct {
    CARD8 reqType B8;
    BYTE pad B8;
    CARD16 length B16;
    INT16 accelNum B16, accelDenum B16;
    INT16 threshold B16;             
    BOOL doAccel B8, doThresh B8;
} xChangePointerControlReq;    

typedef struct {
    CARD8 reqType B8;
    BYTE pad B8;
    CARD16 length B16;
    INT16 timeout B16, interval B16;
    BYTE preferBlank B8, allowExpose B8;  
    CARD16 pad2 B16;
} xSetScreenSaverReq;    

typedef struct {
    CARD8 reqType B8;
    BYTE mode B8;
    CARD16 length B16;
    CARD8 hostFamily B8;
    BYTE pad B8;
    CARD16 hostLength B16;
} xChangeHostsReq;    

typedef struct {
    CARD8 reqType B8;
    BYTE pad B8;
    CARD16 length B16;
    } xListHostsReq;

typedef struct {
    CARD8 reqType B8;
    BYTE mode B8;
    CARD16 length B16;
    } xChangeModeReq;

typedef xChangeModeReq xSetAccessControlReq;
typedef xChangeModeReq xSetCloseDownModeReq;
typedef xChangeModeReq xForceScreenSaverReq;

typedef struct { /* followed by LIST of ATOM */
    CARD8 reqType B8;
    BYTE pad B8;
    CARD16 length B16;
    Window window B32;
    CARD16 nAtoms B16;
    INT16 nPositions B16;
    } xRotatePropertiesReq;
    


/* Reply codes */

#define X←Reply		1		/* Normal reply */
#define X←Error		0		/* Error */

/* Request codes */

#define X←CreateWindow                  1              
#define X←ChangeWindowAttributes        2        
#define X←GetWindowAttributes           3     
#define X←DestroyWindow                 4
#define X←DestroySubwindows             5   
#define X←ChangeSaveSet                 6
#define X←ReparentWindow                7
#define X←MapWindow                     8
#define X←MapSubwindows                 9
#define X←UnmapWindow                  10
#define X←UnmapSubwindows              11  
#define X←ConfigureWindow              12  
#define X←CirculateWindow              13  
#define X←GetGeometry                  14
#define X←QueryTree                    15
#define X←InternAtom                   16
#define X←GetAtomName                  17
#define X←ChangeProperty               18 
#define X←DeleteProperty               19 
#define X←GetProperty                  20
#define X←ListProperties               21 
#define X←SetSelectionOwner            22    
#define X←GetSelectionOwner            23    
#define X←ConvertSelection             24   
#define X←SendEvent                    25
#define X←GrabPointer                  26
#define X←UngrabPointer                27
#define X←GrabButton                   28
#define X←UngrabButton                 29
#define X←ChangeActivePointerGrab      30          
#define X←GrabKeyboard                 31
#define X←UngrabKeyboard               32 
#define X←GrabKey                      33
#define X←UngrabKey                    34
#define X←AllowEvents                  35       
#define X←GrabServer                   36      
#define X←UngrabServer                 37        
#define X←QueryPointer                 38        
#define X←GetMotionEvents              39           
#define X←TranslateCoords              40                
#define X←WarpPointer                  41       
#define X←SetInputFocus                42         
#define X←GetInputFocus                43         
#define X←QueryKeymap                  44       
#define X←OpenFont                     45    
#define X←CloseFont                    46     
#define X←QueryFont                    47
#define X←QueryTextExtents             48     
#define X←ListFonts                    49  
#define X←ListFontsWithInfo    	       50 
#define X←SetFontPath                  51 
#define X←GetFontPath                  52 
#define X←CreatePixmap                 53        
#define X←FreePixmap                   54      
#define X←CreateGC                     55    
#define X←ChangeGC                     56    
#define X←CopyGC                       57  
#define X←SetDashes                    58     
#define X←SetClipRectangles            59             
#define X←FreeGC                       60  
#define X←ClearArea                    61             
#define X←CopyArea                     62    
#define X←CopyPlane                    63     
#define X←PolyPoint                    64     
#define X←PolyLine                     65    
#define X←PolySegment                  66       
#define X←PolyRectangle                67         
#define X←PolyArc                      68   
#define X←FillPoly                     69    
#define X←PolyFillRectangle            70             
#define X←PolyFillArc                  71       
#define X←PutImage                     72    
#define X←GetImage                     73 
#define X←PolyText8                    74     
#define X←PolyText16                   75      
#define X←ImageText8                   76      
#define X←ImageText16                  77       
#define X←CreateColormap               78          
#define X←FreeColormap                 79        
#define X←CopyColormapAndFree          80               
#define X←InstallColormap              81           
#define X←UninstallColormap            82             
#define X←ListInstalledColormaps       83                  
#define X←AllocColor                   84      
#define X←AllocNamedColor              85           
#define X←AllocColorCells              86           
#define X←AllocColorPlanes             87            
#define X←FreeColors                   88      
#define X←StoreColors                  89       
#define X←StoreNamedColor              90           
#define X←QueryColors                  91       
#define X←LookupColor                  92       
#define X←CreateCursor                 93        
#define X←CreateGlyphCursor            94             
#define X←FreeCursor                   95      
#define X←RecolorCursor                96         
#define X←QueryBestSize                97         
#define X←QueryExtension               98          
#define X←ListExtensions               99          
#define X←ChangeKeyboardMapping        100
#define X←GetKeyboardMapping           101
#define X←ChangeKeyboardControl        102                
#define X←GetKeyboardControl           103             
#define X←Bell                         104
#define X←ChangePointerControl         105
#define X←GetPointerControl            106
#define X←SetScreenSaver               107          
#define X←GetScreenSaver               108          
#define X←ChangeHosts                  109       
#define X←ListHosts                    110     
#define X←SetAccessControl             111               
#define X←SetCloseDownMode             112
#define X←KillClient                   113 
#define X←RotateProperties	       114
#define X←ForceScreenSaver	       115
#define X←SetPointerMapping            116
#define X←GetPointerMapping            117
#define X←SetModifierMapping	       118
#define X←GetModifierMapping	       119
#define X←NoOperation                  127

/* restore these definitions back to the typedefs in X.h */
#undef Window
#undef Drawable
#undef Font
#undef Pixmap
#undef Cursor
#undef Colormap
#undef GContext
#undef Atom
#undef VisualID
#undef Time
#undef KeyCode
#undef KeySym
#undef CARD8 int
#undef INT8 int
#undef BYTE int
#undef BOOL int

#endif /* XPROTO←H */