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
// x11-rs: Rust bindings for X11 libraries
// The X11 libraries are available under the MIT license.
// These bindings are public domain.

use std::cmp::min;
use std::convert::From;
use std::mem::{
  size_of,
  zeroed,
};
use std::slice::{
  from_raw_parts,
  from_raw_parts_mut,
};

use libc::{
  c_char,
  c_int,
  c_long,
  c_short,
  c_uchar,
  c_uint,
  c_ulong,
  c_ushort,
  c_void,
  wchar_t,
};

pub mod xcms;
pub mod xkb;


//
// functions
//


#[link(name="X11")]
extern "C" {
  pub fn XActivateScreenSaver (_1: *mut Display) -> c_int;
  pub fn XAddConnectionWatch (_3: *mut Display, _2: Option<unsafe extern "C" fn (*mut Display, *mut c_char, c_int, c_int, *mut *mut c_char)>, _1: *mut c_char) -> c_int;
  pub fn XAddExtension (_1: *mut Display) -> *mut XExtCodes;
  pub fn XAddHost (_2: *mut Display, _1: *mut XHostAddress) -> c_int;
  pub fn XAddHosts (_3: *mut Display, _2: *mut XHostAddress, _1: c_int) -> c_int;
  pub fn XAddPixel (_2: *mut XImage, _1: c_long) -> c_int;
  pub fn XAddToExtensionList (_2: *mut *mut XExtData, _1: *mut XExtData) -> c_int;
  pub fn XAddToSaveSet (_2: *mut Display, _1: c_ulong) -> c_int;
  pub fn XAllocClassHint () -> *mut XClassHint;
  pub fn XAllocColor (_3: *mut Display, _2: c_ulong, _1: *mut XColor) -> c_int;
  pub fn XAllocColorCells (_7: *mut Display, _6: c_ulong, _5: c_int, _4: *mut c_ulong, _3: c_uint, _2: *mut c_ulong, _1: c_uint) -> c_int;
  pub fn XAllocColorPlanes (_11: *mut Display, _10: c_ulong, _9: c_int, _8: *mut c_ulong, _7: c_int, _6: c_int, _5: c_int, _4: c_int, _3: *mut c_ulong, _2: *mut c_ulong, _1: *mut c_ulong) -> c_int;
  pub fn XAllocIconSize () -> *mut XIconSize;
  pub fn XAllocNamedColor (_5: *mut Display, _4: c_ulong, _3: *const c_char, _2: *mut XColor, _1: *mut XColor) -> c_int;
  pub fn XAllocSizeHints () -> *mut XSizeHints;
  pub fn XAllocStandardColormap () -> *mut XStandardColormap;
  pub fn XAllocWMHints () -> *mut XWMHints;
  pub fn XAllowEvents (_3: *mut Display, _2: c_int, _1: c_ulong) -> c_int;
  pub fn XAllPlanes () -> c_ulong;
  pub fn XAutoRepeatOff (_1: *mut Display) -> c_int;
  pub fn XAutoRepeatOn (_1: *mut Display) -> c_int;
  pub fn XBaseFontNameListOfFontSet (_1: XFontSet) -> *mut c_char;
  pub fn XBell (_2: *mut Display, _1: c_int) -> c_int;
  pub fn XBitmapBitOrder (_1: *mut Display) -> c_int;
  pub fn XBitmapPad (_1: *mut Display) -> c_int;
  pub fn XBitmapUnit (_1: *mut Display) -> c_int;
  pub fn XBlackPixel (_2: *mut Display, _1: c_int) -> c_ulong;
  pub fn XBlackPixelOfScreen (_1: *mut Screen) -> c_ulong;
  pub fn XCellsOfScreen (_1: *mut Screen) -> c_int;
  pub fn XChangeActivePointerGrab (_4: *mut Display, _3: c_uint, _2: c_ulong, _1: c_ulong) -> c_int;
  pub fn XChangeGC (_4: *mut Display, _3: GC, _2: c_ulong, _1: *mut XGCValues) -> c_int;
  pub fn XChangeKeyboardControl (_3: *mut Display, _2: c_ulong, _1: *mut XKeyboardControl) -> c_int;
  pub fn XChangeKeyboardMapping (_5: *mut Display, _4: c_int, _3: c_int, _2: *mut c_ulong, _1: c_int) -> c_int;
  pub fn XChangePointerControl (_6: *mut Display, _5: c_int, _4: c_int, _3: c_int, _2: c_int, _1: c_int) -> c_int;
  pub fn XChangeProperty (_8: *mut Display, _7: c_ulong, _6: c_ulong, _5: c_ulong, _4: c_int, _3: c_int, _2: *const c_uchar, _1: c_int) -> c_int;
  pub fn XChangeSaveSet (_3: *mut Display, _2: c_ulong, _1: c_int) -> c_int;
  pub fn XChangeWindowAttributes (_4: *mut Display, _3: c_ulong, _2: c_ulong, _1: *mut XSetWindowAttributes) -> c_int;
  pub fn XCheckIfEvent (_4: *mut Display, _3: *mut XEvent, _2: Option<unsafe extern "C" fn (*mut Display, *mut XEvent, *mut c_char) -> c_int>, _1: *mut c_char) -> c_int;
  pub fn XCheckMaskEvent (_3: *mut Display, _2: c_long, _1: *mut XEvent) -> c_int;
  pub fn XCheckTypedEvent (_3: *mut Display, _2: c_int, _1: *mut XEvent) -> c_int;
  pub fn XCheckTypedWindowEvent (_4: *mut Display, _3: c_ulong, _2: c_int, _1: *mut XEvent) -> c_int;
  pub fn XCheckWindowEvent (_4: *mut Display, _3: c_ulong, _2: c_long, _1: *mut XEvent) -> c_int;
  pub fn XCirculateSubwindows (_3: *mut Display, _2: c_ulong, _1: c_int) -> c_int;
  pub fn XCirculateSubwindowsDown (_2: *mut Display, _1: c_ulong) -> c_int;
  pub fn XCirculateSubwindowsUp (_2: *mut Display, _1: c_ulong) -> c_int;
  pub fn XClearArea (_7: *mut Display, _6: c_ulong, _5: c_int, _4: c_int, _3: c_uint, _2: c_uint, _1: c_int) -> c_int;
  pub fn XClearWindow (_2: *mut Display, _1: c_ulong) -> c_int;
  pub fn XClipBox (_2: Region, _1: *mut XRectangle) -> c_int;
  pub fn XCloseDisplay (_1: *mut Display) -> c_int;
  pub fn XCloseIM (_1: XIM) -> c_int;
  pub fn XCloseOM (_1: XOM) -> c_int;
  pub fn XConfigureWindow (_4: *mut Display, _3: c_ulong, _2: c_uint, _1: *mut XWindowChanges) -> c_int;
  pub fn XConnectionNumber (_1: *mut Display) -> c_int;
  pub fn XContextDependentDrawing (_1: XFontSet) -> c_int;
  pub fn XContextualDrawing (_1: XFontSet) -> c_int;
  pub fn XConvertCase (_3: c_ulong, _2: *mut c_ulong, _1: *mut c_ulong);
  pub fn XConvertSelection (_6: *mut Display, _5: c_ulong, _4: c_ulong, _3: c_ulong, _2: c_ulong, _1: c_ulong) -> c_int;
  pub fn XCopyArea (_10: *mut Display, _9: c_ulong, _8: c_ulong, _7: GC, _6: c_int, _5: c_int, _4: c_uint, _3: c_uint, _2: c_int, _1: c_int) -> c_int;
  pub fn XCopyColormapAndFree (_2: *mut Display, _1: c_ulong) -> c_ulong;
  pub fn XCopyGC (_4: *mut Display, _3: GC, _2: c_ulong, _1: GC) -> c_int;
  pub fn XCopyPlane (_11: *mut Display, _10: c_ulong, _9: c_ulong, _8: GC, _7: c_int, _6: c_int, _5: c_uint, _4: c_uint, _3: c_int, _2: c_int, _1: c_ulong) -> c_int;
  pub fn XCreateBitmapFromData (_5: *mut Display, _4: c_ulong, _3: *const c_char, _2: c_uint, _1: c_uint) -> c_ulong;
  pub fn XCreateColormap (_4: *mut Display, _3: c_ulong, _2: *mut Visual, _1: c_int) -> c_ulong;
  pub fn XCreateFontCursor (_2: *mut Display, _1: c_uint) -> c_ulong;
  pub fn XCreateFontSet (_5: *mut Display, _4: *const c_char, _3: *mut *mut *mut c_char, _2: *mut c_int, _1: *mut *mut c_char) -> XFontSet;
  pub fn XCreateGC (_4: *mut Display, _3: c_ulong, _2: c_ulong, _1: *mut XGCValues) -> GC;
  pub fn XCreateGlyphCursor (_7: *mut Display, _6: c_ulong, _5: c_ulong, _4: c_uint, _3: c_uint, _2: *const XColor, _1: *const XColor) -> c_ulong;
  pub fn XCreateIC (_1: XIM, ...) -> XIC;
  pub fn XCreateImage (_10: *mut Display, _9: *mut Visual, _8: c_uint, _7: c_int, _6: c_int, _5: *mut c_char, _4: c_uint, _3: c_uint, _2: c_int, _1: c_int) -> *mut XImage;
  pub fn XCreateOC (_1: XOM, ...) -> XFontSet;
  pub fn XCreatePixmap (_5: *mut Display, _4: c_ulong, _3: c_uint, _2: c_uint, _1: c_uint) -> c_ulong;
  pub fn XCreatePixmapCursor (_7: *mut Display, _6: c_ulong, _5: c_ulong, _4: *mut XColor, _3: *mut XColor, _2: c_uint, _1: c_uint) -> c_ulong;
  pub fn XCreatePixmapFromBitmapData (_8: *mut Display, _7: c_ulong, _6: *mut c_char, _5: c_uint, _4: c_uint, _3: c_ulong, _2: c_ulong, _1: c_uint) -> c_ulong;
  pub fn XCreateRegion () -> Region;
  pub fn XCreateSimpleWindow (_9: *mut Display, _8: c_ulong, _7: c_int, _6: c_int, _5: c_uint, _4: c_uint, _3: c_uint, _2: c_ulong, _1: c_ulong) -> c_ulong;
  pub fn XCreateWindow (_12: *mut Display, _11: c_ulong, _10: c_int, _9: c_int, _8: c_uint, _7: c_uint, _6: c_uint, _5: c_int, _4: c_uint, _3: *mut Visual, _2: c_ulong, _1: *mut XSetWindowAttributes) -> c_ulong;
  pub fn XDefaultColormap (_2: *mut Display, _1: c_int) -> c_ulong;
  pub fn XDefaultColormapOfScreen (_1: *mut Screen) -> c_ulong;
  pub fn XDefaultDepth (_2: *mut Display, _1: c_int) -> c_int;
  pub fn XDefaultDepthOfScreen (_1: *mut Screen) -> c_int;
  pub fn XDefaultGC (_2: *mut Display, _1: c_int) -> GC;
  pub fn XDefaultGCOfScreen (_1: *mut Screen) -> GC;
  pub fn XDefaultRootWindow (_1: *mut Display) -> c_ulong;
  pub fn XDefaultScreen (_1: *mut Display) -> c_int;
  pub fn XDefaultScreenOfDisplay (_1: *mut Display) -> *mut Screen;
  pub fn XDefaultString () -> *const c_char;
  pub fn XDefaultVisual (_2: *mut Display, _1: c_int) -> *mut Visual;
  pub fn XDefaultVisualOfScreen (_1: *mut Screen) -> *mut Visual;
  pub fn XDefineCursor (_3: *mut Display, _2: c_ulong, _1: c_ulong) -> c_int;
  pub fn XDeleteContext (_3: *mut Display, _2: c_ulong, _1: c_int) -> c_int;
  pub fn XDeleteModifiermapEntry (_3: *mut XModifierKeymap, _2: c_uchar, _1: c_int) -> *mut XModifierKeymap;
  pub fn XDeleteProperty (_3: *mut Display, _2: c_ulong, _1: c_ulong) -> c_int;
  pub fn XDestroyIC (_1: XIC);
  pub fn XDestroyImage (_1: *mut XImage) -> c_int;
  pub fn XDestroyOC (_1: XFontSet);
  pub fn XDestroyRegion (_1: Region) -> c_int;
  pub fn XDestroySubwindows (_2: *mut Display, _1: c_ulong) -> c_int;
  pub fn XDestroyWindow (_2: *mut Display, _1: c_ulong) -> c_int;
  pub fn XDirectionalDependentDrawing (_1: XFontSet) -> c_int;
  pub fn XDisableAccessControl (_1: *mut Display) -> c_int;
  pub fn XDisplayCells (_2: *mut Display, _1: c_int) -> c_int;
  pub fn XDisplayHeight (_2: *mut Display, _1: c_int) -> c_int;
  pub fn XDisplayHeightMM (_2: *mut Display, _1: c_int) -> c_int;
  pub fn XDisplayKeycodes (_3: *mut Display, _2: *mut c_int, _1: *mut c_int) -> c_int;
  pub fn XDisplayMotionBufferSize (_1: *mut Display) -> c_ulong;
  pub fn XDisplayName (_1: *const c_char) -> *mut c_char;
  pub fn XDisplayOfIM (_1: XIM) -> *mut Display;
  pub fn XDisplayOfOM (_1: XOM) -> *mut Display;
  pub fn XDisplayOfScreen (_1: *mut Screen) -> *mut Display;
  pub fn XDisplayPlanes (_2: *mut Display, _1: c_int) -> c_int;
  pub fn XDisplayString (_1: *mut Display) -> *mut c_char;
  pub fn XDisplayWidth (_2: *mut Display, _1: c_int) -> c_int;
  pub fn XDisplayWidthMM (_2: *mut Display, _1: c_int) -> c_int;
  pub fn XDoesBackingStore (_1: *mut Screen) -> c_int;
  pub fn XDoesSaveUnders (_1: *mut Screen) -> c_int;
  pub fn XDrawArc (_9: *mut Display, _8: c_ulong, _7: GC, _6: c_int, _5: c_int, _4: c_uint, _3: c_uint, _2: c_int, _1: c_int) -> c_int;
  pub fn XDrawArcs (_5: *mut Display, _4: c_ulong, _3: GC, _2: *mut XArc, _1: c_int) -> c_int;
  pub fn XDrawImageString (_7: *mut Display, _6: c_ulong, _5: GC, _4: c_int, _3: c_int, _2: *const c_char, _1: c_int) -> c_int;
  pub fn XDrawImageString16 (_7: *mut Display, _6: c_ulong, _5: GC, _4: c_int, _3: c_int, _2: *const XChar2b, _1: c_int) -> c_int;
  pub fn XDrawLine (_7: *mut Display, _6: c_ulong, _5: GC, _4: c_int, _3: c_int, _2: c_int, _1: c_int) -> c_int;
  pub fn XDrawLines (_6: *mut Display, _5: c_ulong, _4: GC, _3: *mut XPoint, _2: c_int, _1: c_int) -> c_int;
  pub fn XDrawPoint (_5: *mut Display, _4: c_ulong, _3: GC, _2: c_int, _1: c_int) -> c_int;
  pub fn XDrawPoints (_6: *mut Display, _5: c_ulong, _4: GC, _3: *mut XPoint, _2: c_int, _1: c_int) -> c_int;
  pub fn XDrawRectangle (_7: *mut Display, _6: c_ulong, _5: GC, _4: c_int, _3: c_int, _2: c_uint, _1: c_uint) -> c_int;
  pub fn XDrawRectangles (_5: *mut Display, _4: c_ulong, _3: GC, _2: *mut XRectangle, _1: c_int) -> c_int;
  pub fn XDrawSegments (_5: *mut Display, _4: c_ulong, _3: GC, _2: *mut XSegment, _1: c_int) -> c_int;
  pub fn XDrawString (_7: *mut Display, _6: c_ulong, _5: GC, _4: c_int, _3: c_int, _2: *const c_char, _1: c_int) -> c_int;
  pub fn XDrawString16 (_7: *mut Display, _6: c_ulong, _5: GC, _4: c_int, _3: c_int, _2: *const XChar2b, _1: c_int) -> c_int;
  pub fn XDrawText (_7: *mut Display, _6: c_ulong, _5: GC, _4: c_int, _3: c_int, _2: *mut XTextItem, _1: c_int) -> c_int;
  pub fn XDrawText16 (_7: *mut Display, _6: c_ulong, _5: GC, _4: c_int, _3: c_int, _2: *mut XTextItem16, _1: c_int) -> c_int;
  pub fn XEHeadOfExtensionList (_1: XEDataObject) -> *mut *mut XExtData;
  pub fn XEmptyRegion (_1: Region) -> c_int;
  pub fn XEnableAccessControl (_1: *mut Display) -> c_int;
  pub fn XEqualRegion (_2: Region, _1: Region) -> c_int;
  pub fn XESetBeforeFlush (_3: *mut Display, _2: c_int, _1: Option<unsafe extern "C" fn (*mut Display, *mut XExtCodes, *const c_char, c_long)>) -> Option<unsafe extern "C" fn (*mut Display, *mut XExtCodes, *const c_char, c_long)>;
  pub fn XESetCloseDisplay (_3: *mut Display, _2: c_int, _1: Option<unsafe extern "C" fn (*mut Display, *mut XExtCodes) -> c_int>) -> Option<unsafe extern "C" fn (*mut Display, *mut XExtCodes) -> c_int>;
  pub fn XESetCopyEventCookie (_3: *mut Display, _2: c_int, _1: Option<unsafe extern "C" fn (*mut Display, *mut XGenericEventCookie, *mut XGenericEventCookie) -> c_int>) -> Option<unsafe extern "C" fn (*mut Display, *mut XGenericEventCookie, *mut XGenericEventCookie) -> c_int>;
  pub fn XESetCopyGC (_3: *mut Display, _2: c_int, _1: Option<unsafe extern "C" fn (*mut Display, GC, *mut XExtCodes) -> c_int>) -> Option<unsafe extern "C" fn (*mut Display, GC, *mut XExtCodes) -> c_int>;
  pub fn XESetCreateFont (_3: *mut Display, _2: c_int, _1: Option<unsafe extern "C" fn (*mut Display, *mut XFontStruct, *mut XExtCodes) -> c_int>) -> Option<unsafe extern "C" fn (*mut Display, *mut XFontStruct, *mut XExtCodes) -> c_int>;
  pub fn XESetCreateGC (_3: *mut Display, _2: c_int, _1: Option<unsafe extern "C" fn (*mut Display, GC, *mut XExtCodes) -> c_int>) -> Option<unsafe extern "C" fn (*mut Display, GC, *mut XExtCodes) -> c_int>;
  pub fn XESetError (_3: *mut Display, _2: c_int, _1: Option<unsafe extern "C" fn (*mut Display, *mut xError, *mut XExtCodes, *mut c_int) -> c_int>) -> Option<unsafe extern "C" fn (*mut Display, *mut xError, *mut XExtCodes, *mut c_int) -> c_int>;
  pub fn XESetErrorString (_3: *mut Display, _2: c_int, _1: Option<unsafe extern "C" fn (*mut Display, c_int, *mut XExtCodes, *mut c_char, c_int) -> *mut c_char>) -> Option<unsafe extern "C" fn (*mut Display, c_int, *mut XExtCodes, *mut c_char, c_int) -> *mut c_char>;
  pub fn XESetEventToWire (_3: *mut Display, _2: c_int, _1: Option<unsafe extern "C" fn (*mut Display, *mut XEvent, *mut xEvent) -> c_int>) -> Option<unsafe extern "C" fn (*mut Display, *mut XEvent, *mut xEvent) -> c_int>;
  pub fn XESetFlushGC (_3: *mut Display, _2: c_int, _1: Option<unsafe extern "C" fn (*mut Display, GC, *mut XExtCodes) -> c_int>) -> Option<unsafe extern "C" fn (*mut Display, GC, *mut XExtCodes) -> c_int>;
  pub fn XESetFreeFont (_3: *mut Display, _2: c_int, _1: Option<unsafe extern "C" fn (*mut Display, *mut XFontStruct, *mut XExtCodes) -> c_int>) -> Option<unsafe extern "C" fn (*mut Display, *mut XFontStruct, *mut XExtCodes) -> c_int>;
  pub fn XESetFreeGC (_3: *mut Display, _2: c_int, _1: Option<unsafe extern "C" fn (*mut Display, GC, *mut XExtCodes) -> c_int>) -> Option<unsafe extern "C" fn (*mut Display, GC, *mut XExtCodes) -> c_int>;
  pub fn XESetPrintErrorValues (_3: *mut Display, _2: c_int, _1: Option<unsafe extern "C" fn (*mut Display, *mut XErrorEvent, *mut c_void)>) -> Option<unsafe extern "C" fn (*mut Display, *mut XErrorEvent, *mut c_void)>;
  pub fn XESetWireToError (_3: *mut Display, _2: c_int, _1: Option<unsafe extern "C" fn (*mut Display, *mut XErrorEvent, *mut xError) -> c_int>) -> Option<unsafe extern "C" fn (*mut Display, *mut XErrorEvent, *mut xError) -> c_int>;
  pub fn XESetWireToEvent (_3: *mut Display, _2: c_int, _1: Option<unsafe extern "C" fn (*mut Display, *mut XEvent, *mut xEvent) -> c_int>) -> Option<unsafe extern "C" fn (*mut Display, *mut XEvent, *mut xEvent) -> c_int>;
  pub fn XESetWireToEventCookie (_3: *mut Display, _2: c_int, _1: Option<unsafe extern "C" fn (*mut Display, *mut XGenericEventCookie, *mut xEvent) -> c_int>) -> Option<unsafe extern "C" fn (*mut Display, *mut XGenericEventCookie, *mut xEvent) -> c_int>;
  pub fn XEventMaskOfScreen (_1: *mut Screen) -> c_long;
  pub fn XEventsQueued (_2: *mut Display, _1: c_int) -> c_int;
  pub fn XExtendedMaxRequestSize (_1: *mut Display) -> c_long;
  pub fn XExtentsOfFontSet (_1: XFontSet) -> *mut XFontSetExtents;
  pub fn XFetchBuffer (_3: *mut Display, _2: *mut c_int, _1: c_int) -> *mut c_char;
  pub fn XFetchBytes (_2: *mut Display, _1: *mut c_int) -> *mut c_char;
  pub fn XFetchName (_3: *mut Display, _2: c_ulong, _1: *mut *mut c_char) -> c_int;
  pub fn XFillArc (_9: *mut Display, _8: c_ulong, _7: GC, _6: c_int, _5: c_int, _4: c_uint, _3: c_uint, _2: c_int, _1: c_int) -> c_int;
  pub fn XFillArcs (_5: *mut Display, _4: c_ulong, _3: GC, _2: *mut XArc, _1: c_int) -> c_int;
  pub fn XFillPolygon (_7: *mut Display, _6: c_ulong, _5: GC, _4: *mut XPoint, _3: c_int, _2: c_int, _1: c_int) -> c_int;
  pub fn XFillRectangle (_7: *mut Display, _6: c_ulong, _5: GC, _4: c_int, _3: c_int, _2: c_uint, _1: c_uint) -> c_int;
  pub fn XFillRectangles (_5: *mut Display, _4: c_ulong, _3: GC, _2: *mut XRectangle, _1: c_int) -> c_int;
  pub fn XFilterEvent (_2: *mut XEvent, _1: c_ulong) -> c_int;
  pub fn XFindContext (_4: *mut Display, _3: c_ulong, _2: c_int, _1: *mut *mut c_char) -> c_int;
  pub fn XFindOnExtensionList (_2: *mut *mut XExtData, _1: c_int) -> *mut XExtData;
  pub fn XFlush (_1: *mut Display) -> c_int;
  pub fn XFlushGC (_2: *mut Display, _1: GC);
  pub fn XFontsOfFontSet (_3: XFontSet, _2: *mut *mut *mut XFontStruct, _1: *mut *mut *mut c_char) -> c_int;
  pub fn XForceScreenSaver (_2: *mut Display, _1: c_int) -> c_int;
  pub fn XFree (_1: *mut c_void) -> c_int;
  pub fn XFreeColormap (_2: *mut Display, _1: c_ulong) -> c_int;
  pub fn XFreeColors (_5: *mut Display, _4: c_ulong, _3: *mut c_ulong, _2: c_int, _1: c_ulong) -> c_int;
  pub fn XFreeCursor (_2: *mut Display, _1: c_ulong) -> c_int;
  pub fn XFreeEventData (_2: *mut Display, _1: *mut XGenericEventCookie);
  pub fn XFreeExtensionList (_1: *mut *mut c_char) -> c_int;
  pub fn XFreeFont (_2: *mut Display, _1: *mut XFontStruct) -> c_int;
  pub fn XFreeFontInfo (_3: *mut *mut c_char, _2: *mut XFontStruct, _1: c_int) -> c_int;
  pub fn XFreeFontNames (_1: *mut *mut c_char) -> c_int;
  pub fn XFreeFontPath (_1: *mut *mut c_char) -> c_int;
  pub fn XFreeFontSet (_2: *mut Display, _1: XFontSet);
  pub fn XFreeGC (_2: *mut Display, _1: GC) -> c_int;
  pub fn XFreeModifiermap (_1: *mut XModifierKeymap) -> c_int;
  pub fn XFreePixmap (_2: *mut Display, _1: c_ulong) -> c_int;
  pub fn XFreeStringList (_1: *mut *mut c_char);
  pub fn XGContextFromGC (_1: GC) -> c_ulong;
  pub fn XGeometry (_13: *mut Display, _12: c_int, _11: *const c_char, _10: *const c_char, _9: c_uint, _8: c_uint, _7: c_uint, _6: c_int, _5: c_int, _4: *mut c_int, _3: *mut c_int, _2: *mut c_int, _1: *mut c_int) -> c_int;
  pub fn XGetAtomName (_2: *mut Display, _1: c_ulong) -> *mut c_char;
  pub fn XGetAtomNames (_4: *mut Display, _3: *mut c_ulong, _2: c_int, _1: *mut *mut c_char) -> c_int;
  pub fn XGetClassHint (_3: *mut Display, _2: c_ulong, _1: *mut XClassHint) -> c_int;
  pub fn XGetCommand (_4: *mut Display, _3: c_ulong, _2: *mut *mut *mut c_char, _1: *mut c_int) -> c_int;
  pub fn XGetDefault (_3: *mut Display, _2: *const c_char, _1: *const c_char) -> *mut c_char;
  pub fn XGetErrorDatabaseText (_6: *mut Display, _5: *const c_char, _4: *const c_char, _3: *const c_char, _2: *mut c_char, _1: c_int) -> c_int;
  pub fn XGetErrorText (_4: *mut Display, _3: c_int, _2: *mut c_char, _1: c_int) -> c_int;
  pub fn XGetEventData (_2: *mut Display, _1: *mut XGenericEventCookie) -> c_int;
  pub fn XGetFontPath (_2: *mut Display, _1: *mut c_int) -> *mut *mut c_char;
  pub fn XGetFontProperty (_3: *mut XFontStruct, _2: c_ulong, _1: *mut c_ulong) -> c_int;
  pub fn XGetGCValues (_4: *mut Display, _3: GC, _2: c_ulong, _1: *mut XGCValues) -> c_int;
  pub fn XGetGeometry (_9: *mut Display, _8: c_ulong, _7: *mut c_ulong, _6: *mut c_int, _5: *mut c_int, _4: *mut c_uint, _3: *mut c_uint, _2: *mut c_uint, _1: *mut c_uint) -> c_int;
  pub fn XGetIconName (_3: *mut Display, _2: c_ulong, _1: *mut *mut c_char) -> c_int;
  pub fn XGetIconSizes (_4: *mut Display, _3: c_ulong, _2: *mut *mut XIconSize, _1: *mut c_int) -> c_int;
  pub fn XGetICValues (_1: XIC, ...) -> *mut c_char;
  pub fn XGetImage (_8: *mut Display, _7: c_ulong, _6: c_int, _5: c_int, _4: c_uint, _3: c_uint, _2: c_ulong, _1: c_int) -> *mut XImage;
  pub fn XGetIMValues (_1: XIM, ...) -> *mut c_char;
  pub fn XGetInputFocus (_3: *mut Display, _2: *mut c_ulong, _1: *mut c_int) -> c_int;
  pub fn XGetKeyboardControl (_2: *mut Display, _1: *mut XKeyboardState) -> c_int;
  pub fn XGetKeyboardMapping (_4: *mut Display, _3: c_uchar, _2: c_int, _1: *mut c_int) -> *mut c_ulong;
  pub fn XGetModifierMapping (_1: *mut Display) -> *mut XModifierKeymap;
  pub fn XGetMotionEvents (_5: *mut Display, _4: c_ulong, _3: c_ulong, _2: c_ulong, _1: *mut c_int) -> *mut XTimeCoord;
  pub fn XGetNormalHints (_3: *mut Display, _2: c_ulong, _1: *mut XSizeHints) -> c_int;
  pub fn XGetOCValues (_1: XFontSet, ...) -> *mut c_char;
  pub fn XGetOMValues (_1: XOM, ...) -> *mut c_char;
  pub fn XGetPixel (_3: *mut XImage, _2: c_int, _1: c_int) -> c_ulong;
  pub fn XGetPointerControl (_4: *mut Display, _3: *mut c_int, _2: *mut c_int, _1: *mut c_int) -> c_int;
  pub fn XGetPointerMapping (_3: *mut Display, _2: *mut c_uchar, _1: c_int) -> c_int;
  pub fn XGetRGBColormaps (_5: *mut Display, _4: c_ulong, _3: *mut *mut XStandardColormap, _2: *mut c_int, _1: c_ulong) -> c_int;
  pub fn XGetScreenSaver (_5: *mut Display, _4: *mut c_int, _3: *mut c_int, _2: *mut c_int, _1: *mut c_int) -> c_int;
  pub fn XGetSelectionOwner (_2: *mut Display, _1: c_ulong) -> c_ulong;
  pub fn XGetSizeHints (_4: *mut Display, _3: c_ulong, _2: *mut XSizeHints, _1: c_ulong) -> c_int;
  pub fn XGetStandardColormap (_4: *mut Display, _3: c_ulong, _2: *mut XStandardColormap, _1: c_ulong) -> c_int;
  pub fn XGetSubImage (_11: *mut Display, _10: c_ulong, _9: c_int, _8: c_int, _7: c_uint, _6: c_uint, _5: c_ulong, _4: c_int, _3: *mut XImage, _2: c_int, _1: c_int) -> *mut XImage;
  pub fn XGetTextProperty (_4: *mut Display, _3: c_ulong, _2: *mut XTextProperty, _1: c_ulong) -> c_int;
  pub fn XGetTransientForHint (_3: *mut Display, _2: c_ulong, _1: *mut c_ulong) -> c_int;
  pub fn XGetVisualInfo (_4: *mut Display, _3: c_long, _2: *mut XVisualInfo, _1: *mut c_int) -> *mut XVisualInfo;
  pub fn XGetWindowAttributes (_3: *mut Display, _2: c_ulong, _1: *mut XWindowAttributes) -> c_int;
  pub fn XGetWindowProperty (_12: *mut Display, _11: c_ulong, _10: c_ulong, _9: c_long, _8: c_long, _7: c_int, _6: c_ulong, _5: *mut c_ulong, _4: *mut c_int, _3: *mut c_ulong, _2: *mut c_ulong, _1: *mut *mut c_uchar) -> c_int;
  pub fn XGetWMClientMachine (_3: *mut Display, _2: c_ulong, _1: *mut XTextProperty) -> c_int;
  pub fn XGetWMColormapWindows (_4: *mut Display, _3: c_ulong, _2: *mut *mut c_ulong, _1: *mut c_int) -> c_int;
  pub fn XGetWMHints (_2: *mut Display, _1: c_ulong) -> *mut XWMHints;
  pub fn XGetWMIconName (_3: *mut Display, _2: c_ulong, _1: *mut XTextProperty) -> c_int;
  pub fn XGetWMName (_3: *mut Display, _2: c_ulong, _1: *mut XTextProperty) -> c_int;
  pub fn XGetWMNormalHints (_4: *mut Display, _3: c_ulong, _2: *mut XSizeHints, _1: *mut c_long) -> c_int;
  pub fn XGetWMProtocols (_4: *mut Display, _3: c_ulong, _2: *mut *mut c_ulong, _1: *mut c_int) -> c_int;
  pub fn XGetWMSizeHints (_5: *mut Display, _4: c_ulong, _3: *mut XSizeHints, _2: *mut c_long, _1: c_ulong) -> c_int;
  pub fn XGetZoomHints (_3: *mut Display, _2: c_ulong, _1: *mut XSizeHints) -> c_int;
  pub fn XGrabButton (_10: *mut Display, _9: c_uint, _8: c_uint, _7: c_ulong, _6: c_int, _5: c_uint, _4: c_int, _3: c_int, _2: c_ulong, _1: c_ulong) -> c_int;
  pub fn XGrabKey (_7: *mut Display, _6: c_int, _5: c_uint, _4: c_ulong, _3: c_int, _2: c_int, _1: c_int) -> c_int;
  pub fn XGrabKeyboard (_6: *mut Display, _5: c_ulong, _4: c_int, _3: c_int, _2: c_int, _1: c_ulong) -> c_int;
  pub fn XGrabPointer (_9: *mut Display, _8: c_ulong, _7: c_int, _6: c_uint, _5: c_int, _4: c_int, _3: c_ulong, _2: c_ulong, _1: c_ulong) -> c_int;
  pub fn XGrabServer (_1: *mut Display) -> c_int;
  pub fn XHeightMMOfScreen (_1: *mut Screen) -> c_int;
  pub fn XHeightOfScreen (_1: *mut Screen) -> c_int;
  pub fn XIconifyWindow (_3: *mut Display, _2: c_ulong, _1: c_int) -> c_int;
  pub fn XIfEvent (_4: *mut Display, _3: *mut XEvent, _2: Option<unsafe extern "C" fn (*mut Display, *mut XEvent, *mut c_char) -> c_int>, _1: *mut c_char) -> c_int;
  pub fn XImageByteOrder (_1: *mut Display) -> c_int;
  pub fn XIMOfIC (_1: XIC) -> XIM;
  pub fn XInitExtension (_2: *mut Display, _1: *const c_char) -> *mut XExtCodes;
  pub fn XInitImage (_1: *mut XImage) -> c_int;
  pub fn XInitThreads () -> c_int;
  pub fn XInsertModifiermapEntry (_3: *mut XModifierKeymap, _2: c_uchar, _1: c_int) -> *mut XModifierKeymap;
  pub fn XInstallColormap (_2: *mut Display, _1: c_ulong) -> c_int;
  pub fn XInternalConnectionNumbers (_3: *mut Display, _2: *mut *mut c_int, _1: *mut c_int) -> c_int;
  pub fn XInternAtom (_3: *mut Display, _2: *const c_char, _1: c_int) -> c_ulong;
  pub fn XInternAtoms (_5: *mut Display, _4: *mut *mut c_char, _3: c_int, _2: c_int, _1: *mut c_ulong) -> c_int;
  pub fn XIntersectRegion (_3: Region, _2: Region, _1: Region) -> c_int;
  pub fn XKeycodeToKeysym (_3: *mut Display, _2: c_uchar, _1: c_int) -> c_ulong;
  pub fn XKeysymToKeycode (_2: *mut Display, _1: c_ulong) -> c_uchar;
  pub fn XKeysymToString (_1: c_ulong) -> *mut c_char;
  pub fn XKillClient (_2: *mut Display, _1: c_ulong) -> c_int;
  pub fn XLastKnownRequestProcessed (_1: *mut Display) -> c_ulong;
  pub fn XListDepths (_3: *mut Display, _2: c_int, _1: *mut c_int) -> *mut c_int;
  pub fn XListExtensions (_2: *mut Display, _1: *mut c_int) -> *mut *mut c_char;
  pub fn XListFonts (_4: *mut Display, _3: *const c_char, _2: c_int, _1: *mut c_int) -> *mut *mut c_char;
  pub fn XListFontsWithInfo (_5: *mut Display, _4: *const c_char, _3: c_int, _2: *mut c_int, _1: *mut *mut XFontStruct) -> *mut *mut c_char;
  pub fn XListHosts (_3: *mut Display, _2: *mut c_int, _1: *mut c_int) -> *mut XHostAddress;
  pub fn XListInstalledColormaps (_3: *mut Display, _2: c_ulong, _1: *mut c_int) -> *mut c_ulong;
  pub fn XListPixmapFormats (_2: *mut Display, _1: *mut c_int) -> *mut XPixmapFormatValues;
  pub fn XListProperties (_3: *mut Display, _2: c_ulong, _1: *mut c_int) -> *mut c_ulong;
  pub fn XLoadFont (_2: *mut Display, _1: *const c_char) -> c_ulong;
  pub fn XLoadQueryFont (_2: *mut Display, _1: *const c_char) -> *mut XFontStruct;
  pub fn XLocaleOfFontSet (_1: XFontSet) -> *mut c_char;
  pub fn XLocaleOfIM (_1: XIM) -> *mut c_char;
  pub fn XLocaleOfOM (_1: XOM) -> *mut c_char;
  pub fn XLockDisplay (_1: *mut Display);
  pub fn XLookupColor (_5: *mut Display, _4: c_ulong, _3: *const c_char, _2: *mut XColor, _1: *mut XColor) -> c_int;
  pub fn XLookupKeysym (_2: *mut XKeyEvent, _1: c_int) -> c_ulong;
  pub fn XLookupString (_5: *mut XKeyEvent, _4: *mut c_char, _3: c_int, _2: *mut c_ulong, _1: *mut XComposeStatus) -> c_int;
  pub fn XLowerWindow (_2: *mut Display, _1: c_ulong) -> c_int;
  pub fn XMapRaised (_2: *mut Display, _1: c_ulong) -> c_int;
  pub fn XMapSubwindows (_2: *mut Display, _1: c_ulong) -> c_int;
  pub fn XMapWindow (_2: *mut Display, _1: c_ulong) -> c_int;
  pub fn XMaskEvent (_3: *mut Display, _2: c_long, _1: *mut XEvent) -> c_int;
  pub fn XMatchVisualInfo (_5: *mut Display, _4: c_int, _3: c_int, _2: c_int, _1: *mut XVisualInfo) -> c_int;
  pub fn XMaxCmapsOfScreen (_1: *mut Screen) -> c_int;
  pub fn XMaxRequestSize (_1: *mut Display) -> c_long;
  pub fn XmbDrawImageString (_8: *mut Display, _7: c_ulong, _6: XFontSet, _5: GC, _4: c_int, _3: c_int, _2: *const c_char, _1: c_int);
  pub fn XmbDrawString (_8: *mut Display, _7: c_ulong, _6: XFontSet, _5: GC, _4: c_int, _3: c_int, _2: *const c_char, _1: c_int);
  pub fn XmbDrawText (_7: *mut Display, _6: c_ulong, _5: GC, _4: c_int, _3: c_int, _2: *mut XmbTextItem, _1: c_int);
  pub fn XmbLookupString (_6: XIC, _5: *mut XKeyEvent, _4: *mut c_char, _3: c_int, _2: *mut c_ulong, _1: *mut c_int) -> c_int;
  pub fn XmbResetIC (_1: XIC) -> *mut c_char;
  pub fn XmbSetWMProperties (_9: *mut Display, _8: c_ulong, _7: *const c_char, _6: *const c_char, _5: *mut *mut c_char, _4: c_int, _3: *mut XSizeHints, _2: *mut XWMHints, _1: *mut XClassHint);
  pub fn XmbTextEscapement (_3: XFontSet, _2: *const c_char, _1: c_int) -> c_int;
  pub fn XmbTextExtents (_5: XFontSet, _4: *const c_char, _3: c_int, _2: *mut XRectangle, _1: *mut XRectangle) -> c_int;
  pub fn XmbTextListToTextProperty (_5: *mut Display, _4: *mut *mut c_char, _3: c_int, _2: XICCEncodingStyle, _1: *mut XTextProperty) -> c_int;
  pub fn XmbTextPerCharExtents (_9: XFontSet, _8: *const c_char, _7: c_int, _6: *mut XRectangle, _5: *mut XRectangle, _4: c_int, _3: *mut c_int, _2: *mut XRectangle, _1: *mut XRectangle) -> c_int;
  pub fn XmbTextPropertyToTextList (_4: *mut Display, _3: *const XTextProperty, _2: *mut *mut *mut c_char, _1: *mut c_int) -> c_int;
  pub fn XMinCmapsOfScreen (_1: *mut Screen) -> c_int;
  pub fn XMoveResizeWindow (_6: *mut Display, _5: c_ulong, _4: c_int, _3: c_int, _2: c_uint, _1: c_uint) -> c_int;
  pub fn XMoveWindow (_4: *mut Display, _3: c_ulong, _2: c_int, _1: c_int) -> c_int;
  pub fn XNewModifiermap (_1: c_int) -> *mut XModifierKeymap;
  pub fn XNextEvent (_2: *mut Display, _1: *mut XEvent) -> c_int;
  pub fn XNextRequest (_1: *mut Display) -> c_ulong;
  pub fn XNoOp (_1: *mut Display) -> c_int;
  pub fn XOffsetRegion (_3: Region, _2: c_int, _1: c_int) -> c_int;
  pub fn XOMOfOC (_1: XFontSet) -> XOM;
  pub fn XOpenDisplay (_1: *const c_char) -> *mut Display;
  pub fn XOpenIM (_4: *mut Display, _3: XrmDatabase, _2: *mut c_char, _1: *mut c_char) -> XIM;
  pub fn XOpenOM (_4: *mut Display, _3: XrmDatabase, _2: *const c_char, _1: *const c_char) -> XOM;
  pub fn XParseColor (_4: *mut Display, _3: c_ulong, _2: *const c_char, _1: *mut XColor) -> c_int;
  pub fn XParseGeometry (_5: *const c_char, _4: *mut c_int, _3: *mut c_int, _2: *mut c_uint, _1: *mut c_uint) -> c_int;
  pub fn XPeekEvent (_2: *mut Display, _1: *mut XEvent) -> c_int;
  pub fn XPeekIfEvent (_4: *mut Display, _3: *mut XEvent, _2: Option<unsafe extern "C" fn (*mut Display, *mut XEvent, *mut c_char) -> c_int>, _1: *mut c_char) -> c_int;
  pub fn XPending (_1: *mut Display) -> c_int;
  pub fn Xpermalloc (_1: c_uint) -> *mut c_char;
  pub fn XPlanesOfScreen (_1: *mut Screen) -> c_int;
  pub fn XPointInRegion (_3: Region, _2: c_int, _1: c_int) -> c_int;
  pub fn XPolygonRegion (_3: *mut XPoint, _2: c_int, _1: c_int) -> Region;
  pub fn XProcessInternalConnection (_2: *mut Display, _1: c_int);
  pub fn XProtocolRevision (_1: *mut Display) -> c_int;
  pub fn XProtocolVersion (_1: *mut Display) -> c_int;
  pub fn XPutBackEvent (_2: *mut Display, _1: *mut XEvent) -> c_int;
  pub fn XPutImage (_10: *mut Display, _9: c_ulong, _8: GC, _7: *mut XImage, _6: c_int, _5: c_int, _4: c_int, _3: c_int, _2: c_uint, _1: c_uint) -> c_int;
  pub fn XPutPixel (_4: *mut XImage, _3: c_int, _2: c_int, _1: c_ulong) -> c_int;
  pub fn XQLength (_1: *mut Display) -> c_int;
  pub fn XQueryBestCursor (_6: *mut Display, _5: c_ulong, _4: c_uint, _3: c_uint, _2: *mut c_uint, _1: *mut c_uint) -> c_int;
  pub fn XQueryBestSize (_7: *mut Display, _6: c_int, _5: c_ulong, _4: c_uint, _3: c_uint, _2: *mut c_uint, _1: *mut c_uint) -> c_int;
  pub fn XQueryBestStipple (_6: *mut Display, _5: c_ulong, _4: c_uint, _3: c_uint, _2: *mut c_uint, _1: *mut c_uint) -> c_int;
  pub fn XQueryBestTile (_6: *mut Display, _5: c_ulong, _4: c_uint, _3: c_uint, _2: *mut c_uint, _1: *mut c_uint) -> c_int;
  pub fn XQueryColor (_3: *mut Display, _2: c_ulong, _1: *mut XColor) -> c_int;
  pub fn XQueryColors (_4: *mut Display, _3: c_ulong, _2: *mut XColor, _1: c_int) -> c_int;
  pub fn XQueryExtension (_5: *mut Display, _4: *const c_char, _3: *mut c_int, _2: *mut c_int, _1: *mut c_int) -> c_int;
  pub fn XQueryFont (_2: *mut Display, _1: c_ulong) -> *mut XFontStruct;
  pub fn XQueryKeymap (_2: *mut Display, _1: *mut c_char) -> c_int;
  pub fn XQueryPointer (_9: *mut Display, _8: c_ulong, _7: *mut c_ulong, _6: *mut c_ulong, _5: *mut c_int, _4: *mut c_int, _3: *mut c_int, _2: *mut c_int, _1: *mut c_uint) -> c_int;
  pub fn XQueryTextExtents (_8: *mut Display, _7: c_ulong, _6: *const c_char, _5: c_int, _4: *mut c_int, _3: *mut c_int, _2: *mut c_int, _1: *mut XCharStruct) -> c_int;
  pub fn XQueryTextExtents16 (_8: *mut Display, _7: c_ulong, _6: *const XChar2b, _5: c_int, _4: *mut c_int, _3: *mut c_int, _2: *mut c_int, _1: *mut XCharStruct) -> c_int;
  pub fn XQueryTree (_6: *mut Display, _5: c_ulong, _4: *mut c_ulong, _3: *mut c_ulong, _2: *mut *mut c_ulong, _1: *mut c_uint) -> c_int;
  pub fn XRaiseWindow (_2: *mut Display, _1: c_ulong) -> c_int;
  pub fn XReadBitmapFile (_8: *mut Display, _7: c_ulong, _6: *const c_char, _5: *mut c_uint, _4: *mut c_uint, _3: *mut c_ulong, _2: *mut c_int, _1: *mut c_int) -> c_int;
  pub fn XReadBitmapFileData (_6: *const c_char, _5: *mut c_uint, _4: *mut c_uint, _3: *mut *mut c_uchar, _2: *mut c_int, _1: *mut c_int) -> c_int;
  pub fn XRebindKeysym (_6: *mut Display, _5: c_ulong, _4: *mut c_ulong, _3: c_int, _2: *const c_uchar, _1: c_int) -> c_int;
  pub fn XRecolorCursor (_4: *mut Display, _3: c_ulong, _2: *mut XColor, _1: *mut XColor) -> c_int;
  pub fn XReconfigureWMWindow (_5: *mut Display, _4: c_ulong, _3: c_int, _2: c_uint, _1: *mut XWindowChanges) -> c_int;
  pub fn XRectInRegion (_5: Region, _4: c_int, _3: c_int, _2: c_uint, _1: c_uint) -> c_int;
  pub fn XRefreshKeyboardMapping (_1: *mut XMappingEvent) -> c_int;
  pub fn XRegisterIMInstantiateCallback (_6: *mut Display, _5: XrmDatabase, _4: *mut c_char, _3: *mut c_char, _2: Option<unsafe extern "C" fn (*mut Display, *mut c_char, *mut c_char)>, _1: *mut c_char) -> c_int;
  pub fn XRemoveConnectionWatch (_3: *mut Display, _2: Option<unsafe extern "C" fn (*mut Display, *mut c_char, c_int, c_int, *mut *mut c_char)>, _1: *mut c_char);
  pub fn XRemoveFromSaveSet (_2: *mut Display, _1: c_ulong) -> c_int;
  pub fn XRemoveHost (_2: *mut Display, _1: *mut XHostAddress) -> c_int;
  pub fn XRemoveHosts (_3: *mut Display, _2: *mut XHostAddress, _1: c_int) -> c_int;
  pub fn XReparentWindow (_5: *mut Display, _4: c_ulong, _3: c_ulong, _2: c_int, _1: c_int) -> c_int;
  pub fn XResetScreenSaver (_1: *mut Display) -> c_int;
  pub fn XResizeWindow (_4: *mut Display, _3: c_ulong, _2: c_uint, _1: c_uint) -> c_int;
  pub fn XResourceManagerString (_1: *mut Display) -> *mut c_char;
  pub fn XRestackWindows (_3: *mut Display, _2: *mut c_ulong, _1: c_int) -> c_int;
  pub fn XrmCombineDatabase (_3: XrmDatabase, _2: *mut XrmDatabase, _1: c_int);
  pub fn XrmCombineFileDatabase (_3: *const c_char, _2: *mut XrmDatabase, _1: c_int) -> c_int;
  pub fn XrmDestroyDatabase (_1: XrmDatabase);
  pub fn XrmEnumerateDatabase (_6: XrmDatabase, _5: *mut c_int, _4: *mut c_int, _3: c_int, _2: Option<unsafe extern "C" fn (*mut XrmDatabase, *mut XrmBinding, *mut c_int, *mut c_int, *mut XrmValue, *mut c_char) -> c_int>, _1: *mut c_char) -> c_int;
  pub fn XrmGetDatabase (_1: *mut Display) -> XrmDatabase;
  pub fn XrmGetFileDatabase (_1: *const c_char) -> XrmDatabase;
  pub fn XrmGetResource (_5: XrmDatabase, _4: *const c_char, _3: *const c_char, _2: *mut *mut c_char, _1: *mut XrmValue) -> c_int;
  pub fn XrmGetStringDatabase (_1: *const c_char) -> XrmDatabase;
  pub fn XrmInitialize ();
  pub fn XrmLocaleOfDatabase (_1: XrmDatabase) -> *const c_char;
  pub fn XrmMergeDatabases (_2: XrmDatabase, _1: *mut XrmDatabase);
  pub fn XrmParseCommand (_6: *mut XrmDatabase, _5: XrmOptionDescList, _4: c_int, _3: *const c_char, _2: *mut c_int, _1: *mut *mut c_char);
  pub fn XrmPermStringToQuark (_1: *const c_char) -> c_int;
  pub fn XrmPutFileDatabase (_2: XrmDatabase, _1: *const c_char);
  pub fn XrmPutLineResource (_2: *mut XrmDatabase, _1: *const c_char);
  pub fn XrmPutResource (_4: *mut XrmDatabase, _3: *const c_char, _2: *const c_char, _1: *mut XrmValue);
  pub fn XrmPutStringResource (_3: *mut XrmDatabase, _2: *const c_char, _1: *const c_char);
  pub fn XrmQGetResource (_5: XrmDatabase, _4: *mut c_int, _3: *mut c_int, _2: *mut c_int, _1: *mut XrmValue) -> c_int;
  pub fn XrmQGetSearchList (_5: XrmDatabase, _4: *mut c_int, _3: *mut c_int, _2: *mut *mut XrmDatabase, _1: c_int) -> c_int;
  pub fn XrmQGetSearchResource (_5: *mut *mut XrmDatabase, _4: c_int, _3: c_int, _2: *mut c_int, _1: *mut XrmValue) -> c_int;
  pub fn XrmQPutResource (_5: *mut XrmDatabase, _4: *mut XrmBinding, _3: *mut c_int, _2: c_int, _1: *mut XrmValue);
  pub fn XrmQPutStringResource (_4: *mut XrmDatabase, _3: *mut XrmBinding, _2: *mut c_int, _1: *const c_char);
  pub fn XrmQuarkToString (_1: c_int) -> *mut c_char;
  pub fn XrmSetDatabase (_2: *mut Display, _1: XrmDatabase);
  pub fn XrmStringToBindingQuarkList (_3: *const c_char, _2: *mut XrmBinding, _1: *mut c_int);
  pub fn XrmStringToQuark (_1: *const c_char) -> c_int;
  pub fn XrmStringToQuarkList (_2: *const c_char, _1: *mut c_int);
  pub fn XrmUniqueQuark () -> c_int;
  pub fn XRootWindow (_2: *mut Display, _1: c_int) -> c_ulong;
  pub fn XRootWindowOfScreen (_1: *mut Screen) -> c_ulong;
  pub fn XRotateBuffers (_2: *mut Display, _1: c_int) -> c_int;
  pub fn XRotateWindowProperties (_5: *mut Display, _4: c_ulong, _3: *mut c_ulong, _2: c_int, _1: c_int) -> c_int;
  pub fn XSaveContext (_4: *mut Display, _3: c_ulong, _2: c_int, _1: *const c_char) -> c_int;
  pub fn XScreenCount (_1: *mut Display) -> c_int;
  pub fn XScreenNumberOfScreen (_1: *mut Screen) -> c_int;
  pub fn XScreenOfDisplay (_2: *mut Display, _1: c_int) -> *mut Screen;
  pub fn XScreenResourceString (_1: *mut Screen) -> *mut c_char;
  pub fn XSelectInput (_3: *mut Display, _2: c_ulong, _1: c_long) -> c_int;
  pub fn XSendEvent (_5: *mut Display, _4: c_ulong, _3: c_int, _2: c_long, _1: *mut XEvent) -> c_int;
  pub fn XServerVendor (_1: *mut Display) -> *mut c_char;
  pub fn XSetAccessControl (_2: *mut Display, _1: c_int) -> c_int;
  pub fn XSetAfterFunction (_2: *mut Display, _1: Option<unsafe extern "C" fn (*mut Display) -> c_int>) -> Option<unsafe extern "C" fn (*mut Display) -> c_int>;
  pub fn XSetArcMode (_3: *mut Display, _2: GC, _1: c_int) -> c_int;
  pub fn XSetAuthorization (_4: *mut c_char, _3: c_int, _2: *mut c_char, _1: c_int);
  pub fn XSetBackground (_3: *mut Display, _2: GC, _1: c_ulong) -> c_int;
  pub fn XSetClassHint (_3: *mut Display, _2: c_ulong, _1: *mut XClassHint) -> c_int;
  pub fn XSetClipMask (_3: *mut Display, _2: GC, _1: c_ulong) -> c_int;
  pub fn XSetClipOrigin (_4: *mut Display, _3: GC, _2: c_int, _1: c_int) -> c_int;
  pub fn XSetClipRectangles (_7: *mut Display, _6: GC, _5: c_int, _4: c_int, _3: *mut XRectangle, _2: c_int, _1: c_int) -> c_int;
  pub fn XSetCloseDownMode (_2: *mut Display, _1: c_int) -> c_int;
  pub fn XSetCommand (_4: *mut Display, _3: c_ulong, _2: *mut *mut c_char, _1: c_int) -> c_int;
  pub fn XSetDashes (_5: *mut Display, _4: GC, _3: c_int, _2: *const c_char, _1: c_int) -> c_int;
  pub fn XSetErrorHandler (_1: Option<unsafe extern "C" fn (*mut Display, *mut XErrorEvent) -> c_int>) -> Option<unsafe extern "C" fn (*mut Display, *mut XErrorEvent) -> c_int>;
  pub fn XSetFillRule (_3: *mut Display, _2: GC, _1: c_int) -> c_int;
  pub fn XSetFillStyle (_3: *mut Display, _2: GC, _1: c_int) -> c_int;
  pub fn XSetFont (_3: *mut Display, _2: GC, _1: c_ulong) -> c_int;
  pub fn XSetFontPath (_3: *mut Display, _2: *mut *mut c_char, _1: c_int) -> c_int;
  pub fn XSetForeground (_3: *mut Display, _2: GC, _1: c_ulong) -> c_int;
  pub fn XSetFunction (_3: *mut Display, _2: GC, _1: c_int) -> c_int;
  pub fn XSetGraphicsExposures (_3: *mut Display, _2: GC, _1: c_int) -> c_int;
  pub fn XSetICFocus (_1: XIC);
  pub fn XSetIconName (_3: *mut Display, _2: c_ulong, _1: *const c_char) -> c_int;
  pub fn XSetIconSizes (_4: *mut Display, _3: c_ulong, _2: *mut XIconSize, _1: c_int) -> c_int;
  pub fn XSetICValues (_1: XIC, ...) -> *mut c_char;
  pub fn XSetIMValues (_1: XIM, ...) -> *mut c_char;
  pub fn XSetInputFocus (_4: *mut Display, _3: c_ulong, _2: c_int, _1: c_ulong) -> c_int;
  pub fn XSetIOErrorHandler (_1: Option<unsafe extern "C" fn (*mut Display) -> c_int>) -> Option<unsafe extern "C" fn (*mut Display) -> c_int>;
  pub fn XSetLineAttributes (_6: *mut Display, _5: GC, _4: c_uint, _3: c_int, _2: c_int, _1: c_int) -> c_int;
  pub fn XSetLocaleModifiers (_1: *const c_char) -> *mut c_char;
  pub fn XSetModifierMapping (_2: *mut Display, _1: *mut XModifierKeymap) -> c_int;
  pub fn XSetNormalHints (_3: *mut Display, _2: c_ulong, _1: *mut XSizeHints) -> c_int;
  pub fn XSetOCValues (_1: XFontSet, ...) -> *mut c_char;
  pub fn XSetOMValues (_1: XOM, ...) -> *mut c_char;
  pub fn XSetPlaneMask (_3: *mut Display, _2: GC, _1: c_ulong) -> c_int;
  pub fn XSetPointerMapping (_3: *mut Display, _2: *const c_uchar, _1: c_int) -> c_int;
  pub fn XSetRegion (_3: *mut Display, _2: GC, _1: Region) -> c_int;
  pub fn XSetRGBColormaps (_5: *mut Display, _4: c_ulong, _3: *mut XStandardColormap, _2: c_int, _1: c_ulong);
  pub fn XSetScreenSaver (_5: *mut Display, _4: c_int, _3: c_int, _2: c_int, _1: c_int) -> c_int;
  pub fn XSetSelectionOwner (_4: *mut Display, _3: c_ulong, _2: c_ulong, _1: c_ulong) -> c_int;
  pub fn XSetSizeHints (_4: *mut Display, _3: c_ulong, _2: *mut XSizeHints, _1: c_ulong) -> c_int;
  pub fn XSetStandardColormap (_4: *mut Display, _3: c_ulong, _2: *mut XStandardColormap, _1: c_ulong);
  pub fn XSetStandardProperties (_8: *mut Display, _7: c_ulong, _6: *const c_char, _5: *const c_char, _4: c_ulong, _3: *mut *mut c_char, _2: c_int, _1: *mut XSizeHints) -> c_int;
  pub fn XSetState (_6: *mut Display, _5: GC, _4: c_ulong, _3: c_ulong, _2: c_int, _1: c_ulong) -> c_int;
  pub fn XSetStipple (_3: *mut Display, _2: GC, _1: c_ulong) -> c_int;
  pub fn XSetSubwindowMode (_3: *mut Display, _2: GC, _1: c_int) -> c_int;
  pub fn XSetTextProperty (_4: *mut Display, _3: c_ulong, _2: *mut XTextProperty, _1: c_ulong);
  pub fn XSetTile (_3: *mut Display, _2: GC, _1: c_ulong) -> c_int;
  pub fn XSetTransientForHint (_3: *mut Display, _2: c_ulong, _1: c_ulong) -> c_int;
  pub fn XSetTSOrigin (_4: *mut Display, _3: GC, _2: c_int, _1: c_int) -> c_int;
  pub fn XSetWindowBackground (_3: *mut Display, _2: c_ulong, _1: c_ulong) -> c_int;
  pub fn XSetWindowBackgroundPixmap (_3: *mut Display, _2: c_ulong, _1: c_ulong) -> c_int;
  pub fn XSetWindowBorder (_3: *mut Display, _2: c_ulong, _1: c_ulong) -> c_int;
  pub fn XSetWindowBorderPixmap (_3: *mut Display, _2: c_ulong, _1: c_ulong) -> c_int;
  pub fn XSetWindowBorderWidth (_3: *mut Display, _2: c_ulong, _1: c_uint) -> c_int;
  pub fn XSetWindowColormap (_3: *mut Display, _2: c_ulong, _1: c_ulong) -> c_int;
  pub fn XSetWMClientMachine (_3: *mut Display, _2: c_ulong, _1: *mut XTextProperty);
  pub fn XSetWMColormapWindows (_4: *mut Display, _3: c_ulong, _2: *mut c_ulong, _1: c_int) -> c_int;
  pub fn XSetWMHints (_3: *mut Display, _2: c_ulong, _1: *mut XWMHints) -> c_int;
  pub fn XSetWMIconName (_3: *mut Display, _2: c_ulong, _1: *mut XTextProperty);
  pub fn XSetWMName (_3: *mut Display, _2: c_ulong, _1: *mut XTextProperty);
  pub fn XSetWMNormalHints (_3: *mut Display, _2: c_ulong, _1: *mut XSizeHints);
  pub fn XSetWMProperties (_9: *mut Display, _8: c_ulong, _7: *mut XTextProperty, _6: *mut XTextProperty, _5: *mut *mut c_char, _4: c_int, _3: *mut XSizeHints, _2: *mut XWMHints, _1: *mut XClassHint);
  pub fn XSetWMProtocols (_4: *mut Display, _3: c_ulong, _2: *mut c_ulong, _1: c_int) -> c_int;
  pub fn XSetWMSizeHints (_4: *mut Display, _3: c_ulong, _2: *mut XSizeHints, _1: c_ulong);
  pub fn XSetZoomHints (_3: *mut Display, _2: c_ulong, _1: *mut XSizeHints) -> c_int;
  pub fn XShrinkRegion (_3: Region, _2: c_int, _1: c_int) -> c_int;
  pub fn XStoreBuffer (_4: *mut Display, _3: *const c_char, _2: c_int, _1: c_int) -> c_int;
  pub fn XStoreBytes (_3: *mut Display, _2: *const c_char, _1: c_int) -> c_int;
  pub fn XStoreColor (_3: *mut Display, _2: c_ulong, _1: *mut XColor) -> c_int;
  pub fn XStoreColors (_4: *mut Display, _3: c_ulong, _2: *mut XColor, _1: c_int) -> c_int;
  pub fn XStoreName (_3: *mut Display, _2: c_ulong, _1: *const c_char) -> c_int;
  pub fn XStoreNamedColor (_5: *mut Display, _4: c_ulong, _3: *const c_char, _2: c_ulong, _1: c_int) -> c_int;
  pub fn XStringListToTextProperty (_3: *mut *mut c_char, _2: c_int, _1: *mut XTextProperty) -> c_int;
  pub fn XStringToKeysym (_1: *const c_char) -> c_ulong;
  pub fn XSubImage (_5: *mut XImage, _4: c_int, _3: c_int, _2: c_uint, _1: c_uint) -> *mut XImage;
  pub fn XSubtractRegion (_3: Region, _2: Region, _1: Region) -> c_int;
  pub fn XSupportsLocale () -> c_int;
  pub fn XSync (_2: *mut Display, _1: c_int) -> c_int;
  pub fn XSynchronize (_2: *mut Display, _1: c_int) -> Option<unsafe extern "C" fn (*mut Display) -> c_int>;
  pub fn XTextExtents (_7: *mut XFontStruct, _6: *const c_char, _5: c_int, _4: *mut c_int, _3: *mut c_int, _2: *mut c_int, _1: *mut XCharStruct) -> c_int;
  pub fn XTextExtents16 (_7: *mut XFontStruct, _6: *const XChar2b, _5: c_int, _4: *mut c_int, _3: *mut c_int, _2: *mut c_int, _1: *mut XCharStruct) -> c_int;
  pub fn XTextPropertyToStringList (_3: *mut XTextProperty, _2: *mut *mut *mut c_char, _1: *mut c_int) -> c_int;
  pub fn XTextWidth (_3: *mut XFontStruct, _2: *const c_char, _1: c_int) -> c_int;
  pub fn XTextWidth16 (_3: *mut XFontStruct, _2: *const XChar2b, _1: c_int) -> c_int;
  pub fn XTranslateCoordinates (_8: *mut Display, _7: c_ulong, _6: c_ulong, _5: c_int, _4: c_int, _3: *mut c_int, _2: *mut c_int, _1: *mut c_ulong) -> c_int;
  pub fn XUndefineCursor (_2: *mut Display, _1: c_ulong) -> c_int;
  pub fn XUngrabButton (_4: *mut Display, _3: c_uint, _2: c_uint, _1: c_ulong) -> c_int;
  pub fn XUngrabKey (_4: *mut Display, _3: c_int, _2: c_uint, _1: c_ulong) -> c_int;
  pub fn XUngrabKeyboard (_2: *mut Display, _1: c_ulong) -> c_int;
  pub fn XUngrabPointer (_2: *mut Display, _1: c_ulong) -> c_int;
  pub fn XUngrabServer (_1: *mut Display) -> c_int;
  pub fn XUninstallColormap (_2: *mut Display, _1: c_ulong) -> c_int;
  pub fn XUnionRectWithRegion (_3: *mut XRectangle, _2: Region, _1: Region) -> c_int;
  pub fn XUnionRegion (_3: Region, _2: Region, _1: Region) -> c_int;
  pub fn XUnloadFont (_2: *mut Display, _1: c_ulong) -> c_int;
  pub fn XUnlockDisplay (_1: *mut Display);
  pub fn XUnmapSubwindows (_2: *mut Display, _1: c_ulong) -> c_int;
  pub fn XUnmapWindow (_2: *mut Display, _1: c_ulong) -> c_int;
  pub fn XUnregisterIMInstantiateCallback (_6: *mut Display, _5: XrmDatabase, _4: *mut c_char, _3: *mut c_char, _2: Option<unsafe extern "C" fn (*mut Display, *mut c_char, *mut c_char)>, _1: *mut c_char) -> c_int;
  pub fn XUnsetICFocus (_1: XIC);
  pub fn Xutf8DrawImageString (_8: *mut Display, _7: c_ulong, _6: XFontSet, _5: GC, _4: c_int, _3: c_int, _2: *const c_char, _1: c_int);
  pub fn Xutf8DrawString (_8: *mut Display, _7: c_ulong, _6: XFontSet, _5: GC, _4: c_int, _3: c_int, _2: *const c_char, _1: c_int);
  pub fn Xutf8DrawText (_7: *mut Display, _6: c_ulong, _5: GC, _4: c_int, _3: c_int, _2: *mut XmbTextItem, _1: c_int);
  pub fn Xutf8LookupString (_6: XIC, _5: *mut XKeyEvent, _4: *mut c_char, _3: c_int, _2: *mut c_ulong, _1: *mut c_int) -> c_int;
  pub fn Xutf8ResetIC (_1: XIC) -> *mut c_char;
  pub fn Xutf8SetWMProperties (_9: *mut Display, _8: c_ulong, _7: *const c_char, _6: *const c_char, _5: *mut *mut c_char, _4: c_int, _3: *mut XSizeHints, _2: *mut XWMHints, _1: *mut XClassHint);
  pub fn Xutf8TextEscapement (_3: XFontSet, _2: *const c_char, _1: c_int) -> c_int;
  pub fn Xutf8TextExtents (_5: XFontSet, _4: *const c_char, _3: c_int, _2: *mut XRectangle, _1: *mut XRectangle) -> c_int;
  pub fn Xutf8TextListToTextProperty (_5: *mut Display, _4: *mut *mut c_char, _3: c_int, _2: XICCEncodingStyle, _1: *mut XTextProperty) -> c_int;
  pub fn Xutf8TextPerCharExtents (_9: XFontSet, _8: *const c_char, _7: c_int, _6: *mut XRectangle, _5: *mut XRectangle, _4: c_int, _3: *mut c_int, _2: *mut XRectangle, _1: *mut XRectangle) -> c_int;
  pub fn Xutf8TextPropertyToTextList (_4: *mut Display, _3: *const XTextProperty, _2: *mut *mut *mut c_char, _1: *mut c_int) -> c_int;
  pub fn XVaCreateNestedList (_1: c_int, ...) -> *mut c_void;
  pub fn XVendorRelease (_1: *mut Display) -> c_int;
  pub fn XVisualIDFromVisual (_1: *mut Visual) -> c_ulong;
  pub fn XWarpPointer (_9: *mut Display, _8: c_ulong, _7: c_ulong, _6: c_int, _5: c_int, _4: c_uint, _3: c_uint, _2: c_int, _1: c_int) -> c_int;
  pub fn XwcDrawImageString (_8: *mut Display, _7: c_ulong, _6: XFontSet, _5: GC, _4: c_int, _3: c_int, _2: *const wchar_t, _1: c_int);
  pub fn XwcDrawString (_8: *mut Display, _7: c_ulong, _6: XFontSet, _5: GC, _4: c_int, _3: c_int, _2: *const wchar_t, _1: c_int);
  pub fn XwcDrawText (_7: *mut Display, _6: c_ulong, _5: GC, _4: c_int, _3: c_int, _2: *mut XwcTextItem, _1: c_int);
  pub fn XwcFreeStringList (_1: *mut *mut wchar_t);
  pub fn XwcLookupString (_6: XIC, _5: *mut XKeyEvent, _4: *mut wchar_t, _3: c_int, _2: *mut c_ulong, _1: *mut c_int) -> c_int;
  pub fn XwcResetIC (_1: XIC) -> *mut wchar_t;
  pub fn XwcTextEscapement (_3: XFontSet, _2: *const wchar_t, _1: c_int) -> c_int;
  pub fn XwcTextExtents (_5: XFontSet, _4: *const wchar_t, _3: c_int, _2: *mut XRectangle, _1: *mut XRectangle) -> c_int;
  pub fn XwcTextListToTextProperty (_5: *mut Display, _4: *mut *mut wchar_t, _3: c_int, _2: XICCEncodingStyle, _1: *mut XTextProperty) -> c_int;
  pub fn XwcTextPerCharExtents (_9: XFontSet, _8: *const wchar_t, _7: c_int, _6: *mut XRectangle, _5: *mut XRectangle, _4: c_int, _3: *mut c_int, _2: *mut XRectangle, _1: *mut XRectangle) -> c_int;
  pub fn XwcTextPropertyToTextList (_4: *mut Display, _3: *const XTextProperty, _2: *mut *mut *mut wchar_t, _1: *mut c_int) -> c_int;
  pub fn XWhitePixel (_2: *mut Display, _1: c_int) -> c_ulong;
  pub fn XWhitePixelOfScreen (_1: *mut Screen) -> c_ulong;
  pub fn XWidthMMOfScreen (_1: *mut Screen) -> c_int;
  pub fn XWidthOfScreen (_1: *mut Screen) -> c_int;
  pub fn XWindowEvent (_4: *mut Display, _3: c_ulong, _2: c_long, _1: *mut XEvent) -> c_int;
  pub fn XWithdrawWindow (_3: *mut Display, _2: c_ulong, _1: c_int) -> c_int;
  pub fn XWMGeometry (_11: *mut Display, _10: c_int, _9: *const c_char, _8: *const c_char, _7: c_uint, _6: *mut XSizeHints, _5: *mut c_int, _4: *mut c_int, _3: *mut c_int, _2: *mut c_int, _1: *mut c_int) -> c_int;
  pub fn XWriteBitmapFile (_7: *mut Display, _6: *const c_char, _5: c_ulong, _4: c_uint, _3: c_uint, _2: c_int, _1: c_int) -> c_int;
  pub fn XXorRegion (_3: Region, _2: Region, _1: Region) -> c_int;
}


