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