1 /* Definitions for the X window system used by server and c bindings */
2 
3 /*
4  * This packet-construction scheme makes the following assumptions:
5  *
6  * 1. The compiler is able
7  * to generate code which addresses one- and two-byte quantities.
8  * In the worst case, this would be done with bit-fields.  If bit-fields
9  * are used it may be necessary to reorder the request fields in this file,
10  * depending on the order in which the machine assigns bit fields to
11  * machine words.  There may also be a problem with sign extension,
12  * as K+R specify that bitfields are always unsigned.
13  *
14  * 2. 2- and 4-byte fields in packet structures must be ordered by hand
15  * such that they are naturally-aligned, so that no compiler will ever
16  * insert padding bytes.
17  *
18  * 3. All packets are hand-padded to a multiple of 4 bytes, for
19  * the same reason.
20  */
21 
22 #ifndef XPROTO_H
23 #define XPROTO_H
24 
25 /***********************************************************
26 
27 Copyright 1987, 1998  The Open Group
28 
29 Permission to use, copy, modify, distribute, and sell this software and its
30 documentation for any purpose is hereby granted without fee, provided that
31 the above copyright notice appear in all copies and that both that
32 copyright notice and this permission notice appear in supporting
33 documentation.
34 
35 The above copyright notice and this permission notice shall be included in
36 all copies or substantial portions of the Software.
37 
38 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
39 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
40 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE
41 OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
42 AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
43 CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
44 
45 Except as contained in this notice, the name of The Open Group shall not be
46 used in advertising or otherwise to promote the sale, use or other dealings
47 in this Software without prior written authorization from The Open Group.
48 
49 
50 Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
51 
52                         All Rights Reserved
53 
54 Permission to use, copy, modify, and distribute this software and its
55 documentation for any purpose and without fee is hereby granted,
56 provided that the above copyright notice appear in all copies and that
57 both that copyright notice and this permission notice appear in
58 supporting documentation, and that the name of Digital not be
59 used in advertising or publicity pertaining to distribution of the
60 software without specific, written prior permission.
61 
62 DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
63 ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
64 DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
65 ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
66 WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
67 ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
68 SOFTWARE.
69 
70 ******************************************************************/
71 
72 #include <X11/Xmd.h>
73 #include <X11/Xprotostr.h>
74 
75 /*
76  * Define constants for the sizes of the network packets.  The sz_ prefix is
77  * used instead of something more descriptive so that the symbols are no more
78  * than 32 characters in length (which causes problems for some compilers).
79  */
80 #define sz_xSegment 8
81 #define sz_xPoint 4
82 #define sz_xRectangle 8
83 #define sz_xArc 12
84 #define sz_xConnClientPrefix 12
85 #define sz_xConnSetupPrefix 8
86 #define sz_xConnSetup 32
87 #define sz_xPixmapFormat 8
88 #define sz_xDepth 8
89 #define sz_xVisualType 24
90 #define sz_xWindowRoot 40
91 #define sz_xTimecoord 8
92 #define sz_xHostEntry 4
93 #define sz_xCharInfo 12
94 #define sz_xFontProp 8
95 #define sz_xTextElt 2
96 #define sz_xColorItem 12
97 #define sz_xrgb 8
98 #define sz_xGenericReply 32
99 #define sz_xGetWindowAttributesReply 44
100 #define sz_xGetGeometryReply 32
101 #define sz_xQueryTreeReply 32
102 #define sz_xInternAtomReply 32
103 #define sz_xGetAtomNameReply 32
104 #define sz_xGetPropertyReply 32
105 #define sz_xListPropertiesReply 32
106 #define sz_xGetSelectionOwnerReply 32
107 #define sz_xGrabPointerReply 32
108 #define sz_xQueryPointerReply 32
109 #define sz_xGetMotionEventsReply 32
110 #define sz_xTranslateCoordsReply 32
111 #define sz_xGetInputFocusReply 32
112 #define sz_xQueryKeymapReply 40
113 #define sz_xQueryFontReply 60
114 #define sz_xQueryTextExtentsReply 32
115 #define sz_xListFontsReply 32
116 #define sz_xGetFontPathReply 32
117 #define sz_xGetImageReply 32
118 #define sz_xListInstalledColormapsReply 32
119 #define sz_xAllocColorReply 32
120 #define sz_xAllocNamedColorReply 32
121 #define sz_xAllocColorCellsReply 32
122 #define sz_xAllocColorPlanesReply 32
123 #define sz_xQueryColorsReply 32
124 #define sz_xLookupColorReply 32
125 #define sz_xQueryBestSizeReply 32
126 #define sz_xQueryExtensionReply 32
127 #define sz_xListExtensionsReply 32
128 #define sz_xSetMappingReply 32
129 #define sz_xGetKeyboardControlReply 52
130 #define sz_xGetPointerControlReply 32
131 #define sz_xGetScreenSaverReply 32
132 #define sz_xListHostsReply 32
133 #define sz_xSetModifierMappingReply 32
134 #define sz_xError 32
135 #define sz_xEvent 32
136 #define sz_xKeymapEvent 32
137 #define sz_xReq 4
138 #define sz_xResourceReq 8
139 #define sz_xCreateWindowReq 32
140 #define sz_xChangeWindowAttributesReq 12
141 #define sz_xChangeSaveSetReq 8
142 #define sz_xReparentWindowReq 16
143 #define sz_xConfigureWindowReq 12
144 #define sz_xCirculateWindowReq 8
145 #define sz_xInternAtomReq 8
146 #define sz_xChangePropertyReq 24
147 #define sz_xDeletePropertyReq 12
148 #define sz_xGetPropertyReq 24
149 #define sz_xSetSelectionOwnerReq 16
150 #define sz_xConvertSelectionReq 24
151 #define sz_xSendEventReq 44
152 #define sz_xGrabPointerReq 24
153 #define sz_xGrabButtonReq 24
154 #define sz_xUngrabButtonReq 12
155 #define sz_xChangeActivePointerGrabReq 16
156 #define sz_xGrabKeyboardReq 16
157 #define sz_xGrabKeyReq 16
158 #define sz_xUngrabKeyReq 12
159 #define sz_xAllowEventsReq 8
160 #define sz_xGetMotionEventsReq 16
161 #define sz_xTranslateCoordsReq 16
162 #define sz_xWarpPointerReq 24
163 #define sz_xSetInputFocusReq 12
164 #define sz_xOpenFontReq 12
165 #define sz_xQueryTextExtentsReq 8
166 #define sz_xListFontsReq 8
167 #define sz_xSetFontPathReq 8
168 #define sz_xCreatePixmapReq 16
169 #define sz_xCreateGCReq 16
170 #define sz_xChangeGCReq 12
171 #define sz_xCopyGCReq 16
172 #define sz_xSetDashesReq 12
173 #define sz_xSetClipRectanglesReq 12
174 #define sz_xCopyAreaReq 28
175 #define sz_xCopyPlaneReq 32
176 #define sz_xPolyPointReq 12
177 #define sz_xPolySegmentReq 12
178 #define sz_xFillPolyReq 16
179 #define sz_xPutImageReq 24
180 #define sz_xGetImageReq 20
181 #define sz_xPolyTextReq 16
182 #define sz_xImageTextReq 16
183 #define sz_xCreateColormapReq 16
184 #define sz_xCopyColormapAndFreeReq 12
185 #define sz_xAllocColorReq 16
186 #define sz_xAllocNamedColorReq 12
187 #define sz_xAllocColorCellsReq 12
188 #define sz_xAllocColorPlanesReq 16
189 #define sz_xFreeColorsReq 12
190 #define sz_xStoreColorsReq 8
191 #define sz_xStoreNamedColorReq 16
192 #define sz_xQueryColorsReq 8
193 #define sz_xLookupColorReq 12
194 #define sz_xCreateCursorReq 32
195 #define sz_xCreateGlyphCursorReq 32
196 #define sz_xRecolorCursorReq 20
197 #define sz_xQueryBestSizeReq 12
198 #define sz_xQueryExtensionReq 8
199 #define sz_xChangeKeyboardControlReq 8
200 #define sz_xBellReq 4
201 #define sz_xChangePointerControlReq 12
202 #define sz_xSetScreenSaverReq 12
203 #define sz_xChangeHostsReq 8
204 #define sz_xListHostsReq 4
205 #define sz_xChangeModeReq 4
206 #define sz_xRotatePropertiesReq 12
207 #define sz_xReply 32
208 #define sz_xGrabKeyboardReply 32
209 #define sz_xListFontsWithInfoReply 60
210 #define sz_xSetPointerMappingReply 32
211 #define sz_xGetKeyboardMappingReply 32
212 #define sz_xGetPointerMappingReply 32
213 #define sz_xGetModifierMappingReply 32
214 #define sz_xListFontsWithInfoReq 8
215 #define sz_xPolyLineReq 12
216 #define sz_xPolyArcReq 12
217 #define sz_xPolyRectangleReq 12
218 #define sz_xPolyFillRectangleReq 12
219 #define sz_xPolyFillArcReq 12
220 #define sz_xPolyText8Req 16
221 #define sz_xPolyText16Req 16
222 #define sz_xImageText8Req 16
223 #define sz_xImageText16Req 16
224 #define sz_xSetPointerMappingReq 4
225 #define sz_xForceScreenSaverReq 4
226 #define sz_xSetCloseDownModeReq 4
227 #define sz_xClearAreaReq 16
228 #define sz_xSetAccessControlReq 4
229 #define sz_xGetKeyboardMappingReq 8
230 #define sz_xSetModifierMappingReq 4
231 #define sz_xPropIconSize 24
232 #define sz_xChangeKeyboardMappingReq 8
233 
234 
235 /* For the purpose of the structure definitions in this file,
236 we must redefine the following types in terms of Xmd.h's types, which may
237 include bit fields.  All of these are #undef'd at the end of this file,
238 restoring the definitions in X.h.  */
239 
240 #define Window CARD32
241 #define Drawable CARD32
242 #define Font CARD32
243 #define Pixmap CARD32
244 #define Cursor CARD32
245 #define Colormap CARD32
246 #define GContext CARD32
247 #define Atom CARD32
248 #define VisualID CARD32
249 #define Time CARD32
250 #define KeyCode CARD8
251 #define KeySym CARD32
252 
253 #define X_TCP_PORT 6000     /* add display number */
254 
255 #define xTrue        1
256 #define xFalse       0
257 
258 
259 typedef CARD16 KeyButMask;
260 
261 /*****************
262    Connection setup structures.  See Chapter 8: Connection Setup
263    of the X Window System Protocol specification for details.
264 *****************/
265 
266 /* Client initiates handshake with this data, followed by the strings
267  * for the auth protocol & data.
268  */
269 typedef struct {
270     CARD8	byteOrder;
271     BYTE	pad;
272     CARD16	majorVersion, minorVersion;
273     CARD16	nbytesAuthProto;	/* Authorization protocol */
274     CARD16	nbytesAuthString;	/* Authorization string */
275     CARD16	pad2;
276 } xConnClientPrefix;
277 
278 /* Server response to xConnClientPrefix.
279  *
280  * If success == Success, this is followed by xConnSetup and
281  * numRoots xWindowRoot structs.
282  *
283  * If success == Failure, this is followed by a reason string.
284  *
285  * The protocol also defines a case of success == Authenticate, but
286  * that doesn't seem to have ever been implemented by the X Consortium.
287  */
288 typedef struct {
289     CARD8          success;
290     BYTE           lengthReason; /*num bytes in string following if failure */
291     CARD16         majorVersion,
292                    minorVersion;
293     CARD16         length;       /* 1/4 additional bytes in setup info */
294 } xConnSetupPrefix;
295 
296 
297 typedef struct {
298     CARD32         release;
299     CARD32         ridBase,
300                    ridMask;
301     CARD32         motionBufferSize;
302     CARD16         nbytesVendor;      /* number of bytes in vendor string */
303     CARD16         maxRequestSize;
304     CARD8          numRoots;          /* number of roots structs to follow */
305     CARD8          numFormats;        /* number of pixmap formats */
306     CARD8          imageByteOrder;        /* LSBFirst, MSBFirst */
307     CARD8          bitmapBitOrder;        /* LeastSignificant, MostSign...*/
308     CARD8          bitmapScanlineUnit,     /* 8, 16, 32 */
309                    bitmapScanlinePad;     /* 8, 16, 32 */
310     KeyCode	   minKeyCode, maxKeyCode;
311     CARD32	   pad2;
312 } xConnSetup;
313 
314 typedef struct {
315     CARD8          depth;
316     CARD8          bitsPerPixel;
317     CARD8          scanLinePad;
318     CARD8          pad1;
319     CARD32	   pad2;
320 } xPixmapFormat;
321 
322 /* window root */
323 
324 typedef struct {
325     CARD8 	depth;
326     CARD8 	pad1;
327     CARD16	nVisuals;  /* number of xVisualType structures following */
328     CARD32	pad2;
329     } xDepth;
330 
331 typedef struct {
332     VisualID visualID;
333 #if defined(__cplusplus) || defined(c_plusplus)
334     CARD8 c_class;
335 #else
336     CARD8 class;
337 #endif
338     CARD8 bitsPerRGB;
339     CARD16 colormapEntries;
340     CARD32 redMask, greenMask, blueMask;
341     CARD32 pad;
342     } xVisualType;
343 
344 typedef struct {
345     Window         windowId;
346     Colormap       defaultColormap;
347     CARD32         whitePixel, blackPixel;
348     CARD32         currentInputMask;
349     CARD16         pixWidth, pixHeight;
350     CARD16         mmWidth, mmHeight;
351     CARD16         minInstalledMaps, maxInstalledMaps;
352     VisualID       rootVisualID;
353     CARD8          backingStore;
354     BOOL           saveUnders;
355     CARD8          rootDepth;
356     CARD8          nDepths;  /* number of xDepth structures following */
357 } xWindowRoot;
358 
359 
360 /*****************************************************************
361  * Structure Defns
362  *   Structures needed for replies
363  *****************************************************************/
364 
365 /* Used in GetMotionEvents */
366 
367 typedef struct {
368     CARD32 time;
369     INT16 x, y;
370 } xTimecoord;
371 
372 typedef struct {
373     CARD8 family;
374     BYTE pad;
375     CARD16 length;
376 } xHostEntry;
377 
378 typedef struct {
379     INT16 leftSideBearing,
380 	  rightSideBearing,
381 	  characterWidth,
382 	  ascent,
383 	  descent;
384     CARD16 attributes;
385 } xCharInfo;
386 
387 typedef struct {
388     Atom name;
389     CARD32 value;
390 } xFontProp;
391 
392 /*
393  * non-aligned big-endian font ID follows this struct
394  */
395 typedef struct {           /* followed by string */
396     CARD8 len;	/* number of *characters* in string, or FontChange (255)
397 		   for font change, or 0 if just delta given */
398     INT8 delta;
399 } xTextElt;
400 
401 
402 typedef struct {
403     CARD32 pixel;
404     CARD16 red, green, blue;
405     CARD8 flags;  /* DoRed, DoGreen, DoBlue booleans */
406     CARD8 pad;
407 } xColorItem;
408 
409 
410 typedef struct {
411     CARD16 red, green, blue, pad;
412 } xrgb;
413 
414 typedef CARD8 KEYCODE;
415 
416 
417 /*****************
418  * XRep:
419  *    meant to be 32 byte quantity
420  *****************/
421 
422 /* GenericReply is the common format of all replies.  The "data" items
423    are specific to each individual reply type. */
424 
425 typedef struct {
426     BYTE type;              /* X_Reply */
427     BYTE data1;             /* depends on reply type */
428     CARD16 sequenceNumber;  /* of last request received by server */
429     CARD32 length;          /* 4 byte quantities beyond size of GenericReply */
430     CARD32 data00;
431     CARD32 data01;
432     CARD32 data02;
433     CARD32 data03;
434     CARD32 data04;
435     CARD32 data05;
436     } xGenericReply;
437 
438 /* Individual reply formats. */
439 
440 typedef struct {
441     BYTE type;  /* X_Reply */
442     CARD8 backingStore;
443     CARD16 sequenceNumber;
444     CARD32 length;	/* NOT 0; this is an extra-large reply */
445     VisualID visualID;
446 #if defined(__cplusplus) || defined(c_plusplus)
447     CARD16 c_class;
448 #else
449     CARD16 class;
450 #endif
451     CARD8 bitGravity;
452     CARD8 winGravity;
453     CARD32 backingBitPlanes;
454     CARD32 backingPixel;
455     BOOL saveUnder;
456     BOOL mapInstalled;
457     CARD8 mapState;
458     BOOL override;
459     Colormap colormap;
460     CARD32 allEventMasks;
461     CARD32 yourEventMask;
462     CARD16 doNotPropagateMask;
463     CARD16 pad;
464     } xGetWindowAttributesReply;
465 
466 typedef struct {
467     BYTE type;   /* X_Reply */
468     CARD8 depth;
469     CARD16 sequenceNumber;
470     CARD32 length;  /* 0 */
471     Window root;
472     INT16 x, y;
473     CARD16 width, height;
474     CARD16 borderWidth;
475     CARD16 pad1;
476     CARD32 pad2;
477     CARD32 pad3;
478     } xGetGeometryReply;
479 
480 typedef struct {
481     BYTE type;  /* X_Reply */
482     BYTE pad1;
483     CARD16 sequenceNumber;
484     CARD32 length;
485     Window root, parent;
486     CARD16 nChildren;
487     CARD16 pad2;
488     CARD32 pad3;
489     CARD32 pad4;
490     CARD32 pad5;
491     } xQueryTreeReply;
492 
493 typedef struct {
494     BYTE type;  /* X_Reply */
495     BYTE pad1;
496     CARD16 sequenceNumber;
497     CARD32 length; /* 0 */
498     Atom atom;
499     CARD32 pad2;
500     CARD32 pad3;
501     CARD32 pad4;
502     CARD32 pad5;
503     CARD32 pad6;
504     } xInternAtomReply;
505 
506 typedef struct {
507     BYTE type;  /* X_Reply */
508     BYTE pad1;
509     CARD16 sequenceNumber;
510     CARD32 length;  /* of additional bytes */
511     CARD16 nameLength;  /* # of characters in name */
512     CARD16 pad2;
513     CARD32 pad3;
514     CARD32 pad4;
515     CARD32 pad5;
516     CARD32 pad6;
517     CARD32 pad7;
518     } xGetAtomNameReply;
519 
520 typedef struct {
521     BYTE type;  /* X_Reply */
522     CARD8 format;
523     CARD16 sequenceNumber;
524     CARD32 length; /* of additional bytes */
525     Atom propertyType;
526     CARD32 bytesAfter;
527     CARD32 nItems; /* # of 8, 16, or 32-bit entities in reply */
528     CARD32 pad1;
529     CARD32 pad2;
530     CARD32 pad3;
531     } xGetPropertyReply;
532 
533 typedef struct {
534     BYTE type;  /* X_Reply */
535     BYTE pad1;
536     CARD16 sequenceNumber;
537     CARD32 length;
538     CARD16 nProperties;
539     CARD16 pad2;
540     CARD32 pad3;
541     CARD32 pad4;
542     CARD32 pad5;
543     CARD32 pad6;
544     CARD32 pad7;
545     } xListPropertiesReply;
546 
547 typedef struct {
548     BYTE type;  /* X_Reply */
549     BYTE pad1;
550     CARD16 sequenceNumber;
551     CARD32 length;  /* 0 */
552     Window owner;
553     CARD32 pad2;
554     CARD32 pad3;
555     CARD32 pad4;
556     CARD32 pad5;
557     CARD32 pad6;
558     } xGetSelectionOwnerReply;
559 
560 typedef struct {
561     BYTE type;  /* X_Reply */
562     BYTE status;
563     CARD16 sequenceNumber;
564     CARD32 length;  /* 0 */
565     CARD32 pad1;
566     CARD32 pad2;
567     CARD32 pad3;
568     CARD32 pad4;
569     CARD32 pad5;
570     CARD32 pad6;
571     } xGrabPointerReply;
572 
573 typedef xGrabPointerReply xGrabKeyboardReply;
574 
575 typedef struct {
576     BYTE type;  /* X_Reply */
577     BOOL sameScreen;
578     CARD16 sequenceNumber;
579     CARD32 length;  /* 0 */
580     Window root, child;
581     INT16 rootX, rootY, winX, winY;
582     CARD16 mask;
583     CARD16 pad1;
584     CARD32 pad;
585     } xQueryPointerReply;
586 
587 typedef struct {
588     BYTE type;  /* X_Reply */
589     BYTE pad1;
590     CARD16 sequenceNumber;
591     CARD32 length;
592     CARD32 nEvents;
593     CARD32 pad2;
594     CARD32 pad3;
595     CARD32 pad4;
596     CARD32 pad5;
597     CARD32 pad6;
598     } xGetMotionEventsReply;
599 
600 typedef struct {
601     BYTE type;  /* X_Reply */
602     BOOL sameScreen;
603     CARD16 sequenceNumber;
604     CARD32 length; /* 0 */
605     Window child;
606     INT16 dstX, dstY;
607     CARD32 pad2;
608     CARD32 pad3;
609     CARD32 pad4;
610     CARD32 pad5;
611     } xTranslateCoordsReply;
612 
613 typedef struct {
614     BYTE type;  /* X_Reply */
615     CARD8 revertTo;
616     CARD16 sequenceNumber;
617     CARD32 length;  /* 0 */
618     Window focus;
619     CARD32 pad1;
620     CARD32 pad2;
621     CARD32 pad3;
622     CARD32 pad4;
623     CARD32 pad5;
624     } xGetInputFocusReply;
625 
626 typedef struct {
627     BYTE type;  /* X_Reply */
628     BYTE pad1;
629     CARD16 sequenceNumber;
630     CARD32 length;  /* 2, NOT 0; this is an extra-large reply */
631     BYTE map[32];
632     } xQueryKeymapReply;
633 
634 /* Warning: this MUST match (up to component renaming) xListFontsWithInfoReply */
635 typedef struct _xQueryFontReply {
636     BYTE type;  /* X_Reply */
637     BYTE pad1;
638     CARD16 sequenceNumber;
639     CARD32 length;  /* definitely > 0, even if "nCharInfos" is 0 */
640     xCharInfo minBounds;
641     CARD32 walign1;
642     xCharInfo maxBounds;
643     CARD32 walign2;
644     CARD16 minCharOrByte2, maxCharOrByte2;
645     CARD16 defaultChar;
646     CARD16 nFontProps;  /* followed by this many xFontProp structures */
647     CARD8 drawDirection;
648     CARD8 minByte1, maxByte1;
649     BOOL allCharsExist;
650     INT16 fontAscent, fontDescent;
651     CARD32 nCharInfos; /* followed by this many xCharInfo structures */
652 } xQueryFontReply;
653 
654 typedef struct {
655     BYTE type;  /* X_Reply */
656     CARD8 drawDirection;
657     CARD16 sequenceNumber;
658     CARD32 length;  /* 0 */
659     INT16 fontAscent, fontDescent;
660     INT16 overallAscent, overallDescent;
661     INT32 overallWidth, overallLeft, overallRight;
662     CARD32 pad;
663     } xQueryTextExtentsReply;
664 
665 typedef struct {
666     BYTE type;  /* X_Reply */
667     BYTE pad1;
668     CARD16 sequenceNumber;
669     CARD32 length;
670     CARD16 nFonts;
671     CARD16 pad2;
672     CARD32 pad3;
673     CARD32 pad4;
674     CARD32 pad5;
675     CARD32 pad6;
676     CARD32 pad7;
677     } xListFontsReply;
678 
679 /* Warning: this MUST match (up to component renaming) xQueryFontReply */
680 typedef struct {
681     BYTE type;  /* X_Reply */
682     CARD8 nameLength;  /* 0 indicates end-of-reply-sequence */
683     CARD16 sequenceNumber;
684     CARD32 length;  /* definitely > 0, even if "nameLength" is 0 */
685     xCharInfo minBounds;
686     CARD32 walign1;
687     xCharInfo maxBounds;
688     CARD32 walign2;
689     CARD16 minCharOrByte2, maxCharOrByte2;
690     CARD16 defaultChar;
691     CARD16 nFontProps;  /* followed by this many xFontProp structures */
692     CARD8 drawDirection;
693     CARD8 minByte1, maxByte1;
694     BOOL allCharsExist;
695     INT16 fontAscent, fontDescent;
696     CARD32 nReplies;   /* hint as to how many more replies might be coming */
697 } xListFontsWithInfoReply;
698 
699 typedef struct {
700     BYTE type;  /* X_Reply */
701     BYTE pad1;
702     CARD16 sequenceNumber;
703     CARD32 length;
704     CARD16 nPaths;
705     CARD16 pad2;
706     CARD32 pad3;
707     CARD32 pad4;
708     CARD32 pad5;
709     CARD32 pad6;
710     CARD32 pad7;
711     } xGetFontPathReply;
712 
713 typedef struct {
714     BYTE type;  /* X_Reply */
715     CARD8 depth;
716     CARD16 sequenceNumber;
717     CARD32 length;
718     VisualID visual;
719     CARD32 pad3;
720     CARD32 pad4;
721     CARD32 pad5;
722     CARD32 pad6;
723     CARD32 pad7;
724     } xGetImageReply;
725 
726 typedef struct {
727     BYTE type;  /* X_Reply */
728     BYTE pad1;
729     CARD16 sequenceNumber;
730     CARD32 length;
731     CARD16 nColormaps;
732     CARD16 pad2;
733     CARD32 pad3;
734     CARD32 pad4;
735     CARD32 pad5;
736     CARD32 pad6;
737     CARD32 pad7;
738     } xListInstalledColormapsReply;
739 
740 typedef struct {
741     BYTE type; /* X_Reply */
742     BYTE pad1;
743     CARD16 sequenceNumber;
744     CARD32 length;   /* 0 */
745     CARD16 red, green, blue;
746     CARD16 pad2;
747     CARD32 pixel;
748     CARD32 pad3;
749     CARD32 pad4;
750     CARD32 pad5;
751     } xAllocColorReply;
752 
753 typedef struct {
754     BYTE type; /* X_Reply */
755     BYTE pad1;
756     CARD16 sequenceNumber;
757     CARD32 length;  /* 0 */
758     CARD32 pixel;
759     CARD16 exactRed, exactGreen, exactBlue;
760     CARD16 screenRed, screenGreen, screenBlue;
761     CARD32 pad2;
762     CARD32 pad3;
763     } xAllocNamedColorReply;
764 
765 typedef struct {
766     BYTE type;  /* X_Reply */
767     BYTE pad1;
768     CARD16 sequenceNumber;
769     CARD32 length;
770     CARD16 nPixels, nMasks;
771     CARD32 pad3;
772     CARD32 pad4;
773     CARD32 pad5;
774     CARD32 pad6;
775     CARD32 pad7;
776     } xAllocColorCellsReply;
777 
778 typedef struct {
779     BYTE type; /* X_Reply */
780     BYTE pad1;
781     CARD16 sequenceNumber;
782     CARD32 length;
783     CARD16 nPixels;
784     CARD16 pad2;
785     CARD32 redMask, greenMask, blueMask;
786     CARD32 pad3;
787     CARD32 pad4;
788     } xAllocColorPlanesReply;
789 
790 typedef struct {
791     BYTE type; /* X_Reply */
792     BYTE pad1;
793     CARD16 sequenceNumber;
794     CARD32 length;
795     CARD16 nColors;
796     CARD16 pad2;
797     CARD32 pad3;
798     CARD32 pad4;
799     CARD32 pad5;
800     CARD32 pad6;
801     CARD32 pad7;
802     } xQueryColorsReply;
803 
804 typedef struct {
805     BYTE type;  /* X_Reply */
806     BYTE pad1;
807     CARD16 sequenceNumber;
808     CARD32 length;  /* 0 */
809     CARD16 exactRed, exactGreen, exactBlue;
810     CARD16 screenRed, screenGreen, screenBlue;
811     CARD32 pad3;
812     CARD32 pad4;
813     CARD32 pad5;
814     } xLookupColorReply;
815 
816 typedef struct {
817     BYTE type;  /* X_Reply */
818     BYTE pad1;
819     CARD16 sequenceNumber;
820     CARD32 length;  /* 0 */
821     CARD16 width, height;
822     CARD32 pad3;
823     CARD32 pad4;
824     CARD32 pad5;
825     CARD32 pad6;
826     CARD32 pad7;
827     } xQueryBestSizeReply;
828 
829 typedef struct {
830     BYTE type;  /* X_Reply */
831     BYTE pad1;
832     CARD16 sequenceNumber;
833     CARD32 length; /* 0 */
834     BOOL  present;
835     CARD8 major_opcode;
836     CARD8 first_event;
837     CARD8 first_error;
838     CARD32 pad3;
839     CARD32 pad4;
840     CARD32 pad5;
841     CARD32 pad6;
842     CARD32 pad7;
843     } xQueryExtensionReply;
844 
845 typedef struct {
846     BYTE type;  /* X_Reply */
847     CARD8 nExtensions;
848     CARD16 sequenceNumber;
849     CARD32 length;
850     CARD32 pad2;
851     CARD32 pad3;
852     CARD32 pad4;
853     CARD32 pad5;
854     CARD32 pad6;
855     CARD32 pad7;
856     } xListExtensionsReply;
857 
858 
859 typedef struct {
860     BYTE   type;  /* X_Reply */
861     CARD8  success;
862     CARD16 sequenceNumber;
863     CARD32 length;
864     CARD32 pad2;
865     CARD32 pad3;
866     CARD32 pad4;
867     CARD32 pad5;
868     CARD32 pad6;
869     CARD32 pad7;
870     } xSetMappingReply;
871 typedef xSetMappingReply xSetPointerMappingReply;
872 typedef xSetMappingReply xSetModifierMappingReply;
873 
874 typedef struct {
875     BYTE type;  /* X_Reply */
876     CARD8 nElts;  /* how many elements does the map have */
877     CARD16 sequenceNumber;
878     CARD32 length;
879     CARD32 pad2;
880     CARD32 pad3;
881     CARD32 pad4;
882     CARD32 pad5;
883     CARD32 pad6;
884     CARD32 pad7;
885     } xGetPointerMappingReply;
886 
887 typedef struct {
888     BYTE type;
889     CARD8 keySymsPerKeyCode;
890     CARD16 sequenceNumber;
891     CARD32 length;
892     CARD32 pad2;
893     CARD32 pad3;
894     CARD32 pad4;
895     CARD32 pad5;
896     CARD32 pad6;
897     CARD32 pad7;
898 } xGetKeyboardMappingReply;
899 
900 typedef struct {
901     BYTE type;
902     CARD8 numKeyPerModifier;
903     CARD16 sequenceNumber;
904     CARD32 length;
905     CARD32 pad1;
906     CARD32 pad2;
907     CARD32 pad3;
908     CARD32 pad4;
909     CARD32 pad5;
910     CARD32 pad6;
911 } xGetModifierMappingReply;
912 
913 typedef struct {
914     BYTE type;  /* X_Reply */
915     BOOL globalAutoRepeat;
916     CARD16 sequenceNumber;
917     CARD32 length;  /* 5 */
918     CARD32 ledMask;
919     CARD8 keyClickPercent, bellPercent;
920     CARD16 bellPitch, bellDuration;
921     CARD16 pad;
922     BYTE map[32];  /* bit masks start here */
923     } xGetKeyboardControlReply;
924 
925 typedef struct {
926     BYTE type;  /* X_Reply */
927     BYTE pad1;
928     CARD16 sequenceNumber;
929     CARD32 length;  /* 0 */
930     CARD16 accelNumerator, accelDenominator;
931     CARD16 threshold;
932     CARD16 pad2;
933     CARD32 pad3;
934     CARD32 pad4;
935     CARD32 pad5;
936     CARD32 pad6;
937     } xGetPointerControlReply;
938 
939 typedef struct {
940     BYTE type;  /* X_Reply */
941     BYTE pad1;
942     CARD16 sequenceNumber;
943     CARD32 length;  /* 0 */
944     CARD16 timeout, interval;
945     BOOL preferBlanking;
946     BOOL allowExposures;
947     CARD16 pad2;
948     CARD32 pad3;
949     CARD32 pad4;
950     CARD32 pad5;
951     CARD32 pad6;
952     } xGetScreenSaverReply;
953 
954 typedef struct {
955     BYTE type;  /* X_Reply */
956     BOOL enabled;
957     CARD16 sequenceNumber;
958     CARD32 length;
959     CARD16 nHosts;
960     CARD16 pad1;
961     CARD32 pad3;
962     CARD32 pad4;
963     CARD32 pad5;
964     CARD32 pad6;
965     CARD32 pad7;
966     } xListHostsReply;
967 
968 
969 
970 
971 /*****************************************************************
972  * Xerror
973  *    All errors  are 32 bytes
974  *****************************************************************/
975 
976 typedef struct {
977     BYTE type;                  /* X_Error */
978     BYTE errorCode;
979     CARD16 sequenceNumber;       /* the nth request from this client */
980     CARD32 resourceID;
981     CARD16 minorCode;
982     CARD8 majorCode;
983     BYTE pad1;
984     CARD32 pad3;
985     CARD32 pad4;
986     CARD32 pad5;
987     CARD32 pad6;
988     CARD32 pad7;
989 } xError;
990 
991 /*****************************************************************
992  * xEvent
993  *    All events are 32 bytes
994  *****************************************************************/
995 
996 typedef struct _xEvent {
997     union {
998 	struct {
999 	    BYTE type;
1000 	    BYTE detail;
1001 	    CARD16 sequenceNumber;
1002 	    } u;
1003 	struct {
1004 	    CARD32 pad00;
1005 	    Time time;
1006 	    Window root, event, child;
1007 	    INT16 rootX, rootY, eventX, eventY;
1008 	    KeyButMask state;
1009 	    BOOL sameScreen;
1010 	    BYTE pad1;
1011 	} keyButtonPointer;
1012 	struct {
1013 	    CARD32 pad00;
1014 	    Time time;
1015 	    Window root, event, child;
1016 	    INT16 rootX, rootY, eventX, eventY;
1017 	    KeyButMask state;
1018 	    BYTE mode; 			/* really XMode */
1019 	    BYTE flags;		/* sameScreen and focus booleans, packed together */
1020 #define ELFlagFocus        (1<<0)
1021 #define ELFlagSameScreen   (1<<1)
1022 	} enterLeave;
1023 	struct {
1024 	    CARD32 pad00;
1025 	    Window window;
1026 	    BYTE mode; 			/* really XMode */
1027 	    BYTE pad1, pad2, pad3;
1028 	} focus;
1029 	struct {
1030 	    CARD32 pad00;
1031 	    Window window;
1032 	    CARD16 x, y, width, height;
1033 	    CARD16 count;
1034 	    CARD16 pad2;
1035 	} expose;
1036 	struct {
1037 	    CARD32 pad00;
1038 	    Drawable drawable;
1039 	    CARD16 x, y, width, height;
1040 	    CARD16 minorEvent;
1041 	    CARD16 count;
1042 	    BYTE majorEvent;
1043 	    BYTE pad1, pad2, pad3;
1044 	} graphicsExposure;
1045 	struct {
1046 	    CARD32 pad00;
1047 	    Drawable drawable;
1048 	    CARD16 minorEvent;
1049 	    BYTE majorEvent;
1050 	    BYTE bpad;
1051 	} noExposure;
1052 	struct {
1053 	    CARD32 pad00;
1054 	    Window window;
1055 	    CARD8 state;
1056 	    BYTE pad1, pad2, pad3;
1057 	} visibility;
1058 	struct {
1059 	    CARD32 pad00;
1060 	    Window parent, window;
1061 	    INT16 x, y;
1062 	    CARD16 width, height, borderWidth;
1063 	    BOOL override;
1064 	    BYTE bpad;
1065         } createNotify;
1066 /*
1067  * The event fields in the structures for DestroyNotify, UnmapNotify,
1068  * MapNotify, ReparentNotify, ConfigureNotify, CirculateNotify, GravityNotify,
1069  * must be at the same offset because server internal code is depending upon
1070  * this to patch up the events before they are delivered.
1071  * Also note that MapRequest, ConfigureRequest and CirculateRequest have
1072  * the same offset for the event window.
1073  */
1074 	struct {
1075 	    CARD32 pad00;
1076 	    Window event, window;
1077 	} destroyNotify;
1078 	struct {
1079 	    CARD32 pad00;
1080 	    Window event, window;
1081 	    BOOL fromConfigure;
1082 	    BYTE pad1, pad2, pad3;
1083         } unmapNotify;
1084 	struct {
1085 	    CARD32 pad00;
1086 	    Window event, window;
1087 	    BOOL override;
1088 	    BYTE pad1, pad2, pad3;
1089         } mapNotify;
1090 	struct {
1091 	    CARD32 pad00;
1092 	    Window parent, window;
1093         } mapRequest;
1094 	struct {
1095 	    CARD32 pad00;
1096 	    Window event, window, parent;
1097 	    INT16 x, y;
1098 	    BOOL override;
1099 	    BYTE pad1, pad2, pad3;
1100 	} reparent;
1101 	struct {
1102 	    CARD32 pad00;
1103 	    Window event, window, aboveSibling;
1104 	    INT16 x, y;
1105 	    CARD16 width, height, borderWidth;
1106 	    BOOL override;
1107 	    BYTE bpad;
1108 	} configureNotify;
1109 	struct {
1110 	    CARD32 pad00;
1111 	    Window parent, window, sibling;
1112 	    INT16 x, y;
1113 	    CARD16 width, height, borderWidth;
1114 	    CARD16 valueMask;
1115 	    CARD32 pad1;
1116 	} configureRequest;
1117 	struct {
1118 	    CARD32 pad00;
1119 	    Window event, window;
1120 	    INT16 x, y;
1121 	    CARD32 pad1, pad2, pad3, pad4;
1122 	} gravity;
1123 	struct {
1124 	    CARD32 pad00;
1125 	    Window window;
1126 	    CARD16 width, height;
1127 	} resizeRequest;
1128 	struct {
1129 /* The event field in the circulate record is really the parent when this
1130    is used as a CirculateRequest instead of a CirculateNotify */
1131 	    CARD32 pad00;
1132 	    Window event, window, parent;
1133 	    BYTE place;			/* Top or Bottom */
1134 	    BYTE pad1, pad2, pad3;
1135 	} circulate;
1136 	struct {
1137 	    CARD32 pad00;
1138 	    Window window;
1139 	    Atom atom;
1140 	    Time time;
1141 	    BYTE state;			/* NewValue or Deleted */
1142 	    BYTE pad1;
1143 	    CARD16 pad2;
1144 	} property;
1145 	struct {
1146 	    CARD32 pad00;
1147 	    Time time;
1148 	    Window window;
1149 	    Atom atom;
1150 	} selectionClear;
1151 	struct {
1152 	    CARD32 pad00;
1153 	    Time time;
1154 	    Window owner, requestor;
1155 	    Atom selection, target, property;
1156 	} selectionRequest;
1157 	struct {
1158 	    CARD32 pad00;
1159 	    Time time;
1160 	    Window requestor;
1161 	    Atom selection, target, property;
1162 	} selectionNotify;
1163 	struct {
1164 	    CARD32 pad00;
1165 	    Window window;
1166 	    Colormap colormap;
1167 #if defined(__cplusplus) || defined(c_plusplus)
1168 	    BOOL c_new;
1169 #else
1170 	    BOOL new;
1171 #endif
1172 	    BYTE state;			/* Installed or UnInstalled */
1173 	    BYTE pad1, pad2;
1174 	} colormap;
1175 	struct {
1176 	    CARD32 pad00;
1177 	    CARD8 request;
1178 	    KeyCode firstKeyCode;
1179 	    CARD8 count;
1180 	    BYTE pad1;
1181 	} mappingNotify;
1182 	struct {
1183 	    CARD32 pad00;
1184 	    Window window;
1185 	    union {
1186 		struct {
1187 		    Atom type;
1188 		    INT32 longs0;
1189 		    INT32 longs1;
1190 		    INT32 longs2;
1191 		    INT32 longs3;
1192 		    INT32 longs4;
1193 		} l;
1194 		struct {
1195 		    Atom type;
1196 		    INT16 shorts0;
1197 		    INT16 shorts1;
1198 		    INT16 shorts2;
1199 		    INT16 shorts3;
1200 		    INT16 shorts4;
1201 		    INT16 shorts5;
1202 		    INT16 shorts6;
1203 		    INT16 shorts7;
1204 		    INT16 shorts8;
1205 		    INT16 shorts9;
1206 		} s;
1207 		struct {
1208 		    Atom type;
1209 		    INT8 bytes[20];
1210 		} b;
1211 	    } u;
1212 	} clientMessage;
1213     } u;
1214 } xEvent;
1215 
1216 /*********************************************************
1217  *
1218  * Generic event
1219  *
1220  * Those events are not part of the core protocol spec and can be used by
1221  * various extensions.
1222  * type is always GenericEvent
1223  * extension is the minor opcode of the extension the event belongs to.
1224  * evtype is the actual event type, unique __per extension__.
1225  *
1226  * GenericEvents can be longer than 32 bytes, with the length field
1227  * specifying the number of 4 byte blocks after the first 32 bytes.
1228  *
1229  *
1230  */
1231 typedef struct
1232 {
1233     BYTE    type;
1234     CARD8   extension;
1235     CARD16  sequenceNumber;
1236     CARD32  length;
1237     CARD16  evtype;
1238     CARD16  pad2;
1239     CARD32  pad3;
1240     CARD32  pad4;
1241     CARD32  pad5;
1242     CARD32  pad6;
1243     CARD32  pad7;
1244 } xGenericEvent;
1245 
1246 
1247 
1248 /* KeymapNotify events are not included in the above union because they
1249    are different from all other events: they do not have a "detail"
1250    or "sequenceNumber", so there is room for a 248-bit key mask. */
1251 
1252 typedef struct {
1253     BYTE type;
1254     BYTE map[31];
1255     } xKeymapEvent;
1256 
1257 #define XEventSize (sizeof(xEvent))
1258 
1259 /* XReply is the union of all the replies above whose "fixed part"
1260 fits in 32 bytes.  It does NOT include GetWindowAttributesReply,
1261 QueryFontReply, QueryKeymapReply, or GetKeyboardControlReply
1262 ListFontsWithInfoReply */
1263 
1264 typedef union {
1265     xGenericReply generic;
1266     xGetGeometryReply geom;
1267     xQueryTreeReply tree;
1268     xInternAtomReply atom;
1269     xGetAtomNameReply atomName;
1270     xGetPropertyReply property;
1271     xListPropertiesReply listProperties;
1272     xGetSelectionOwnerReply selection;
1273     xGrabPointerReply grabPointer;
1274     xGrabKeyboardReply grabKeyboard;
1275     xQueryPointerReply pointer;
1276     xGetMotionEventsReply motionEvents;
1277     xTranslateCoordsReply coords;
1278     xGetInputFocusReply inputFocus;
1279     xQueryTextExtentsReply textExtents;
1280     xListFontsReply fonts;
1281     xGetFontPathReply fontPath;
1282     xGetImageReply image;
1283     xListInstalledColormapsReply colormaps;
1284     xAllocColorReply allocColor;
1285     xAllocNamedColorReply allocNamedColor;
1286     xAllocColorCellsReply colorCells;
1287     xAllocColorPlanesReply colorPlanes;
1288     xQueryColorsReply colors;
1289     xLookupColorReply lookupColor;
1290     xQueryBestSizeReply bestSize;
1291     xQueryExtensionReply extension;
1292     xListExtensionsReply extensions;
1293     xSetModifierMappingReply setModifierMapping;
1294     xGetModifierMappingReply getModifierMapping;
1295     xSetPointerMappingReply setPointerMapping;
1296     xGetKeyboardMappingReply getKeyboardMapping;
1297     xGetPointerMappingReply getPointerMapping;
1298     xGetPointerControlReply pointerControl;
1299     xGetScreenSaverReply screenSaver;
1300     xListHostsReply hosts;
1301     xError error;
1302     xEvent event;
1303 } xReply;
1304 
1305 
1306 
1307 /*****************************************************************
1308  * REQUESTS
1309  *****************************************************************/
1310 
1311 
1312 /* Request structure */
1313 
1314 typedef struct _xReq {
1315 	CARD8 reqType;
1316 	CARD8 data;            /* meaning depends on request type */
1317 	CARD16 length;         /* length in 4 bytes quantities
1318 				  of whole request, including this header */
1319 } xReq;
1320 
1321 /*****************************************************************
1322  *  structures that follow request.
1323  *****************************************************************/
1324 
1325 /* ResourceReq is used for any request which has a resource ID
1326    (or Atom or Time) as its one and only argument.  */
1327 
1328 typedef struct {
1329     CARD8 reqType;
1330     BYTE pad;
1331     CARD16 length;
1332     CARD32 id;  /* a Window, Drawable, Font, GContext, Pixmap, etc. */
1333     } xResourceReq;
1334 
1335 typedef struct {
1336     CARD8 reqType;
1337     CARD8 depth;
1338     CARD16 length;
1339     Window wid, parent;
1340     INT16 x, y;
1341     CARD16 width, height, borderWidth;
1342 #if defined(__cplusplus) || defined(c_plusplus)
1343     CARD16 c_class;
1344 #else
1345     CARD16 class;
1346 #endif
1347     VisualID visual;
1348     CARD32 mask;
1349 } xCreateWindowReq;
1350 
1351 typedef struct {
1352     CARD8 reqType;
1353     BYTE pad;
1354     CARD16 length;
1355     Window window;
1356     CARD32 valueMask;
1357 } xChangeWindowAttributesReq;
1358 
1359 typedef struct {
1360     CARD8 reqType;
1361     BYTE mode;
1362     CARD16 length;
1363     Window window;
1364 } xChangeSaveSetReq;
1365 
1366 typedef struct {
1367     CARD8 reqType;
1368     BYTE pad;
1369     CARD16 length;
1370     Window window, parent;
1371     INT16 x, y;
1372 } xReparentWindowReq;
1373 
1374 typedef struct {
1375     CARD8 reqType;
1376     CARD8 pad;
1377     CARD16 length;
1378     Window window;
1379     CARD16 mask;
1380     CARD16 pad2;
1381 } xConfigureWindowReq;
1382 
1383 typedef struct {
1384     CARD8 reqType;
1385     CARD8 direction;
1386     CARD16 length;
1387     Window window;
1388 } xCirculateWindowReq;
1389 
1390 typedef struct {    /* followed by padded string */
1391     CARD8 reqType;
1392     BOOL onlyIfExists;
1393     CARD16 length;
1394     CARD16 nbytes;    /* number of bytes in string */
1395     CARD16 pad;
1396 } xInternAtomReq;
1397 
1398 typedef struct {
1399     CARD8 reqType;
1400     CARD8 mode;
1401     CARD16 length;
1402     Window window;
1403     Atom property, type;
1404     CARD8 format;
1405     BYTE pad[3];
1406     CARD32 nUnits;     /* length of stuff following, depends on format */
1407 } xChangePropertyReq;
1408 
1409 typedef struct {
1410     CARD8 reqType;
1411     BYTE pad;
1412     CARD16 length;
1413     Window window;
1414     Atom property;
1415 } xDeletePropertyReq;
1416 
1417 typedef struct {
1418     CARD8 reqType;
1419 #if defined(__cplusplus) || defined(c_plusplus)
1420     BOOL c_delete;
1421 #else
1422     BOOL delete;
1423 #endif
1424     CARD16 length;
1425     Window window;
1426     Atom property, type;
1427     CARD32 longOffset;
1428     CARD32 longLength;
1429 } xGetPropertyReq;
1430 
1431 typedef struct {
1432     CARD8 reqType;
1433     BYTE pad;
1434     CARD16 length;
1435     Window window;
1436     Atom selection;
1437     Time time;
1438 } xSetSelectionOwnerReq;
1439 
1440 typedef struct {
1441     CARD8 reqType;
1442     BYTE pad;
1443     CARD16 length;
1444     Window requestor;
1445     Atom selection, target, property;
1446     Time time;
1447     } xConvertSelectionReq;
1448 
1449 typedef struct {
1450     CARD8 reqType;
1451     BOOL propagate;
1452     CARD16 length;
1453     Window destination;
1454     CARD32 eventMask;
1455     xEvent event;
1456 } xSendEventReq;
1457 
1458 typedef struct {
1459     CARD8 reqType;
1460     BOOL ownerEvents;
1461     CARD16 length;
1462     Window grabWindow;
1463     CARD16 eventMask;
1464     BYTE pointerMode, keyboardMode;
1465     Window confineTo;
1466     Cursor cursor;
1467     Time time;
1468 } xGrabPointerReq;
1469 
1470 typedef struct {
1471     CARD8 reqType;
1472     BOOL ownerEvents;
1473     CARD16 length;
1474     Window grabWindow;
1475     CARD16 eventMask;
1476     BYTE pointerMode, keyboardMode;
1477     Window confineTo;
1478     Cursor cursor;
1479     CARD8 button;
1480     BYTE pad;
1481     CARD16 modifiers;
1482 } xGrabButtonReq;
1483 
1484 typedef struct {
1485     CARD8 reqType;
1486     CARD8 button;
1487     CARD16 length;
1488     Window grabWindow;
1489     CARD16 modifiers;
1490     CARD16 pad;
1491 } xUngrabButtonReq;
1492 
1493 typedef struct {
1494     CARD8 reqType;
1495     BYTE pad;
1496     CARD16 length;
1497     Cursor cursor;
1498     Time time;
1499     CARD16 eventMask;
1500     CARD16 pad2;
1501 } xChangeActivePointerGrabReq;
1502 
1503 typedef struct {
1504     CARD8 reqType;
1505     BOOL ownerEvents;
1506     CARD16 length;
1507     Window grabWindow;
1508     Time time;
1509     BYTE pointerMode, keyboardMode;
1510     CARD16 pad;
1511 } xGrabKeyboardReq;
1512 
1513 typedef struct {
1514     CARD8 reqType;
1515     BOOL ownerEvents;
1516     CARD16 length;
1517     Window grabWindow;
1518     CARD16 modifiers;
1519     CARD8 key;
1520     BYTE pointerMode, keyboardMode;
1521     BYTE pad1, pad2, pad3;
1522 } xGrabKeyReq;
1523 
1524 typedef struct {
1525     CARD8 reqType;
1526     CARD8 key;
1527     CARD16 length;
1528     Window grabWindow;
1529     CARD16 modifiers;
1530     CARD16 pad;
1531 } xUngrabKeyReq;
1532 
1533 typedef struct {
1534     CARD8 reqType;
1535     CARD8 mode;
1536     CARD16 length;
1537     Time time;
1538 } xAllowEventsReq;
1539 
1540 typedef struct {
1541     CARD8 reqType;
1542     BYTE pad;
1543     CARD16 length;
1544     Window window;
1545     Time start, stop;
1546 } xGetMotionEventsReq;
1547 
1548 typedef struct {
1549     CARD8 reqType;
1550     BYTE pad;
1551     CARD16 length;
1552     Window srcWid, dstWid;
1553     INT16 srcX, srcY;
1554 } xTranslateCoordsReq;
1555 
1556 typedef struct {
1557     CARD8 reqType;
1558     BYTE pad;
1559     CARD16 length;
1560     Window srcWid, dstWid;
1561     INT16 srcX, srcY;
1562     CARD16 srcWidth, srcHeight;
1563     INT16 dstX, dstY;
1564 } xWarpPointerReq;
1565 
1566 typedef struct {
1567     CARD8 reqType;
1568     CARD8 revertTo;
1569     CARD16 length;
1570     Window focus;
1571     Time time;
1572 } xSetInputFocusReq;
1573 
1574 typedef struct {
1575     CARD8 reqType;
1576     BYTE pad;
1577     CARD16 length;
1578     Font fid;
1579     CARD16 nbytes;
1580     BYTE pad1, pad2;	/* string follows on word boundary */
1581 } xOpenFontReq;
1582 
1583 typedef struct {
1584     CARD8 reqType;
1585     BOOL oddLength;
1586     CARD16 length;
1587     Font fid;
1588     } xQueryTextExtentsReq;
1589 
1590 typedef struct {
1591     CARD8 reqType;
1592     BYTE pad;
1593     CARD16 length;
1594     CARD16 maxNames;
1595     CARD16 nbytes;	/* followed immediately by string bytes */
1596 } xListFontsReq;
1597 
1598 typedef xListFontsReq xListFontsWithInfoReq;
1599 
1600 typedef struct {
1601     CARD8 reqType;
1602     BYTE pad;
1603     CARD16 length;
1604     CARD16 nFonts;
1605     BYTE pad1, pad2;	/* LISTofSTRING8 follows on word boundary */
1606 } xSetFontPathReq;
1607 
1608 typedef struct {
1609     CARD8 reqType;
1610     CARD8 depth;
1611     CARD16 length;
1612     Pixmap pid;
1613     Drawable drawable;
1614     CARD16 width, height;
1615 } xCreatePixmapReq;
1616 
1617 typedef struct {
1618     CARD8 reqType;
1619     BYTE pad;
1620     CARD16 length;
1621     GContext gc;
1622     Drawable drawable;
1623     CARD32 mask;
1624 } xCreateGCReq;
1625 
1626 typedef struct {
1627     CARD8 reqType;
1628     BYTE pad;
1629     CARD16 length;
1630     GContext gc;
1631     CARD32 mask;
1632 } xChangeGCReq;
1633 
1634 typedef struct {
1635     CARD8 reqType;
1636     BYTE pad;
1637     CARD16 length;
1638     GContext srcGC, dstGC;
1639     CARD32 mask;
1640 } xCopyGCReq;
1641 
1642 typedef struct {
1643     CARD8 reqType;
1644     BYTE pad;
1645     CARD16 length;
1646     GContext gc;
1647     CARD16 dashOffset;
1648     CARD16 nDashes;	/* length LISTofCARD8 of values following */
1649 } xSetDashesReq;
1650 
1651 typedef struct {
1652     CARD8 reqType;
1653     BYTE ordering;
1654     CARD16 length;
1655     GContext gc;
1656     INT16 xOrigin, yOrigin;
1657 } xSetClipRectanglesReq;
1658 
1659 typedef struct {
1660     CARD8 reqType;
1661     BOOL exposures;
1662     CARD16 length;
1663     Window window;
1664     INT16 x, y;
1665     CARD16 width, height;
1666 } xClearAreaReq;
1667 
1668 typedef struct {
1669     CARD8 reqType;
1670     BYTE pad;
1671     CARD16 length;
1672     Drawable srcDrawable, dstDrawable;
1673     GContext gc;
1674     INT16 srcX, srcY, dstX, dstY;
1675     CARD16 width, height;
1676 } xCopyAreaReq;
1677 
1678 typedef struct {
1679     CARD8 reqType;
1680     BYTE pad;
1681     CARD16 length;
1682     Drawable srcDrawable, dstDrawable;
1683     GContext gc;
1684     INT16 srcX, srcY, dstX, dstY;
1685     CARD16 width, height;
1686     CARD32 bitPlane;
1687 } xCopyPlaneReq;
1688 
1689 typedef struct {
1690     CARD8 reqType;
1691     BYTE coordMode;
1692     CARD16 length;
1693     Drawable drawable;
1694     GContext gc;
1695 } xPolyPointReq;
1696 
1697 typedef xPolyPointReq xPolyLineReq;  /* same request structure */
1698 
1699 /* The following used for PolySegment, PolyRectangle, PolyArc, PolyFillRectangle, PolyFillArc */
1700 
1701 typedef struct {
1702     CARD8 reqType;
1703     BYTE pad;
1704     CARD16 length;
1705     Drawable drawable;
1706     GContext gc;
1707 } xPolySegmentReq;
1708 
1709 typedef xPolySegmentReq xPolyArcReq;
1710 typedef xPolySegmentReq xPolyRectangleReq;
1711 typedef xPolySegmentReq xPolyFillRectangleReq;
1712 typedef xPolySegmentReq xPolyFillArcReq;
1713 
1714 typedef struct _FillPolyReq {
1715     CARD8 reqType;
1716     BYTE pad;
1717     CARD16 length;
1718     Drawable drawable;
1719     GContext gc;
1720     BYTE shape;
1721     BYTE coordMode;
1722     CARD16 pad1;
1723 } xFillPolyReq;
1724 
1725 
1726 typedef struct _PutImageReq {
1727     CARD8 reqType;
1728     CARD8 format;
1729     CARD16 length;
1730     Drawable drawable;
1731     GContext gc;
1732     CARD16 width, height;
1733     INT16 dstX, dstY;
1734     CARD8 leftPad;
1735     CARD8 depth;
1736     CARD16 pad;
1737 } xPutImageReq;
1738 
1739 typedef struct {
1740     CARD8 reqType;
1741     CARD8 format;
1742     CARD16 length;
1743     Drawable drawable;
1744     INT16 x, y;
1745     CARD16 width, height;
1746     CARD32 planeMask;
1747 } xGetImageReq;
1748 
1749 /* the following used by PolyText8 and PolyText16 */
1750 
1751 typedef struct {
1752     CARD8 reqType;
1753     CARD8 pad;
1754     CARD16 length;
1755     Drawable drawable;
1756     GContext gc;
1757     INT16 x, y;		/* items (xTextElt) start after struct */
1758 } xPolyTextReq;
1759 
1760 typedef xPolyTextReq xPolyText8Req;
1761 typedef xPolyTextReq xPolyText16Req;
1762 
1763 typedef struct {
1764     CARD8 reqType;
1765     BYTE nChars;
1766     CARD16 length;
1767     Drawable drawable;
1768     GContext gc;
1769     INT16 x, y;
1770 } xImageTextReq;
1771 
1772 typedef xImageTextReq xImageText8Req;
1773 typedef xImageTextReq xImageText16Req;
1774 
1775 typedef struct {
1776     CARD8 reqType;
1777     BYTE alloc;
1778     CARD16 length;
1779     Colormap mid;
1780     Window window;
1781     VisualID visual;
1782 } xCreateColormapReq;
1783 
1784 typedef struct {
1785     CARD8 reqType;
1786     BYTE pad;
1787     CARD16 length;
1788     Colormap mid;
1789     Colormap srcCmap;
1790 } xCopyColormapAndFreeReq;
1791 
1792 typedef struct {
1793     CARD8 reqType;
1794     BYTE pad;
1795     CARD16 length;
1796     Colormap cmap;
1797     CARD16 red, green, blue;
1798     CARD16 pad2;
1799 } xAllocColorReq;
1800 
1801 typedef struct {
1802     CARD8 reqType;
1803     BYTE pad;
1804     CARD16 length;
1805     Colormap cmap;
1806     CARD16 nbytes;	/* followed by structure */
1807     BYTE pad1, pad2;
1808 } xAllocNamedColorReq;
1809 
1810 typedef struct {
1811     CARD8 reqType;
1812     BOOL contiguous;
1813     CARD16 length;
1814     Colormap cmap;
1815     CARD16 colors, planes;
1816 } xAllocColorCellsReq;
1817 
1818 typedef struct {
1819     CARD8 reqType;
1820     BOOL contiguous;
1821     CARD16 length;
1822     Colormap cmap;
1823     CARD16 colors, red, green, blue;
1824 } xAllocColorPlanesReq;
1825 
1826 typedef struct {
1827     CARD8 reqType;
1828     BYTE pad;
1829     CARD16 length;
1830     Colormap cmap;
1831     CARD32 planeMask;
1832 } xFreeColorsReq;
1833 
1834 typedef struct {
1835     CARD8 reqType;
1836     BYTE pad;
1837     CARD16 length;
1838     Colormap cmap;
1839 } xStoreColorsReq;
1840 
1841 typedef struct {
1842     CARD8 reqType;
1843     CARD8 flags;   /* DoRed, DoGreen, DoBlue, as in xColorItem */
1844     CARD16 length;
1845     Colormap cmap;
1846     CARD32 pixel;
1847     CARD16 nbytes;  /* number of name string bytes following structure */
1848     BYTE pad1, pad2;
1849     } xStoreNamedColorReq;
1850 
1851 typedef struct {
1852     CARD8 reqType;
1853     BYTE pad;
1854     CARD16 length;
1855     Colormap cmap;
1856 } xQueryColorsReq;
1857 
1858 typedef struct {    /* followed  by string of length len */
1859     CARD8 reqType;
1860     BYTE pad;
1861     CARD16 length;
1862     Colormap cmap;
1863     CARD16 nbytes;  /* number of string bytes following structure*/
1864     BYTE pad1, pad2;
1865 } xLookupColorReq;
1866 
1867 typedef struct {
1868     CARD8 reqType;
1869     BYTE pad;
1870     CARD16 length;
1871     Cursor cid;
1872     Pixmap source, mask;
1873     CARD16 foreRed, foreGreen, foreBlue;
1874     CARD16 backRed, backGreen, backBlue;
1875     CARD16 x, y;
1876 } xCreateCursorReq;
1877 
1878 typedef struct {
1879     CARD8 reqType;
1880     BYTE pad;
1881     CARD16 length;
1882     Cursor cid;
1883     Font source, mask;
1884     CARD16 sourceChar, maskChar;
1885     CARD16 foreRed, foreGreen, foreBlue;
1886     CARD16 backRed, backGreen, backBlue;
1887 } xCreateGlyphCursorReq;
1888 
1889 typedef struct {
1890     CARD8 reqType;
1891     BYTE pad;
1892     CARD16 length;
1893     Cursor cursor;
1894     CARD16 foreRed, foreGreen, foreBlue;
1895     CARD16 backRed, backGreen, backBlue;
1896 } xRecolorCursorReq;
1897 
1898 typedef struct {
1899     CARD8 reqType;
1900 #if defined(__cplusplus) || defined(c_plusplus)
1901     CARD8 c_class;
1902 #else
1903     CARD8 class;
1904 #endif
1905     CARD16 length;
1906     Drawable drawable;
1907     CARD16 width, height;
1908 } xQueryBestSizeReq;
1909 
1910 typedef struct {
1911     CARD8 reqType;
1912     BYTE pad;
1913     CARD16 length;
1914     CARD16 nbytes;	/* number of string bytes following structure */
1915     BYTE pad1, pad2;
1916 } xQueryExtensionReq;
1917 
1918 typedef struct {
1919     CARD8   reqType;
1920     CARD8   numKeyPerModifier;
1921     CARD16  length;
1922 } xSetModifierMappingReq;
1923 
1924 typedef struct {
1925     CARD8 reqType;
1926     CARD8 nElts;	/* how many elements in the map */
1927     CARD16 length;
1928 } xSetPointerMappingReq;
1929 
1930 typedef struct {
1931     CARD8 reqType;
1932     BYTE pad;
1933     CARD16 length;
1934     KeyCode firstKeyCode;
1935     CARD8 count;
1936     CARD16 pad1;
1937 } xGetKeyboardMappingReq;
1938 
1939 typedef struct {
1940     CARD8 reqType;
1941     CARD8 keyCodes;
1942     CARD16 length;
1943     KeyCode firstKeyCode;
1944     CARD8 keySymsPerKeyCode;
1945     CARD16 pad1;
1946 } xChangeKeyboardMappingReq;
1947 
1948 typedef struct {
1949     CARD8 reqType;
1950     BYTE pad;
1951     CARD16 length;
1952     CARD32 mask;
1953 } xChangeKeyboardControlReq;
1954 
1955 typedef struct {
1956     CARD8 reqType;
1957     INT8 percent;  /* -100 to 100 */
1958     CARD16 length;
1959 } xBellReq;
1960 
1961 typedef struct {
1962     CARD8 reqType;
1963     BYTE pad;
1964     CARD16 length;
1965     INT16 accelNum, accelDenum;
1966     INT16 threshold;
1967     BOOL doAccel, doThresh;
1968 } xChangePointerControlReq;
1969 
1970 typedef struct {
1971     CARD8 reqType;
1972     BYTE pad;
1973     CARD16 length;
1974     INT16 timeout, interval;
1975     BYTE preferBlank, allowExpose;
1976     CARD16 pad2;
1977 } xSetScreenSaverReq;
1978 
1979 typedef struct {
1980     CARD8 reqType;
1981     BYTE mode;
1982     CARD16 length;
1983     CARD8 hostFamily;
1984     BYTE pad;
1985     CARD16 hostLength;
1986 } xChangeHostsReq;
1987 
1988 typedef struct {
1989     CARD8 reqType;
1990     BYTE pad;
1991     CARD16 length;
1992     } xListHostsReq;
1993 
1994 typedef struct {
1995     CARD8 reqType;
1996     BYTE mode;
1997     CARD16 length;
1998     } xChangeModeReq;
1999 
2000 typedef xChangeModeReq xSetAccessControlReq;
2001 typedef xChangeModeReq xSetCloseDownModeReq;
2002 typedef xChangeModeReq xForceScreenSaverReq;
2003 
2004 typedef struct { /* followed by LIST of ATOM */
2005     CARD8 reqType;
2006     BYTE pad;
2007     CARD16 length;
2008     Window window;
2009     CARD16 nAtoms;
2010     INT16 nPositions;
2011     } xRotatePropertiesReq;
2012 
2013 
2014 
2015 /* Reply codes */
2016 
2017 #define X_Reply		1		/* Normal reply */
2018 #define X_Error		0		/* Error */
2019 
2020 /* Request codes */
2021 
2022 #define X_CreateWindow                  1
2023 #define X_ChangeWindowAttributes        2
2024 #define X_GetWindowAttributes           3
2025 #define X_DestroyWindow                 4
2026 #define X_DestroySubwindows             5
2027 #define X_ChangeSaveSet                 6
2028 #define X_ReparentWindow                7
2029 #define X_MapWindow                     8
2030 #define X_MapSubwindows                 9
2031 #define X_UnmapWindow                  10
2032 #define X_UnmapSubwindows              11
2033 #define X_ConfigureWindow              12
2034 #define X_CirculateWindow              13
2035 #define X_GetGeometry                  14
2036 #define X_QueryTree                    15
2037 #define X_InternAtom                   16
2038 #define X_GetAtomName                  17
2039 #define X_ChangeProperty               18
2040 #define X_DeleteProperty               19
2041 #define X_GetProperty                  20
2042 #define X_ListProperties               21
2043 #define X_SetSelectionOwner            22
2044 #define X_GetSelectionOwner            23
2045 #define X_ConvertSelection             24
2046 #define X_SendEvent                    25
2047 #define X_GrabPointer                  26
2048 #define X_UngrabPointer                27
2049 #define X_GrabButton                   28
2050 #define X_UngrabButton                 29
2051 #define X_ChangeActivePointerGrab      30
2052 #define X_GrabKeyboard                 31
2053 #define X_UngrabKeyboard               32
2054 #define X_GrabKey                      33
2055 #define X_UngrabKey                    34
2056 #define X_AllowEvents                  35
2057 #define X_GrabServer                   36
2058 #define X_UngrabServer                 37
2059 #define X_QueryPointer                 38
2060 #define X_GetMotionEvents              39
2061 #define X_TranslateCoords              40
2062 #define X_WarpPointer                  41
2063 #define X_SetInputFocus                42
2064 #define X_GetInputFocus                43
2065 #define X_QueryKeymap                  44
2066 #define X_OpenFont                     45
2067 #define X_CloseFont                    46
2068 #define X_QueryFont                    47
2069 #define X_QueryTextExtents             48
2070 #define X_ListFonts                    49
2071 #define X_ListFontsWithInfo    	       50
2072 #define X_SetFontPath                  51
2073 #define X_GetFontPath                  52
2074 #define X_CreatePixmap                 53
2075 #define X_FreePixmap                   54
2076 #define X_CreateGC                     55
2077 #define X_ChangeGC                     56
2078 #define X_CopyGC                       57
2079 #define X_SetDashes                    58
2080 #define X_SetClipRectangles            59
2081 #define X_FreeGC                       60
2082 #define X_ClearArea                    61
2083 #define X_CopyArea                     62
2084 #define X_CopyPlane                    63
2085 #define X_PolyPoint                    64
2086 #define X_PolyLine                     65
2087 #define X_PolySegment                  66
2088 #define X_PolyRectangle                67
2089 #define X_PolyArc                      68
2090 #define X_FillPoly                     69
2091 #define X_PolyFillRectangle            70
2092 #define X_PolyFillArc                  71
2093 #define X_PutImage                     72
2094 #define X_GetImage                     73
2095 #define X_PolyText8                    74
2096 #define X_PolyText16                   75
2097 #define X_ImageText8                   76
2098 #define X_ImageText16                  77
2099 #define X_CreateColormap               78
2100 #define X_FreeColormap                 79
2101 #define X_CopyColormapAndFree          80
2102 #define X_InstallColormap              81
2103 #define X_UninstallColormap            82
2104 #define X_ListInstalledColormaps       83
2105 #define X_AllocColor                   84
2106 #define X_AllocNamedColor              85
2107 #define X_AllocColorCells              86
2108 #define X_AllocColorPlanes             87
2109 #define X_FreeColors                   88
2110 #define X_StoreColors                  89
2111 #define X_StoreNamedColor              90
2112 #define X_QueryColors                  91
2113 #define X_LookupColor                  92
2114 #define X_CreateCursor                 93
2115 #define X_CreateGlyphCursor            94
2116 #define X_FreeCursor                   95
2117 #define X_RecolorCursor                96
2118 #define X_QueryBestSize                97
2119 #define X_QueryExtension               98
2120 #define X_ListExtensions               99
2121 #define X_ChangeKeyboardMapping        100
2122 #define X_GetKeyboardMapping           101
2123 #define X_ChangeKeyboardControl        102
2124 #define X_GetKeyboardControl           103
2125 #define X_Bell                         104
2126 #define X_ChangePointerControl         105
2127 #define X_GetPointerControl            106
2128 #define X_SetScreenSaver               107
2129 #define X_GetScreenSaver               108
2130 #define X_ChangeHosts                  109
2131 #define X_ListHosts                    110
2132 #define X_SetAccessControl             111
2133 #define X_SetCloseDownMode             112
2134 #define X_KillClient                   113
2135 #define X_RotateProperties	       114
2136 #define X_ForceScreenSaver	       115
2137 #define X_SetPointerMapping            116
2138 #define X_GetPointerMapping            117
2139 #define X_SetModifierMapping	       118
2140 #define X_GetModifierMapping	       119
2141 #define X_NoOperation                  127
2142 
2143 /* restore these definitions back to the typedefs in X.h */
2144 #undef Window
2145 #undef Drawable
2146 #undef Font
2147 #undef Pixmap
2148 #undef Cursor
2149 #undef Colormap
2150 #undef GContext
2151 #undef Atom
2152 #undef VisualID
2153 #undef Time
2154 #undef KeyCode
2155 #undef KeySym
2156 
2157 #endif /* XPROTO_H */
2158