//
// types
//


// common types
pub type Atom = XID;
pub type Bool = c_int;
pub type Colormap = XID;
pub type Cursor = XID;
pub type Drawable = XID;
pub type Font = XID;
pub type KeyCode = c_uchar;
pub type KeySym = XID;
pub type Mask = c_ulong;
pub type Pixmap = XID;
pub type Status = Bool;
pub type Time = c_ulong;
pub type VisualID = XID;
pub type Window = XID;
pub type XID = c_ulong;
pub type XPointer = *mut c_void;

// opaque structures
#[repr(C)] pub struct Screen;
#[repr(C)] pub struct Visual;
#[repr(C)] pub struct _XDisplay;
#[repr(C)] pub struct xError;
#[repr(C)] pub struct xEvent;
#[repr(C)] pub struct _XGC;
#[repr(C)] pub struct _XIC;
#[repr(C)] pub struct _XIM;
#[repr(C)] pub struct _XRegion;
#[repr(C)] pub struct _XOC;
#[repr(C)] pub struct _XOM;
#[repr(C)] pub struct _XrmHashBucketRec;

// placeholder structures
#[repr(C)] pub struct _XEDataObjectRec;

// opaque types
pub type Display = _XDisplay;
pub type GC = *mut _XGC;
pub type Region = *mut _XRegion;
pub type XEDataObject = *mut _XEDataObjectRec;
pub type XFontSet = *mut _XOC;
pub type XIC = *mut _XIC;
pub type XIM = *mut _XIM;
pub type XOM = *mut _XOM;
pub type XrmDatabase = *mut _XrmHashBucketRec;
pub type XrmOptionDescList = *mut XrmOptionDescRec;

