summaryrefslogtreecommitdiff
path: root/specs/encoding.xml
blob: 8161dc7635502991e9b0807b04128d66321c22e4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
2336
2337
2338
2339
2340
2341
2342
2343
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
2359
2360
2361
2362
2363
2364
2365
2366
2367
2368
2369
2370
2371
2372
2373
2374
2375
2376
2377
2378
2379
2380
2381
2382
2383
2384
2385
2386
2387
2388
2389
2390
2391
2392
2393
2394
2395
2396
2397
2398
2399
2400
2401
2402
2403
2404
2405
2406
2407
2408
2409
2410
2411
2412
2413
2414
2415
2416
2417
2418
2419
2420
2421
2422
2423
2424
2425
2426
2427
2428
2429
2430
2431
2432
2433
2434
2435
2436
2437
2438
2439
2440
2441
2442
2443
2444
2445
2446
2447
2448
2449
2450
2451
2452
2453
2454
2455
2456
2457
2458
2459
2460
2461
2462
2463
2464
2465
2466
2467
2468
2469
2470
2471
2472
2473
2474
2475
2476
2477
2478
2479
2480
2481
2482
2483
2484
2485
2486
2487
2488
2489
2490
2491
2492
2493
2494
2495
2496
2497
2498
2499
2500
2501
2502
2503
2504
2505
2506
2507
2508
2509
2510
2511
2512
2513
2514
2515
2516
2517
2518
2519
2520
2521
2522
2523
2524
2525
2526
2527
2528
2529
2530
2531
2532
2533
2534
2535
2536
2537
2538
2539
2540
2541
2542
2543
2544
2545
2546
2547
2548
2549
2550
2551
2552
2553
2554
2555
2556
2557
2558
2559
2560
2561
2562
2563
2564
2565
2566
2567
2568
2569
2570
2571
2572
2573
2574
2575
2576
2577
2578
2579
2580
2581
2582
2583
2584
2585
2586
2587
2588
2589
2590
2591
2592
2593
2594
2595
2596
2597
2598
2599
2600
2601
2602
2603
2604
2605
2606
2607
2608
2609
2610
2611
2612
2613
2614
2615
2616
2617
2618
2619
2620
2621
2622
2623
2624
2625
2626
2627
2628
2629
2630
2631
2632
2633
2634
2635
2636
2637
2638
2639
2640
2641
2642
2643
2644
2645
2646
2647
2648
2649
2650
2651
2652
2653
2654
2655
2656
2657
2658
2659
2660
2661
2662
2663
2664
2665
2666
2667
2668
2669
2670
2671
2672
2673
2674
2675
2676
2677
2678
2679
2680
2681
2682
2683
2684
2685
2686
2687
2688
2689
2690
2691
2692
2693
2694
2695
2696
2697
2698
2699
2700
2701
2702
2703
2704
2705
2706
2707
2708
2709
2710
2711
2712
2713
2714
2715
2716
2717
2718
2719
2720
2721
2722
2723
2724
2725
2726
2727
2728
2729
2730
2731
2732
2733
2734
2735
2736
2737
2738
2739
2740
2741
2742
2743
2744
2745
2746
2747
2748
2749
2750
2751
2752
2753
2754
2755
2756
2757
2758
2759
2760
2761
2762
2763
2764
2765
2766
2767
2768
2769
2770
2771
2772
2773
2774
2775
2776
2777
2778
2779
2780
2781
2782
2783
2784
2785
2786
2787
2788
2789
2790
2791
2792
2793
2794
2795
2796
2797
2798
2799
2800
2801
2802
2803
2804
2805
2806
2807
2808
2809
2810
2811
2812
2813
2814
2815
2816
2817
2818
2819
2820
2821
2822
2823
2824
2825
2826
2827
2828
2829
2830
2831
2832
2833
2834
2835
2836
2837
2838
2839
2840
2841
2842
2843
2844
2845
2846
2847
2848
2849
2850
2851
2852
2853
2854
2855
2856
2857
2858
2859
2860
2861
2862
2863
2864
2865
2866
2867
2868
2869
2870
2871
2872
2873
2874
2875
2876
2877
2878
2879
2880
2881
2882
2883
2884
2885
2886
2887
2888
2889
2890
2891
2892
2893
2894
2895
2896
2897
2898
2899
2900
2901
2902
2903
2904
2905
2906
2907
2908
2909
2910
2911
2912
2913
2914
2915
2916
2917
2918
2919
2920
2921
2922
2923
2924
2925
2926
2927
2928
2929
2930
2931
2932
2933
2934
2935
2936
2937
2938
2939
2940
2941
2942
2943
2944
2945
2946
2947
2948
2949
2950
2951
2952
2953
2954
2955
2956
2957
2958
2959
2960
2961
2962
2963
2964
2965
2966
2967
2968
2969
2970
2971
2972
2973
2974
2975
2976
2977
2978
2979
2980
2981
2982
2983
2984
2985
2986
2987
2988
2989
2990
2991
2992
2993
2994
2995
2996
2997
2998
2999
3000
3001
3002
3003
3004
3005
3006
3007
3008
3009
3010
3011
3012
3013
3014
3015
3016
3017
3018
3019
3020
3021
3022
3023
3024
3025
3026
3027
3028
3029
3030
3031
3032
3033
3034
3035
3036
3037
3038
3039
3040
3041
3042
3043
3044
3045
3046
3047
3048
3049
3050
3051
3052
3053
3054
3055
3056
3057
3058
3059
3060
3061
3062
3063
3064
3065
3066
3067
3068
3069
3070
3071
3072
3073
3074
3075
3076
3077
3078
3079
3080
3081
3082
3083
3084
3085
3086
3087
3088
3089
3090
3091
3092
3093
3094
3095
3096
3097
3098
3099
3100
3101
3102
3103
3104
3105
3106
3107
3108
3109
3110
3111
3112
3113
3114
3115
3116
3117
3118
3119
3120
3121
3122
3123
3124
3125
3126
3127
3128
3129
3130
3131
3132
3133
3134
3135
3136
3137
3138
3139
3140
3141
3142
3143
3144
3145
3146
3147
3148
3149
3150
3151
3152
3153
3154
3155
3156
3157
3158
3159
3160
3161
3162
3163
3164
3165
3166
3167
3168
3169
3170
3171
3172
3173
3174
3175
3176
3177
3178
3179
3180
3181
3182
3183
3184
3185
3186
3187
3188
3189
3190
3191
3192
3193
3194
3195
3196
3197
3198
3199
3200
3201
3202
3203
3204
3205
3206
3207
3208
3209
3210
3211
3212
3213
3214
3215
3216
3217
3218
3219
3220
3221
3222
3223
3224
3225
3226
3227
3228
3229
3230
3231
3232
3233
3234
3235
3236
3237
3238
3239
3240
3241
3242
3243
3244
3245
3246
3247
3248
3249
3250
3251
3252
3253
3254
3255
3256
3257
3258
3259
3260
<appendix id="protocol_encoding">
<title>Protocol Encoding</title>
<!--
     The sections in this appendix correspond to their
     number counterparts in the protocol document.
-->
<sect1  id="syntactic_conventions_b">
<title>Syntactic Conventions</title>

<para>
All numbers are in decimal,
unless prefixed with #x, in which case they are in hexadecimal (base 16).
</para>

<para>
The general syntax used to describe requests, replies, errors, events, and
compound types is:
</para>

<literallayout class="monospaced">
   <emphasis role='bold'>NameofThing</emphasis>
   encode-form
   ...
   encode-form
</literallayout>

<para>
Each encode-form describes a single component.
</para>
<para>
For components described in the protocol as:
</para>
<literallayout class="monospaced">
   name: TYPE
</literallayout>

<para>
the encode-form is:
</para>

<literallayout class="monospaced">
   N     TYPE     name
</literallayout>

<para>
N is the number of bytes occupied in the data stream,
and TYPE is the interpretation of those bytes.
For example,
</para>

<literallayout class="monospaced">
   depth: CARD8
</literallayout>

<para>
becomes:
</para>

<literallayout class="monospaced">
   1     CARD8     depth
</literallayout>

<para>
For components with a static numeric value the encode-form is:
</para>

<literallayout class="monospaced">
   N     value     name
</literallayout>

<para>
The value is always interpreted as an N-byte unsigned integer.
For example,
the first two bytes of a
<emphasis role='bold'>Window</emphasis>
error are always zero (indicating an
error in general) and three (indicating the
<emphasis role='bold'>Window</emphasis>
error in particular):
</para>

<literallayout class="monospaced">
   1      0      Error
   1      3      code
</literallayout>

<para>
For components described in the protocol as:
</para>

<para>
name:
{ <emphasis role='bold'>Name1</emphasis>,...,
<emphasis role='bold'>NameI</emphasis>}
</para>

<para>
the encode-form is:
</para>

<literallayout class="monospaced">
   N          name
        value1 Name1
        ...
        valueI NameI
</literallayout>

<para>
The value is always interpreted as an N-byte unsigned integer.
Note that the size of N is sometimes larger than that strictly required
to encode the values.
For example:
</para>

<para>
class:
{ <emphasis role='bold'>InputOutput</emphasis>,
<emphasis role='bold'>InputOnly</emphasis>,
<emphasis role='bold'>CopyFromParent</emphasis> }
</para>

<para>
becomes:
</para>

<literallayout class="monospaced">
2               class
     0     CopyFromParent
     1     InputOutput
     2     InputOnly
</literallayout>

<para>
For components described in the protocol as:
</para>

<para>
NAME: TYPE or
<emphasis role='bold'>Alternative1 ...or</emphasis>
<emphasis role='bold'>AlternativeI</emphasis>
</para>

<para>
the encode-form is:
</para>

<literallayout class="monospaced">
N     TYPE               NAME
     value1     Alternative1
     ...
     valueI     AlternativeI
</literallayout>

<para>
The alternative values are guaranteed not to conflict with the encoding
of TYPE.
For example:
</para>

<para>
destination: WINDOW or
<emphasis role='bold'>PointerWindow</emphasis>
or
<emphasis role='bold'>InputFocus</emphasis>
</para>

<para>
becomes:
</para>

<literallayout class="monospaced">
4     WINDOW          destination
     0     PointerWindow
     1     InputFocus
</literallayout>

<para>
For components described in the protocol as:
</para>

<literallayout class="monospaced">
   value-mask: BITMASK
</literallayout>

<para>
the encode-form is:
</para>

<literallayout class="monospaced">
N     BITMASK               value-mask
     mask1     mask-name1
     ...
     maskI     mask-nameI
</literallayout>

<para>
The individual bits in the mask are specified and named,
and N is 2 or 4.
The most-significant bit in a BITMASK is reserved for use in defining
chained (multiword) bitmasks, as extensions augment existing core requests.
The precise interpretation of this bit is not yet defined here,
although a probable mechanism is that a 1-bit indicates that another N bytes
of bitmask follows, with bits within the overall mask still interpreted
from least-significant to most-significant with an N-byte unit,
with N-byte units
interpreted in stream order, and with the overall mask being byte-swapped
in individual N-byte units.
</para>

<para>
For LISTofVALUE encodings, the request is followed by a section of the form:
</para>

<literallayout class="monospaced">
   VALUEs
   encode-form
   ...
   encode-form
</literallayout>

<para>
listing an encode-form for each VALUE.
The NAME in each encode-form keys to the corresponding BITMASK bit.
The encoding of a VALUE always occupies four bytes,
but the number of bytes specified in the encoding-form indicates how
many of the least-significant bytes are actually used;
the remaining bytes are unused and their values do not matter.
</para>

<para>
In various cases, the number of bytes occupied by a component will be
specified
by a lowercase single-letter variable name instead of a specific numeric
value, and often some other component will have its value specified as a
simple numeric expression involving these variables.
Components specified with such expressions are always interpreted
as unsigned integers.
The scope of such variables is always just the enclosing request, reply,
error, event, or compound type structure.
For example:
</para>

<literallayout class="monospaced">
2      3+n                  request length
4n     LISTofPOINT          points
</literallayout>

