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
27Copyright 1987, 1998  The Open Group
28
29Permission to use, copy, modify, distribute, and sell this software and its
30documentation for any purpose is hereby granted without fee, provided that
31the above copyright notice appear in all copies and that both that
32copyright notice and this permission notice appear in supporting
33documentation.
34
35The above copyright notice and this permission notice shall be included in
36all copies or substantial portions of the Software.
37
38THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
39IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
40FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE
41OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
42AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
43CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
44
45Except as contained in this notice, the name of The Open Group shall not be
46used in advertising or otherwise to promote the sale, use or other dealings
47in this Software without prior written authorization from The Open Group.
48
49
50Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
51
52                        All Rights Reserved
53
54Permission to use, copy, modify, and distribute this software and its
55documentation for any purpose and without fee is hereby granted,
56provided that the above copyright notice appear in all copies and that
57both that copyright notice and this permission notice appear in
58supporting documentation, and that the name of Digital not be
59used in advertising or publicity pertaining to distribution of the
60software without specific, written prior permission.
61
62DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
63ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
64DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
65ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
66WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
67ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
68SOFTWARE.
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,
236we must redefine the following types in terms of Xmd.h's types, which may
237include bit fields.  All of these are #undef'd at the end of this file,
238restoring 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
259typedef CARD16 KeyButMask;
260
261/*****************
262   connection setup structure.  This is followed by
263   numRoots xWindowRoot structs.
264*****************/
265
266typedef struct {
267    CARD8	byteOrder;
268    BYTE	pad;
269    CARD16	majorVersion B16, minorVersion B16;
270    CARD16	nbytesAuthProto B16;	/* Authorization protocol */
271    CARD16	nbytesAuthString B16;	/* Authorization string */
272    CARD16	pad2 B16;
273} xConnClientPrefix;
274
275typedef struct {
276    CARD8          success;
277    BYTE           lengthReason; /*num bytes in string following if failure */
278    CARD16         majorVersion B16,
279                   minorVersion B16;
280    CARD16         length B16;  /* 1/4 additional bytes in setup info */
281} xConnSetupPrefix;
282
283
284typedef struct {
285    CARD32         release B32;
286    CARD32         ridBase B32,
287                   ridMask B32;
288    CARD32         motionBufferSize B32;
289    CARD16         nbytesVendor B16;  /* number of bytes in vendor string */
290    CARD16         maxRequestSize B16;
291    CARD8          numRoots;          /* number of roots structs to follow */
292    CARD8          numFormats;        /* number of pixmap formats */
293    CARD8          imageByteOrder;        /* LSBFirst, MSBFirst */
294    CARD8          bitmapBitOrder;        /* LeastSignificant, MostSign...*/
295    CARD8          bitmapScanlineUnit,     /* 8, 16, 32 */
296                   bitmapScanlinePad;     /* 8, 16, 32 */
297    KeyCode	   minKeyCode, maxKeyCode;
298    CARD32	   pad2 B32;
299} xConnSetup;
300
301typedef struct {
302    CARD8          depth;
303    CARD8          bitsPerPixel;
304    CARD8          scanLinePad;
305    CARD8          pad1;
306    CARD32	   pad2 B32;
307} xPixmapFormat;
308
309/* window root */
310
311typedef struct {
312    CARD8 	depth;
313    CARD8 	pad1;
314    CARD16	nVisuals B16;  /* number of xVisualType structures following */
315    CARD32	pad2 B32;
316    } xDepth;
317
318typedef struct {
319    VisualID visualID B32;
320#if defined(__cplusplus) || defined(c_plusplus)
321    CARD8 c_class;
322#else
323    CARD8 class;
324#endif
325    CARD8 bitsPerRGB;
326    CARD16 colormapEntries B16;
327    CARD32 redMask B32, greenMask B32, blueMask B32;
328    CARD32 pad B32;
329    } xVisualType;
330
331typedef struct {
332    Window         windowId B32;
333    Colormap       defaultColormap B32;
334    CARD32         whitePixel B32, blackPixel B32;
335    CARD32         currentInputMask B32;
336    CARD16         pixWidth B16, pixHeight B16;
337    CARD16         mmWidth B16, mmHeight B16;
338    CARD16         minInstalledMaps B16, maxInstalledMaps B16;
339    VisualID       rootVisualID B32;
340    CARD8          backingStore;
341    BOOL           saveUnders;
342    CARD8          rootDepth;
343    CARD8          nDepths;  /* number of xDepth structures following */
344} xWindowRoot;
345
346
347/*****************************************************************
348 * Structure Defns
349 *   Structures needed for replies
350 *****************************************************************/
351
352/* Used in GetMotionEvents */
353
354typedef struct {
355    CARD32 time B32;
356    INT16 x B16, y B16;
357} xTimecoord;
358
359typedef struct {
360    CARD8 family;
361    BYTE pad;
362    CARD16 length B16;
363} xHostEntry;
364
365typedef struct {
366    INT16 leftSideBearing B16,
367	  rightSideBearing B16,
368	  characterWidth B16,
369	  ascent B16,
370	  descent B16;
371    CARD16 attributes B16;
372} xCharInfo;
373
374typedef struct {
375    Atom name B32;
376    CARD32 value B32;
377} xFontProp;
378
379/*
380 * non-aligned big-endian font ID follows this struct
381 */
382typedef struct {           /* followed by string */
383    CARD8 len;	/* number of *characters* in string, or FontChange (255)
384		   for font change, or 0 if just delta given */
385    INT8 delta;
386} xTextElt;
387
388
389typedef struct {
390    CARD32 pixel B32;
391    CARD16 red B16, green B16, blue B16;
392    CARD8 flags;  /* DoRed, DoGreen, DoBlue booleans */
393    CARD8 pad;
394} xColorItem;
395
396
397typedef struct {
398    CARD16 red B16, green B16, blue B16, pad B16;
399} xrgb;
400
401typedef CARD8 KEYCODE;
402
403
404/*****************
405 * XRep:
406 *    meant to be 32 byte quantity
407 *****************/
408
409/* GenericReply is the common format of all replies.  The "data" items
410   are specific to each individual reply type. */
411
412typedef struct {
413    BYTE type;              /* X_Reply */
414    BYTE data1;             /* depends on reply type */
415    CARD16 sequenceNumber B16;  /* of last request received by server */
416    CARD32 length B32;      /* 4 byte quantities beyond size of GenericReply */
417    CARD32 data00 B32;
418    CARD32 data01 B32;
419    CARD32 data02 B32;
420    CARD32 data03 B32;
421    CARD32 data04 B32;
422    CARD32 data05 B32;
423    } xGenericReply;
424
425/* Individual reply formats. */
426
427typedef struct {
428    BYTE type;  /* X_Reply */
429    CARD8 backingStore;
430    CARD16 sequenceNumber B16;
431    CARD32 length B32;	/* NOT 0; this is an extra-large reply */
432    VisualID visualID B32;
433#if defined(__cplusplus) || defined(c_plusplus)
434    CARD16 c_class B16;
435#else
436    CARD16 class B16;
437#endif
438    CARD8 bitGravity;
439    CARD8 winGravity;
440    CARD32 backingBitPlanes B32;
441    CARD32 backingPixel B32;
442    BOOL saveUnder;
443    BOOL mapInstalled;
444    CARD8 mapState;
445    BOOL override;
446    Colormap colormap B32;
447    CARD32 allEventMasks B32;
448    CARD32 yourEventMask B32;
449    CARD16 doNotPropagateMask B16;
450    CARD16 pad B16;
451    } xGetWindowAttributesReply;
452
453typedef struct {
454    BYTE type;   /* X_Reply */
455    CARD8 depth;
456    CARD16 sequenceNumber B16;
457    CARD32 length B32;  /* 0 */
458    Window root B32;
459    INT16 x B16, y B16;
460    CARD16 width B16, height B16;
461    CARD16 borderWidth B16;
462    CARD16 pad1 B16;
463    CARD32 pad2 B32;
464    CARD32 pad3 B32;
465    } xGetGeometryReply;
466
467typedef struct {
468    BYTE type;  /* X_Reply */
469    BYTE pad1;
470    CARD16 sequenceNumber B16;
471    CARD32 length B32;
472    Window root B32, parent B32;
473    CARD16 nChildren B16;
474    CARD16 pad2 B16;
475    CARD32 pad3 B32;
476    CARD32 pad4 B32;
477    CARD32 pad5 B32;
478    } xQueryTreeReply;
479
480typedef struct {
481    BYTE type;  /* X_Reply */
482    BYTE pad1;
483    CARD16 sequenceNumber B16;
484    CARD32 length B32; /* 0 */
485    Atom atom B32;
486    CARD32 pad2 B32;
487    CARD32 pad3 B32;
488    CARD32 pad4 B32;
489    CARD32 pad5 B32;
490    CARD32 pad6 B32;
491    } xInternAtomReply;
492
493typedef struct {
494    BYTE type;  /* X_Reply */
495    BYTE pad1;
496    CARD16 sequenceNumber B16;
497    CARD32 length B32;  /* of additional bytes */
498    CARD16 nameLength B16;  /* # of characters in name */
499    CARD16 pad2 B16;
500    CARD32 pad3 B32;
501    CARD32 pad4 B32;
502    CARD32 pad5 B32;
503    CARD32 pad6 B32;
504    CARD32 pad7 B32;
505    } xGetAtomNameReply;
506
507typedef struct {
508    BYTE type;  /* X_Reply */
509    CARD8 format;
510    CARD16 sequenceNumber B16;
511    CARD32 length B32; /* of additional bytes */
512    Atom propertyType B32;
513    CARD32 bytesAfter B32;
514    CARD32 nItems B32; /* # of 8, 16, or 32-bit entities in reply */
515    CARD32 pad1 B32;
516    CARD32 pad2 B32;
517    CARD32 pad3 B32;
518    } xGetPropertyReply;
519
520typedef struct {
521    BYTE type;  /* X_Reply */
522    BYTE pad1;
523    CARD16 sequenceNumber B16;
524    CARD32 length B32;
525    CARD16 nProperties B16;
526    CARD16 pad2 B16;
527    CARD32 pad3 B32;
528    CARD32 pad4 B32;
529    CARD32 pad5 B32;
530    CARD32 pad6 B32;
531    CARD32 pad7 B32;
532    } xListPropertiesReply;
533
534typedef struct {
535    BYTE type;  /* X_Reply */
536    BYTE pad1;
537    CARD16 sequenceNumber B16;
538    CARD32 length B32;  /* 0 */
539    Window owner B32;
540    CARD32 pad2 B32;
541    CARD32 pad3 B32;
542    CARD32 pad4 B32;
543    CARD32 pad5 B32;
544    CARD32 pad6 B32;
545    } xGetSelectionOwnerReply;
546
547typedef struct {
548    BYTE type;  /* X_Reply */
549    BYTE status;
550    CARD16 sequenceNumber B16;
551    CARD32 length B32;  /* 0 */
552    CARD32 pad1 B32;
553    CARD32 pad2 B32;
554    CARD32 pad3 B32;
555    CARD32 pad4 B32;
556    CARD32 pad5 B32;
557    CARD32 pad6 B32;
558    } xGrabPointerReply;
559
560typedef xGrabPointerReply xGrabKeyboardReply;
561
562typedef struct {
563    BYTE type;  /* X_Reply */
564    BOOL sameScreen;
565    CARD16 sequenceNumber B16;
566    CARD32 length B32;  /* 0 */
567    Window root B32, child B32;
568    INT16 rootX B16, rootY B16, winX B16, winY B16;
569    CARD16 mask B16;
570    CARD16 pad1 B16;
571    CARD32 pad B32;
572    } xQueryPointerReply;
573
574typedef struct {
575    BYTE type;  /* X_Reply */
576    BYTE pad1;
577    CARD16 sequenceNumber B16;
578    CARD32 length B32;
579    CARD32 nEvents B32;
580    CARD32 pad2 B32;
581    CARD32 pad3 B32;
582    CARD32 pad4 B32;
583    CARD32 pad5 B32;
584    CARD32 pad6 B32;
585    } xGetMotionEventsReply;
586
587typedef struct {
588    BYTE type;  /* X_Reply */
589    BOOL sameScreen;
590    CARD16 sequenceNumber B16;
591    CARD32 length B32; /* 0 */
592    Window child B32;
593    INT16 dstX B16, dstY B16;
594    CARD32 pad2 B32;
595    CARD32 pad3 B32;
596    CARD32 pad4 B32;
597    CARD32 pad5 B32;
598    } xTranslateCoordsReply;
599
600typedef struct {
601    BYTE type;  /* X_Reply */
602    CARD8 revertTo;
603    CARD16 sequenceNumber B16;
604    CARD32 length B32;  /* 0 */
605    Window focus B32;
606    CARD32 pad1 B32;
607    CARD32 pad2 B32;
608    CARD32 pad3 B32;
609    CARD32 pad4 B32;
610    CARD32 pad5 B32;
611    } xGetInputFocusReply;
612
613typedef struct {
614    BYTE type;  /* X_Reply */
615    BYTE pad1;
616    CARD16 sequenceNumber B16;
617    CARD32 length B32;  /* 2, NOT 0; this is an extra-large reply */
618    BYTE map[32];
619    } xQueryKeymapReply;
620
621/* Warning: this MUST match (up to component renaming) xListFontsWithInfoReply */
622typedef struct _xQueryFontReply {
623    BYTE type;  /* X_Reply */
624    BYTE pad1;
625    CARD16 sequenceNumber B16;
626    CARD32 length B32;  /* definitely > 0, even if "nCharInfos" is 0 */
627    xCharInfo minBounds;
628#ifndef WORD64
629    CARD32 walign1 B32;
630#endif
631    xCharInfo maxBounds;
632#ifndef WORD64
633    CARD32 walign2 B32;
634#endif
635    CARD16 minCharOrByte2 B16, maxCharOrByte2 B16;
636    CARD16 defaultChar B16;
637    CARD16 nFontProps B16;  /* followed by this many xFontProp structures */
638    CARD8 drawDirection;
639    CARD8 minByte1, maxByte1;
640    BOOL allCharsExist;
641    INT16 fontAscent B16, fontDescent B16;
642    CARD32 nCharInfos B32; /* followed by this many xCharInfo structures */
643} xQueryFontReply;
644
645typedef struct {
646    BYTE type;  /* X_Reply */
647    CARD8 drawDirection;
648    CARD16 sequenceNumber B16;
649    CARD32 length B32;  /* 0 */
650    INT16 fontAscent B16, fontDescent B16;
651    INT16 overallAscent B16, overallDescent B16;
652    INT32 overallWidth B32, overallLeft B32, overallRight B32;
653    CARD32 pad B32;
654    } xQueryTextExtentsReply;
655
656typedef struct {
657    BYTE type;  /* X_Reply */
658    BYTE pad1;
659    CARD16 sequenceNumber B16;
660    CARD32 length B32;
661    CARD16 nFonts B16;
662    CARD16 pad2 B16;
663    CARD32 pad3 B32;
664    CARD32 pad4 B32;
665    CARD32 pad5 B32;
666    CARD32 pad6 B32;
667    CARD32 pad7 B32;
668    } xListFontsReply;
669
670/* Warning: this MUST match (up to component renaming) xQueryFontReply */
671typedef struct {
672    BYTE type;  /* X_Reply */
673    CARD8 nameLength;  /* 0 indicates end-of-reply-sequence */
674    CARD16 sequenceNumber B16;
675    CARD32 length B32;  /* definitely > 0, even if "nameLength" is 0 */
676    xCharInfo minBounds;
677#ifndef WORD64
678    CARD32 walign1 B32;
679#endif
680    xCharInfo maxBounds;
681#ifndef WORD64
682    CARD32 walign2 B32;
683#endif
684    CARD16 minCharOrByte2 B16, maxCharOrByte2 B16;
685    CARD16 defaultChar B16;
686    CARD16 nFontProps B16;  /* followed by this many xFontProp structures */
687    CARD8 drawDirection;
688    CARD8 minByte1, maxByte1;
689    BOOL allCharsExist;
690    INT16 fontAscent B16, fontDescent B16;
691    CARD32 nReplies B32;   /* hint as to how many more replies might be coming */
692} xListFontsWithInfoReply;
693
694typedef struct {
695    BYTE type;  /* X_Reply */
696    BYTE pad1;
697    CARD16 sequenceNumber B16;
698    CARD32 length B32;
699    CARD16 nPaths B16;
700    CARD16 pad2 B16;
701    CARD32 pad3 B32;
702    CARD32 pad4 B32;
703    CARD32 pad5 B32;
704    CARD32 pad6 B32;
705    CARD32 pad7 B32;
706    } xGetFontPathReply;
707
708typedef struct {
709    BYTE type;  /* X_Reply */
710    CARD8 depth;
711    CARD16 sequenceNumber B16;
712    CARD32 length B32;
713    VisualID visual B32;
714    CARD32 pad3 B32;
715    CARD32 pad4 B32;
716    CARD32 pad5 B32;
717    CARD32 pad6 B32;
718    CARD32 pad7 B32;
719    } xGetImageReply;
720
721typedef struct {
722    BYTE type;  /* X_Reply */
723    BYTE pad1;
724    CARD16 sequenceNumber B16;
725    CARD32 length B32;
726    CARD16 nColormaps B16;
727    CARD16 pad2 B16;
728    CARD32 pad3 B32;
729    CARD32 pad4 B32;
730    CARD32 pad5 B32;
731    CARD32 pad6 B32;
732    CARD32 pad7 B32;
733    } xListInstalledColormapsReply;
734
735typedef struct {
736    BYTE type; /* X_Reply */
737    BYTE pad1;
738    CARD16 sequenceNumber B16;
739    CARD32 length B32;   /* 0 */
740    CARD16 red B16, green B16, blue B16;
741    CARD16 pad2 B16;
742    CARD32 pixel B32;
743    CARD32 pad3 B32;
744    CARD32 pad4 B32;
745    CARD32 pad5 B32;
746    } xAllocColorReply;
747
748typedef struct {
749    BYTE type; /* X_Reply */
750    BYTE pad1;
751    CARD16 sequenceNumber B16;
752    CARD32 length B32;  /* 0 */
753    CARD32 pixel B32;
754    CARD16 exactRed B16, exactGreen B16, exactBlue B16;
755    CARD16 screenRed B16, screenGreen B16, screenBlue B16;
756    CARD32 pad2 B32;
757    CARD32 pad3 B32;
758    } xAllocNamedColorReply;
759
760typedef struct {
761    BYTE type;  /* X_Reply */
762    BYTE pad1;
763    CARD16 sequenceNumber B16;
764    CARD32 length B32;
765    CARD16 nPixels B16, nMasks B16;
766    CARD32 pad3 B32;
767    CARD32 pad4 B32;
768    CARD32 pad5 B32;
769    CARD32 pad6 B32;
770    CARD32 pad7 B32;
771    } xAllocColorCellsReply;
772
773typedef struct {
774    BYTE type; /* X_Reply */
775    BYTE pad1;
776    CARD16 sequenceNumber B16;
777    CARD32 length B32;
778    CARD16 nPixels B16;
779    CARD16 pad2 B16;
780    CARD32 redMask B32, greenMask B32, blueMask B32;
781    CARD32 pad3 B32;
782    CARD32 pad4 B32;
783    } xAllocColorPlanesReply;
784
785typedef struct {
786    BYTE type; /* X_Reply */
787    BYTE pad1;
788    CARD16 sequenceNumber B16;
789    CARD32 length B32;
790    CARD16 nColors B16;
791    CARD16 pad2 B16;
792    CARD32 pad3 B32;
793    CARD32 pad4 B32;
794    CARD32 pad5 B32;
795    CARD32 pad6 B32;
796    CARD32 pad7 B32;
797    } xQueryColorsReply;
798
799typedef struct {
800    BYTE type;  /* X_Reply */
801    BYTE pad1;
802    CARD16 sequenceNumber B16;
803    CARD32 length B32;  /* 0 */
804    CARD16 exactRed B16, exactGreen B16, exactBlue B16;
805    CARD16 screenRed B16, screenGreen B16, screenBlue B16;
806    CARD32 pad3 B32;
807    CARD32 pad4 B32;
808    CARD32 pad5 B32;
809    } xLookupColorReply;
810
811typedef struct {
812    BYTE type;  /* X_Reply */
813    BYTE pad1;
814    CARD16 sequenceNumber B16;
815    CARD32 length B32;  /* 0 */
816    CARD16 width B16, height B16;
817    CARD32 pad3 B32;
818    CARD32 pad4 B32;
819    CARD32 pad5 B32;
820    CARD32 pad6 B32;
821    CARD32 pad7 B32;
822    } xQueryBestSizeReply;
823
824typedef struct {
825    BYTE type;  /* X_Reply */
826    BYTE pad1;
827    CARD16 sequenceNumber B16;
828    CARD32 length B32; /* 0 */
829    BOOL  present;
830    CARD8 major_opcode;
831    CARD8 first_event;
832    CARD8 first_error;
833    CARD32 pad3 B32;
834    CARD32 pad4 B32;
835    CARD32 pad5 B32;
836    CARD32 pad6 B32;
837    CARD32 pad7 B32;
838    } xQueryExtensionReply;
839
840typedef struct {
841    BYTE type;  /* X_Reply */
842    CARD8 nExtensions;
843    CARD16 sequenceNumber B16;
844    CARD32 length B32;
845    CARD32 pad2 B32;
846    CARD32 pad3 B32;
847    CARD32 pad4 B32;
848    CARD32 pad5 B32;
849    CARD32 pad6 B32;
850    CARD32 pad7 B32;
851    } xListExtensionsReply;
852
853
854typedef struct {
855    BYTE   type;  /* X_Reply */
856    CARD8  success;
857    CARD16 sequenceNumber B16;
858    CARD32 length B32;
859    CARD32 pad2 B32;
860    CARD32 pad3 B32;
861    CARD32 pad4 B32;
862    CARD32 pad5 B32;
863    CARD32 pad6 B32;
864    CARD32 pad7 B32;
865    } xSetMappingReply;
866typedef xSetMappingReply xSetPointerMappingReply;
867typedef xSetMappingReply xSetModifierMappingReply;
868
869typedef struct {
870    BYTE type;  /* X_Reply */
871    CARD8 nElts;  /* how many elements does the map have */
872    CARD16 sequenceNumber B16;
873    CARD32 length B32;
874    CARD32 pad2 B32;
875    CARD32 pad3 B32;
876    CARD32 pad4 B32;
877    CARD32 pad5 B32;
878    CARD32 pad6 B32;
879    CARD32 pad7 B32;
880    } xGetPointerMappingReply;
881
882typedef struct {
883    BYTE type;
884    CARD8 keySymsPerKeyCode;
885    CARD16 sequenceNumber B16;
886    CARD32 length B32;
887    CARD32 pad2 B32;
888    CARD32 pad3 B32;
889    CARD32 pad4 B32;
890    CARD32 pad5 B32;
891    CARD32 pad6 B32;
892    CARD32 pad7 B32;
893} xGetKeyboardMappingReply;
894
895typedef struct {
896    BYTE type;
897    CARD8 numKeyPerModifier;
898    CARD16 sequenceNumber B16;
899    CARD32 length B32;
900    CARD32 pad1 B32;
901    CARD32 pad2 B32;
902    CARD32 pad3 B32;
903    CARD32 pad4 B32;
904    CARD32 pad5 B32;
905    CARD32 pad6 B32;
906} xGetModifierMappingReply;
907
908typedef struct {
909    BYTE type;  /* X_Reply */
910    BOOL globalAutoRepeat;
911    CARD16 sequenceNumber B16;
912    CARD32 length B32;  /* 5 */
913    CARD32 ledMask B32;
914    CARD8 keyClickPercent, bellPercent;
915    CARD16 bellPitch B16, bellDuration B16;
916    CARD16 pad B16;
917    BYTE map[32];  /* bit masks start here */
918    } xGetKeyboardControlReply;
919
920typedef struct {
921    BYTE type;  /* X_Reply */
922    BYTE pad1;
923    CARD16 sequenceNumber B16;
924    CARD32 length B32;  /* 0 */
925    CARD16 accelNumerator B16, accelDenominator B16;
926    CARD16 threshold B16;
927    CARD16 pad2 B16;
928    CARD32 pad3 B32;
929    CARD32 pad4 B32;
930    CARD32 pad5 B32;
931    CARD32 pad6 B32;
932    } xGetPointerControlReply;
933
934typedef struct {
935    BYTE type;  /* X_Reply */
936    BYTE pad1;
937    CARD16 sequenceNumber B16;
938    CARD32 length B32;  /* 0 */
939    CARD16 timeout B16, interval B16;
940    BOOL preferBlanking;
941    BOOL allowExposures;
942    CARD16 pad2 B16;
943    CARD32 pad3 B32;
944    CARD32 pad4 B32;
945    CARD32 pad5 B32;
946    CARD32 pad6 B32;
947    } xGetScreenSaverReply;
948
949typedef struct {
950    BYTE type;  /* X_Reply */
951    BOOL enabled;
952    CARD16 sequenceNumber B16;
953    CARD32 length B32;
954    CARD16 nHosts B16;
955    CARD16 pad1 B16;
956    CARD32 pad3 B32;
957    CARD32 pad4 B32;
958    CARD32 pad5 B32;
959    CARD32 pad6 B32;
960    CARD32 pad7 B32;
961    } xListHostsReply;
962
963
964
965
966/*****************************************************************
967 * Xerror
968 *    All errors  are 32 bytes
969 *****************************************************************/
970
971typedef struct {
972    BYTE type;                  /* X_Error */
973    BYTE errorCode;
974    CARD16 sequenceNumber B16;       /* the nth request from this client */
975    CARD32 resourceID B32;
976    CARD16 minorCode B16;
977    CARD8 majorCode;
978    BYTE pad1;
979    CARD32 pad3 B32;
980    CARD32 pad4 B32;
981    CARD32 pad5 B32;
982    CARD32 pad6 B32;
983    CARD32 pad7 B32;
984} xError;
985
986/*****************************************************************
987 * xEvent
988 *    All events are 32 bytes
989 *****************************************************************/
990
991typedef struct _xEvent {
992    union {
993	struct {
994	    BYTE type;
995	    BYTE detail;
996	    CARD16 sequenceNumber B16;
997	    } u;
998	struct {
999            CARD32 pad00 B32;
1000	    Time time B32;
1001	    Window root B32, event B32, child B32;
1002	    INT16 rootX B16, rootY B16, eventX B16, eventY B16;
1003	    KeyButMask state B16;
1004	    BOOL sameScreen;
1005	    BYTE pad1;
1006	} keyButtonPointer;
1007	struct {
1008            CARD32 pad00 B32;
1009            Time time B32;
1010	    Window root B32, event B32, child B32;
1011	    INT16 rootX B16, rootY B16, eventX B16, eventY B16;
1012	    KeyButMask state B16;
1013	    BYTE mode; 			/* really XMode */
1014	    BYTE flags;		/* sameScreen and focus booleans, packed together */
1015#define ELFlagFocus        (1<<0)
1016#define ELFlagSameScreen   (1<<1)
1017	} enterLeave;
1018	struct {
1019            CARD32 pad00 B32;
1020	    Window window B32;
1021	    BYTE mode; 			/* really XMode */
1022	    BYTE pad1, pad2, pad3;
1023	} focus;
1024	struct {
1025            CARD32 pad00 B32;
1026	    Window window B32;
1027	    CARD16 x B16, y B16, width B16, height B16;
1028	    CARD16 count B16;
1029	    CARD16 pad2 B16;
1030	} expose;
1031	struct {
1032            CARD32 pad00 B32;
1033	    Drawable drawable B32;
1034	    CARD16 x B16, y B16, width B16, height B16;
1035	    CARD16 minorEvent B16;
1036	    CARD16 count B16;
1037	    BYTE majorEvent;
1038	    BYTE pad1, pad2, pad3;
1039	} graphicsExposure;
1040	struct {
1041            CARD32 pad00 B32;
1042	    Drawable drawable B32;
1043	    CARD16 minorEvent B16;
1044	    BYTE majorEvent;
1045	    BYTE bpad;
1046	} noExposure;
1047	struct {
1048            CARD32 pad00 B32;
1049	    Window window B32;
1050	    CARD8 state;
1051	    BYTE pad1, pad2, pad3;
1052	} visibility;
1053	struct {
1054            CARD32 pad00 B32;
1055	    Window parent B32, window B32;
1056	    INT16 x B16, y B16;
1057	    CARD16 width B16, height B16, borderWidth B16;
1058	    BOOL override;
1059	    BYTE bpad;
1060        } createNotify;
1061/*
1062 * The event fields in the structures for DestroyNotify, UnmapNotify,
1063 * MapNotify, ReparentNotify, ConfigureNotify, CirculateNotify, GravityNotify,
1064 * must be at the same offset because server internal code is depending upon
1065 * this to patch up the events before they are delivered.
1066 * Also note that MapRequest, ConfigureRequest and CirculateRequest have
1067 * the same offset for the event window.
1068 */
1069	struct {
1070            CARD32 pad00 B32;
1071	    Window event B32, window B32;
1072	} destroyNotify;
1073	struct {
1074            CARD32 pad00 B32;
1075	    Window event B32, window B32;
1076	    BOOL fromConfigure;
1077	    BYTE pad1, pad2, pad3;
1078        } unmapNotify;
1079	struct {
1080            CARD32 pad00 B32;
1081	    Window event B32, window B32;
1082	    BOOL override;
1083	    BYTE pad1, pad2, pad3;
1084        } mapNotify;
1085	struct {
1086            CARD32 pad00 B32;
1087	    Window parent B32, window B32;
1088        } mapRequest;
1089	struct {
1090            CARD32 pad00 B32;
1091	    Window event B32, window B32, parent B32;
1092	    INT16 x B16, y B16;
1093	    BOOL override;
1094	    BYTE pad1, pad2, pad3;
1095	} reparent;
1096	struct {
1097            CARD32 pad00 B32;
1098	    Window event B32, window B32, aboveSibling B32;
1099	    INT16 x B16, y B16;
1100	    CARD16 width B16, height B16, borderWidth B16;
1101	    BOOL override;
1102	    BYTE bpad;
1103	} configureNotify;
1104	struct {
1105            CARD32 pad00 B32;
1106	    Window parent B32, window B32, sibling B32;
1107	    INT16 x B16, y B16;
1108	    CARD16 width B16, height B16, borderWidth B16;
1109	    CARD16 valueMask B16;
1110	    CARD32 pad1 B32;
1111	} configureRequest;
1112	struct {
1113            CARD32 pad00 B32;
1114	    Window event B32, window B32;
1115	    INT16 x B16, y B16;
1116	    CARD32 pad1 B32, pad2 B32, pad3 B32, pad4 B32;
1117	} gravity;
1118	struct {
1119            CARD32 pad00 B32;
1120	    Window window B32;
1121	    CARD16 width B16, height B16;
1122	} resizeRequest;
1123	struct {
1124/* The event field in the circulate record is really the parent when this
1125   is used as a CirculateRequest instead of a CirculateNotify */
1126            CARD32 pad00 B32;
1127	    Window event B32, window B32, parent B32;
1128	    BYTE place;			/* Top or Bottom */
1129	    BYTE pad1, pad2, pad3;
1130	} circulate;
1131	struct {
1132            CARD32 pad00 B32;
1133	    Window window B32;
1134	    Atom atom B32;
1135	    Time time B32;
1136	    BYTE state;			/* NewValue or Deleted */
1137	    BYTE pad1;
1138	    CARD16 pad2 B16;
1139	} property;
1140	struct {
1141            CARD32 pad00 B32;
1142            Time time B32;
1143	    Window window B32;
1144	    Atom atom B32;
1145	} selectionClear;
1146	struct {
1147            CARD32 pad00 B32;
1148            Time time B32;
1149	    Window owner B32, requestor B32;
1150	    Atom selection B32, target B32, property B32;
1151	} selectionRequest;
1152	struct {
1153            CARD32 pad00 B32;
1154            Time time B32;
1155	    Window requestor B32;
1156	    Atom selection B32, target B32, property B32;
1157	} selectionNotify;
1158	struct {
1159            CARD32 pad00 B32;
1160	    Window window B32;
1161	    Colormap colormap B32;
1162#if defined(__cplusplus) || defined(c_plusplus)
1163	    BOOL c_new;
1164#else
1165	    BOOL new;
1166#endif
1167	    BYTE state;			/* Installed or UnInstalled */
1168	    BYTE pad1, pad2;
1169	} colormap;
1170	struct {
1171	    CARD32 pad00 B32;
1172	    CARD8 request;
1173	    KeyCode firstKeyCode;
1174	    CARD8 count;
1175	    BYTE pad1;
1176	} mappingNotify;
1177	struct {
1178            CARD32 pad00 B32;
1179	    Window window B32;
1180	    union {
1181		struct {
1182		    Atom type B32;
1183		    INT32 longs0 B32;
1184		    INT32 longs1 B32;
1185		    INT32 longs2 B32;
1186		    INT32 longs3 B32;
1187		    INT32 longs4 B32;
1188		} l;
1189		struct {
1190		    Atom type B32;
1191		    INT16 shorts0 B16;
1192		    INT16 shorts1 B16;
1193		    INT16 shorts2 B16;
1194		    INT16 shorts3 B16;
1195		    INT16 shorts4 B16;
1196		    INT16 shorts5 B16;
1197		    INT16 shorts6 B16;
1198		    INT16 shorts7 B16;
1199		    INT16 shorts8 B16;
1200		    INT16 shorts9 B16;
1201		} s;
1202		struct {
1203		    Atom type B32;
1204		    INT8 bytes[20];
1205		} b;
1206	    } u;
1207	} clientMessage;
1208    } u;
1209} xEvent;
1210
1211/*********************************************************
1212 *
1213 * Generic event
1214 *
1215 * Those events are not part of the core protocol spec and can be used by
1216 * various extensions.
1217 * type is always GenericEvent
1218 * extension is the minor opcode of the extension the event belongs to.
1219 * evtype is the actual event type, unique __per extension__.
1220 *
1221 * GenericEvents can be longer than 32 bytes, with the length field
1222 * specifying the number of 4 byte blocks after the first 32 bytes.
1223 *
1224 *
1225 */
1226typedef struct
1227{
1228    BYTE    type;
1229    CARD8   extension;
1230    CARD16  sequenceNumber B16;
1231    CARD32  length B32;
1232    CARD16  evtype B16;
1233    CARD16  pad2 B16;
1234    CARD32  pad3 B32;
1235    CARD32  pad4 B32;
1236    CARD32  pad5 B32;
1237    CARD32  pad6 B32;
1238    CARD32  pad7 B32;
1239} xGenericEvent;
1240
1241
1242
1243/* KeymapNotify events are not included in the above union because they
1244   are different from all other events: they do not have a "detail"
1245   or "sequenceNumber", so there is room for a 248-bit key mask. */
1246
1247typedef struct {
1248    BYTE type;
1249    BYTE map[31];
1250    } xKeymapEvent;
1251
1252#define XEventSize (sizeof(xEvent))
1253
1254/* XReply is the union of all the replies above whose "fixed part"
1255fits in 32 bytes.  It does NOT include GetWindowAttributesReply,
1256QueryFontReply, QueryKeymapReply, or GetKeyboardControlReply
1257ListFontsWithInfoReply */
1258
1259typedef union {
1260    xGenericReply generic;
1261    xGetGeometryReply geom;
1262    xQueryTreeReply tree;
1263    xInternAtomReply atom;
1264    xGetAtomNameReply atomName;
1265    xGetPropertyReply property;
1266    xListPropertiesReply listProperties;
1267    xGetSelectionOwnerReply selection;
1268    xGrabPointerReply grabPointer;
1269    xGrabKeyboardReply grabKeyboard;
1270    xQueryPointerReply pointer;
1271    xGetMotionEventsReply motionEvents;
1272    xTranslateCoordsReply coords;
1273    xGetInputFocusReply inputFocus;
1274    xQueryTextExtentsReply textExtents;
1275    xListFontsReply fonts;
1276    xGetFontPathReply fontPath;
1277    xGetImageReply image;
1278    xListInstalledColormapsReply colormaps;
1279    xAllocColorReply allocColor;
1280    xAllocNamedColorReply allocNamedColor;
1281    xAllocColorCellsReply colorCells;
1282    xAllocColorPlanesReply colorPlanes;
1283    xQueryColorsReply colors;
1284    xLookupColorReply lookupColor;
1285    xQueryBestSizeReply bestSize;
1286    xQueryExtensionReply extension;
1287    xListExtensionsReply extensions;
1288    xSetModifierMappingReply setModifierMapping;
1289    xGetModifierMappingReply getModifierMapping;
1290    xSetPointerMappingReply setPointerMapping;
1291    xGetKeyboardMappingReply getKeyboardMapping;
1292    xGetPointerMappingReply getPointerMapping;
1293    xGetPointerControlReply pointerControl;
1294    xGetScreenSaverReply screenSaver;
1295    xListHostsReply hosts;
1296    xError error;
1297    xEvent event;
1298} xReply;
1299
1300
1301
1302/*****************************************************************
1303 * REQUESTS
1304 *****************************************************************/
1305
1306
1307/* Request structure */
1308
1309typedef struct _xReq {
1310	CARD8 reqType;
1311	CARD8 data;            /* meaning depends on request type */
1312	CARD16 length B16;         /* length in 4 bytes quantities
1313				  of whole request, including this header */
1314} xReq;
1315
1316/*****************************************************************
1317 *  structures that follow request.
1318 *****************************************************************/
1319
1320/* ResourceReq is used for any request which has a resource ID
1321   (or Atom or Time) as its one and only argument.  */
1322
1323typedef struct {
1324    CARD8 reqType;
1325    BYTE pad;
1326    CARD16 length B16;
1327    CARD32 id B32;  /* a Window, Drawable, Font, GContext, Pixmap, etc. */
1328    } xResourceReq;
1329
1330typedef struct {
1331    CARD8 reqType;
1332    CARD8 depth;
1333    CARD16 length B16;
1334    Window wid B32, parent B32;
1335    INT16 x B16, y B16;
1336    CARD16 width B16, height B16, borderWidth B16;
1337#if defined(__cplusplus) || defined(c_plusplus)
1338    CARD16 c_class B16;
1339#else
1340    CARD16 class B16;
1341#endif
1342    VisualID visual B32;
1343    CARD32 mask B32;
1344} xCreateWindowReq;
1345
1346typedef struct {
1347    CARD8 reqType;
1348    BYTE pad;
1349    CARD16 length B16;
1350    Window window B32;
1351    CARD32 valueMask B32;
1352} xChangeWindowAttributesReq;
1353
1354typedef struct {
1355    CARD8 reqType;
1356    BYTE mode;
1357    CARD16 length B16;
1358    Window window B32;
1359} xChangeSaveSetReq;
1360
1361typedef struct {
1362    CARD8 reqType;
1363    BYTE pad;
1364    CARD16 length B16;
1365    Window window B32, parent B32;
1366    INT16 x B16, y B16;
1367} xReparentWindowReq;
1368
1369typedef struct {
1370    CARD8 reqType;
1371    CARD8 pad;
1372    CARD16 length B16;
1373    Window window B32;
1374    CARD16 mask B16;
1375    CARD16 pad2 B16;
1376} xConfigureWindowReq;
1377
1378typedef struct {
1379    CARD8 reqType;
1380    CARD8 direction;
1381    CARD16 length B16;
1382    Window window B32;
1383} xCirculateWindowReq;
1384
1385typedef struct {    /* followed by padded string */
1386    CARD8 reqType;
1387    BOOL onlyIfExists;
1388    CARD16 length B16;
1389    CARD16 nbytes  B16;    /* number of bytes in string */
1390    CARD16 pad B16;
1391} xInternAtomReq;
1392
1393typedef struct {
1394    CARD8 reqType;
1395    CARD8 mode;
1396    CARD16 length B16;
1397    Window window B32;
1398    Atom property B32, type B32;
1399    CARD8 format;
1400    BYTE pad[3];
1401    CARD32 nUnits B32;     /* length of stuff following, depends on format */
1402} xChangePropertyReq;
1403
1404typedef struct {
1405    CARD8 reqType;
1406    BYTE pad;
1407    CARD16 length B16;
1408    Window window B32;
1409    Atom property B32;
1410} xDeletePropertyReq;
1411
1412typedef struct {
1413    CARD8 reqType;
1414#if defined(__cplusplus) || defined(c_plusplus)
1415    BOOL c_delete;
1416#else
1417    BOOL delete;
1418#endif
1419    CARD16 length B16;
1420    Window window B32;
1421    Atom property B32, type B32;
1422    CARD32 longOffset B32;
1423    CARD32 longLength B32;
1424} xGetPropertyReq;
1425
1426typedef struct {
1427    CARD8 reqType;
1428    BYTE pad;
1429    CARD16 length B16;
1430    Window window B32;
1431    Atom selection B32;
1432    Time time B32;
1433} xSetSelectionOwnerReq;
1434
1435typedef struct {
1436    CARD8 reqType;
1437    BYTE pad;
1438    CARD16 length B16;
1439    Window requestor B32;
1440    Atom selection B32, target B32, property B32;
1441    Time time B32;
1442    } xConvertSelectionReq;
1443
1444typedef struct {
1445    CARD8 reqType;
1446    BOOL propagate;
1447    CARD16 length B16;
1448    Window destination B32;
1449    CARD32 eventMask B32;
1450#ifdef WORD64
1451    /* the structure should have been quad-aligned */
1452    BYTE eventdata[SIZEOF(xEvent)];
1453#else
1454    xEvent event;
1455#endif /* WORD64 */
1456} xSendEventReq;
1457
1458typedef struct {
1459    CARD8 reqType;
1460    BOOL ownerEvents;
1461    CARD16 length B16;
1462    Window grabWindow B32;
1463    CARD16 eventMask B16;
1464    BYTE pointerMode, keyboardMode;
1465    Window confineTo B32;
1466    Cursor cursor B32;
1467    Time time B32;
1468} xGrabPointerReq;
1469
1470typedef struct {
1471    CARD8 reqType;
1472    BOOL ownerEvents;
1473    CARD16 length B16;
1474    Window grabWindow B32;
1475    CARD16 eventMask B16;
1476    BYTE pointerMode, keyboardMode;
1477    Window confineTo B32;
1478    Cursor cursor B32;
1479    CARD8 button;
1480    BYTE pad;
1481    CARD16 modifiers B16;
1482} xGrabButtonReq;
1483
1484typedef struct {
1485    CARD8 reqType;
1486    CARD8 button;
1487    CARD16 length B16;
1488    Window grabWindow B32;
1489    CARD16 modifiers B16;
1490    CARD16 pad B16;
1491} xUngrabButtonReq;
1492
1493typedef struct {
1494    CARD8 reqType;
1495    BYTE pad;
1496    CARD16 length B16;
1497    Cursor cursor B32;
1498    Time time B32;
1499    CARD16 eventMask B16;
1500    CARD16 pad2 B16;
1501} xChangeActivePointerGrabReq;
1502
1503typedef struct {
1504    CARD8 reqType;
1505    BOOL ownerEvents;
1506    CARD16 length B16;
1507    Window grabWindow B32;
1508    Time time B32;
1509    BYTE pointerMode, keyboardMode;
1510    CARD16 pad B16;
1511} xGrabKeyboardReq;
1512
1513typedef struct {
1514    CARD8 reqType;
1515    BOOL ownerEvents;
1516    CARD16 length B16;
1517    Window grabWindow B32;
1518    CARD16 modifiers B16;
1519    CARD8 key;
1520    BYTE pointerMode, keyboardMode;
1521    BYTE pad1, pad2, pad3;
1522} xGrabKeyReq;
1523
1524typedef struct {
1525    CARD8 reqType;
1526    CARD8 key;
1527    CARD16 length B16;
1528    Window grabWindow B32;
1529    CARD16 modifiers B16;
1530    CARD16 pad B16;
1531} xUngrabKeyReq;
1532
1533typedef struct {
1534    CARD8 reqType;
1535    CARD8 mode;
1536    CARD16 length B16;
1537    Time time B32;
1538} xAllowEventsReq;
1539
1540typedef struct {
1541    CARD8 reqType;
1542    BYTE pad;
1543    CARD16 length B16;
1544    Window window B32;
1545    Time start B32, stop B32;
1546} xGetMotionEventsReq;
1547
1548typedef struct {
1549    CARD8 reqType;
1550    BYTE pad;
1551    CARD16 length B16;
1552    Window srcWid B32, dstWid B32;
1553    INT16 srcX B16, srcY B16;
1554} xTranslateCoordsReq;
1555
1556typedef struct {
1557    CARD8 reqType;
1558    BYTE pad;
1559    CARD16 length B16;
1560    Window srcWid B32, dstWid B32;
1561    INT16 srcX B16, srcY B16;
1562    CARD16 srcWidth B16, srcHeight B16;
1563    INT16 dstX B16, dstY B16;
1564} xWarpPointerReq;
1565
1566typedef struct {
1567    CARD8 reqType;
1568    CARD8 revertTo;
1569    CARD16 length B16;
1570    Window focus B32;
1571    Time time B32;
1572} xSetInputFocusReq;
1573
1574typedef struct {
1575    CARD8 reqType;
1576    BYTE pad;
1577    CARD16 length B16;
1578    Font fid B32;
1579    CARD16 nbytes B16;
1580    BYTE pad1, pad2;	/* string follows on word boundary */
1581} xOpenFontReq;
1582
1583typedef struct {
1584    CARD8 reqType;
1585    BOOL oddLength;
1586    CARD16 length B16;
1587    Font fid B32;
1588    } xQueryTextExtentsReq;
1589
1590typedef struct {
1591    CARD8 reqType;
1592    BYTE pad;
1593    CARD16 length B16;
1594    CARD16 maxNames B16;
1595    CARD16 nbytes B16;  /* followed immediately by string bytes */
1596} xListFontsReq;
1597
1598typedef xListFontsReq xListFontsWithInfoReq;
1599
1600typedef struct {
1601    CARD8 reqType;
1602    BYTE pad;
1603    CARD16 length B16;
1604    CARD16 nFonts B16;
1605    BYTE pad1, pad2;	/* LISTofSTRING8 follows on word boundary */
1606} xSetFontPathReq;
1607
1608typedef struct {
1609    CARD8 reqType;
1610    CARD8 depth;
1611    CARD16 length B16;
1612    Pixmap pid B32;
1613    Drawable drawable B32;
1614    CARD16 width B16, height B16;
1615} xCreatePixmapReq;
1616
1617typedef struct {
1618    CARD8 reqType;
1619    BYTE pad;
1620    CARD16 length B16;
1621    GContext gc B32;
1622    Drawable drawable B32;
1623    CARD32 mask B32;
1624} xCreateGCReq;
1625
1626typedef struct {
1627    CARD8 reqType;
1628    BYTE pad;
1629    CARD16 length B16;
1630    GContext gc B32;
1631    CARD32 mask B32;
1632} xChangeGCReq;
1633
1634typedef struct {
1635    CARD8 reqType;
1636    BYTE pad;
1637    CARD16 length B16;
1638    GContext srcGC B32, dstGC B32;
1639    CARD32 mask B32;
1640} xCopyGCReq;
1641
1642typedef struct {
1643    CARD8 reqType;
1644    BYTE pad;
1645    CARD16 length B16;
1646    GContext gc B32;
1647    CARD16 dashOffset B16;
1648    CARD16 nDashes B16;        /* length LISTofCARD8 of values following */
1649} xSetDashesReq;
1650
1651typedef struct {
1652    CARD8 reqType;
1653    BYTE ordering;
1654    CARD16 length B16;
1655    GContext gc B32;
1656    INT16 xOrigin B16, yOrigin B16;
1657} xSetClipRectanglesReq;
1658
1659typedef struct {
1660    CARD8 reqType;
1661    BOOL exposures;
1662    CARD16 length B16;
1663    Window window B32;
1664    INT16 x B16, y B16;
1665    CARD16 width B16, height B16;
1666} xClearAreaReq;
1667
1668typedef struct {
1669    CARD8 reqType;
1670    BYTE pad;
1671    CARD16 length B16;
1672    Drawable srcDrawable B32, dstDrawable B32;
1673    GContext gc B32;
1674    INT16 srcX B16, srcY B16, dstX B16, dstY B16;
1675    CARD16 width B16, height B16;
1676} xCopyAreaReq;
1677
1678typedef struct {
1679    CARD8 reqType;
1680    BYTE pad;
1681    CARD16 length B16;
1682    Drawable srcDrawable B32, dstDrawable B32;
1683    GContext gc B32;
1684    INT16 srcX B16, srcY B16, dstX B16, dstY B16;
1685    CARD16 width B16, height B16;
1686    CARD32 bitPlane B32;
1687} xCopyPlaneReq;
1688
1689typedef struct {
1690    CARD8 reqType;
1691    BYTE coordMode;
1692    CARD16 length B16;
1693    Drawable drawable B32;
1694    GContext gc B32;
1695} xPolyPointReq;
1696
1697typedef xPolyPointReq xPolyLineReq;  /* same request structure */
1698
1699/* The following used for PolySegment, PolyRectangle, PolyArc, PolyFillRectangle, PolyFillArc */
1700
1701typedef struct {
1702    CARD8 reqType;
1703    BYTE pad;
1704    CARD16 length B16;
1705    Drawable drawable B32;
1706    GContext gc B32;
1707} xPolySegmentReq;
1708
1709typedef xPolySegmentReq xPolyArcReq;
1710typedef xPolySegmentReq xPolyRectangleReq;
1711typedef xPolySegmentReq xPolyFillRectangleReq;
1712typedef xPolySegmentReq xPolyFillArcReq;
1713
1714typedef struct _FillPolyReq {
1715    CARD8 reqType;
1716    BYTE pad;
1717    CARD16 length B16;
1718    Drawable drawable B32;
1719    GContext gc B32;
1720    BYTE shape;
1721    BYTE coordMode;
1722    CARD16 pad1 B16;
1723} xFillPolyReq;
1724
1725
1726typedef struct _PutImageReq {
1727    CARD8 reqType;
1728    CARD8 format;
1729    CARD16 length B16;
1730    Drawable drawable B32;
1731    GContext gc B32;
1732    CARD16 width B16, height B16;
1733    INT16 dstX B16, dstY B16;
1734    CARD8 leftPad;
1735    CARD8 depth;
1736    CARD16 pad B16;
1737} xPutImageReq;
1738
1739typedef struct {
1740    CARD8 reqType;
1741    CARD8 format;
1742    CARD16 length B16;
1743    Drawable drawable B32;
1744    INT16 x B16, y B16;
1745    CARD16 width B16, height B16;
1746    CARD32 planeMask B32;
1747} xGetImageReq;
1748
1749/* the following used by PolyText8 and PolyText16 */
1750
1751typedef struct {
1752    CARD8 reqType;
1753    CARD8 pad;
1754    CARD16 length B16;
1755    Drawable drawable B32;
1756    GContext gc B32;
1757    INT16 x B16, y B16;		/* items (xTextElt) start after struct */
1758} xPolyTextReq;
1759
1760typedef xPolyTextReq xPolyText8Req;
1761typedef xPolyTextReq xPolyText16Req;
1762
1763typedef struct {
1764    CARD8 reqType;
1765    BYTE nChars;
1766    CARD16 length B16;
1767    Drawable drawable B32;
1768    GContext gc B32;
1769    INT16 x B16, y B16;
1770} xImageTextReq;
1771
1772typedef xImageTextReq xImageText8Req;
1773typedef xImageTextReq xImageText16Req;
1774
1775typedef struct {
1776    CARD8 reqType;
1777    BYTE alloc;
1778    CARD16 length B16;
1779    Colormap mid B32;
1780    Window window B32;
1781    VisualID visual B32;
1782} xCreateColormapReq;
1783
1784typedef struct {
1785    CARD8 reqType;
1786    BYTE pad;
1787    CARD16 length B16;
1788    Colormap mid B32;
1789    Colormap srcCmap B32;
1790} xCopyColormapAndFreeReq;
1791
1792typedef struct {
1793    CARD8 reqType;
1794    BYTE pad;
1795    CARD16 length B16;
1796    Colormap cmap B32;
1797    CARD16 red B16, green B16, blue B16;
1798    CARD16 pad2 B16;
1799} xAllocColorReq;
1800
1801typedef struct {
1802    CARD8 reqType;
1803    BYTE pad;
1804    CARD16 length B16;
1805    Colormap cmap B32;
1806    CARD16 nbytes B16;  /* followed by structure */
1807    BYTE pad1, pad2;
1808} xAllocNamedColorReq;
1809
1810typedef struct {
1811    CARD8 reqType;
1812    BOOL contiguous;
1813    CARD16 length B16;
1814    Colormap cmap B32;
1815    CARD16 colors B16, planes B16;
1816} xAllocColorCellsReq;
1817
1818typedef struct {
1819    CARD8 reqType;
1820    BOOL contiguous;
1821    CARD16 length B16;
1822    Colormap cmap B32;
1823    CARD16 colors B16, red B16, green B16, blue B16;
1824} xAllocColorPlanesReq;
1825
1826typedef struct {
1827    CARD8 reqType;
1828    BYTE pad;
1829    CARD16 length B16;
1830    Colormap cmap B32;
1831    CARD32 planeMask B32;
1832} xFreeColorsReq;
1833
1834typedef struct {
1835    CARD8 reqType;
1836    BYTE pad;
1837    CARD16 length B16;
1838    Colormap cmap B32;
1839} xStoreColorsReq;
1840
1841typedef struct {
1842    CARD8 reqType;
1843    CARD8 flags;   /* DoRed, DoGreen, DoBlue, as in xColorItem */
1844    CARD16 length B16;
1845    Colormap cmap B32;
1846    CARD32 pixel B32;
1847    CARD16 nbytes B16;  /* number of name string bytes following structure */
1848    BYTE pad1, pad2;
1849    } xStoreNamedColorReq;
1850
1851typedef struct {
1852    CARD8 reqType;
1853    BYTE pad;
1854    CARD16 length B16;
1855    Colormap cmap B32;
1856} xQueryColorsReq;
1857
1858typedef struct {    /* followed  by string of length len */
1859    CARD8 reqType;
1860    BYTE pad;
1861    CARD16 length B16;
1862    Colormap cmap B32;
1863    CARD16 nbytes B16;  /* number of string bytes following structure*/
1864    BYTE pad1, pad2;
1865} xLookupColorReq;
1866
1867typedef struct {
1868    CARD8 reqType;
1869    BYTE pad;
1870    CARD16 length B16;
1871    Cursor cid B32;
1872    Pixmap source B32, mask B32;
1873    CARD16 foreRed B16, foreGreen B16, foreBlue B16;
1874    CARD16 backRed B16, backGreen B16, backBlue B16;
1875    CARD16 x B16, y B16;
1876} xCreateCursorReq;
1877
1878typedef struct {
1879    CARD8 reqType;
1880    BYTE pad;
1881    CARD16 length B16;
1882    Cursor cid B32;
1883    Font source B32, mask B32;
1884    CARD16 sourceChar B16, maskChar B16;
1885    CARD16 foreRed B16, foreGreen B16, foreBlue B16;
1886    CARD16 backRed B16, backGreen B16, backBlue B16;
1887} xCreateGlyphCursorReq;
1888
1889typedef struct {
1890    CARD8 reqType;
1891    BYTE pad;
1892    CARD16 length B16;
1893    Cursor cursor B32;
1894    CARD16 foreRed B16, foreGreen B16, foreBlue B16;
1895    CARD16 backRed B16, backGreen B16, backBlue B16;
1896} xRecolorCursorReq;
1897
1898typedef 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 B16;
1906    Drawable drawable B32;
1907    CARD16 width B16, height B16;
1908} xQueryBestSizeReq;
1909
1910typedef struct {
1911    CARD8 reqType;
1912    BYTE pad;
1913    CARD16 length B16;
1914    CARD16 nbytes B16;  /* number of string bytes following structure */
1915    BYTE pad1, pad2;
1916} xQueryExtensionReq;
1917
1918typedef struct {
1919    CARD8   reqType;
1920    CARD8   numKeyPerModifier;
1921    CARD16  length B16;
1922} xSetModifierMappingReq;
1923
1924typedef struct {
1925    CARD8 reqType;
1926    CARD8 nElts;  /* how many elements in the map */
1927    CARD16 length B16;
1928} xSetPointerMappingReq;
1929
1930typedef struct {
1931    CARD8 reqType;
1932    BYTE pad;
1933    CARD16 length B16;
1934    KeyCode firstKeyCode;
1935    CARD8 count;
1936    CARD16 pad1 B16;
1937} xGetKeyboardMappingReq;
1938
1939typedef struct {
1940    CARD8 reqType;
1941    CARD8 keyCodes;
1942    CARD16 length B16;
1943    KeyCode firstKeyCode;
1944    CARD8 keySymsPerKeyCode;
1945    CARD16 pad1 B16;
1946} xChangeKeyboardMappingReq;
1947
1948typedef struct {
1949    CARD8 reqType;
1950    BYTE pad;
1951    CARD16 length B16;
1952    CARD32 mask B32;
1953} xChangeKeyboardControlReq;
1954
1955typedef struct {
1956    CARD8 reqType;
1957    INT8 percent;  /* -100 to 100 */
1958    CARD16 length B16;
1959} xBellReq;
1960
1961typedef struct {
1962    CARD8 reqType;
1963    BYTE pad;
1964    CARD16 length B16;
1965    INT16 accelNum B16, accelDenum B16;
1966    INT16 threshold B16;
1967    BOOL doAccel, doThresh;
1968} xChangePointerControlReq;
1969
1970typedef struct {
1971    CARD8 reqType;
1972    BYTE pad;
1973    CARD16 length B16;
1974    INT16 timeout B16, interval B16;
1975    BYTE preferBlank, allowExpose;
1976    CARD16 pad2 B16;
1977} xSetScreenSaverReq;
1978
1979typedef struct {
1980    CARD8 reqType;
1981    BYTE mode;
1982    CARD16 length B16;
1983    CARD8 hostFamily;
1984    BYTE pad;
1985    CARD16 hostLength B16;
1986} xChangeHostsReq;
1987
1988typedef struct {
1989    CARD8 reqType;
1990    BYTE pad;
1991    CARD16 length B16;
1992    } xListHostsReq;
1993
1994typedef struct {
1995    CARD8 reqType;
1996    BYTE mode;
1997    CARD16 length B16;
1998    } xChangeModeReq;
1999
2000typedef xChangeModeReq xSetAccessControlReq;
2001typedef xChangeModeReq xSetCloseDownModeReq;
2002typedef xChangeModeReq xForceScreenSaverReq;
2003
2004typedef struct { /* followed by LIST of ATOM */
2005    CARD8 reqType;
2006    BYTE pad;
2007    CARD16 length B16;
2008    Window window B32;
2009    CARD16 nAtoms B16;
2010    INT16 nPositions B16;
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