// function pointers
pub type XConnectionWatchProc = Option<unsafe extern "C" fn (*mut Display, XPointer, c_int, Bool, XPointer)>;


//
// enums
//


#[derive(Clone, Copy, PartialEq)]
#[repr(C)]
pub enum XICCEncodingStyle {
  XStringStyle,
  XCompoundTextStyle,
  XTextStyle,
  XStdICCTextStyle,
  XUTF8StringStyle,
}

#[derive(Clone, Copy, PartialEq)]
#[repr(C)]
pub enum XrmBinding {
  XrmBindTightly,
  XrmBindLoosely,
}

#[derive(Clone, Copy, PartialEq)]
#[repr(C)]
pub enum XrmOptionKind {
  XrmoptionNoArg,
  XrmoptionIsArg,
  XrmoptionStickyArg,
  XrmoptionSepArg,
  XrmoptionResArg,
  XrmoptionSkipArg,
  XrmoptionSkipLine,
  XrmoptionSkipNArgs,
}


//
// event structures
//


#[derive(Clone, Copy, PartialEq)]
#[repr(C)]
pub struct XEvent {
  pub pad: [c_long; 24],
}

impl XEvent {
  pub fn get_type (&self) -> c_int {
    unsafe {
      *(self as *const XEvent as *const c_int)
    }
  }
}