<para>
For unused bytes (the values of the bytes are undefined and do no matter),
the encode-form is:
</para>

<literallayout class="monospaced">
   N               unused
</literallayout>

<para>
<!-- .LP -->
If the number of unused bytes is variable, the encode-form typically is:
</para>

<literallayout class="monospaced">
   p               unused, p=pad(E)
</literallayout>

<para>
where E is some expression,
and pad(E) is the number of bytes needed to round E up to a multiple of four.
</para>

<literallayout class="monospaced">
   pad(E) = (4 - (E mod 4)) mod 4
</literallayout>
</sect1>

<sect1 id="common_types_encoding">
<title>Common Types</title>

<variablelist>
  <varlistentry>
    <term>LISTofFOO</term>
    <listitem>
      <para>
In this document the LISTof notation strictly means some number of repetitions
of the FOO encoding;
the actual length of the list is encoded elsewhere.
      </para>
    </listitem>
  </varlistentry>
  <varlistentry>
    <term>SETofFOO</term>
    <listitem>
      <para>
A set is always represented by a bitmask, with a 1-bit indicating presence in
the set.
      </para>
    </listitem>
  </varlistentry>
</variablelist>

<informaltable frame='none'>
  <tgroup cols='1' align='left'>
  <colspec colname='c1' colsep="0"/>
  <tbody>
    <row rowsep='0'>
      <entry>
BITMASK: CARD32
      </entry>
    </row>
    <row rowsep='0'>
      <entry>
WINDOW: CARD32
      </entry>
    </row>
    <row rowsep='0'>
      <entry>
PIXMAP: CARD32
      </entry>
    </row>
    <row rowsep='0'>
      <entry>
CURSOR: CARD32
      </entry>
    </row>
    <row rowsep='0'>
      <entry>
FONT: CARD32
      </entry>
    </row>
    <row rowsep='0'>
      <entry>
GCONTEXT: CARD32
      </entry>
    </row>
    <row rowsep='0'>
      <entry>
COLORMAP: CARD32
      </entry>
    </row>
    <row rowsep='0'>
      <entry>
DRAWABLE: CARD32
      </entry>
    </row>
    <row rowsep='0'>
      <entry>
FONTABLE: CARD32
      </entry>
    </row>
    <row rowsep='0'>
      <entry>
ATOM: CARD32
      </entry>
    </row>
    <row rowsep='0'>
      <entry>
VISUALID: CARD32
      </entry>
    </row>
    <row rowsep='0'>
      <entry>
BYTE: 8-bit value
      </entry>
    </row>
    <row rowsep='0'>
      <entry>
INT8: 8-bit signed integer
      </entry>
    </row>
    <row rowsep='0'>
      <entry>
INT16: 16-bit signed integer
      </entry>
    </row>
    <row rowsep='0'>
      <entry>
INT32: 32-bit signed integer
      </entry>
    </row>
    <row rowsep='0'>
      <entry>
CARD8: 8-bit unsigned integer
      </entry>
    </row>
    <row rowsep='0'>
      <entry>
CARD16: 16-bit unsigned integer
      </entry>
    </row>
    <row rowsep='0'>
      <entry>
CARD32: 32-bit unsigned integer
      </entry>
    </row>
    <row rowsep='0'>
      <entry>
TIMESTAMP: CARD32
      </entry>
    </row>
  </tbody>
  </tgroup>
</informaltable>


<literallayout class="monospaced">
BITGRAVITY
     0     Forget
     1     NorthWest
     2     North
     3     NorthEast
     4     West
     5     Center
     6     East
     7     SouthWest
     8     South
     9     SouthEast
     10     Static

WINGRAVITY
     0     Unmap
     1     NorthWest
     2     North
     3     NorthEast
     4     West
     5     Center
     6     East
     7     SouthWest
     8     South
     9     SouthEast
     10     Static

BOOL
     0     False
     1     True

SETofEVENT
     #x00000001     KeyPress
     #x00000002     KeyRelease
     #x00000004     ButtonPress
     #x00000008     ButtonRelease
     #x00000010     EnterWindow
     #x00000020     LeaveWindow
     #x00000040     PointerMotion
     #x00000080     PointerMotionHint
     #x00000100     Button1Motion
     #x00000200     Button2Motion
     #x00000400     Button3Motion
     #x00000800     Button4Motion
     #x00001000     Button5Motion
     #x00002000     ButtonMotion
     #x00004000     KeymapState
     #x00008000     Exposure
     #x00010000     VisibilityChange
     #x00020000     StructureNotify
     #x00040000     ResizeRedirect
     #x00080000     SubstructureNotify
     #x00100000     SubstructureRedirect
     #x00200000     FocusChange
     #x00400000     PropertyChange
     #x00800000     ColormapChange
     #x01000000     OwnerGrabButton
     #xFE000000     unused but must be zero

SETofPOINTEREVENT
     encodings are the same as for SETofEVENT, except with
     #xFFFF8003     unused but must be zero

SETofDEVICEEVENT
     encodings are the same as for SETofEVENT, except with
     #xFFFFC0B0     unused but must be zero

KEYSYM: CARD32
KEYCODE: CARD8
BUTTON: CARD8

SETofKEYBUTMASK
     #x0001     Shift
     #x0002     Lock
     #x0004     Control
     #x0008     Mod1
     #x0010     Mod2
     #x0020     Mod3
     #x0040     Mod4
     #x0080     Mod5
     #x0100     Button1
     #x0200     Button2
     #x0400     Button3
     #x0800     Button4
     #x1000     Button5
     #xE000     unused but must be zero

SETofKEYMASK
     encodings are the same as for SETofKEYBUTMASK, except with
     #xFF00          unused but must be zero
STRING8: LISTofCARD8
STRING16: LISTofCHAR2B

CHAR2B
     1     CARD8     byte1
     1     CARD8     byte2

POINT
     2     INT16     x
     2     INT16     y

RECTANGLE
     2     INT16     x
     2     INT16     y
     2     CARD16    width
     2     CARD16    height

ARC
     2     INT16     x
     2     INT16     y
     2     CARD16    width
     2     CARD16    height
     2     INT16     angle1
     2     INT16     angle2

HOST
     1                         family
           0         Internet
           1         DECnet
           2         Chaos
           5         ServerInterpreted
           6         InternetV6
     1                         unused
     2      n                  length of address
     n      LISTofBYTE         address
     p                         unused, p=pad(n)

STR
     1      n                  length of name in bytes
     n      STRING8            name

</literallayout>
</sect1>

<sect1 id="errors_encoding">
<title>Errors</title>

<literallayout class="monospaced">
<emphasis role='bold'>Request</emphasis>
     1     0                               Error
     1     1                               code
     2     CARD16                          sequence number
     4                                     unused
     2     CARD16                          minor opcode
     1     CARD8                           major opcode
     21                                    unused

<emphasis role='bold'>Value</emphasis>
     1     0                               Error
     1     2                               code
     2     CARD16                          sequence number
     4     &lt;32-bits&gt;                 bad value
     2     CARD16                          minor opcode
     1     CARD8                           major opcode
     21                                    unused

<emphasis role='bold'>Window</emphasis>
     1     0                               Error
     1     3                               code
     2     CARD16                          sequence number
     4     CARD32                          bad resource id
     2     CARD16                          minor opcode
     1     CARD8                           major opcode
     21                                    unused

<emphasis role='bold'>Pixmap</emphasis>
     1     0                               Error
     1     4                               code
     2     CARD16                          sequence number
     4     CARD32                          bad resource id
     2     CARD16                          minor opcode
     1     CARD8                           major opcode
     21                                    unused

<emphasis role='bold'>Atom</emphasis>
     1     0                               Error
     1     5                               code
     2     CARD16                          sequence number
     4     CARD32                          bad atom id
     2     CARD16                          minor opcode
     1     CARD8                           major opcode
     21                                    unused

<emphasis role='bold'>Cursor</emphasis>
     1     0                               Error
     1     6                               code
     2     CARD16                          sequence number
     4     CARD32                          bad resource id
     2     CARD16                          minor opcode
     1     CARD8                           major opcode
     21                                    unused

<emphasis role='bold'>Font</emphasis>
     1     0                               Error
     1     7                               code
     2     CARD16                          sequence number
     4     CARD32                          bad resource id
     2     CARD16                          minor opcode
     1     CARD8                           major opcode
     21                                    unused

<emphasis role='bold'>Match</emphasis>
     1     0                               Error
     1     8                               code
     2     CARD16                          sequence number
     4                                     unused
     2     CARD16                          minor opcode
     1     CARD8                           major opcode
     21                                    unused

<emphasis role='bold'>Drawable</emphasis>
     1     0                               Error
     1     9                               code
     2     CARD16                          sequence number
     4     CARD32                          bad resource id
     2     CARD16                          minor opcode
     1     CARD8                           major opcode
     21                                    unused

<emphasis role='bold'>Access</emphasis>
     1     0                               Error
     1     10                              code
     2     CARD16                          sequence number
     4                                     unused
     2     CARD16                          minor opcode
     1     CARD8                           major opcode
     21                                    unused

<emphasis role='bold'>Alloc</emphasis>
     1     0                               Error
     1     11                              code
     2     CARD16                          sequence number
     4                                     unused
     2     CARD16                          minor opcode
     1     CARD8                           major opcode
     21                                    unused

<emphasis role='bold'>Colormap</emphasis>
     1     0                               Error
     1     12                              code
     2     CARD16                          sequence number
     4     CARD32                          bad resource id
     2     CARD16                          minor opcode
     1     CARD8                           major opcode
     21                                    unused

<emphasis role='bold'>GContext</emphasis>
     1     0                               Error
     1     13                              code
     2     CARD16                          sequence number
     4     CARD32                          bad resource id
     2     CARD16                          minor opcode
     1     CARD8                           major opcode
     21                                    unused

<emphasis role='bold'>IDChoice</emphasis>
     1     0                               Error
     1     14                              code
     2     CARD16                          sequence number
     4     CARD32                          bad resource id
     2     CARD16                          minor opcode
     1     CARD8                           major opcode
     21                                    unused

<emphasis role='bold'>Name</emphasis>
     1     0                               Error
     1     15                              code
     2     CARD16                          sequence number
     4                                     unused
     2     CARD16                          minor opcode
     1     CARD8                           major opcode
     21                                    unused

<emphasis role='bold'>Length</emphasis>
     1     0                               Error
     1     16                              code
     2     CARD16                          sequence number
     4                                     unused
     2     CARD16                          minor opcode
     1     CARD8                           major opcode
     21                                    unused

<emphasis role='bold'>Implementation</emphasis>
     1     0                               Error
     1     17                              code
     2     CARD16                          sequence number
     4                                     unused
     2     CARD16                          minor opcode
     1     CARD8                           major opcode
     21                                    unused
</literallayout>
</sect1>

<sect1 id="keyboards_encoding">
<title>Keyboards</title>

<para>
KEYCODE values are always greater than 7 (and less than 256).
</para>

<para>
KEYSYM values with the bit #x10000000 set are reserved as vendor-specific.
</para>

<para>
The names and encodings of the standard KEYSYM values are contained in
<link linkend="keysym_encoding">Appendix A, Keysym Encoding</link>.
</para>
</sect1>

<sect1 id="pointers_encoding">
<title>Pointers</title>

<para>
BUTTON values are numbered starting with one.
</para>

</sect1>
<sect1 id="predefined">
<title>Predefined Atoms</title>