impl From<XAnyEvent> for XEvent {
  fn from (e: XAnyEvent) -> XEvent {
    unsafe { transmute_union(&e) }
  }
}

impl From<XButtonEvent> for XEvent {
  fn from (e: XButtonEvent) -> XEvent {
    unsafe { transmute_union(&e) }
  }
}

impl From<XCirculateEvent> for XEvent {
  fn from (e: XCirculateEvent) -> XEvent {
    unsafe { transmute_union(&e) }
  }
}

impl From<XCirculateRequestEvent> for XEvent {
  fn from (e: XCirculateRequestEvent) -> XEvent {
    unsafe { transmute_union(&e) }
  }
}

impl From<XClientMessageEvent> for XEvent {
  fn from (e: XClientMessageEvent) -> XEvent {
    unsafe { transmute_union(&e) }
  }
}

impl From<XColormapEvent> for XEvent {
  fn from (e: XColormapEvent) -> XEvent {
    unsafe { transmute_union(&e) }
  }
}

impl From<XConfigureEvent> for XEvent {
  fn from (e: XConfigureEvent) -> XEvent {
    unsafe { transmute_union(&e) }
  }
}

impl From<XConfigureRequestEvent> for XEvent {
  fn from (e: XConfigureRequestEvent) -> XEvent {
    unsafe { transmute_union(&e) }
  }
}