<literallayout class="monospaced">
PRIMARY           1      WM_NORMAL_HINTS     40
SECONDARY         2      WM_SIZE_HINTS       41
ARC               3      WM_ZOOM_HINTS       42
ATOM              4      MIN_SPACE           43
BITMAP            5      NORM_SPACE          44
CARDINAL          6      MAX_SPACE           45
COLORMAP          7      END_SPACE           46
CURSOR            8      SUPERSCRIPT_X       47
CUT_BUFFER0       9      SUPERSCRIPT_Y       48
CUT_BUFFER1       10     SUBSCRIPT_X         49
CUT_BUFFER2       11     SUBSCRIPT_Y         50
CUT_BUFFER3       12     UNDERLINE_POSITION  51
CUT_BUFFER4       13     UNDERLINE_THICKNESS 52
CUT_BUFFER5       14     STRIKEOUT_ASCENT    53
CUT_BUFFER6       15     STRIKEOUT_DESCENT   54
CUT_BUFFER7       16     ITALIC_ANGLE        55
DRAWABLE          17     X_HEIGHT            56
FONT              18     QUAD_WIDTH          57
INTEGER           19     WEIGHT              58
PIXMAP            20     POINT_SIZE          59
POINT             21     RESOLUTION          60
RECTANGLE         22     COPYRIGHT           61
RESOURCE_MANAGER  23     NOTICE              62
RGB_COLOR_MAP     24     FONT_NAME           63
RGB_BEST_MAP      25     FAMILY_NAME         64
RGB_BLUE_MAP      26     FULL_NAME           65
RGB_DEFAULT_MAP   27     CAP_HEIGHT          66
RGB_GRAY_MAP      28     WM_CLASS            67
RGB_GREEN_MAP     29     WM_TRANSIENT_FOR    68
RGB_RED_MAP       30
STRING            31
VISUALID          32
WINDOW            33
WM_COMMAND        34
WM_HINTS          35
WM_CLIENT_MACHINE 36
WM_ICON_NAME      37
WM_ICON_SIZE      38
WM_NAME           39
</literallayout>
</sect1>

<sect1 id="connection_setup_encoding">
<title>Connection Setup</title>

<para>
For TCP connections,
displays on a given host are numbered starting from 0,
and the server for display N listens and accepts connections on port 6000 + N.
For DECnet connections,
displays on a given host are numbered starting from 0,
and the server for display N listens and accepts connections on the object
name obtained by concatenating "X$X" with the decimal representation of N,
for example, X$X0 and X$X1.
</para>

<para>
Information sent by the client at connection setup:
</para>

<literallayout class="monospaced">
     1                       byte-order
          #x42     MSB first
          #x6C     LSB first
     1                       unused
     2     CARD16            protocol-major-version
     2     CARD16            protocol-minor-version
     2     n                 length of authorization-protocol-name
     2     d                 length of authorization-protocol-data
     2                       unused
     n     STRING8           authorization-protocol-name
     p                       unused, p=pad(n)
     d     STRING8           authorization-protocol-data
     q                       unused, q=pad(d)
</literallayout>

<para>
Except where explicitly noted in the protocol,
all 16-bit and 32-bit quantities sent by the client must be transmitted
with the specified byte order,
and all 16-bit and 32-bit quantities returned by the server will be transmitted
with this byte order.
</para>

<para>
Information received by the client if the connection is refused:
</para>

<literallayout class="monospaced">
     1     0                 Failed
     1     n                 length of reason in bytes
     2     CARD16            protocol-major-version
     2     CARD16            protocol-minor-version
     2     (n+p)/4           length in 4-byte units of "additional data"
     n     STRING8           reason
     p                       unused, p=pad(n)
</literallayout>

<para>
Information received by the client if further authentication is required:
</para>

<literallayout class="monospaced">
     1     2                 Authenticate
     5                       unused
     2     (n+p)/4           length in 4-byte units of "additional data"
     n     STRING8           reason
     p                       unused, p=pad(n)
</literallayout>

<para>
Information received by the client if the connection is accepted:
</para>

<literallayout class="monospaced">
     1     1                               Success
     1                                     unused
     2     CARD16                          protocol-major-version
     2     CARD16                          protocol-minor-version
     2     8+2n+(v+p+m)/4                  length in 4-byte units of
                                           "additional data"
     4     CARD32                          release-number
     4     CARD32                          resource-id-base
     4     CARD32                          resource-id-mask
     4     CARD32                          motion-buffer-size
     2     v                               length of vendor
     2     CARD16                          maximum-request-length
     1     CARD8                           number of SCREENs in roots
     1     n                               number for FORMATs in
                                           pixmap-formats
     1                                     image-byte-order
          0     LSBFirst
          1     MSBFirst
     1                                     bitmap-format-bit-order
          0     LeastSignificant
          1     MostSignificant
     1     CARD8                           bitmap-format-scanline-unit
     1     CARD8                           bitmap-format-scanline-pad
     1     KEYCODE                         min-keycode
     1     KEYCODE                         max-keycode
     4                                     unused
     v     STRING8                         vendor
     p                                     unused, p=pad(v)
     8n     LISTofFORMAT                   pixmap-formats
     m     LISTofSCREEN                    roots (m is always a multiple of 4)
</literallayout>

<literallayout class="monospaced">
FORMAT
     1     CARD8                           depth
     1     CARD8                           bits-per-pixel
     1     CARD8                           scanline-pad
     5                                     unused
</literallayout>

<literallayout class="monospaced">
SCREEN
     4     WINDOW                          root
     4     COLORMAP                        default-colormap
     4     CARD32                          white-pixel
     4     CARD32                          black-pixel
     4     SETofEVENT                      current-input-masks
     2     CARD16                          width-in-pixels
     2     CARD16                          height-in-pixels
     2     CARD16                          width-in-millimeters
     2     CARD16                          height-in-millimeters
     2     CARD16                          min-installed-maps
     2     CARD16                          max-installed-maps
     4     VISUALID                        root-visual
     1                                     backing-stores
          0     Never
          1     WhenMapped
          2     Always
     1     BOOL                            save-unders
     1     CARD8                           root-depth
     1     CARD8                           number of DEPTHs in allowed-depths
     n     LISTofDEPTH                     allowed-depths (n is always a
                                           multiple of 4)
</literallayout>

<literallayout class="monospaced">
DEPTH
     1     CARD8                           depth
     1                                     unused
     2     n                               number of VISUALTYPES in visuals
     4                                     unused
     24n     LISTofVISUALTYPE              visuals
</literallayout>

<literallayout class="monospaced">
VISUALTYPE
     4     VISUALID                        visual-id
     1                                     class
          0     StaticGray
          1     GrayScale
          2     StaticColor
          3     PseudoColor
          4     TrueColor
          5     DirectColor
     1     CARD8                           bits-per-rgb-value
     2     CARD16                          colormap-entries
     4     CARD32                          red-mask
     4     CARD32                          green-mask
     4     CARD32                          blue-mask
     4                                     unused
</literallayout>
</sect1>

<sect1 id="requests_encoding">
<title>Requests</title>

<literallayout class="monospaced">
<emphasis role='bold'>CreateWindow</emphasis>
     1     1                               opcode
     1     CARD8                           depth
     2     8+n                             request length
     4     WINDOW                          wid
     4     WINDOW                          parent
     2     INT16                           x
     2     INT16                           y
     2     CARD16                          width
     2     CARD16                          height
     2     CARD16                          border-width
     2                                     class
          0     CopyFromParent
          1     InputOutput
          2     InputOnly
     4     VISUALID                        visual
          0     CopyFromParent
     4     BITMASK                         value-mask (has n bits set to 1)
          #x00000001     background-pixmap
          #x00000002     background-pixel
          #x00000004     border-pixmap
          #x00000008     border-pixel
          #x00000010     bit-gravity
          #x00000020     win-gravity
          #x00000040     backing-store
          #x00000080     backing-planes
          #x00000100     backing-pixel
          #x00000200     override-redirect
          #x00000400     save-under
          #x00000800     event-mask
          #x00001000     do-not-propagate-mask
          #x00002000     colormap
          #x00004000     cursor
     4n     LISTofVALUE                    value-list

  VALUEs
     4     PIXMAP                          background-pixmap
          0     None
          1     ParentRelative
     4     CARD32                          background-pixel
     4     PIXMAP                          border-pixmap
          0     CopyFromParent
     4     CARD32                          border-pixel
     1     BITGRAVITY                      bit-gravity
     1     WINGRAVITY                      win-gravity
     1                                     backing-store
          0     NotUseful
          1     WhenMapped
          2     Always
     4     CARD32                          backing-planes
     4     CARD32                          backing-pixel
     1     BOOL                            override-redirect
     1     BOOL                            save-under
     4     SETofEVENT                      event-mask
     4     SETofDEVICEEVENT                do-not-propagate-mask
     4     COLORMAP                        colormap
          0     CopyFromParent
     4     CURSOR                          cursor
          0     None

<emphasis role='bold'>ChangeWindowAttributes</emphasis>
     1     2                               opcode
     1                                     unused
     2     3+n                             request length
     4     WINDOW                          window
     4     BITMASK                         value-mask (has n bits set to 1)
          encodings are the same as for CreateWindow
     4n     LISTofVALUE                    value-list
          encodings are the same as for CreateWindow

<emphasis role='bold'>GetWindowAttributes</emphasis>
     1     3                               opcode
     1                                     unused
     2     2                               request length
     4     WINDOW                          window

-&gt;
     1     1                               Reply
     1                                     backing-store
          0     NotUseful
          1     WhenMapped
          2     Always
     2     CARD16                          sequence number
     4     3                               reply length
     4     VISUALID                        visual
     2                                     class
          1     InputOutput
          2     InputOnly
     1     BITGRAVITY                      bit-gravity
     1     WINGRAVITY                      win-gravity
     4     CARD32                          backing-planes
     4     CARD32                          backing-pixel
     1     BOOL                            save-under
     1     BOOL                            map-is-installed
     1                                     map-state
          0     Unmapped
          1     Unviewable
          2     Viewable
     1     BOOL                            override-redirect
     4     COLORMAP                        colormap
          0     None
     4     SETofEVENT                      all-event-masks
     4     SETofEVENT                      your-event-mask
     2     SETofDEVICEEVENT                do-not-propagate-mask
     2                                     unused

<emphasis role='bold'>DestroyWindow</emphasis>
     1     4                               opcode
     1                                     unused
     2     2                               request length
     4     WINDOW                          window

<emphasis role='bold'>DestroySubwindows</emphasis>
     1     5                               opcode
     1                                     unused
     2     2                               request length
     4     WINDOW                          window

<emphasis role='bold'>ChangeSaveSet</emphasis>
     1     6                               opcode
     1                                     mode
          0     Insert
          1     Delete
     2     2                               request length
     4     WINDOW                          window

<emphasis role='bold'>ReparentWindow</emphasis>
     1     7                               opcode
     1                                     unused
     2     4                               request length
     4     WINDOW                          window
     4     WINDOW                          parent
     2     INT16                           x
     2     INT16                           y

<emphasis role='bold'>MapWindow</emphasis>
     1     8                               opcode
     1                                     unused
     2     2                               request length
     4     WINDOW                          window

<emphasis role='bold'>MapSubwindows</emphasis>
     1     9                               opcode
     1                                     unused
     2     2                               request length
     4     WINDOW                          window

<emphasis role='bold'>UnmapWindow</emphasis>
     1     10                              opcode
     1                                     unused
     2     2                               request length
     4     WINDOW                          window

<emphasis role='bold'>UnmapSubwindows</emphasis>
     1     11                              opcode
     1                                     unused
     2     2                               request length
     4     WINDOW                          window

<emphasis role='bold'>ConfigureWindow</emphasis>
     1     12                              opcode
     1                                     unused
     2     3+n                             request length
     4     WINDOW                          window
     2     BITMASK                         value-mask (has n bits set to 1)
          #x0001     x
          #x0002     y
          #x0004     width
          #x0008     height
          #x0010     border-width
          #x0020     sibling
          #x0040     stack-mode
     2               unused
     4n     LISTofVALUE                    value-list

  VALUEs
     2     INT16                           x
     2     INT16                           y
     2     CARD16                          width
     2     CARD16                          height
     2     CARD16                          border-width
     4     WINDOW                          sibling
     1                                     stack-mode
          0     Above
          1     Below
          2     TopIf
          3     BottomIf
          4     Opposite

<emphasis role='bold'>CirculateWindow</emphasis>
     1     13                              opcode
     1                                     direction
          0     RaiseLowest
          1     LowerHighest
     2     2                               request length
     4     WINDOW                          window

<emphasis role='bold'>GetGeometry</emphasis>
     1     14                              opcode
     1                                     unused
     2     2                               request length
     4     DRAWABLE                        drawable

-&gt;
     1     1                               Reply
     1     CARD8                           depth
     2     CARD16                          sequence number
     4     0                               reply length
     4     WINDOW                          root
     2     INT16                           x
     2     INT16                           y
     2     CARD16                          width
     2     CARD16                          height
     2     CARD16                          border-width
     10                                    unused

<emphasis role='bold'>QueryTree</emphasis>
     1     15                              opcode
     1                                     unused
     2     2                               request length
     4     WINDOW                          window

-&gt;
     1     1                               Reply
     1                                     unused
     2     CARD16                          sequence number
     4     n                               reply length
     4     WINDOW                          root
     4     WINDOW                          parent
          0     None
     2     n                               number of WINDOWs in children
     14                                    unused
     4n     LISTofWINDOW                   children

<emphasis role='bold'>InternAtom</emphasis>
     1     16                              opcode
     1     BOOL                            only-if-exists
     2     2+(n+p)/4                       request length
     2     n                               length of name
     2                                     unused
     n     STRING8                         name
     p                                     unused, p=pad(n)

-&gt;
     1     1                               Reply
     1                                     unused
     2     CARD16                          sequence number
     4     0                               reply length
     4     ATOM                            atom
           0     None
     20                                    unused

<emphasis role='bold'>GetAtomName</emphasis>
     1     17                              opcode
     1                                     unused
     2     2                               request length
     4     ATOM                            atom

-&gt;
     1     1                               Reply
     1                                     unused
     2     CARD16                          sequence number
     4     (n+p)/4                         reply length
     2     n                               length of name
     22                                    unused
     n     STRING8                         name
     p                                     unused, p=pad(n)

<emphasis role='bold'>ChangeProperty</emphasis>
     1     18                              opcode
     1                                     mode
          0     Replace
          1     Prepend
          2     Append
     2     6+(n+p)/4                       request length
     4     WINDOW                          window
     4     ATOM                            property
     4     ATOM                            type
     1     CARD8                           format
     3                                     unused
     4     CARD32                          length of data in format units
                    (= n for format = 8)
                    (= n/2 for format = 16)
                    (= n/4 for format = 32)
     n     LISTofBYTE                      data
                    (n is a multiple of 2 for format = 16)
                    (n is a multiple of 4 for format = 32)
     p                                     unused, p=pad(n)


<emphasis role='bold'>DeleteProperty</emphasis>
     1     19                              opcode
     1                                     unused
     2     3                               request length
     4     WINDOW                          window
     4     ATOM                            property

<emphasis role='bold'>GetProperty</emphasis>
     1     20                              opcode
     1     BOOL                            delete
     2     6                               request length
     4     WINDOW                          window
     4     ATOM                            property
     4     ATOM                            type
          0     AnyPropertyType
     4     CARD32                          long-offset
     4     CARD32                          long-length

-&gt;
     1     1                               Reply
     1     CARD8                           format
     2     CARD16                          sequence number
     4     (n+p)/4                         reply length
     4     ATOM                            type
          0     None
     4     CARD32                          bytes-after
     4     CARD32                          length of value in format units
                    (= 0 for format = 0)
                    (= n for format = 8)
                    (= n/2 for format = 16)
                    (= n/4 for format = 32)
     12                                    unused
     n     LISTofBYTE                      value
                    (n is zero for format = 0)
                    (n is a multiple of 2 for format = 16)
                    (n is a multiple of 4 for format = 32)
     p                                     unused, p=pad(n)

<emphasis role='bold'>ListProperties</emphasis>
     1     21                              opcode
     1                                     unused
     2     2                               request length
     4     WINDOW                          window

-&gt;
     1     1                               Reply
     1                                     unused
     2     CARD16                          sequence number
     4     n                               reply length
     2     n                               number of ATOMs in atoms
     22                                    unused
     4n     LISTofATOM                     atoms

<emphasis role='bold'>SetSelectionOwner</emphasis>
     1     22                              opcode
     1                                     unused
     2     4                               request length
     4     WINDOW                          owner
          0     None
     4     ATOM                            selection
     4     TIMESTAMP                       time
          0     CurrentTime

<emphasis role='bold'>GetSelectionOwner</emphasis>
     1     23                              opcode
     1                                     unused
     2     2                               request length
     4     ATOM                            selection

-&gt;
     1     1                               Reply
     1                                     unused
     2     CARD16                          sequence number
     4     0                               reply length
     4     WINDOW                          owner
          0     None
     20                                    unused

<emphasis role='bold'>ConvertSelection</emphasis>
     1     24                              opcode
     1                                     unused
     2     6                               request length
     4     WINDOW                          requestor
     4     ATOM                            selection
     4     ATOM                            target
     4     ATOM                            property
          0     None
     4     TIMESTAMP                       time
          0     CurrentTime

<emphasis role='bold'>SendEvent</emphasis>
     1     25                              opcode
     1     BOOL                            propagate
     2     11                              requestlength
     4     WINDOW                          destination
          0     PointerWindow
          1     InputFocus
     4     SETofEVENT                      event-mask
     32                                    event
          standard event format (see <link linkend="events_encoding">the Events section</link>)

<emphasis role='bold'>GrabPointer</emphasis>
     1     26                              opcode
     1     BOOL                            owner-events
     2     6                               request length
     4     WINDOW                          grab-window
     2     SETofPOINTEREVENT               event-mask
     1                                     pointer-mode
          0     Synchronous
          1     Asynchronous
     1                                     keyboard-mode
          0     Synchronous
          1     Asynchronous
     4     WINDOW                          confine-to
          0     None
     4     CURSOR                          cursor
          0     None
     4     TIMESTAMP                       time
          0     CurrentTime

-&gt;
     1     1                               Reply
     1                                     status
          0     Success
          1     AlreadyGrabbed
          2     InvalidTime
          3     NotViewable
          4     Frozen
     2     CARD16                          sequence number
     4     0                               reply length
     24                                    unused

<emphasis role='bold'>UngrabPointer</emphasis>
     1     27                              opcode
     1                                     unused
     2     2                               request length
     4     TIMESTAMP                       time
          0     CurrentTime

<emphasis role='bold'>GrabButton</emphasis>
     1     28                              opcode
     1     BOOL                            owner-events
     2     6                               request length
     4     WINDOW                          grab-window
     2     SETofPOINTEREVENT               event-mask
     1                                     pointer-mode
          0     Synchronous
          1     Asynchronous
     1                                     keyboard-mode
          0     Synchronous
          1     Asynchronous
     4     WINDOW                          confine-to
          0     None
     4     CURSOR                          cursor
          0     None
     1     BUTTON                          button
          0     AnyButton
     1                                     unused
     2     SETofKEYMASK                    modifiers
          #x8000                           AnyModifier

<emphasis role='bold'>UngrabButton</emphasis>
     1     29                              opcode
     1     BUTTON                          button
          0     AnyButton
     2     3                               request length
     4     WINDOW                          grab-window
     2     SETofKEYMASK                    modifiers
          #x8000                           AnyModifier
     2                                     unused

<emphasis role='bold'>ChangeActivePointerGrab</emphasis>
     1     30                              opcode
     1                                     unused
     2     4                               request length
     4     CURSOR                          cursor
          0     None
     4     TIMESTAMP                       time
          0     CurrentTime
     2     SETofPOINTEREVENT               event-mask
     2                                     unused

<emphasis role='bold'>GrabKeyboard</emphasis>
     1     31                              opcode
     1     BOOL                            owner-events
     2     4                               request length
     4     WINDOW                          grab-window
     4     TIMESTAMP                       time
          0     CurrentTime
     1                                     pointer-mode
          0     Synchronous
          1     Asynchronous
     1                                     keyboard-mode
          0     Synchronous
          1     Asynchronous
     2                                     unused

-&gt;
     1     1                               Reply
     1                                     status
          0     Success
          1     AlreadyGrabbed
          2     InvalidTime
          3     NotViewable
          4     Frozen
     2     CARD16                          sequence number
     4     0                               reply length
     24                                    unused

<emphasis role='bold'>UngrabKeyboard</emphasis>
     1     32                              opcode
     1                                     unused
     2     2                               request length
     4     TIMESTAMP                       time
          0     CurrentTime

<emphasis role='bold'>GrabKey</emphasis>
     1     33                              opcode
     1     BOOL                            owner-events
     2     4                               request length
     4     WINDOW                          grab-window
     2     SETofKEYMASK                    modifiers
          #x8000     AnyModifier
     1     KEYCODE                         key
          0     AnyKey
     1                                     pointer-mode
          0     Synchronous
          1     Asynchronous
     1                                     keyboard-mode
          0     Synchronous
          1     Asynchronous
     3                                     unused

<emphasis role='bold'>UngrabKey</emphasis>
     1     34                              opcode
     1     KEYCODE                         key
          0     AnyKey
     2     3                               request length
     4     WINDOW                          grab-window
     2     SETofKEYMASK                    modifiers
          #x8000     AnyModifier
     2                                     unused

<emphasis role='bold'>AllowEvents</emphasis>
     1     35                              opcode
     1                                     mode
          0     AsyncPointer
          1     SyncPointer
          2     ReplayPointer
          3     AsyncKeyboard
          4     SyncKeyboard
          5     ReplayKeyboard
          6     AsyncBoth
          7     SyncBoth
     2     2                               request length
     4     TIMESTAMP                       time
          0     CurrentTime

<emphasis role='bold'>GrabServer</emphasis>
     1     36                              opcode
     1                                     unused
     2     1                               request length

<emphasis role='bold'>UngrabServer</emphasis>
     1     37                              opcode
     1                                     unused
     2     1                               request length

<emphasis role='bold'>QueryPointer</emphasis>
     1     38                              opcode
     1                                     unused
     2     2                               request length
     4     WINDOW                          window

-&gt;
     1     1                               Reply
     1     BOOL                            same-screen
     2     CARD16                          sequence number
     4     0                               reply length
     4     WINDOW                          root
     4     WINDOW                          child
          0     None
     2     INT16                           root-x
     2     INT16                           root-y
     2     INT16                           win-x
     2     INT16                           win-y
     2     SETofKEYBUTMASK                 mask
     6                                     unused

<emphasis role='bold'>GetMotionEvents</emphasis>
     1     39                              opcode
     1                                     unused
     2     4                               request length
     4     WINDOW                          window
     4     TIMESTAMP                       start
          0     CurrentTime
     4     TIMESTAMP                       stop
          0     CurrentTime

-&gt;
     1     1                               Reply
     1                                     unused
     2     CARD16                          sequence number
     4     2n                              reply length
     4     n                               number of TIMECOORDs in events
     20                                    unused
     8n     LISTofTIMECOORD                events

  TIMECOORD
     4     TIMESTAMP                       time
     2     INT16                           x
     2     INT16                           y

<emphasis role='bold'>TranslateCoordinates</emphasis>
     1     40                              opcode
     1                                     unused
     2     4                               request length
     4     WINDOW                          src-window
     4     WINDOW                          dst-window
     2     INT16                           src-x
     2     INT16                           src-y
-&gt;
     1     1                               Reply
     1     BOOL                            same-screen
     2     CARD16                          sequence number
     4     0                               reply length
     4     WINDOW                          child
          0     None
     2     INT16                           dst-x
     2     INT16                           dst-y
     16                                    unused

<emphasis role='bold'>WarpPointer</emphasis>
     1     41                              opcode
     1                                     unused
     2     6                               request length
     4     WINDOW                          src-window
          0     None
     4     WINDOW                          dst-window
          0     None
     2     INT16                           src-x
     2     INT16                           src-y
     2     CARD16                          src-width
     2     CARD16                          src-height
     2     INT16                           dst-x
     2     INT16                           dst-y