impl From<XCreateWindowEvent> for XEvent {
  fn from (e: XCreateWindowEvent) -> XEvent {
    unsafe { transmute_union(&e) }
  }
}

impl From<XCrossingEvent> for XEvent {
  fn from (e: XCrossingEvent) -> XEvent {
    unsafe { transmute_union(&e) }
  }
}

impl From<XDestroyWindowEvent> for XEvent {
  fn from (e: XDestroyWindowEvent) -> XEvent {
    unsafe { transmute_union(&e) }
  }
}

impl From<XErrorEvent> for XEvent {
  fn from (e: XErrorEvent) -> XEvent {
    unsafe { transmute_union(&e) }
  }
}

impl From<XExposeEvent> for XEvent {
  fn from (e: XExposeEvent) -> XEvent {
    unsafe { transmute_union(&e) }
  }
}

impl From<XFocusChangeEvent> for XEvent {
  fn from (e: XFocusChangeEvent) -> XEvent {
    unsafe { transmute_union(&e) }
  }
}

impl From<XGraphicsExposeEvent> for XEvent {
  fn from (e: XGraphicsExposeEvent) -> XEvent {
    unsafe { transmute_union(&e) }
  }
}

impl From<XGravityEvent> for XEvent {
  fn from (e: XGravityEvent) -> XEvent {
    unsafe { transmute_union(&e) }
  }
}

impl From<XKeyEvent> for XEvent {
  fn from (e: XKeyEvent) -> XEvent {
    unsafe { transmute_union(&e) }
  }
}

impl From<XKeymapEvent> for XEvent {
  fn from (e: XKeymapEvent) -> XEvent {
    unsafe { transmute_union(&e) }
  }
}

impl From<XMapEvent> for XEvent {
  fn from (e: XMapEvent) -> XEvent {
    unsafe { transmute_union(&e) }
  }
}

impl From<XMappingEvent> for XEvent {
  fn from (e: XMappingEvent) -> XEvent {
    unsafe { transmute_union(&e) }
  }
}

impl From<XMotionEvent> for XEvent {
  fn from (e: XMotionEvent) -> XEvent {
    unsafe { transmute_union(&e) }
  }
}

impl From<XNoExposeEvent> for XEvent {
  fn from (e: XNoExposeEvent) -> XEvent {
    unsafe { transmute_union(&e) }
  }
}

impl From<XPropertyEvent> for XEvent {
  fn from (e: XPropertyEvent) -> XEvent {
    unsafe { transmute_union(&e) }
  }
}

impl From<XReparentEvent> for XEvent {
  fn from (e: XReparentEvent) -> XEvent {
    unsafe { transmute_union(&e) }
  }
}

impl From<XResizeRequestEvent> for XEvent {
  fn from (e: XResizeRequestEvent) -> XEvent {
    unsafe { transmute_union(&e) }
  }
}

impl From<XSelectionClearEvent> for XEvent {
  fn from (e: XSelectionClearEvent) -> XEvent {
    unsafe { transmute_union(&e) }
  }
}

impl From<XSelectionEvent> for XEvent {
  fn from (e: XSelectionEvent) -> XEvent {
    unsafe { transmute_union(&e) }
  }
}

impl From<XSelectionRequestEvent> for XEvent {
  fn from (e: XSelectionRequestEvent) -> XEvent {
    unsafe { transmute_union(&e) }
  }
}

impl From<XUnmapEvent> for XEvent {
  fn from (e: XUnmapEvent) -> XEvent {
    unsafe { transmute_union(&e) }
  }
}

impl From<XVisibilityEvent> for XEvent {
  fn from (e: XVisibilityEvent) -> XEvent {
    unsafe { transmute_union(&e) }
  }
}