<emphasis role='bold'>SetInputFocus</emphasis>
     1     42                              opcode
     1                                     revert-to
          0     None
          1     PointerRoot
          2     Parent
     2     3                               request length
     4     WINDOW                          focus
          0     None
          1     PointerRoot
     4     TIMESTAMP                       time
          0     CurrentTime

<emphasis role='bold'>GetInputFocus</emphasis>
     1     43                              opcode
     1                                     unused
     2     1                               request length

-&gt;
     1     1                               Reply
     1                                     revert-to
          0     None
          1     PointerRoot
          2     Parent
     2     CARD16                          sequence number
     4     0                               reply length
     4     WINDOW                          focus
          0     None
          1     PointerRoot
     20                                    unused

<emphasis role='bold'>QueryKeymap</emphasis>
     1     44                              opcode
     1                                     unused
     2     1                               request length

-&gt;
     1     1                               Reply
     1                                     unused
     2     CARD16                          sequence number
     4     2                               reply length
     32     LISTofCARD8                    keys

<emphasis role='bold'>OpenFont</emphasis>
     1     45                              opcode
     1                                     unused
     2     3+(n+p)/4                       request length
     4     FONT                            fid
     2     n                               length of name
     2                                     unused
     n     STRING8                         name
     p                                     unused, p=pad(n)

<emphasis role='bold'>CloseFont</emphasis>
     1     46                              opcode
     1                                     unused
     2     2                               request length
     4     FONT                            font

<emphasis role='bold'>QueryFont</emphasis>
     1     47                              opcode
     1                                     unused
     2     2                               request length
     4     FONTABLE                        font

-&gt;
     1     1                               Reply
     1                                     unused
     2     CARD16                          sequence number
     4     7+2n+3m                         reply length
     12     CHARINFO                       min-bounds
     4                                     unused
     12     CHARINFO                       max-bounds
     4                                     unused
     2     CARD16                          min-char-or-byte2
     2     CARD16                          max-char-or-byte2
     2     CARD16                          default-char
     2     n                               number of FONTPROPs in properties
     1                                     draw-direction
          0     LeftToRight
          1     RightToLeft
     1     CARD8                           min-byte1
     1     CARD8                           max-byte1
     1     BOOL                            all-chars-exist
     2     INT16                           font-ascent
     2     INT16                           font-descent
     4     m                               number of CHARINFOs in char-infos
     8n     LISTofFONTPROP                 properties
     12m     LISTofCHARINFO                char-infos

  FONTPROP
     4     ATOM                            name
     4     &lt;32-bits&gt;                 value

  CHARINFO
     2     INT16                           left-side-bearing
     2     INT16                           right-side-bearing
     2     INT16                           character-width
     2     INT16                           ascent
     2     INT16                           descent
     2     CARD16                          attributes

<emphasis role='bold'>QueryTextExtents</emphasis>
     1     48                              opcode
     1     BOOL                            odd length, True if p = 2
     2     2+(2n+p)/4                      request length
     4     FONTABLE                        font
     2n     STRING16                       string
     p                                     unused, p=pad(2n)

-&gt;
     1     1                               Reply
     1                                     draw-direction
          0     LeftToRight
          1     RightToLeft
     2     CARD16                          sequence number
     4     0                               reply length
     2     INT16                           font-ascent
     2     INT16                           font-descent
     2     INT16                           overall-ascent
     2     INT16                           overall-descent
     4     INT32                           overall-width
     4     INT32                           overall-left
     4     INT32                           overall-right
     4                                     unused

<emphasis role='bold'>ListFonts</emphasis>
     1     49                              opcode
     1                                     unused
     2     2+(n+p)/4                       request length
     2     CARD16                          max-names
     2     n                               length of pattern
     n     STRING8                         pattern
     p                                     unused, p=pad(n)

-&gt;
     1     1                               Reply
     1                                     unused
     2     CARD16                          sequence number
     4     (n+p)/4                         reply length
     2     CARD16                          number of STRs in names
     22                                    unused
     n     LISTofSTR                       names
     p                                     unused, p=pad(n)

<emphasis role='bold'>ListFontsWithInfo</emphasis>
     1     50                              opcode
     1                                     unused
     2     2+(n+p)/4                       request length
     2     CARD16                          max-names
     2     n                               length of pattern
     n     STRING8                         pattern
     p                                     unused, p=pad(n)

-&gt; (except for last in series)
     1     1                               Reply
     1     n                               length of name in bytes
     2     CARD16                          sequence number
     4     7+2m+(n+p)/4                    reply length
     12     CHARINFO                       min-bounds
     4                                     unused
     12     CHARINFO                       max-bounds
     4                                     unused
     2     CARD16                          min-char-or-byte2
     2     CARD16                          max-char-or-byte2
     2     CARD16                          default-char
     2     m                               number of FONTPROPs in properties
     1                                     draw-direction
          0     LeftToRight
          1     RightToLeft
     1     CARD8                           min-byte1
     1     CARD8                           max-byte1
     1     BOOL                            all-chars-exist
     2     INT16                           font-ascent
     2     INT16                           font-descent
     4     CARD32                          replies-hint
     8m     LISTofFONTPROP                 properties
     n     STRING8                         name
     p                                     unused, p=pad(n)

  FONTPROP
     encodings are the same as for QueryFont

  CHARINFO
     encodings are the same as for QueryFont

-&gt; (last in series)
     1     1                               Reply
     1     0                               last-reply indicator
     2     CARD16                          sequence number
     4     7                               reply length
     52                                    unused

<emphasis role='bold'>SetFontPath</emphasis>
     1     51                              opcode
     1                                     unused
     2     2+(n+p)/4                       request length
     2     CARD16                          number of STRs in path
     2                                     unused
     n     LISTofSTR                       path
     p                                     unused, p=pad(n)

<emphasis role='bold'>GetFontPath</emphasis>
     1     52                              opcode
     1                                     unused
     2     1                               request list

-&gt;
     1     1                               Reply
     1                                     unused
     2     CARD16                          sequence number
     4     (n+p)/4                         reply length
     2     CARD16                          number of STRs in path
     22                                    unused
     n     LISTofSTR                       path
     p                                     unused, p=pad(n)

<emphasis role='bold'>CreatePixmap</emphasis>
     1     53                              opcode
     1     CARD8                           depth
     2     4                               request length
     4     PIXMAP                          pid
     4     DRAWABLE                        drawable
     2     CARD16                          width
     2     CARD16                          height

<emphasis role='bold'>FreePixmap</emphasis>
     1     54                              opcode
     1                                     unused
     2     2                               request length
     4     PIXMAP                          pixmap

<emphasis role='bold'>CreateGC</emphasis>
     1     55                              opcode
     1                                     unused
     2     4+n                             request length
     4     GCONTEXT                        cid
     4     DRAWABLE                        drawable
     4     BITMASK                         value-mask (has n bits set to 1)
          #x00000001     function
          #x00000002     plane-mask
          #x00000004     foreground
          #x00000008     background
          #x00000010     line-width
          #x00000020     line-style
          #x00000040     cap-style
          #x00000080     join-style
          #x00000100     fill-style
          #x00000200     fill-rule
          #x00000400     tile
          #x00000800     stipple
          #x00001000     tile-stipple-x-origin
          #x00002000     tile-stipple-y-origin
          #x00004000     font
          #x00008000     subwindow-mode
          #x00010000     graphics-exposures
          #x00020000     clip-x-origin
          #x00040000     clip-y-origin
          #x00080000     clip-mask
          #x00100000     dash-offset
          #x00200000     dashes
          #x00400000     arc-mode
     4n     LISTofVALUE                    value-list

  VALUEs
     1                                     function
           0     Clear
           1     And
           2     AndReverse
           3     Copy
           4     AndInverted
           5     NoOp
           6     Xor
           7     Or
           8     Nor
           9     Equiv
          10     Invert
          11     OrReverse
          12     CopyInverted
          13     OrInverted
          14     Nand
          15     Set
     4     CARD32                          plane-mask
     4     CARD32                          foreground
     4     CARD32                          background
     2     CARD16                          line-width
     1                                     line-style
          0     Solid
          1     OnOffDash
          2     DoubleDash
     1                                     cap-style
          0     NotLast
          1     Butt
          2     Round
          3     Projecting
     1                                     join-style
          0     Miter
          1     Round
          2     Bevel
     1                                     fill-style
          0     Solid
          1     Tiled
          2     Stippled
          3     OpaqueStippled
     1                                     fill-rule
          0     EvenOdd
          1     Winding
     4     PIXMAP                          tile
     4     PIXMAP                          stipple
     2     INT16                           tile-stipple-x-origin
     2     INT16                           tile-stipple-y-origin
     4     FONT                            font
     1                                     subwindow-mode
          0     ClipByChildren
          1     IncludeInferiors
     1     BOOL                            graphics-exposures
     2     INT16                           clip-x-origin
     2     INT16                           clip-y-origin
     4     PIXMAP                          clip-mask
          0     None
     2     CARD16                          dash-offset
     1     CARD8                           dashes
     1                                     arc-mode
          0     Chord
          1     PieSlice

<emphasis role='bold'>ChangeGC</emphasis>
     1     56                              opcode
     1                                     unused
     2     3+n                             request length
     4     GCONTEXT                        gc
     4     BITMASK                         value-mask (has n bits set to 1)
          encodings are the same as for CreateGC
     4n     LISTofVALUE                    value-list
          encodings are the same as for CreateGC

<emphasis role='bold'>CopyGC</emphasis>
     1     57                              opcode
     1                                     unused
     2     4                               request length
     4     GCONTEXT                        src-gc
     4     GCONTEXT                        dst-gc
     4     BITMASK                         value-mask
          encodings are the same as for CreateGC

<emphasis role='bold'>SetDashes</emphasis>
     1     58                              opcode
     1                                     unused
     2     3+(n+p)/4                       request length
     4     GCONTEXT                        gc
     2     CARD16                          dash-offset
     2     n                               length of dashes
     n     LISTofCARD8                     dashes
     p                                     unused, p=pad(n)

<emphasis role='bold'>SetClipRectangles</emphasis>
     1     59                              opcode
     1                                     ordering
          0     UnSorted
          1     YSorted
          2     YXSorted
          3     YXBanded
     2     3+2n                            request length
     4     GCONTEXT                        gc
     2     INT16                           clip-x-origin
     2     INT16                           clip-y-origin
     8n     LISTofRECTANGLE                rectangles

<emphasis role='bold'>FreeGC</emphasis>
     1     60                              opcode
     1                                     unused
     2     2                               request length
     4     GCONTEXT                        gc

<emphasis role='bold'>ClearArea</emphasis>
     1     61                              opcode
     1     BOOL                            exposures
     2     4                               request length
     4     WINDOW                          window
     2     INT16                           x
     2     INT16                           y
     2     CARD16                          width
     2     CARD16                          height

<emphasis role='bold'>CopyArea</emphasis>
     1     62                              opcode
     1                                     unused
     2     7                               request length
     4     DRAWABLE                        src-drawable
     4     DRAWABLE                        dst-drawable
     4     GCONTEXT                        gc
     2     INT16                           src-x
     2     INT16                           src-y
     2     INT16                           dst-x
     2     INT16                           dst-y
     2     CARD16                          width
     2     CARD16                          height

<emphasis role='bold'>CopyPlane</emphasis>
     1     63                              opcode
     1                                     unused
     2     8                               request length
     4     DRAWABLE                        src-drawable
     4     DRAWABLE                        dst-drawable
     4     GCONTEXT                        gc
     2     INT16                           src-x
     2     INT16                           src-y
     2     INT16                           dst-x
     2     INT16                           dst-y
     2     CARD16                          width
     2     CARD16                          height
     4     CARD32                          bit-plane

<emphasis role='bold'>PolyPoint</emphasis>
     1     64                              opcode
     1                                     coordinate-mode
          0     Origin
          1     Previous
     2     3+n                             request length
     4     DRAWABLE                        drawable
     4     GCONTEXT                        gc
     4n     LISTofPOINT                    points