#[test]
fn xevent_size_test () {
  assert!(size_of::<XEvent>() >= size_of::<XAnyEvent>());
  assert!(size_of::<XEvent>() >= size_of::<XButtonEvent>());
  assert!(size_of::<XEvent>() >= size_of::<XCirculateEvent>());
  assert!(size_of::<XEvent>() >= size_of::<XCirculateRequestEvent>());
  assert!(size_of::<XEvent>() >= size_of::<XClientMessageEvent>());
  assert!(size_of::<XEvent>() >= size_of::<XColormapEvent>());
  assert!(size_of::<XEvent>() >= size_of::<XConfigureEvent>());
  assert!(size_of::<XEvent>() >= size_of::<XConfigureRequestEvent>());
  assert!(size_of::<XEvent>() >= size_of::<XCreateWindowEvent>());
  assert!(size_of::<XEvent>() >= size_of::<XCrossingEvent>());
  assert!(size_of::<XEvent>() >= size_of::<XDestroyWindowEvent>());
  assert!(size_of::<XEvent>() >= size_of::<XErrorEvent>());
  assert!(size_of::<XEvent>() >= size_of::<XExposeEvent>());
  assert!(size_of::<XEvent>() >= size_of::<XFocusChangeEvent>());
  assert!(size_of::<XEvent>() >= size_of::<XGraphicsExposeEvent>());
  assert!(size_of::<XEvent>() >= size_of::<XGravityEvent>());
  assert!(size_of::<XEvent>() >= size_of::<XKeyEvent>());
  assert!(size_of::<XEvent>() >= size_of::<XKeymapEvent>());
  assert!(size_of::<XEvent>() >= size_of::<XMapEvent>());
  assert!(size_of::<XEvent>() >= size_of::<XMappingEvent>());
  assert!(size_of::<XEvent>() >= size_of::<XMapRequestEvent>());
  assert!(size_of::<XEvent>() >= size_of::<XMotionEvent>());
  assert!(size_of::<XEvent>() >= size_of::<XNoExposeEvent>());
  assert!(size_of::<XEvent>() >= size_of::<XPropertyEvent>());
  assert!(size_of::<XEvent>() >= size_of::<XReparentEvent>());
  assert!(size_of::<XEvent>() >= size_of::<XResizeRequestEvent>());
  assert!(size_of::<XEvent>() >= size_of::<XSelectionClearEvent>());
  assert!(size_of::<XEvent>() >= size_of::<XSelectionEvent>());
  assert!(size_of::<XEvent>() >= size_of::<XSelectionRequestEvent>());
  assert!(size_of::<XEvent>() >= size_of::<XUnmapEvent>());
  assert!(size_of::<XEvent>() >= size_of::<XVisibilityEvent>());
}

#[allow(raw_pointer_derive)]
#[derive(Clone, Copy, PartialEq)]
#[repr(C)]
pub struct XAnyEvent {
  pub type_: c_int,
  pub serial: c_ulong,
  pub send_event: Bool,
  pub display: *mut Display,
  pub window: Window,
}

impl From<XEvent> for XAnyEvent {
  fn from (e: XEvent) -> XAnyEvent {
    unsafe { transmute_union(&e) }
  }
}

#[allow(raw_pointer_derive)]
#[derive(Clone, Copy, PartialEq)]
#[repr(C)]
pub struct XButtonEvent {
  pub type_: c_int,
  pub serial: c_ulong,
  pub send_event: Bool,
  pub display: *mut Display,
  pub window: Window,
  pub root: Window,
  pub subwindow: Window,
  pub time: Time,
  pub x: c_int,
  pub y: c_int,
  pub x_root: c_int,
  pub y_root: c_int,
  pub state: c_uint,
  pub button: c_uint,
  pub same_screen: Bool,
}
pub type XButtonPressedEvent = XButtonEvent;
pub type XButtonReleasedEvent = XButtonEvent;

impl From<XEvent> for XButtonEvent {
  fn from (e: XEvent) -> XButtonEvent {
    unsafe { transmute_union(&e) }
  }
}

#[allow(raw_pointer_derive)]
#[derive(Clone, Copy, PartialEq)]
#[repr(C)]
pub struct XCirculateEvent {
  pub type_: c_int,
  pub serial: c_ulong,
  pub send_event: Bool,
  pub display: *mut Display,
  pub event: Window,
  pub window: Window,
  pub place: c_int,
}

impl From<XEvent> for XCirculateEvent {
  fn from (e: XEvent) -> XCirculateEvent {
    unsafe { transmute_union(&e) }
  }
}

#[allow(raw_pointer_derive)]
#[derive(Clone, Copy, PartialEq)]
#[repr(C)]
pub struct XCirculateRequestEvent {
  pub type_: c_int,
  pub serial: c_ulong,
  pub send_event: Bool,
  pub display: *mut Display,
  pub parent: Window,
  pub window: Window,
  pub place: c_int,
}

impl From<XEvent> for XCirculateRequestEvent {
  fn from (e: XEvent) -> XCirculateRequestEvent {
    unsafe { transmute_union(&e) }
  }
}

#[allow(raw_pointer_derive)]
#[derive(Clone, Copy, PartialEq)]
#[repr(C)]
pub struct XClientMessageEvent {
  pub type_: c_int,
  pub serial: c_ulong,
  pub send_event: Bool,
  pub display: *mut Display,
  pub window: Window,
  pub message_type: Atom,
  pub format: c_int,
  pub data: ClientMessageData,
}

impl From<XEvent> for XClientMessageEvent {
  fn from (e: XEvent) -> XClientMessageEvent {
    unsafe { transmute_union(&e) }
  }
}

#[allow(raw_pointer_derive)]
#[derive(Clone, Copy, PartialEq)]
#[repr(C)]
pub struct XColormapEvent {
  pub type_: c_int,
  pub serial: c_ulong,
  pub send_event: Bool,
  pub display: *mut Display,
  pub window: Window,
  pub colormap: Colormap,
  pub new: Bool,
  pub state: c_int,
}

impl From<XEvent> for XColormapEvent {
  fn from (e: XEvent) -> XColormapEvent {
    unsafe { transmute_union(&e) }
  }
}

#[allow(raw_pointer_derive)]
#[derive(Clone, Copy, PartialEq)]
#[repr(C)]
pub struct XConfigureEvent {
  pub type_: c_int,
  pub serial: c_ulong,
  pub send_event: Bool,
  pub display: *mut Display,
  pub event: Window,
  pub window: Window,
  pub x: c_int,
  pub y: c_int,
  pub width: c_int,
  pub height: c_int,
  pub border_width: c_int,
  pub above: Window,
  pub override_redirect: Bool,
}

impl From<XEvent> for XConfigureEvent {
  fn from (e: XEvent) -> XConfigureEvent {
    unsafe { transmute_union(&e) }
  }
}

#[allow(raw_pointer_derive)]
#[derive(Clone, Copy, PartialEq)]
#[repr(C)]
pub struct XConfigureRequestEvent {
  pub type_: c_int,
  pub serial: c_ulong,
  pub send_event: Bool,
  pub display: *mut Display,
  pub parent: Window,
  pub window: Window,
  pub x: c_int,
  pub y: c_int,
  pub width: c_int,
  pub height: c_int,
  pub border_width: c_int,
  pub above: Window,
  pub detail: c_int,
  pub value_mask: c_ulong,
}

impl From<XEvent> for XConfigureRequestEvent {
  fn from (e: XEvent) -> XConfigureRequestEvent {
    unsafe { transmute_union(&e) }
  }
}

#[allow(raw_pointer_derive)]
#[derive(Clone, Copy, PartialEq)]
#[repr(C)]
pub struct XCreateWindowEvent {
  pub type_: c_int,
  pub serial: c_ulong,
  pub send_event: Bool,
  pub display: *mut Display,
  pub parent: Window,
  pub window: Window,
  pub x: c_int,
  pub y: c_int,
  pub width: c_int,
  pub height: c_int,
  pub border_width: c_int,
  pub override_redirect: Bool,
}

impl From<XEvent> for XCreateWindowEvent {
  fn from (e: XEvent) -> XCreateWindowEvent {
    unsafe { transmute_union(&e) }
  }
}

#[allow(raw_pointer_derive)]
#[derive(Clone, Copy, PartialEq)]
#[repr(C)]
pub struct XCrossingEvent {
  pub type_: c_int,
  pub serial: c_ulong,
  pub send_event: Bool,
  pub display: *mut Display,
  pub window: Window,
  pub root: Window,
  pub subwindow: Window,
  pub time: Time,
  pub x: c_int,
  pub y: c_int,
  pub x_root: c_int,
  pub y_root: c_int,
  pub mode: c_int,
  pub detail: c_int,
  pub same_screen: Bool,
  pub focus: Bool,
  pub state: c_uint,
}
pub type XEnterWindowEvent = XCrossingEvent;
pub type XLeaveWindowEvent = XCrossingEvent;

impl From<XEvent> for XCrossingEvent {
  fn from (e: XEvent) -> XCrossingEvent {
    unsafe { transmute_union(&e) }
  }
}

#[allow(raw_pointer_derive)]
#[derive(Clone, Copy, PartialEq)]
#[repr(C)]
pub struct XDestroyWindowEvent {
  pub type_: c_int,
  pub serial: c_ulong,
  pub send_event: Bool,
  pub display: *mut Display,
  pub event: Window,
  pub window: Window,
}

impl From<XEvent> for XDestroyWindowEvent {
  fn from (e: XEvent) -> XDestroyWindowEvent {
    unsafe { transmute_union(&e) }
  }
}

#[allow(raw_pointer_derive)]
#[derive(Clone, Copy, PartialEq)]
#[repr(C)]
pub struct XErrorEvent {
  pub type_: c_int,
  pub display: *mut Display,
  pub serial: c_ulong,
  pub error_code: c_uchar,
  pub request_code: c_uchar,
  pub minor_code: c_uchar,
  pub resourceid: XID,
}

impl From<XEvent> for XErrorEvent {
  fn from (e: XEvent) -> XErrorEvent {
    unsafe { transmute_union(&e) }
  }
}

#[allow(raw_pointer_derive)]
#[derive(Clone, Copy, PartialEq)]
#[repr(C)]
pub struct XExposeEvent {
  pub type_: c_int,
  pub serial: c_ulong,
  pub send_event: Bool,
  pub display: *mut Display,
  pub window: Window,
  pub x: c_int,
  pub y: c_int,
  pub width: c_int,
  pub height: c_int,
  pub count: c_int,
}

impl From<XEvent> for XExposeEvent {
  fn from (e: XEvent) -> XExposeEvent {
    unsafe { transmute_union(&e) }
  }
}

#[allow(raw_pointer_derive)]
#[derive(Clone, Copy, PartialEq)]
#[repr(C)]
pub struct XFocusChangeEvent {
  pub type_: c_int,
  pub serial: c_ulong,
  pub send_event: Bool,
  pub display: *mut Display,
  pub window: Window,
  pub mode: c_int,
  pub detail: c_int,
}
pub type XFocusInEvent = XFocusChangeEvent;
pub type XFocusOutEvent = XFocusChangeEvent;

impl From<XEvent> for XFocusChangeEvent {
  fn from (e: XEvent) -> XFocusChangeEvent {
    unsafe { transmute_union(&e) }
  }
}

#[allow(raw_pointer_derive)]
#[derive(Clone, Copy, PartialEq)]
#[repr(C)]
pub struct XGraphicsExposeEvent {
  pub type_: c_int,
  pub serial: c_ulong,
  pub send_event: Bool,
  pub display: *mut Display,
  pub drawable: Drawable,
  pub x: c_int,
  pub y: c_int,
  pub width: c_int,
  pub height: c_int,
  pub count: c_int,
  pub major_code: c_int,
  pub minor_code: c_int,
}

impl From<XEvent> for XGraphicsExposeEvent {
  fn from (e: XEvent) -> XGraphicsExposeEvent {
    unsafe { transmute_union(&e) }
  }
}

#[allow(raw_pointer_derive)]
#[derive(Clone, Copy, PartialEq)]
#[repr(C)]
pub struct XGravityEvent {
  pub type_: c_int,
  pub serial: c_ulong,
  pub send_event: Bool,
  pub display: *mut Display,
  pub event: Window,
  pub window: Window,
  pub x: c_int,
  pub y: c_int,
}

impl From<XEvent> for XGravityEvent {
  fn from (e: XEvent) -> XGravityEvent {
    unsafe { transmute_union(&e) }
  }
}

#[allow(raw_pointer_derive)]
#[derive(Clone, Copy, PartialEq)]
#[repr(C)]
pub struct XKeyEvent {
  pub type_: c_int,
  pub serial: c_ulong,
  pub send_event: Bool,
  pub display: *mut Display,
  pub window: Window,
  pub root: Window,
  pub subwindow: Window,
  pub time: Time,
  pub x: c_int,
  pub y: c_int,
  pub x_root: c_int,
  pub y_root: c_int,
  pub state: c_uint,
  pub keycode: c_uint,
  pub same_screen: Bool,
}
pub type XKeyPressedEvent = XKeyEvent;
pub type XKeyReleasedEvent = XKeyEvent;

impl From<XEvent> for XKeyEvent {
  fn from (e: XEvent) -> XKeyEvent {
    unsafe { transmute_union(&e) }
  }
}

#[allow(raw_pointer_derive)]
#[derive(Clone, Copy, PartialEq)]
#[repr(C)]
pub struct XKeymapEvent {
  pub type_: c_int,
  pub serial: c_ulong,
  pub send_event: Bool,
  pub display: *mut Display,
  pub window: Window,
  pub key_vector: [c_char; 32],
}

impl From<XEvent> for XKeymapEvent {
  fn from (e: XEvent) -> XKeymapEvent {
    unsafe { transmute_union(&e) }
  }
}

#[allow(raw_pointer_derive)]
#[derive(Clone, Copy, PartialEq)]
#[repr(C)]
pub struct XMapEvent {
  pub type_: c_int,
  pub serial: c_ulong,
  pub send_event: Bool,
  pub display: *mut Display,
  pub event: Window,
  pub window: Window,
  pub override_redirect: Bool,
}

impl From<XEvent> for XMapEvent {
  fn from (e: XEvent) -> XMapEvent {
    unsafe { transmute_union(&e) }
  }
}

#[allow(raw_pointer_derive)]
#[derive(Clone, Copy, PartialEq)]
#[repr(C)]
pub struct XMappingEvent {
  pub type_: c_int,
  pub serial: c_ulong,
  pub send_event: Bool,
  pub display: *mut Display,
  pub event: Window,
  pub request: c_int,
  pub first_keycode: c_int,
  pub count: c_int,
}

impl From<XEvent> for XMappingEvent {
  fn from (e: XEvent) -> XMappingEvent {
    unsafe { transmute_union(&e) }
  }
}

#[allow(raw_pointer_derive)]
#[derive(Clone, Copy, PartialEq)]
#[repr(C)]
pub struct XMapRequestEvent {
  pub type_: c_int,
  pub serial: c_ulong,
  pub send_event: Bool,
  pub display: *mut Display,
  pub parent: Window,
  pub window: Window,
}

impl From<XEvent> for XMapRequestEvent {
  fn from (e: XEvent) -> XMapRequestEvent {
    unsafe { transmute_union(&e) }
  }
}

#[allow(raw_pointer_derive)]
#[derive(Clone, Copy, PartialEq)]
#[repr(C)]
pub struct XMotionEvent {
  pub type_: c_int,
  pub serial: c_ulong,
  pub send_event: Bool,
  pub display: *mut Display,
  pub window: Window,
  pub root: Window,
  pub subwindow: Window,
  pub time: Time,
  pub x: c_int,
  pub y: c_int,
  pub x_root: c_int,
  pub y_root: c_int,
  pub state: c_uint,
  pub is_hint: c_char,
  pub same_screen: Bool,
}
pub type XPointerMovedEvent = XMotionEvent;

impl From<XEvent> for XMotionEvent {
  fn from (e: XEvent) -> XMotionEvent {
    unsafe { transmute_union(&e) }
  }
}

#[allow(raw_pointer_derive)]
#[derive(Clone, Copy, PartialEq)]
#[repr(C)]
pub struct XNoExposeEvent {
  pub type_: c_int,
  pub serial: c_ulong,
  pub send_event: Bool,
  pub display: *mut Display,
  pub drawable: Drawable,
  pub major_code: c_int,
  pub minor_code: c_int,
}

impl From<XEvent> for XNoExposeEvent {
  fn from (e: XEvent) -> XNoExposeEvent {
    unsafe { transmute_union(&e) }
  }
}

#[allow(raw_pointer_derive)]
#[derive(Clone, Copy, PartialEq)]
#[repr(C)]
pub struct XPropertyEvent {
  pub type_: c_int,
  pub serial: c_ulong,
  pub send_event: Bool,
  pub display: *mut Display,
  pub window: Window,
  pub atom: Atom,
  pub time: Time,
  pub state: c_int,
}

impl From<XEvent> for XPropertyEvent {
  fn from (e: XEvent) -> XPropertyEvent {
    unsafe { transmute_union(&e) }
  }
}

#[allow(raw_pointer_derive)]
#[derive(Clone, Copy, PartialEq)]
#[repr(C)]
pub struct XReparentEvent {
  pub type_: c_int,
  pub serial: c_ulong,
  pub send_event: Bool,
  pub display: *mut Display,
  pub event: Window,
  pub window: Window,
  pub parent: Window,
  pub x: c_int,
  pub y: c_int,
  pub override_redirect: Bool,
}

impl From<XEvent> for XReparentEvent {
  fn from (e: XEvent) -> XReparentEvent {
    unsafe { transmute_union(&e) }
  }
}

#[allow(raw_pointer_derive)]
#[derive(Clone, Copy, PartialEq)]
#[repr(C)]
pub struct XResizeRequestEvent {
  pub type_: c_int,
  pub serial: c_ulong,
  pub send_event: Bool,
  pub display: *mut Display,
  pub window: Window,
  pub width: c_int,
  pub height: c_int,
}

impl From<XEvent> for XResizeRequestEvent {
  fn from (e: XEvent) -> XResizeRequestEvent {
    unsafe { transmute_union(&e) }
  }
}

#[allow(raw_pointer_derive)]
#[derive(Clone, Copy, PartialEq)]
#[repr(C)]
pub struct XSelectionClearEvent {
  pub type_: c_int,
  pub serial: c_ulong,
  pub send_event: Bool,
  pub display: *mut Display,
  pub window: Window,
  pub selection: Atom,
  pub time: Time,
}

impl From<XEvent> for XSelectionClearEvent {
  fn from (e: XEvent) -> XSelectionClearEvent {
    unsafe { transmute_union(&e) }
  }
}

#[allow(raw_pointer_derive)]
#[derive(Clone, Copy, PartialEq)]
#[repr(C)]
pub struct XSelectionEvent {
  pub type_: c_int,
  pub serial: c_ulong,
  pub send_event: Bool,
  pub display: *mut Display,
  pub requestor: Window,
  pub selection: Atom,
  pub target: Atom,
  pub property: Atom,
  pub time: Time,
}

impl From<XEvent> for XSelectionEvent {
  fn from (e: XEvent) -> XSelectionEvent {
    unsafe { transmute_union(&e) }
  }
}

#[allow(raw_pointer_derive)]
#[derive(Clone, Copy, PartialEq)]
#[repr(C)]
pub struct XSelectionRequestEvent {
  pub type_: c_int,
  pub serial: c_ulong,
  pub send_event: Bool,
  pub display: *mut Display,
  pub owner: Window,
  pub requestor: Window,
  pub selection: Atom,
  pub target: Atom,
  pub property: Atom,
  pub time: Time,
}

impl From<XEvent> for XSelectionRequestEvent {
  fn from (e: XEvent) -> XSelectionRequestEvent {
    unsafe { transmute_union(&e) }
  }
}

#[allow(raw_pointer_derive)]
#[derive(Clone, Copy, PartialEq)]
#[repr(C)]
pub struct XUnmapEvent {
  pub type_: c_int,
  pub serial: c_ulong,
  pub send_event: Bool,
  pub display: *mut Display,
  pub event: Window,
  pub window: Window,
  pub from_configure: Bool,
}

impl From<XEvent> for XUnmapEvent {
  fn from (e: XEvent) -> XUnmapEvent {
    unsafe { transmute_union(&e) }
  }
}

#[allow(raw_pointer_derive)]
#[derive(Clone, Copy, PartialEq)]
#[repr(C)]
pub struct XVisibilityEvent {
  pub type_: c_int,
  pub serial: c_ulong,
  pub send_event: Bool,
  pub display: *mut Display,
  pub window: Window,
  pub state: c_int,
}

impl From<XEvent> for XVisibilityEvent {
  fn from (e: XEvent) -> XVisibilityEvent {
    unsafe { transmute_union(&e) }
  }
}


//
// other structures
//


#[derive(Clone, Copy, PartialEq)]
#[repr(C)]
pub struct XArc {
  pub x: c_short,
  pub y: c_short,
  pub width: c_ushort,
  pub height: c_ushort,
  pub angle1: c_short,
  pub angle2: c_short,
}

#[derive(Clone, Copy, PartialEq)]
#[repr(C)]
pub struct XChar2b {
  pub byte1: c_uchar,
  pub byte2: c_uchar,
}

#[derive(Clone, Copy, PartialEq)]
#[repr(C)]
pub struct XCharStruct {
  pub lbearing: c_short,
  pub rbearing: c_short,
  pub width: c_short,
  pub ascent: c_short,
  pub descent: c_short,
  pub attributes: c_ushort,
}

#[allow(raw_pointer_derive)]
#[derive(Clone, Copy, PartialEq)]
#[repr(C)]
pub struct XClassHint {
  pub res_name: *mut c_char,
  pub res_class: *mut c_char,
}

#[derive(Clone, Copy, PartialEq)]
#[repr(C)]
pub struct XColor {
  pub pixel: c_ulong,
  pub red: c_ushort,
  pub green: c_ushort,
  pub blue: c_ushort,
  pub flags: c_char,
  pub pad: c_char,
}

#[allow(raw_pointer_derive)]
#[derive(Clone, Copy, PartialEq)]
#[repr(C)]
pub struct XComposeStatus {
  pub compose_ptr: XPointer,
  pub chars_matched: c_int,
}

#[derive(Clone, Copy, PartialEq)]
#[repr(C)]
pub struct XExtCodes {
  pub extension: c_int,
  pub major_opcode: c_int,
  pub first_event: c_int,
  pub first_error: c_int,
}

#[allow(raw_pointer_derive)]
#[repr(C)]
pub struct XExtData {
  pub number: c_int,
  pub next: *mut XExtData,
  pub free_private: Option<unsafe extern "C" fn () -> c_int>,
  pub private_data: XPointer,
}

#[derive(Clone, Copy, PartialEq)]
#[repr(C)]
pub struct XFontProp {
  pub name: Atom,
  pub card32: c_ulong,
}

#[derive(Clone, Copy, PartialEq)]
#[repr(C)]
pub struct XFontSetExtents {
  pub max_ink_extent: XRectangle,
  pub max_logical_extent: XRectangle,
}

#[allow(raw_pointer_derive)]
#[derive(Clone, Copy, PartialEq)]
#[repr(C)]
pub struct XFontStruct {
  pub ext_data: *mut XExtData,
  pub fid: Font,
  pub direction: c_uint,
  pub min_char_or_byte2: c_uint,
  pub max_char_or_byte2: c_uint,
  pub min_byte1: c_uint,
  pub max_byte1: c_uint,
  pub all_chars_exist: Bool,
  pub default_char: c_uint,
  pub n_properties: c_int,
  pub properties: *mut XFontProp,
  pub min_bounds: XCharStruct,
  pub max_bounds: XCharStruct,
  pub per_char: *mut XCharStruct,
  pub ascent: c_int,
  pub descent: c_int,
}

#[derive(Clone, Copy, PartialEq)]
#[repr(C)]
pub struct XGCValues {
  pub function: c_int,
  pub plane_mask: c_ulong,
  pub foreground: c_ulong,
  pub background: c_ulong,
  pub line_width: c_int,
  pub line_style: c_int,
  pub cap_style: c_int,
  pub join_style: c_int,
  pub fill_style: c_int,
  pub fill_rule: c_int,
  pub arc_mode: c_int,
  pub tile: Pixmap,
  pub stipple: Pixmap,
  pub ts_x_origin: c_int,
  pub ts_y_origin: c_int,
  pub font: Font,
  pub subwindow_mode: c_int,
  pub graphics_exposures: Bool,
  pub clip_x_origin: c_int,
  pub clip_y_origin: c_int,
  pub clip_mask: Pixmap,
  pub dash_offset: c_int,
  pub dashes: c_char,
}

#[allow(raw_pointer_derive)]
#[derive(Clone, Copy, PartialEq)]
#[repr(C)]
pub struct XGenericEventCookie {
  pub type_: c_int,
  pub serial: c_ulong,
  pub send_event: Bool,
  pub display: *mut Display,
  pub extension: c_int,
  pub evtype: c_int,
  pub cookie: c_uint,
  pub data: *mut c_void,
}

#[allow(raw_pointer_derive)]
#[derive(Clone, Copy, PartialEq)]
#[repr(C)]
pub struct XHostAddress {
  pub family: c_int,
  pub length: c_int,
  pub address: *mut c_char,
}

#[derive(Clone, Copy, PartialEq)]
#[repr(C)]
pub struct XIconSize {
  pub min_width: c_int,
  pub min_height: c_int,
  pub max_width: c_int,
  pub max_height: c_int,
  pub width_inc: c_int,
  pub height_inc: c_int,
}

#[allow(raw_pointer_derive)]
#[derive(Clone, Copy, PartialEq)]
#[repr(C)]
pub struct XImage {
  pub width: c_int,
  pub height: c_int,
  pub xoffset: c_int,
  pub format: c_int,
  pub data: *mut c_char,
  pub byte_order: c_int,
  pub bitmap_unity: c_int,
  pub bitmap_bit_order: c_int,
  pub bitmap_pad: c_int,
  pub depth: c_int,
  pub bytes_per_line: c_int,
  pub bits_per_pixel: c_int,
  pub red_mask: c_ulong,
  pub green_mask: c_ulong,
  pub blue_mask: c_ulong,
  pub obdata: XPointer,
  pub funcs: ImageFns,
}

#[derive(Clone, Copy, PartialEq)]
#[repr(C)]
pub struct XKeyboardControl {
  pub key_click_percent: c_int,
  pub bell_percent: c_int,
  pub bell_pitch: c_int,
  pub bell_duration: c_int,
  pub led: c_int,
  pub led_mode: c_int,
  pub key: c_int,
  pub auto_repeat_mode: c_int,
}

#[derive(Clone, Copy, PartialEq)]
#[repr(C)]
pub struct XKeyboardState {
  pub key_click_percent: c_int,
  pub bell_percent: c_int,
  pub bell_pitch: c_uint,
  pub bell_duration: c_uint,
  pub led_mask: c_ulong,
  pub global_auto_repeat: c_int,
  pub auto_repeats: [c_char; 32],
}

#[allow(raw_pointer_derive)]
#[derive(Clone, Copy, PartialEq)]
#[repr(C)]
pub struct XmbTextItem {
  pub chars: *mut c_char,
  pub nchars: c_int,
  pub delta: c_int,
  pub font_set: XFontSet,
}

#[allow(raw_pointer_derive)]
#[derive(Clone, Copy, PartialEq)]
#[repr(C)]
pub struct XModifierKeymap {
  pub max_keypermod: c_int,
  pub modifiermap: *mut KeyCode,
}

#[derive(Clone, Copy, PartialEq)]
#[repr(C)]
pub struct XPixmapFormatValues {
  pub depth: c_int,
  pub bits_per_pixel: c_int,
  pub scanline_pad: c_int,
}

#[derive(Clone, Copy, PartialEq)]
#[repr(C)]
pub struct XPoint {
  pub x: c_short,
  pub y: c_short,
}

#[derive(Clone, Copy, PartialEq)]
#[repr(C)]
pub struct XRectangle {
  pub x: c_short,
  pub y: c_short,
  pub width: c_ushort,
  pub height: c_ushort,
}

#[allow(raw_pointer_derive)]
#[derive(Clone, Copy, PartialEq)]
#[repr(C)]
pub struct XrmOptionDescRec {
  pub option: *mut c_char,
  pub specifier: *mut c_char,
  pub argKind: XrmOptionKind,
  pub value: XPointer,
}

#[allow(raw_pointer_derive)]
#[derive(Clone, Copy, PartialEq)]
#[repr(C)]
pub struct XrmValue {
  pub size: c_uint,
  pub addr: XPointer,
}

#[derive(Clone, Copy, PartialEq)]
#[repr(C)]
pub struct XSegment {
  pub x1: c_short,
  pub y1: c_short,
  pub x2: c_short,
  pub y2: c_short,
}

#[derive(Clone, Copy, PartialEq)]
#[repr(C)]
pub struct XSetWindowAttributes {
  pub background_pixmap: Pixmap,
  pub background_pixel: c_ulong,
  pub border_pixmap: Pixmap,
  pub border_pixel: c_ulong,
  pub bit_gravity: c_int,
  pub win_gravity: c_int,
  pub backing_store: c_int,
  pub backing_planes: c_ulong,
  pub backing_pixel: c_ulong,
  pub save_under: Bool,
  pub event_mask: c_long,
  pub do_not_propagate_mask: c_long,
  pub override_redirect: Bool,
  pub colormap: Colormap,
  pub cursor: Cursor,
}

#[derive(Clone, Copy, PartialEq)]
#[repr(C)]
pub struct XSizeHints {
  pub flags: c_long,
  pub x: c_int,
  pub y: c_int,
  pub width: c_int,
  pub height: c_int,
  pub min_width: c_int,
  pub min_height: c_int,
  pub max_width: c_int,
  pub max_height: c_int,
  pub width_inc: c_int,
  pub height_inc: c_int,
  pub min_aspect: AspectRatio,
  pub max_aspect: AspectRatio,
  pub base_width: c_int,
  pub base_height: c_int,
  pub win_gravity: c_int,
}

#[derive(Clone, Copy, PartialEq)]
#[repr(C)]
pub struct XStandardColormap {
  pub colormap: Colormap,
  pub red_max: c_ulong,
  pub red_mult: c_ulong,
  pub green_max: c_ulong,
  pub green_mult: c_ulong,
  pub blue_max: c_ulong,
  pub blue_mult: c_ulong,
  pub base_pixel: c_ulong,
  pub visualid: VisualID,
  pub killid: XID,
}

#[allow(raw_pointer_derive)]
#[derive(Clone, Copy, PartialEq)]
#[repr(C)]
pub struct XTextItem {
  pub chars: *mut c_char,
  pub nchars: c_int,
  pub delta: c_int,
  pub font: Font,
}

#[allow(raw_pointer_derive)]
#[derive(Clone, Copy, PartialEq)]
#[repr(C)]
pub struct XTextItem16 {
  pub chars: *mut XChar2b,
  pub nchars: c_int,
  pub delta: c_int,
  pub font: Font,
}

#[allow(raw_pointer_derive)]
#[derive(Clone, Copy, PartialEq)]
#[repr(C)]
pub struct XTextProperty {
  pub value: *mut c_uchar,
  pub encoding: Atom,
  pub format: c_int,
  pub nitems: c_ulong,
}

#[derive(Clone, Copy, PartialEq)]
#[repr(C)]
pub struct XTimeCoord {
  pub time: Time,
  pub x: c_short,
  pub y: c_short,
}

#[allow(raw_pointer_derive)]
#[derive(Clone, Copy, PartialEq)]
#[repr(C)]
pub struct XVisualInfo {
  pub visual: *mut Visual,
  pub visualid: VisualID,
  pub screen: c_int,
  pub depth: c_int,
  pub class: c_int,
  pub red_mask: c_ulong,
  pub green_mask: c_ulong,
  pub blue_mask: c_ulong,
  pub colormap_size: c_int,
  pub bits_per_rgb: c_int,
}

#[allow(raw_pointer_derive)]
#[derive(Clone, Copy, PartialEq)]
#[repr(C)]
pub struct XwcTextItem {
  pub chars: *mut wchar_t,
  pub nchars: c_int,
  pub delta: c_int,
  pub font_set: XFontSet,
}

#[allow(raw_pointer_derive)]
#[derive(Clone, Copy, PartialEq)]
#[repr(C)]
pub struct XWindowAttributes {
  pub x: c_int,
  pub y: c_int,
  pub width: c_int,
  pub height: c_int,
  pub border_width: c_int,
  pub depth: c_int,
  pub visual: *mut Visual,
  pub root: Window,
  pub class: c_int,
  pub bit_gravity: c_int,
  pub win_gravity: c_int,
  pub backing_store: c_int,
  pub backing_planes: c_ulong,
  pub backing_pixel: c_ulong,
  pub save_under: Bool,
  pub colormap: Colormap,
  pub map_installed: Bool,
  pub map_state: c_int,
  pub all_event_masks: c_long,
  pub your_event_mask: c_long,
  pub do_not_propagate_mask: c_long,
  pub override_redirect: Bool,
  pub screen: *mut Screen,
}

#[derive(Clone, Copy, PartialEq)]
#[repr(C)]
pub struct XWindowChanges {
  pub x: c_int,
  pub y: c_int,
  pub width: c_int,
  pub height: c_int,
  pub border_width: c_int,
  pub sibling: Window,
  pub stack_mode: c_int,
}