<emphasis role='bold'>PolyLine</emphasis>
     1     65                              opcode
     1                                     coordinate-mode
          0     Origin
          1     Previous
     2     3+n                             request length
     4     DRAWABLE                        drawable
     4     GCONTEXT                        gc
     4n     LISTofPOINT                    points

<emphasis role='bold'>PolySegment</emphasis>
     1     66                              opcode
     1                                     unused
     2     3+2n                            request length
     4     DRAWABLE                        drawable
     4     GCONTEXT                        gc
     8n     LISTofSEGMENT                  segments

  SEGMENT
     2     INT16                           x1
     2     INT16                           y1
     2     INT16                           x2
     2     INT16                           y2

<emphasis role='bold'>PolyRectangle</emphasis>
     1     67                              opcode
     1                                     unused
     2     3+2n                            request length
     4     DRAWABLE                        drawable
     4     GCONTEXT                        gc
     8n     LISTofRECTANGLE                rectangles

<emphasis role='bold'>PolyArc</emphasis>
     1     68                              opcode
     1                                     unused
     2     3+3n                            request length
     4     DRAWABLE                        drawable
     4     GCONTEXT                        gc
     12n     LISTofARC                     arcs

<emphasis role='bold'>FillPoly</emphasis>
     1     69                              opcode
     1                                     unused
     2     4+n                             request length
     4     DRAWABLE                        drawable
     4     GCONTEXT                        gc
     1                                     shape
          0     Complex
          1     Nonconvex
          2     Convex
     1                                     coordinate-mode
          0     Origin
          1     Previous
     2                                     unused
     4n     LISTofPOINT                    points

<emphasis role='bold'>PolyFillRectangle</emphasis>
     1     70                              opcode
     1                                     unused
     2     3+2n                            request length
     4     DRAWABLE                        drawable
     4     GCONTEXT                        gc
     8n     LISTofRECTANGLE                rectangles

<emphasis role='bold'>PolyFillArc</emphasis>
     1     71                              opcode
     1                                     unused
     2     3+3n                            request length
     4     DRAWABLE                        drawable
     4     GCONTEXT                        gc
     12n     LISTofARC                     arcs

<emphasis role='bold'>PutImage</emphasis>
     1     72                              opcode
     1                                     format
          0     Bitmap
          1     XYPixmap
          2     ZPixmap
     2     6+(n+p)/4                       request length
     4     DRAWABLE                        drawable
     4     GCONTEXT                        gc
     2     CARD16                          width
     2     CARD16                          height
     2     INT16                           dst-x
     2     INT16                           dst-y
     1     CARD8                           left-pad
     1     CARD8                           depth
     2                                     unused
     n     LISTofBYTE                      data
     p                                     unused, p=pad(n)

<emphasis role='bold'>GetImage</emphasis>
     1     73                              opcode
     1                                     format
          1     XYPixmap
          2     ZPixmap
     2     5                               request length
     4     DRAWABLE                        drawable
     2     INT16                           x
     2     INT16                           y
     2     CARD16                          width
     2     CARD16                          height
     4     CARD32                          plane-mask

-&gt;
     1     1                               Reply
     1     CARD8                           depth
     2     CARD16                          sequence number
     4     (n+p)/4                         reply length
     4     VISUALID                        visual
          0     None
     20                                    unused
     n     LISTofBYTE                      data
     p                                     unused, p=pad(n)

<emphasis role='bold'>PolyText8</emphasis>
     1     74                              opcode
     1                                     unused
     2     4+(n+p)/4                       request length
     4     DRAWABLE                        drawable
     4     GCONTEXT                        gc
     2     INT16                           x
     2     INT16                           y
     n     LISTofTEXTITEM8                 items
     p                                     unused, p=pad(n)  (p is always 0
                                           or 1)

  TEXTITEM8
     1     m                               length of string (cannot be 255)
     1     INT8                            delta
     m     STRING8                         string
  or
     1     255                             font-shift indicator
     1                                     font byte 3 (most-significant)
     1                                     font byte 2
     1                                     font byte 1
     1                                     font byte 0 (least-significant)

<emphasis role='bold'>PolyText16</emphasis>
     1     75                              opcode
     1                                     unused
     2     4+(n+p)/4                       request length
     4     DRAWABLE                        drawable
     4     GCONTEXT                        gc
     2     INT16                           x
     2     INT16                           y
     n     LISTofTEXTITEM16                items
     p                                     unused, p=pad(n)  (p must be 0 or
                                           1)

  TEXTITEM16
     1     m                               number of CHAR2Bs in string
                                           (cannot be 255)
     1     INT8                            delta
     2m     STRING16                       string
  or
     1     255                             font-shift indicator
     1                                     font byte 3 (most-significant)
     1                                     font byte 2
     1                                     font byte 1
     1                                     font byte 0 (least-significant)

<emphasis role='bold'>ImageText8</emphasis>
     1     76                              opcode
     1     n                               length of string
     2     4+(n+p)/4                       request length
     4     DRAWABLE                        drawable
     4     GCONTEXT                        gc
     2     INT16                           x
     2     INT16                           y
     n     STRING8                         string
     p                                     unused, p=pad(n)

<emphasis role='bold'>ImageText16</emphasis>
     1     77                              opcode
     1     n                               number of CHAR2Bs in string
     2     4+(2n+p)/4                      request length
     4     DRAWABLE                        drawable
     4     GCONTEXT                        gc
     2     INT16                           x
     2     INT16                           y
     2n     STRING16                       string
     p                                     unused, p=pad(2n)

<emphasis role='bold'>CreateColormap</emphasis>
     1     78                              opcode
     1                                     alloc
          0     None
          1     All
     2     4                               request length
     4     COLORMAP                        mid
     4     WINDOW                          window
     4     VISUALID                        visual

<emphasis role='bold'>FreeColormap</emphasis>
     1     79                              opcode
     1                                     unused
     2     2                               request length
     4     COLORMAP                        cmap

<emphasis role='bold'>CopyColormapAndFree</emphasis>
     1     80                              opcode
     1                                     unused
     2     3                               request length
     4     COLORMAP                        mid
     4     COLORMAP                        src-cmap

<emphasis role='bold'>InstallColormap</emphasis>
     1     81                              opcode
     1                                     unused
     2     2                               request length
     4     COLORMAP                        cmap

<emphasis role='bold'>UninstallColormap</emphasis>
     1     82                              opcode
     1                                     unused
     2     2                               request length
     4     COLORMAP                        cmap

<emphasis role='bold'>ListInstalledColormaps</emphasis>
     1     83                              opcode
     1                                     unused
     2     2                               request length
     4     WINDOW                          window

-&gt;
     1     1                               Reply
     1                                     unused
     2     CARD16                          sequence number
     4     n                               reply length
     2     n                               number of COLORMAPs in cmaps
     22                                    unused
     4n     LISTofCOLORMAP                 cmaps

<emphasis role='bold'>AllocColor</emphasis>
     1     84                              opcode
     1                                     unused
     2     4                               request length
     4     COLORMAP                        cmap
     2     CARD16                          red
     2     CARD16                          green
     2     CARD16                          blue
     2                                     unused

-&gt;
     1     1                               Reply
     1                                     unused
     2     CARD16                          sequence number
     4     0                               reply length
     2     CARD16                          red
     2     CARD16                          green
     2     CARD16                          blue
     2                                     unused
     4     CARD32                          pixel
     12                                    unused

<emphasis role='bold'>AllocNamedColor</emphasis>
     1     85                              opcode
     1                                     unused
     2     3+(n+p)/4                       request length
     4     COLORMAP                        cmap
     2     n                               length of name
     2                                     unused
     n     STRING8                         name
     p                                     unused, p=pad(n)

-&gt;
     1     1                               Reply
     1                                     unused
     2     CARD16                          sequence number
     4     0                               reply length
     4     CARD32                          pixel
     2     CARD16                          exact-red
     2     CARD16                          exact-green
     2     CARD16                          exact-blue
     2     CARD16                          visual-red
     2     CARD16                          visual-green
     2     CARD16                          visual-blue
     8                                     unused

<emphasis role='bold'>AllocColorCells</emphasis>
     1     86                              opcode
     1     BOOL                            contiguous
     2     3                               request length
     4     COLORMAP                        cmap
     2     CARD16                          colors
     2     CARD16                          planes

-&gt;
     1     1                               Reply
     1                                     unused
     2     CARD16                          sequence number
     4     n+m                             reply length
     2     n                               number of CARD32s in pixels
     2     m                               number of CARD32s in masks
     20                                    unused
     4n     LISTofCARD32                   pixels
     4m     LISTofCARD32                   masks

<emphasis role='bold'>AllocColorPlanes</emphasis>
     1     87                              opcode
     1     BOOL                            contiguous
     2     4                               request length
     4     COLORMAP                        cmap
     2     CARD16                          colors
     2     CARD16                          reds
     2     CARD16                          greens
     2     CARD16                          blues

-&gt;
     1     1                               Reply
     1                                     unused
     2     CARD16                          sequence number
     4     n                               reply length
     2     n                               number of CARD32s in pixels
     2                                     unused
     4     CARD32                          red-mask
     4     CARD32                          green-mask
     4     CARD32                          blue-mask
     8                                     unused
     4n     LISTofCARD32                   pixels

<emphasis role='bold'>FreeColors</emphasis>
     1     88                              opcode
     1                                     unused
     2     3+n                             request length
     4     COLORMAP                        cmap
     4     CARD32                          plane-mask
     4n     LISTofCARD32                   pixels

<emphasis role='bold'>StoreColors</emphasis>
     1     89                              opcode
     1                                     unused
     2     2+3n                            request length
     4     COLORMAP                        cmap
     12n     LISTofCOLORITEM               items

  COLORITEM
     4     CARD32                          pixel
     2     CARD16                          red
     2     CARD16                          green
     2     CARD16                          blue
     1                                     do-red, do-green, do-blue
          #x01     do-red (1 is True, 0 is False)
          #x02     do-green (1 is True, 0 is False)
          #x04     do-blue (1 is True, 0 is False)
          #xF8     unused
     1                                     unused

<emphasis role='bold'>StoreNamedColor</emphasis>
     1     90                              opcode
     1                                     do-red, do-green, do-blue
          #x01     do-red (1 is True, 0 is False)
          #x02     do-green (1 is True, 0 is False)
          #x04     do-blue (1 is True, 0 is False)
          #xF8     unused
     2     4+(n+p)/4                       request length
     4     COLORMAP                        cmap
     4     CARD32                          pixel
     2     n                               length of name
     2                                     unused
     n     STRING8                         name
     p                                     unused, p=pad(n)

<emphasis role='bold'>QueryColors</emphasis>
     1     91                              opcode
     1                                     unused
     2     2+n                             request length
     4     COLORMAP                        cmap
     4n     LISTofCARD32                   pixels

-&gt;
     1     1                               Reply
     1                                     unused
     2     CARD16                          sequence number
     4     2n                              reply length
     2     n                               number of RGBs in colors
     22                                    unused
     8n     LISTofRGB                      colors

  RGB
     2     CARD16                          red
     2     CARD16                          green
     2     CARD16                          blue
     2                                     unused

<emphasis role='bold'>LookupColor</emphasis>
     1     92                              opcode
     1                                     unused
     2     3+(n+p)/4                       request length
     4     COLORMAP                        cmap
     2     n                               length of name
     2                                     unused
     n     STRING8                         name
     p                                     unused, p=pad(n)

-&gt;
     1     1                               Reply
     1                                     unused
     2     CARD16                          sequence number
     4     0                               reply length
     2     CARD16                          exact-red
     2     CARD16                          exact-green
     2     CARD16                          exact-blue
     2     CARD16                          visual-red
     2     CARD16                          visual-green
     2     CARD16                          visual-blue
     12                                    unused

<emphasis role='bold'>CreateCursor</emphasis>
     1     93                              opcode
     1                                     unused
     2     8                               request length
     4     CURSOR                          cid
     4     PIXMAP                          source
     4     PIXMAP                          mask
          0     None
     2     CARD16                          fore-red
     2     CARD16                          fore-green
     2     CARD16                          fore-blue
     2     CARD16                          back-red
     2     CARD16                          back-green
     2     CARD16                          back-blue
     2     CARD16                          x
     2     CARD16                          y

<emphasis role='bold'>CreateGlyphCursor</emphasis>
     1     94                              opcode
     1                                     unused
     2     8                               request length
     4     CURSOR                          cid
     4     FONT                            source-font
     4     FONT                            mask-font
          0     None
     2     CARD16                          source-char
     2     CARD16                          mask-char
     2     CARD16                          fore-red
     2     CARD16                          fore-green
     2     CARD16                          fore-blue
     2     CARD16                          back-red
     2     CARD16                          back-green
     2     CARD16                          back-blue

<emphasis role='bold'>FreeCursor</emphasis>
     1     95                              opcode
     1                                     unused
     2     2                               request length
     4     CURSOR                          cursor

<emphasis role='bold'>RecolorCursor</emphasis>
     1     96                              opcode
     1                                     unused
     2     5                               request length
     4     CURSOR                          cursor
     2     CARD16                          fore-red
     2     CARD16                          fore-green
     2     CARD16                          fore-blue
     2     CARD16                          back-red
     2     CARD16                          back-green
     2     CARD16                          back-blue

<emphasis role='bold'>QueryBestSize</emphasis>
     1     97                              opcode
     1                                     class
          0     Cursor
          1     Tile
          2     Stipple
     2     3                               request length
     4     DRAWABLE                        drawable
     2     CARD16                          width
     2     CARD16                          height

-&gt;
     1     1                               Reply
     1                                     unused
     2     CARD16                          sequence number
     4     0                               reply length
     2     CARD16                          width
     2     CARD16                          height
     20                                    unused

<emphasis role='bold'>QueryExtension</emphasis>
     1     98                              opcode
     1                                     unused
     2     2+(n+p)/4                       request length
     2     n                               length of name
     2                                     unused
     n     STRING8                         name
     p                                     unused, p=pad(n)

-&gt;
     1     1                               Reply
     1                                     unused
     2     CARD16                          sequence number
     4     0                               reply length
     1     BOOL                            present
     1     CARD8                           major-opcode
     1     CARD8                           first-event
     1     CARD8                           first-error
     20                                    unused

<emphasis role='bold'>ListExtensions</emphasis>
     1     99                              opcode
     1                                     unused
     2     1                               request length

-&gt;
     1     1                               Reply
     1     CARD8                           number of STRs in names
     2     CARD16                          sequence number
     4     (n+p)/4                         reply length
     24                                    unused
     n     LISTofSTR                       names
     p                                     unused, p=pad(n)

<emphasis role='bold'>ChangeKeyboardMapping</emphasis>
     1     100                             opcode
     1     n                               keycode-count
     2     2+nm                            request length
     1     KEYCODE                         first-keycode
     1     m                               keysyms-per-keycode
     2                                     unused
     4nm     LISTofKEYSYM                  keysyms

<emphasis role='bold'>GetKeyboardMapping</emphasis>
     1     101                             opcode
     1                                     unused
     2     2                               request length
     1     KEYCODE                         first-keycode
     1     m                               count
     2                                     unused

-&gt;
     1     1                               Reply
     1     n                               keysyms-per-keycode
     2     CARD16                          sequence number
     4     nm                              reply length (m = count field
                                           from the request)
     24                                    unused
     4nm     LISTofKEYSYM                  keysyms

<emphasis role='bold'>ChangeKeyboardControl</emphasis>
     1     102                             opcode
     1                                     unused
     2     2+n                             request length
     4     BITMASK                         value-mask (has n bits set to 1)
          #x0001     key-click-percent
          #x0002     bell-percent
          #x0004     bell-pitch
          #x0008     bell-duration
          #x0010     led
          #x0020     led-mode
          #x0040     key
          #x0080     auto-repeat-mode
     4n     LISTofVALUE                    value-list

  VALUEs
     1     INT8                            key-click-percent
     1     INT8                            bell-percent
     2     INT16                           bell-pitch
     2     INT16                           bell-duration
     1     CARD8                           led
     1                                     led-mode
          0     Off
          1     On
     1     KEYCODE                         key
     1                                     auto-repeat-mode
          0     Off
          1     On
          2     Default

<emphasis role='bold'>GetKeyboardControl</emphasis>
     1     103                             opcode
     1                                     unused
     2     1                               request length

-&gt;
     1     1                               Reply
     1                                     global-auto-repeat
          0     Off
          1     On
     2     CARD16                          sequence number
     4     5                               reply length
     4     CARD32                          led-mask
     1     CARD8                           key-click-percent
     1     CARD8                           bell-percent
     2     CARD16                          bell-pitch
     2     CARD16                          bell-duration
     2                                     unused
     32     LISTofCARD8                    auto-repeats

<emphasis role='bold'>Bell</emphasis>
     1     104                             opcode
     1     INT8                            percent
     2     1                               request length

<emphasis role='bold'>ChangePointerControl</emphasis>
     1     105                             opcode
     1                                     unused
     2     3                               request length
     2     INT16                           acceleration-numerator
     2     INT16                           acceleration-denominator
     2     INT16                           threshold
     1     BOOL                            do-acceleration
     1     BOOL                            do-threshold

<emphasis role='bold'>GetPointerControl</emphasis>
     1     106                             opcode
     1                                     unused
     2     1                               request length

-&gt;
     1     1                               Reply
     1                                     unused
     2     CARD16                          sequence number
     4     0                               reply length
     2     CARD16                          acceleration-numerator
     2     CARD16                          acceleration-denominator
     2     CARD16                          threshold
     18                                    unused

<emphasis role='bold'>SetScreenSaver</emphasis>
     1     107                             opcode
     1                                     unused
     2     3                               request length
     2     INT16                           timeout
     2     INT16                           interval
     1                                     prefer-blanking
          0     No
          1     Yes
          2     Default
     1                                     allow-exposures
          0     No
          1     Yes
          2     Default
     2                                     unused

<emphasis role='bold'>GetScreenSaver</emphasis>
     1     108                             opcode
     1                                     unused
     2     1                               request length

-&gt;
     1     1                               Reply
     1                                     unused
     2     CARD16                          sequence number
     4     0                               reply length
     2     CARD16                          timeout
     2     CARD16                          interval
     1                                     prefer-blanking
          0     No
          1     Yes
     1                                     allow-exposures
          0     No
          1     Yes
     18                                    unused

<emphasis role='bold'>ChangeHosts</emphasis>
     1     109                             opcode
     1                                     mode
          0     Insert
          1     Delete
     2     2+(n+p)/4                       request length
     1                                     family
          0     Internet
          1     DECnet
          2     Chaos
     1                                     unused
     2     n                               length of address
     n     LISTofCARD8                     address
     p                                     unused, p=pad(n)

<emphasis role='bold'>ListHosts</emphasis>
     1     110                             opcode
     1                                     unused
     2     1                               request length

-&gt;
     1     1                               Reply
     1                                     mode
          0     Disabled
          1     Enabled
     2     CARD16                          sequence number
     4     n/4                             reply length
     2     CARD16                          number of HOSTs in hosts
     22                                    unused
     n     LISTofHOST                      hosts (n always a multiple of 4)

<emphasis role='bold'>SetAccessControl</emphasis>
     1     111                             opcode
     1                                     mode
          0     Disable
          1     Enable
     2     1                               request length

<emphasis role='bold'>SetCloseDownMode</emphasis>
     1     112                             opcode
     1                                     mode
          0     Destroy
          1     RetainPermanent
          2     RetainTemporary
     2     1                               request length

<emphasis role='bold'>KillClient</emphasis>
     1     113                             opcode
     1                                     unused
     2     2                               request length
     4     CARD32                          resource
          0     AllTemporary

<emphasis role='bold'>RotateProperties</emphasis>
     1     114                             opcode
     1                                     unused
     2     3+n                             request length
     4     WINDOW                          window
     2     n                               number of properties
     2     INT16                           delta
     4n    LISTofATOM                      properties

<emphasis role='bold'>ForceScreenSaver</emphasis>
     1     115                             opcode
     1                                     mode
          0     Reset
          1     Activate
     2     1                               request length

<emphasis role='bold'>SetPointerMapping</emphasis>
     1     116                             opcode
     1     n                               length of map
     2     1+(n+p)/4                       request length
     n     LISTofCARD8                     map
     p                                     unused, p=pad(n)

-&gt;
     1     1                               Reply
     1                                     status
          0     Success
          1     Busy
     2     CARD16                          sequence number
     4     0                               reply length
     24                                    unused

<emphasis role='bold'>GetPointerMapping</emphasis>
     1     117                             opcode
     1                                     unused
     2     1                               request length

-&gt;
     1     1                               Reply
     1     n                               length of map
     2     CARD16                          sequence number
     4     (n+p)/4                         reply length
     24                                    unused
     n     LISTofCARD8                     map
     p                                     unused, p=pad(n)

<emphasis role='bold'>SetModifierMapping</emphasis>
     1     118                             opcode
     1     n                               keycodes-per-modifier
     2     1+2n                            request length
     8n    LISTofKEYCODE                   keycodes

-&gt;
     1     1                               Reply
     1                                     status
          0     Success
          1     Busy
          2     Failed
     2     CARD16                          sequence number
     4     0                               reply length
     24                                    unused

<emphasis role='bold'>GetModifierMapping</emphasis>
     1     119                             opcode
     1                                     unused
     2     1                               request length

-&gt;
     1     1                               Reply
     1     n                               keycodes-per-modifier
     2     CARD16                          sequence number
     4     2n                              reply length
     24                                    unused
     8n     LISTofKEYCODE                  keycodes

<emphasis role='bold'>NoOperation</emphasis>
     1     127                             opcode
     1                                     unused
     2     1+n                             request length
     4n                                    unused
</literallayout>
</sect1>

<sect1 id="events_encoding">
<title>Events</title>

<literallayout class="monospaced">
<link linkend="events:KeyPress"><emphasis role='bold'>KeyPress</emphasis></link>
     1     2                               code
     1     KEYCODE                         detail
     2     CARD16                          sequence number
     4     TIMESTAMP                       time
     4     WINDOW                          root
     4     WINDOW                          event
     4     WINDOW                          child
          0     None
     2     INT16                           root-x
     2     INT16                           root-y
     2     INT16                           event-x
     2     INT16                           event-y
     2     SETofKEYBUTMASK                 state
     1     BOOL                            same-screen
     1                                     unused

<link linkend="events:KeyRelease"><emphasis role='bold'>KeyRelease</emphasis></link>
     1     3                               code
     1     KEYCODE                         detail
     2     CARD16                          sequence number
     4     TIMESTAMP                       time
     4     WINDOW                          root
     4     WINDOW                          event
     4     WINDOW                          child
          0     None
     2     INT16                           root-x
     2     INT16                           root-y
     2     INT16                           event-x
     2     INT16                           event-y
     2     SETofKEYBUTMASK                 state
     1     BOOL                            same-screen
     1                                     unused

<link linkend="events:ButtonPress"><emphasis role='bold'>ButtonPress</emphasis></link>
     1     4                               code
     1     BUTTON                          detail
     2     CARD16                          sequence number
     4     TIMESTAMP                       time
     4     WINDOW                          root
     4     WINDOW                          event
     4     WINDOW                          child
          0     None
     2     INT16                           root-x
     2     INT16                           root-y
     2     INT16                           event-x
     2     INT16                           event-y
     2     SETofKEYBUTMASK                 state
     1     BOOL                            same-screen
     1                                     unused

<link linkend="events:ButtonRelease"><emphasis role='bold'>ButtonRelease</emphasis></link>
     1     5                               code
     1     BUTTON                          detail
     2     CARD16                          sequence number
     4     TIMESTAMP                       time
     4     WINDOW                          root
     4     WINDOW                          event
     4     WINDOW                          child
          0     None
     2     INT16                           root-x
     2     INT16                           root-y
     2     INT16                           event-x
     2     INT16                           event-y
     2     SETofKEYBUTMASK                 state
     1     BOOL                            same-screen
     1                                     unused