#[derive(Clone, Copy, PartialEq)]
#[repr(C)]
pub struct XWMHints {
  pub flags: c_long,
  pub input: Bool,
  pub initial_state: c_int,
  pub icon_pixmap: Pixmap,
  pub icon_window: Window,
  pub icon_x: c_int,
  pub icon_y: c_int,
  pub icon_mask: Pixmap,
  pub window_group: XID,
}


//
// anonymous structures
//


#[derive(Clone, Copy, PartialEq)]
#[repr(C)]
pub struct AspectRatio {
  pub x: c_int,
  pub y: c_int,
}

#[derive(Clone, Copy, PartialEq)]
#[repr(C)]
pub struct ClientMessageData {
  longs: [c_long; 5],
}

impl ClientMessageData {
  pub fn get_byte (&self, index: usize) -> c_char {
    unsafe {
      from_raw_parts(&self.longs[0] as *const c_long as *const c_char, 20)[index]
    }
  }

  pub fn get_long (&self, index: usize) -> c_long {
    self.longs[index]
  }

  pub fn get_short (&self, index: usize) -> c_short {
    unsafe {
      from_raw_parts(&self.longs[0] as *const c_long as *const c_short, 10)[index]
    }
  }

  pub fn set_byte (&mut self, index: usize, value: c_char) {
    unsafe {
      from_raw_parts_mut(&mut self.longs[0] as *mut c_long as *mut c_char, 20)[index] = value;
    }
  }

  pub fn set_long (&mut self, index: usize, value: c_long) {
    self.longs[index] = value;
  }

  pub fn set_short (&mut self, index: usize, value: c_short) {
    unsafe {
      from_raw_parts_mut(&mut self.longs[0] as *mut c_long as *mut c_short, 10)[index] = value;
    }
  }
}

#[test]
fn client_message_size_test () {
  assert!(size_of::<ClientMessageData>() >= size_of::<[c_char; 20]>());
  assert!(size_of::<ClientMessageData>() >= size_of::<[c_short; 10]>());
}

#[derive(Copy)]
#[repr(C)]
pub struct ImageFns {
  pub create_image: Option<unsafe extern "C" fn (*mut Display, *mut Visual, c_uint, c_int, c_int, *mut c_char, c_uint, c_uint, c_int, c_int) -> *mut XImage>,
  pub destroy_image: Option<unsafe extern "C" fn (*mut XImage) -> c_int>,
  pub get_pixel: Option<unsafe extern "C" fn (*mut XImage, c_int, c_int) -> c_ulong>,
  pub put_pixel: Option<unsafe extern "C" fn (*mut XImage, c_int, c_int, c_ulong) -> c_int>,
  pub sub_image: Option<unsafe extern "C" fn (*mut XImage, c_int, c_int, c_uint, c_uint) -> *mut XImage>,
  pub add_pixel: Option<unsafe extern "C" fn (&mut XImage, c_long) -> c_int>,
}

impl Clone for ImageFns {
  fn clone (&self) -> ImageFns {
    *self
  }
}

impl PartialEq for ImageFns {
  fn eq (&self, rhs: &ImageFns) -> bool {
    unsafe { mem_eq(self, rhs) }
  }
}


//
// constants
//


// allocate colormap
pub const AllocNone: c_int = 0;
pub const AllocAll: c_int = 1;

// atoms
pub const XA_PRIMARY: Atom = 1;
pub const XA_SECONDARY: Atom = 2;
pub const XA_ARC: Atom = 3;
pub const XA_ATOM: Atom = 4;
pub const XA_BITMAP: Atom = 5;
pub const XA_CARDINAL: Atom = 6;
pub const XA_COLORMAP: Atom = 7;
pub const XA_CURSOR: Atom = 8;
pub const XA_CUT_BUFFER0: Atom = 9;
pub const XA_CUT_BUFFER1: Atom = 10;
pub const XA_CUT_BUFFER2: Atom = 11;
pub const XA_CUT_BUFFER3: Atom = 12;
pub const XA_CUT_BUFFER4: Atom = 13;
pub const XA_CUT_BUFFER5: Atom = 14;
pub const XA_CUT_BUFFER6: Atom = 15;
pub const XA_CUT_BUFFER7: Atom = 16;
pub const XA_DRAWABLE: Atom = 17;
pub const XA_FONT: Atom = 18;
pub const XA_INTEGER: Atom = 19;
pub const XA_PIXMAP: Atom = 20;
pub const XA_POINT: Atom = 21;
pub const XA_RECTANGLE: Atom = 22;
pub const XA_RESOURCE_MANAGER: Atom = 23;
pub const XA_RGB_COLOR_MAP: Atom = 24;
pub const XA_RGB_BEST_MAP: Atom = 25;
pub const XA_RGB_BLUE_MAP: Atom = 26;
pub const XA_RGB_DEFAULT_MAP: Atom = 27;
pub const XA_RGB_GRAY_MAP: Atom = 28;
pub const XA_RGB_GREEN_MAP: Atom = 29;
pub const XA_RGB_RED_MAP: Atom = 30;
pub const XA_STRING: Atom = 31;
pub const XA_VISUALID: Atom = 32;
pub const XA_WINDOW: Atom = 33;
pub const XA_WM_COMMAND: Atom = 34;
pub const XA_WM_HINTS: Atom = 35;
pub const XA_WM_CLIENT_MACHINE: Atom = 36;
pub const XA_WM_ICON_NAME: Atom = 37;
pub const XA_WM_ICON_SIZE: Atom = 38;
pub const XA_WM_NAME: Atom = 39;
pub const XA_WM_NORMAL_HINTS: Atom = 40;
pub const XA_WM_SIZE_HINTS: Atom = 41;
pub const XA_WM_ZOOM_HINTS: Atom = 42;
pub const XA_MIN_SPACE: Atom = 43;
pub const XA_NORM_SPACE: Atom = 44;
pub const XA_MAX_SPACE: Atom = 45;
pub const XA_END_SPACE: Atom = 46;
pub const XA_SUPERSCRIPT_X: Atom = 47;
pub const XA_SUPERSCRIPT_Y: Atom = 48;
pub const XA_SUBSCRIPT_X: Atom = 49;
pub const XA_SUBSCRIPT_Y: Atom = 50;
pub const XA_UNDERLINE_POSITION: Atom = 51;
pub const XA_UNDERLINE_THICKNESS: Atom = 52;
pub const XA_STRIKEOUT_ASCENT: Atom = 53;
pub const XA_STRIKEOUT_DESCENT: Atom = 54;
pub const XA_ITALIC_ANGLE: Atom = 55;
pub const XA_X_HEIGHT: Atom = 56;
pub const XA_QUAD_WIDTH: Atom = 57;
pub const XA_WEIGHT: Atom = 58;
pub const XA_POINT_SIZE: Atom = 59;
pub const XA_RESOLUTION: Atom = 60;
pub const XA_COPYRIGHT: Atom = 61;
pub const XA_NOTICE: Atom = 62;
pub const XA_FONT_NAME: Atom = 63;
pub const XA_FAMILY_NAME: Atom = 64;
pub const XA_FULL_NAME: Atom = 65;
pub const XA_CAP_HEIGHT: Atom = 66;
pub const XA_WM_CLASS: Atom = 67;
pub const XA_WM_TRANSIENT_FOR: Atom = 68;

// boolean values
pub const False: Bool = 0;
pub const True: Bool = 1;

// clip rect ordering
pub const Unsorted: c_int = 0;
pub const YSorted: c_int = 1;
pub const YXSorted: c_int = 2;
pub const YXBanded: c_int = 3;

// color component mask
pub const DoRed: c_char = 1;
pub const DoGreen: c_char = 2;
pub const DoBlue: c_char = 4;

// error codes
pub const Success: c_int = 0;
pub const BadRequest: c_int = 1;
pub const BadValue: c_int = 2;
pub const BadWindow: c_int = 3;
pub const BadPixmap: c_int = 4;
pub const BadAtom: c_int = 5;
pub const BadCursor: c_int = 6;
pub const BadFont: c_int = 7;
pub const BadMatch: c_int = 8;
pub const BadDrawable: c_int = 9;
pub const BadAccess: c_int = 10;
pub const BadAlloc: c_int = 11;
pub const BadColor: c_int = 12;
pub const BadGC: c_int = 13;
pub const BadIDChoice: c_int = 14;
pub const BadName: c_int = 15;
pub const BadLength: c_int = 16;
pub const BadImplementation: c_int = 17;
pub const FirstExtensionError: c_int = 128;
pub const LastExtensionError: c_int = 255;

// event kinds
pub const KeyPress: c_int = 2;
pub const KeyRelease: c_int = 3;
pub const ButtonPress: c_int = 4;
pub const ButtonRelease: c_int = 5;
pub const MotionNotify: c_int = 6;
pub const EnterNotify: c_int = 7;
pub const LeaveNotify: c_int = 8;
pub const FocusIn: c_int = 9;
pub const FocusOut: c_int = 10;
pub const KeymapNotify: c_int = 11;
pub const Expose: c_int = 12;
pub const GraphicsExpose: c_int = 13;
pub const NoExpose: c_int = 14;
pub const VisibilityNotify: c_int = 15;
pub const CreateNotify: c_int = 16;
pub const DestroyNotify: c_int = 17;
pub const UnmapNotify: c_int = 18;
pub const MapNotify: c_int = 19;
pub const MapRequest: c_int = 20;
pub const ReparentNotify: c_int = 21;
pub const ConfigureNotify: c_int = 22;
pub const ConfigureRequest: c_int = 23;
pub const GravityNotify: c_int = 24;
pub const ResizeRequest: c_int = 25;
pub const CirculateNotify: c_int = 26;
pub const CirculateRequest: c_int = 27;
pub const PropertyNotify: c_int = 28;
pub const SelectionClear: c_int = 29;
pub const SelectionRequest: c_int = 30;
pub const SelectionNotify: c_int = 31;
pub const ColormapNotify: c_int = 32;
pub const ClientMessage: c_int = 33;
pub const MappingNotify: c_int = 34;

// event mask
pub const NoEventMask: c_long = 0;
pub const KeyPressMask: c_long = 0x0000_0001;
pub const KeyReleaseMask: c_long = 0x0000_0002;
pub const ButtonPressMask: c_long = 0x0000_0004;
pub const ButtonReleaseMask: c_long = 0x0000_0008;
pub const EnterWindowMask: c_long = 0x0000_0010;
pub const LeaveWindowMask: c_long = 0x0000_0020;
pub const PointerMotionMask: c_long = 0x0000_0040;
pub const PointerMotionHintMask: c_long = 0x0000_0080;
pub const Button1MotionMask: c_long = 0x0000_0100;
pub const Button2MotionMask: c_long = 0x0000_0200;
pub const Button3MotionMask: c_long = 0x0000_0400;
pub const Button4MotionMask: c_long = 0x0000_0800;
pub const Button5MotionMask: c_long = 0x0000_1000;
pub const ButtonMotionMask: c_long = 0x0000_2000;
pub const KeymapStateMask: c_long = 0x0000_4000;
pub const ExposureMask: c_long = 0x0000_8000;
pub const VisibilityChangeMask: c_long = 0x0001_0000;
pub const StructureNotifyMask: c_long = 0x0002_0000;
pub const ResizeRedirectMask: c_long = 0x0004_0000;
pub const SubstructureNotifyMask: c_long = 0x0008_0000;
pub const SubstructureRedirectMask: c_long = 0x0010_0000;
pub const FocusChangeMask: c_long = 0x0020_0000;
pub const PropertyChangeMask: c_long = 0x0040_0000;
pub const ColormapChangeMask: c_long = 0x0080_0000;
pub const OwnerGrabButtonMask: c_long = 0x0100_0000;

// grab modes
pub const GrabModeSync: c_int = 0;
pub const GrabModeAsync: c_int = 1;

// grab status
pub const GrabSuccess: c_int = 0;
pub const AlreadyGrabbed: c_int = 1;
pub const GrabInvalidTime: c_int = 2;
pub const GrabNotViewable: c_int = 3;
pub const GrabFrozen: c_int = 4;

// map state
pub const IsUnmapped: c_int = 0;
pub const IsUnviewable: c_int = 1;
pub const IsViewable: c_int = 2;

// mouse buttons
pub const Button1: c_uint = 1;
pub const Button2: c_uint = 2;
pub const Button3: c_uint = 3;
pub const Button4: c_uint = 4;
pub const Button5: c_uint = 5;

// size hints mask
pub const USPosition: c_long = 0x0001;
pub const USSize: c_long = 0x0002;
pub const PPosition: c_long = 0x0004;
pub const PSize: c_long = 0x0008;
pub const PMinSize: c_long = 0x0010;
pub const PMaxSize: c_long = 0x0020;
pub const PResizeInc: c_long = 0x0040;
pub const PAspect: c_long = 0x0080;
pub const PBaseSize: c_long = 0x0100;
pub const PWinGravity: c_long = 0x0200;
pub const PAllHints: c_long = PPosition | PSize | PMinSize | PMaxSize | PResizeInc | PAspect;

// time constants
pub const CurrentTime: Time = 0;

// visual class
pub const StaticGray: c_int = 0;
pub const GrayScale: c_int = 1;
pub const StaticColor: c_int = 2;
pub const PseudoColor: c_int = 3;
pub const TrueColor: c_int = 4;
pub const DirectColor: c_int = 5;

// visual info mask
pub const VisualNoMask: c_long = 0x0000;
pub const VisualIDMask: c_long = 0x0001;
pub const VisualScreenMask: c_long = 0x0002;
pub const VisualDepthMask: c_long = 0x0004;
pub const VisualClassMask: c_long = 0x0008;
pub const VisualRedMaskMask: c_long = 0x0010;
pub const VisualGreenMaskMask: c_long = 0x0020;
pub const VisualBlueMaskMask: c_long = 0x0040;
pub const VisualColormapSizeMask: c_long = 0x0080;
pub const VisualBitsPerRGBMask: c_long = 0x0100;
pub const VisualAllMask: c_long = 0x01ff;

// window attributes
pub const CWBackPixmap: c_ulong = 0x0001;
pub const CWBackPixel: c_ulong = 0x0002;
pub const CWBorderPixmap: c_ulong = 0x0004;
pub const CWBorderPixel: c_ulong = 0x0008;
pub const CWBitGravity: c_ulong = 0x0010;
pub const CWWinGravity: c_ulong = 0x0020;
pub const CWBackingStore: c_ulong = 0x0040;
pub const CWBackingPlanes: c_ulong = 0x0080;
pub const CWBackingPixel: c_ulong = 0x0100;
pub const CWOverrideRedirect: c_ulong = 0x0200;
pub const CWSaveUnder: c_ulong = 0x0400;
pub const CWEventMask: c_ulong = 0x0800;
pub const CWDontPropagate: c_ulong = 0x1000;
pub const CWColormap: c_ulong = 0x2000;
pub const CWCursor: c_ulong = 0x4000;

// window classes
pub const InputOutput: c_int = 1;
pub const InputOnly: c_int = 2;

// XCreateIC values
pub const XIMPreeditArea: c_int = 0x0001;
pub const XIMPreeditCallbacks: c_int = 0x0002;
pub const XIMPreeditPosition: c_int = 0x0004;
pub const XIMPreeditNothing: c_int = 0x0008;
pub const XIMPreeditNone: c_int = 0x0010;
pub const XIMStatusArea: c_int = 0x0100;
pub const XIMStatusCallbacks: c_int = 0x0200;
pub const XIMStatusNothing: c_int = 0x0400;
pub const XIMStatusNone: c_int = 0x0800;


//
// private functions
//


unsafe fn mem_eq<T: Sized> (a: &T, b: &T) -> bool {
  let a_addr = a as *const T as usize;
  let b_addr = b as *const T as usize;

  for i in (0..size_of::<T>()) {
    if *((a_addr + i) as *const u8) != *((b_addr + i) as *const u8) {
      return false;
    }
  }

  return true;
}

unsafe fn transmute_union<I, O> (input: &I) -> O
  where I : Sized, O : Sized
{
  let mut output: O = zeroed();
  let copy_len = min(size_of::<I>(), size_of::<O>());

  for i in 0..copy_len {
    *((&mut output as *mut O as usize + i) as *mut u8) = *((input as *const I as usize + i) as *const u8);
  }

  return output;
}