<link linkend="events:MotionNotify"><emphasis role='bold'>MotionNotify</emphasis></link>
     1     6                               code
     1                                     detail
          0     Normal
          1     Hint
     2     CARD16                          sequence number
     4     TIMESTAMP                       time
     4     WINDOW                          root
     4     WINDOW                          event
     4     WINDOW                          child
           0     None
     2     INT16                           root-x
     2     INT16                           root-y
     2     INT16                           event-x
     2     INT16                           event-y
     2     SETofKEYBUTMASK                 state
     1     BOOL                            same-screen
     1                                     unused

<link linkend="events:EnterNotify"><emphasis role='bold'>EnterNotify</emphasis></link>
     1     7                               code
     1                                     detail
          0     Ancestor
          1     Virtual
          2     Inferior
          3     Nonlinear
          4     NonlinearVirtual
     2     CARD16                          sequence number
     4     TIMESTAMP                       time
     4     WINDOW                          root
     4     WINDOW                          event
     4     WINDOW                          child
          0     None
     2     INT16                           root-x
     2     INT16                           root-y
     2     INT16                           event-x
     2     INT16                           event-y
     2     SETofKEYBUTMASK                 state
     1                                     mode
          0     Normal
          1     Grab
          2     Ungrab
     1                                     same-screen, focus
          #x01     focus (1 is True, 0 is False)
          #x02     same-screen (1 is True, 0 is False)
          #xFC     unused

<link linkend="events:LeaveNotify"><emphasis role='bold'>LeaveNotify</emphasis></link>
     1     8                               code
     1                                     detail
          0     Ancestor
          1     Virtual
          2     Inferior
          3     Nonlinear
          4     NonlinearVirtual
     2     CARD16                          sequence number
     4     TIMESTAMP                       time
     4     WINDOW                          root
     4     WINDOW                          event
     4     WINDOW                          child
          0     None
     2     INT16                           root-x
     2     INT16                           root-y
     2     INT16                           event-x
     2     INT16                           event-y
     2     SETofKEYBUTMASK                 state
     1                                     mode
          0     Normal
          1     Grab
          2     Ungrab
     1                                     same-screen, focus
          #x01     focus (1 is True, 0 is False)
          #x02     same-screen (1 is True, 0 is False)
          #xFC     unused

<link linkend="events:FocusIn"><emphasis role='bold'>FocusIn</emphasis></link>
     1     9                               code
     1                                     detail
          0     Ancestor
          1     Virtual
          2     Inferior
          3     Nonlinear
          4     NonlinearVirtual
          5     Pointer
          6     PointerRoot
          7     None
     2     CARD16                          sequence number
     4     WINDOW                          event
     1                                     mode
          0     Normal
          1     Grab
          2     Ungrab
          3     WhileGrabbed
     23                                    unused

<link linkend="events:FocusOut"><emphasis role='bold'>FocusOut</emphasis></link>
     1     10                              code
     1                                     detail
          0     Ancestor
          1     Virtual
          2     Inferior
          3     Nonlinear
          4     NonlinearVirtual
          5     Pointer
          6     PointerRoot
          7     None
     2     CARD16                          sequence number
     4     WINDOW                          event
     1                                     mode
          0     Normal
          1     Grab
          2     Ungrab
          3     WhileGrabbed
     23                                    unused

<link linkend="events:KeymapNotify"><emphasis role='bold'>KeymapNotify</emphasis></link>
     1     11                              code
     31    LISTofCARD8                     keys (byte for keycodes 0-7 is
                                           omitted)

<link linkend="events:Expose"><emphasis role='bold'>Expose</emphasis></link>
     1     12                              code
     1                                     unused
     2     CARD16                          sequence number
     4     WINDOW                          window
     2     CARD16                          x
     2     CARD16                          y
     2     CARD16                          width
     2     CARD16                          height
     2     CARD16                          count
     14                                    unused

<link linkend="events:GraphicsExposure"><emphasis role='bold'>GraphicsExposure</emphasis></link>
     1     13                              code
     1                                     unused
     2     CARD16                          sequence number
     4     DRAWABLE                        drawable
     2     CARD16                          x
     2     CARD16                          y
     2     CARD16                          width
     2     CARD16                          height
     2     CARD16                          minor-opcode
     2     CARD16                          count
     1     CARD8                           major-opcode
     11                                    unused

<link linkend="events:NoExposure"><emphasis role='bold'>NoExposure</emphasis></link>
     1     14                              code
     1                                     unused
     2     CARD16                          sequence number
     4     DRAWABLE                        drawable
     2     CARD16                          minor-opcode
     1     CARD8                           major-opcode
     21                                    unused

<link linkend="events:VisibilityNotify"><emphasis role='bold'>VisibilityNotify</emphasis></link>
     1     15                              code
     1                                     unused
     2     CARD16                          sequence number
     4     WINDOW                          window
     1                                     state
          0     Unobscured
          1     PartiallyObscured
          2     FullyObscured
     23                                    unused

<link linkend="events:CreateNotify"><emphasis role='bold'>CreateNotify</emphasis></link>
     1     16                              code
     1                                     unused
     2     CARD16                          sequence number
     4     WINDOW                          parent
     4     WINDOW                          window
     2     INT16                           x
     2     INT16                           y
     2     CARD16                          width
     2     CARD16                          height
     2     CARD16                          border-width
     1     BOOL                            override-redirect
     9                                     unused

<link linkend="events:DestroyNotify"><emphasis role='bold'>DestroyNotify</emphasis></link>
     1     17                              code
     1                                     unused
     2     CARD16                          sequence number
     4     WINDOW                          event
     4     WINDOW                          window
     20                                    unused

<link linkend="events:UnmapNotify"><emphasis role='bold'>UnmapNotify</emphasis></link>
     1     18                              code
     1                                     unused
     2     CARD16                          sequence number
     4     WINDOW                          event
     4     WINDOW                          window
     1     BOOL                            from-configure
     19                                    unused

<link linkend="events:MapNotify"><emphasis role='bold'>MapNotify</emphasis></link>
     1     19                              code
     1                                     unused
     2     CARD16                          sequence number
     4     WINDOW                          event
     4     WINDOW                          window
     1     BOOL                            override-redirect
     19                                    unused

<link linkend="events:MapRequest"><emphasis role='bold'>MapRequest</emphasis></link>
     1     20                              code
     1                                     unused
     2     CARD16                          sequence number
     4     WINDOW                          parent
     4     WINDOW                          window
     20                                    unused

<link linkend="events:ReparentNotify"><emphasis role='bold'>ReparentNotify</emphasis></link>
     1     21                              code
     1                                     unused
     2     CARD16                          sequence number
     4     WINDOW                          event
     4     WINDOW                          window
     4     WINDOW                          parent
     2     INT16                           x
     2     INT16                           y
     1     BOOL                            override-redirect
     11                                    unused

<link linkend="events:ConfigureNotify"><emphasis role='bold'>ConfigureNotify</emphasis></link>
     1     22                              code
     1                                     unused
     2     CARD16                          sequence number
     4     WINDOW                          event
     4     WINDOW                          window
     4     WINDOW                          above-sibling
          0     None
     2     INT16                           x
     2     INT16                           y
     2     CARD16                          width
     2     CARD16                          height
     2     CARD16                          border-width
     1     BOOL                            override-redirect
     5                                     unused

<link linkend="events:ConfigureRequest"><emphasis role='bold'>ConfigureRequest</emphasis></link>
     1     23                              code
     1                                     stack-mode
          0     Above
          1     Below
          2     TopIf
          3     BottomIf
          4     Opposite
     2     CARD16                          sequence number
     4     WINDOW                          parent
     4     WINDOW                          window
     4     WINDOW                          sibling
          0     None
     2     INT16                           x
     2     INT16                           y
     2     CARD16                          width
     2     CARD16                          height
     2     CARD16                          border-width
     2     BITMASK                         value-mask
          #x0001     x
          #x0002     y
          #x0004     width
          #x0008     height
          #x0010     border-width
          #x0020     sibling
          #x0040     stack-mode
     4                                     unused

<link linkend="events:GravityNotify"><emphasis role='bold'>GravityNotify</emphasis></link>
     1     24                              code
     1                                     unused
     2     CARD16                          sequence number
     4     WINDOW                          event
     4     WINDOW                          window
     2     INT16                           x
     2     INT16                           y
     16                                    unused

<link linkend="events:ResizeRequest"><emphasis role='bold'>ResizeRequest</emphasis></link>
     1     25                              code
     1                                     unused
     2     CARD16                          sequence number
     4     WINDOW                          window
     2     CARD16                          width
     2     CARD16                          height
     20                                    unused

<link linkend="events:CirculateNotify"><emphasis role='bold'>CirculateNotify</emphasis></link>
     1     26                              code
     1                                     unused
     2     CARD16                          sequence number
     4     WINDOW                          event
     4     WINDOW                          window
     4     WINDOW                          unused
     1                                     place
          0     Top
          1     Bottom
     15                                    unused

<link linkend="events:CirculateRequest"><emphasis role='bold'>CirculateRequest</emphasis></link>
     1     27                              code
     1                                     unused
     2     CARD16                          sequence number
     4     WINDOW                          parent
     4     WINDOW                          window
     4                                     unused
     1                                     place
          0     Top
          1     Bottom
     15                                    unused

<link linkend="events:PropertyNotify"><emphasis role='bold'>PropertyNotify</emphasis></link>
     1     28                              code
     1                                     unused
     2     CARD16                          sequence number
     4     WINDOW                          window
     4     ATOM                            atom
     4     TIMESTAMP                       time
     1                                     state
          0     NewValue
          1     Deleted
     15                                    unused

<link linkend="events:SelectionClear"><emphasis role='bold'>SelectionClear</emphasis></link>
     1     29                              code
     1                                     unused
     2     CARD16                          sequence number
     4     TIMESTAMP                       time
     4     WINDOW                          owner
     4     ATOM                            selection
     16                                    unused

<link linkend="events:SelectionRequest"><emphasis role='bold'>SelectionRequest</emphasis></link>
     1     30                              code
     1                                     unused
     2     CARD16                          sequence number
     4     TIMESTAMP                       time
          0     CurrentTime
     4     WINDOW                          owner
     4     WINDOW                          requestor
     4     ATOM                            selection
     4     ATOM                            target
     4     ATOM                            property
          0     None
     4                                     unused

<link linkend="events:SelectionNotify"><emphasis role='bold'>SelectionNotify</emphasis></link>
     1     31                              code
     1                                     unused
     2     CARD16                          sequence number
     4     TIMESTAMP                       time
          0     CurrentTime
     4     WINDOW                          requestor
     4     ATOM                            selection
     4     ATOM                            target
     4     ATOM                            property
          0     None
     8                                     unused

<link linkend="events:ColormapNotify"><emphasis role='bold'>ColormapNotify</emphasis></link>
     1     32                              code
     1                                     unused
     2     CARD16                          sequence number
     4     WINDOW                          window
     4     COLORMAP                        colormap
          0     None
     1     BOOL                            new
     1                                     state
          0     Uninstalled
          1     Installed
     18                                    unused

<link linkend="events:ClientMessage"><emphasis role='bold'>ClientMessage</emphasis></link>
     1     33                              code
     1     CARD8                           format
     2     CARD16                          sequence number
     4     WINDOW                          window
     4     ATOM                            type
     20                                    data

<link linkend="events:MappingNotify"><emphasis role='bold'>MappingNotify</emphasis></link>
     1     34                              code
     1                                     unused
     2     CARD16                          sequence number
     1                                     request
          0     Modifier
          1     Keyboard
          2     Pointer
     1     KEYCODE                         first-keycode
     1     CARD8                           count
     25                                    unused
</literallayout>

</sect1>
</appendix>