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

<para>
A number of resources are used when performing graphics operations in X. Most information
about performing graphics (for example, foreground color, background color, line style, and so
on) is stored in resources called graphics contexts (GCs). Most graphics operations (see chapter
8) take a GC as an argument. Although in theory the X protocol permits sharing of GCs between
applications, it is expected that applications will use their own GCs when performing operations.
Sharing of GCs is highly discouraged because the library may cache GC state.
</para>
<para>
Graphics operations can be performed to either windows or pixmaps, which collectively are
called drawables. Each drawable exists on a single screen. A GC is created for a specific screen
and drawable depth and can only be used with drawables of matching screen and depth.
</para>
<para>
This chapter discusses how to:
</para>
<itemizedlist>
  <listitem><para>Manipulate graphics context/state</para></listitem>
  <listitem><para>Use graphics context convenience functions</para></listitem>
</itemizedlist>

<sect1 id='Manipulating_Graphics_ContextState'>
<title>Manipulating Graphics Context/State</title>
<!-- .XS -->
<!-- (SN Manipulating Graphics Context/State  -->
<!-- .XE -->
<para>
<!-- .LP -->
Most attributes of graphics operations are stored in GCs.
These include line width, line style, plane mask, foreground, background,
tile, stipple, clipping region, end style, join style, and so on.
Graphics operations (for example, drawing lines) use these values
to determine the actual drawing operation.
Extensions to X may add additional components to GCs.
The contents of a GC are private to Xlib.
</para>
<para>
<!-- .LP -->
Xlib implements a write-back cache for all elements of a GC that are not
resource IDs to allow Xlib to implement the transparent coalescing of changes 
to GCs.
For example,
a call to
<xref linkend='XSetForeground' xrefstyle='select: title'/>
of a GC followed by a call to
<xref linkend='XSetLineAttributes' xrefstyle='select: title'/>
results in only a single-change GC protocol request to the server.
GCs are neither expected nor encouraged to be shared between client 
applications, so this write-back caching should present no problems.
Applications cannot share GCs without external synchronization.
Therefore,
sharing GCs between applications is highly discouraged. 
</para>
<para>
<!-- .LP -->
To set an attribute of a GC,
set the appropriate member of the
<structname>XGCValues</structname>
structure and OR in the corresponding value bitmask in your subsequent calls to
<xref linkend='XCreateGC' xrefstyle='select: title'/>.
The symbols for the value mask bits and the
<structname>XGCValues</structname>
structure are:
<!-- .sM -->
</para>


<literallayout class="monospaced">
/* GC attribute value mask bits */

#define     GCFunction              (1L&lt;&lt;0)
#define     GCPlaneMask             (1L&lt;&lt;1)
#define     GCForeground            (1L&lt;&lt;2)
#define     GCBackground            (1L&lt;&lt;3)
#define     GCLineWidth             (1L&lt;&lt;4)
#define     GCLineStyle             (1L&lt;&lt;5)
#define     GCCapStyle              (1L&lt;&lt;6)
#define     GCJoinStyle             (1L&lt;&lt;7)
#define     GCFillStyle             (1L&lt;&lt;8)
#define     GCFillRule              (1L&lt;&lt;9)
#define     GCTile                  (1L&lt;&lt;10)
#define     GCStipple               (1L&lt;&lt;11)
#define     GCTileStipXOrigin       (1L&lt;&lt;12)
#define     GCTileStipYOrigin       (1L&lt;&lt;13)
#define     GCFont                  (1L&lt;&lt;14)
#define     GCSubwindowMode         (1L&lt;&lt;15)
#define     GCGraphicsExposures     (1L&lt;&lt;16)
#define     GCClipXOrigin           (1L&lt;&lt;17)
#define     GCClipYOrigin           (1L&lt;&lt;18)
#define     GCClipMask              (1L&lt;&lt;19)
#define     GCDashOffset            (1L&lt;&lt;20)
#define     GCDashList              (1L&lt;&lt;21)
#define     GCArcMode               (1L&lt;&lt;22)
</literallayout>

<literallayout class="monospaced">
<!-- .TA .5i 3i -->
<!-- .ta .5i 3i -->
/* Values */

typedef struct {
     int function;                 /* logical operation */
     unsigned long plane_mask;     /* plane mask */
     unsigned long foreground;     /* foreground pixel */
     unsigned long background;     /* background pixel */
     int line_width;               /* line width (in pixels) */
     int line_style;               /* LineSolid, LineOnOffDash, LineDoubleDash */
     int cap_style;                /* CapNotLast, CapButt, CapRound, CapProjecting */
     int join_style;               /* JoinMiter, JoinRound, JoinBevel */
     int fill_style;               /* FillSolid, FillTiled, FillStippled FillOpaqueStippled*/
     int fill_rule;                /* EvenOddRule, WindingRule */
     int arc_mode;                 /* ArcChord, ArcPieSlice */
     Pixmap tile;                  /* tile pixmap for tiling operations */
     Pixmap stipple;               /* stipple 1 plane pixmap for stippling */
     int ts_x_origin;              /* offset for tile or stipple operations */
     int ts_y_origin
     Font font;                    /* default text font for text operations */
     int subwindow_mode;           /* ClipByChildren, IncludeInferiors */
     Bool graphics_exposures;      /* boolean, should exposures be generated */
     int clip_x_origin;            /* origin for clipping */
     int clip_y_origin;
     Pixmap clip_mask;             /* bitmap clipping; other calls for rects */
     int dash_offset;              /* patterned/dashed line information */
     char dashes;
} XGCValues;
</literallayout>

<para>
<!-- .LP -->
<!-- .eM  -->
The default GC values are:
</para>
<informaltable frame='topbot'>
  <?dbfo keep-together="auto" ?>
  <tgroup cols='2' align='left' colsep='0' rowsep='0'>
  <colspec colname='c1' colwidth='1.0*'/>
  <colspec colname='c2' colwidth='1.0*'/>
  <thead>
    <row rowsep='1'>
      <entry>Component</entry>
      <entry>Default</entry>
    </row>
  </thead>
  <tbody>
    <row>
      <entry>function</entry>
      <entry><symbol>GXcopy</symbol></entry>
    </row>
    <row>
      <entry>plane_mask</entry>
      <entry>All ones</entry>
    </row>
    <row>
      <entry>foreground</entry>
      <entry>0</entry>
    </row>
    <row>
      <entry>background</entry>
      <entry>1</entry>
    </row>
    <row>
      <entry>line_width</entry>
      <entry>0</entry>
    </row>
    <row>
      <entry>line_style</entry>
      <entry><symbol>LineSolid</symbol></entry>
    </row>
    <row>
      <entry>cap_style</entry>
      <entry><symbol>CapButt</symbol></entry>
    </row>
    <row>
      <entry>join_style</entry>
      <entry><symbol>JoinMiter</symbol></entry>
    </row>
    <row>
      <entry>fill_style</entry>
      <entry><symbol>FillSolid</symbol></entry>
    </row>
    <row>
      <entry>fill_rule</entry>
      <entry><symbol>EvenOddRule</symbol></entry>
    </row>
    <row>
      <entry>arc_mode</entry>
      <entry><symbol>ArcPieSlice</symbol></entry>
    </row>
    <row>
      <entry>tile</entry>
      <entry>
      <para>Pixmap of unspecified size filled with foreground pixel</para>
      <para>(that is, client specified pixel if any, else 0)</para>
      <para>(subsequent changes to foreground do not affect this pixmap)</para>
      </entry>
    </row>
    <row>
      <entry>stipple</entry>
      <entry>Pixmap of unspecified size filled with ones</entry>
    </row>
    <row>
      <entry>ts_x_origin</entry>
      <entry>0</entry>
    </row>
    <row>
      <entry>ts_y_origin</entry>
      <entry>0</entry>
    </row>
    <row>
      <entry>font</entry>
      <entry>&lt;implementation dependent&gt;</entry>
    </row>
    <row>
      <entry>subwindow_mode</entry>
      <entry><symbol>ClipByChildren</symbol></entry>
    </row>
    <row>
      <entry>graphics_exposures</entry>
      <entry><symbol>True</symbol></entry>
    </row>
    <row>
      <entry>clip_x_origin</entry>
      <entry>0</entry>
    </row>
    <row>
      <entry>clip_y_origin</entry>
      <entry>0</entry>
    </row>
    <row>
      <entry>clip_mask</entry>
      <entry><symbol>None</symbol></entry>
    </row>
    <row>
      <entry>dash_offset</entry>
      <entry>0</entry>
    </row>
    <row>
      <entry>dashes</entry>
      <entry>4 (that is, the list [4, 4])</entry>
    </row>
  </tbody>
  </tgroup>
</informaltable>

<para>
<!-- .LP -->
Note that foreground and background are not set to any values likely
to be useful in a window.
</para>

<para>
<!-- .LP -->
<indexterm significance="preferred"><primary>Display Functions</primary></indexterm>
<indexterm significance="preferred"><primary>Source</primary></indexterm>
<indexterm significance="preferred"><primary>Destination</primary></indexterm>
The function attributes of a GC are used when you update a section of
a drawable (the destination) with bits from somewhere else (the source).  
The function in a GC defines how the new destination bits are to be
computed from the source bits and the old destination bits.
<symbol>GXcopy</symbol>
is typically the most useful because it will work on a color display,
but special applications may use other functions,
particularly in concert with particular planes of a color display.
The 16 GC functions, defined in 
<filename class="headerfile">&lt;X11/X.h&gt;</filename>,
<indexterm type="file"><primary><filename class="headerfile">X11/X.h</filename></primary></indexterm>
<indexterm><primary>Files</primary><secondary><filename class="headerfile">&lt;X11/X.h&gt;</filename></secondary></indexterm>
<indexterm><primary>Headers</primary><secondary><filename class="headerfile">&lt;X11/X.h&gt;</filename></secondary></indexterm>
are:
</para>
<!-- .\" are listed in Table 5-1 along with the  -->
<!-- .\"the associated hexadecimal code -->
<!-- .\" and operation. -->
<!-- .\".CP T 1 -->
<!-- .\"Display Functions -->
<informaltable frame='topbot'>
  <?dbfo keep-together="auto" ?>
  <tgroup cols='3' align='left' colsep='0' rowsep='0'>
  <colspec colname='c1' colwidth='1.0*'/>
  <colspec colname='c2' colwidth='1.0*'/>
  <colspec colname='c3' colwidth='1.0*'/>
  <thead>
    <row rowsep='1'>
      <entry>Function Name</entry>
      <entry>Value</entry>
      <entry>Operation</entry>
    </row>
  </thead>
  <tbody>
    <row>
      <entry><symbol>GXclear</symbol></entry>
      <entry>0x0</entry>
      <entry>0</entry>
    </row>
    <row>
      <entry><symbol>GXand</symbol></entry>
      <entry>0x1</entry>
      <entry>src AND dst</entry>
    </row>
    <row>
      <entry><symbol>GXandReverse</symbol></entry>
      <entry>0x2</entry>
      <entry>src AND NOT dst</entry>
    </row>
    <row>
      <entry><symbol>GXcopy</symbol></entry>
      <entry>0x3</entry>
      <entry>src</entry>
    </row>
    <row>
      <entry><symbol>GXandInverted</symbol></entry>
      <entry>0x4</entry>
      <entry>(NOT src) AND dst</entry>
    </row>
    <row>
      <entry><symbol>GXnoop</symbol></entry>
      <entry>0x5</entry>
      <entry>dst</entry>
    </row>
    <row>
      <entry><symbol>GXxor</symbol></entry>
      <entry>0x6</entry>
      <entry>src XOR dst</entry>
    </row>
    <row>
      <entry><symbol>GXor</symbol></entry>
      <entry>0x7</entry>
      <entry>src OR dst</entry>
    </row>
    <row>
      <entry><symbol>GXnor</symbol></entry>
      <entry>0x8</entry>
      <entry>(NOT src) AND (NOT dst)</entry>
    </row>
    <row>
      <entry><symbol>GXequiv</symbol></entry>
      <entry>0x9</entry>
      <entry>(NOT src) XOR dst</entry>
    </row>
    <row>
      <entry><symbol>GXinvert</symbol></entry>
      <entry>0xa</entry>
      <entry>NOT dst</entry>
    </row>
    <row>
      <entry><symbol>GXorReverse</symbol></entry>
      <entry>0xb</entry>
      <entry>src OR (NOT dst)</entry>
    </row>
    <row>
      <entry><symbol>GXcopyInverted</symbol></entry>
      <entry>0xc</entry>
      <entry>NOT src</entry>
    </row>
    <row>
      <entry><symbol>GXorInverted</symbol></entry>
      <entry>0xd</entry>
      <entry>(NOT src) OR dst</entry>
    </row>
    <row>
      <entry><symbol>GXnand</symbol></entry>
      <entry>0xe</entry>
      <entry>(NOT src) OR (NOT dst)</entry>
    </row>
    <row>
      <entry><symbol>GXset</symbol></entry>
      <entry>0xf</entry>
      <entry>1</entry>
    </row>
  </tbody>
  </tgroup>
</informaltable>

<para>
<!-- .LP -->
Many graphics operations depend on either pixel values or planes in a GC.
<indexterm><primary>Pixel value</primary></indexterm>
The planes attribute is of type long, and it specifies which planes of the
destination are to be modified, one bit per plane.
<indexterm><primary>Plane</primary><secondary>mask</secondary></indexterm>
A monochrome display has only one plane and
will be the least significant bit of the word.
As planes are added to the display hardware, they will occupy more
significant bits in the plane mask.
</para>
<para>
<!-- .LP -->
In graphics operations, given a source and destination pixel, 
the result is computed bitwise on corresponding bits of the pixels.
That is, a Boolean operation is performed in each bit plane.  
The plane_mask restricts the operation to a subset of planes.
A macro constant
<symbol>AllPlanes</symbol>
can be used to refer to all planes of the screen simultaneously.
The result is computed by the following:
</para>
<para>
<!-- .LP -->
<literallayout class="monospaced">
((src FUNC dst) AND plane-mask) OR (dst AND (NOT plane-mask))
</literallayout>
</para>
<para>
<!-- .LP -->
Range checking is not performed on the values for foreground,
background, or plane_mask.
They are simply truncated to the appropriate
number of bits.
The line-width is measured in pixels and either can be greater than or equal to
one (wide line) or can be the special value zero (thin line).
</para>
<para>
<!-- .LP -->
Wide lines are drawn centered on the path described by the graphics request.
Unless otherwise specified by the join-style or cap-style,
the bounding box of a wide line with endpoints [x1, y1], [x2, y2] and
width w is a rectangle with vertices at the following real coordinates:
</para>
<para>
<!-- .LP -->
<literallayout class="monospaced">
<!-- .TA .5i 2.5i -->
<!-- .ta .5i 2.5i -->
[x1-(w*sn/2), y1+(w*cs/2)], [x1+(w*sn/2), y1-(w*cs/2)],
[x2-(w*sn/2), y2+(w*cs/2)], [x2+(w*sn/2), y2-(w*cs/2)]
</literallayout>
</para>
<para>
<!-- .LP -->
Here sn is the sine of the angle of the line,
and cs is the cosine of the angle of the line.
A pixel is part of the line and so is drawn
if the center of the pixel is fully inside the bounding box
(which is viewed as having infinitely thin edges).
If the center of the pixel is exactly on the bounding box,
it is part of the line if and only if the interior is immediately to its right
(x increasing direction).
Pixels with centers on a horizontal edge are a special case and are part of
the line if and only if the interior or the boundary is immediately below 
(y increasing direction) and the interior or the boundary is immediately
to the right (x increasing direction).
</para>
<para>
<!-- .LP -->
Thin lines (zero line-width) are one-pixel-wide lines drawn using an
unspecified, device-dependent algorithm.
There are only two constraints on this algorithm. 
</para>
<itemizedlist>
  <listitem>
    <para>
If a line is drawn unclipped from [x1,y1] to [x2,y2] and
if another line is drawn unclipped from [x1+dx,y1+dy] to [x2+dx,y2+dy],
a point [x,y] is touched by drawing the first line 
if and only if the point [x+dx,y+dy] is touched by drawing the second line.
    </para>
  </listitem>
  <listitem>
    <para>
The effective set of points comprising a line cannot be affected by clipping.
That is, a point is touched in a clipped line if and only if the point 
lies inside the clipping region and the point would be touched
by the line when drawn unclipped.
    </para>
  </listitem>
</itemizedlist>
<para>
<!-- .LP -->
A wide line drawn from [x1,y1] to [x2,y2] always draws the same pixels 
as a wide line drawn from [x2,y2] to [x1,y1], not counting cap-style 
and join-style.
It is recommended that this property be true for thin lines, 
but this is not required.
A line-width of zero may differ from a line-width of one in which pixels are
drawn.
This permits the use of many manufacturers' line drawing hardware,
which may run many times faster than the more precisely specified
wide lines.
</para>
<para>
<!-- .LP -->
In general, 
drawing a thin line will be faster than drawing a wide line of width one.
However, because of their different drawing algorithms,
thin lines may not mix well aesthetically with wide lines.
If it is desirable to obtain precise and uniform results across all displays,
a client should always use a line-width of one rather than a line-width of zero.
</para>
<para>
<!-- .LP -->
The line-style defines which sections of a line are drawn:
</para>

<variablelist>
  <varlistentry>
    <term><symbol>LineSolid</symbol></term>
    <listitem>
      <para>The full path of the line is drawn.</para>
    </listitem>
  </varlistentry>
  <varlistentry>
    <term><symbol>LineDoubleDash</symbol></term>
    <listitem>
      <para>
The full path of the line is drawn,
but the even dashes are filled differently
from the odd dashes (see fill-style) with <!-- xref -->
<symbol>CapButt</symbol>
style used where even and odd dashes meet.
      </para>
    </listitem>
  </varlistentry>
  <varlistentry>
    <term><symbol>LineOnOffDash</symbol></term>
    <listitem>
      <para>
Only the even dashes are drawn,
and cap-style applies to 
all internal ends of the individual dashes,
except
<symbol>CapNotLast</symbol>
is treated as
<symbol>CapButt</symbol>.
      </para>
    </listitem>
  </varlistentry>
</variablelist>
<para>
The cap-style defines how the endpoints of a path are drawn:
</para>

<variablelist>
  <varlistentry>
    <term><symbol>CapNotLast</symbol></term>
    <listitem>
      <para>
This is equivalent to
<symbol>CapButt</symbol>
except that for a line-width of zero the final endpoint is not drawn.
     </para>
    </listitem>
  </varlistentry>

  <varlistentry>
    <term><symbol>CapButt</symbol></term>
    <listitem>
      <para>
The line is square at the endpoint (perpendicular to the slope of the line)
with no projection beyond.
      </para>
    </listitem>
  </varlistentry>
  <varlistentry>
    <term><symbol>CapRound</symbol></term>
    <listitem>
      <para>
The line has a circular arc with the diameter equal to the line-width,
centered on the endpoint.
(This is equivalent to 
<symbol>CapButt</symbol>
for line-width of zero).
      </para>
    </listitem>
  </varlistentry>
  <varlistentry>
    <term><symbol>CapProjecting</symbol></term>
    <listitem>
      <para>
The line is square at the end, but the path continues beyond the endpoint
for a distance equal to half the line-width.
(This is equivalent to
<symbol>CapButt</symbol>
for line-width of zero).
      </para>
    </listitem>
  </varlistentry>
</variablelist>

<para>
The join-style defines how corners are drawn for wide lines:
</para>

<variablelist>
  <varlistentry>
    <term><symbol>JoinMiter</symbol></term>
    <listitem>
      <para>
The outer edges of two lines extend to meet at an angle.
However, if the angle is less than 11 degrees,
then a
<symbol>JoinBevel</symbol>
join-style is used instead.
      </para>
    </listitem>
  </varlistentry>
  <varlistentry>
    <term><symbol>JoinRound</symbol></term>
    <listitem>
      <para>
The corner is a circular arc with the diameter equal to the line-width,
centered on the joinpoint.
      </para>
    </listitem>
  </varlistentry>
  <varlistentry>
    <term><symbol>JoinBevel</symbol></term>
    <listitem>
      <para>
The corner has
<symbol>CapButt</symbol>
endpoint styles with the triangular notch filled.
      </para>
    </listitem>
  </varlistentry>
</variablelist>


<para>
<!-- .LP -->
For a line with coincident endpoints (x1=x2, y1=y2), 
when the cap-style is applied to both endpoints, 
the semantics depends on the line-width and the cap-style:
</para>

<informaltable frame='none'>
  <?dbfo keep-together="always" ?>
  <tgroup cols='3' align='left' colsep='0' rowsep='0'>
  <colspec colname='c1' colwidth='1.0*'/>
  <colspec colname='c2' colwidth='1.0*'/>
  <colspec colname='c3' colwidth='3.0*'/>
  <tbody>
    <row>
      <entry><symbol>CapNotLast</symbol></entry>
      <entry>thin</entry>
      <entry>The results are device dependent,
      but the desired effect is that nothing is drawn.</entry>
    </row>
    <row>
      <entry><symbol>CapButt</symbol></entry>
      <entry>thin</entry>
      <entry>The results are device dependent,
      but the desired effect is that a single pixel is drawn.</entry>
    </row>
    <row>
      <entry><symbol>CapRound</symbol></entry>
      <entry>thin</entry>
      <entry>The results are the same as for
      <symbol>CapButt</symbol> /thin.</entry>
    </row>
    <row>
      <entry><symbol>CapProjecting</symbol></entry>
      <entry>thin</entry>
      <entry>The results are the same as for
      <symbol>CapButt</symbol> /thin.</entry>
    </row>
    <row>
      <entry><symbol>CapButt</symbol></entry>
      <entry>wide</entry>
      <entry>Nothing is drawn.</entry>
    </row>
    <row>
      <entry><symbol>CapRound</symbol></entry>
      <entry>wide</entry>
      <entry>The closed path is a circle, centered at the endpoint, and
      with the diameter equal to the line-width.</entry>
    </row>
    <row>
      <entry><symbol>CapProjecting</symbol></entry>
      <entry>wide</entry>
      <entry>The closed path is a square, aligned with the coordinate axes, centered at the
      endpoint, and with the sides equal to the line-width.</entry>
    </row>
  </tbody>
  </tgroup>
</informaltable>

<para>
<!-- .LP -->
For a line with coincident endpoints (x1=x2, y1=y2), 
when the join-style is applied at one or both endpoints, 
the effect is as if the line was removed from the overall path.
However, if the total path consists of or is reduced to a single point joined
with itself, the effect is the same as when the cap-style is applied at both
endpoints.
</para>
<para>
<!-- .LP -->
The tile/stipple represents an infinite two-dimensional plane,
with the tile/stipple replicated in all dimensions.
When that plane is superimposed on the drawable
for use in a graphics operation, the upper-left corner
of some instance of the tile/stipple is at the coordinates within
the drawable specified by the tile/stipple origin.
The tile/stipple and clip origins are interpreted relative to the
origin of whatever destination drawable is specified in a graphics
request.
The tile pixmap must have the same root and depth as the GC,
or a
<errorname>BadMatch</errorname>
error results.
The stipple pixmap must have depth one and must have the same root as the
GC, or a 
<errorname>BadMatch</errorname>
error results.  
For stipple operations where the fill-style is
<symbol>FillStippled</symbol>
but not 
<symbol>FillOpaqueStippled</symbol>,
the stipple pattern is tiled in a
single plane and acts as an additional clip mask to be ANDed with the clip-mask.
Although some sizes may be faster to use than others,
any size pixmap can be used for tiling or stippling.
</para>

<para>
<!-- .LP -->
The fill-style defines the contents of the source for line, text, and
fill requests.  
For all text and fill requests (for example,
<xref linkend='XDrawText' xrefstyle='select: title'/>,
<xref linkend='XDrawText16' xrefstyle='select: title'/>,
<xref linkend='XFillRectangle' xrefstyle='select: title'/>,
<xref linkend='XFillPolygon' xrefstyle='select: title'/>,
and
<xref linkend='XFillArc' xrefstyle='select: title'/>);
for line requests 
with line-style 
<symbol>LineSolid</symbol>
(for example,
<xref linkend='XDrawLine' xrefstyle='select: title'/>,
<xref linkend='XDrawSegments' xrefstyle='select: title'/>,
<xref linkend='XDrawRectangle' xrefstyle='select: title'/>,
<xref linkend='XDrawArc' xrefstyle='select: title'/>);
and for the even dashes for line requests with line-style 
<symbol>LineOnOffDash</symbol>
or 
<symbol>LineDoubleDash</symbol>,
the following apply:
</para>

<informaltable frame='none'>
  <?dbfo keep-together="always" ?>
  <tgroup cols='2' align='left' colsep='0' rowsep='0'>
  <colspec colname='c1' colwidth='1.0*'/>
  <colspec colname='c2' colwidth='2.0*'/>
  <tbody>
    <row>
      <entry><symbol>FillSolid</symbol></entry>
      <entry>Foreground</entry>
    </row>
    <row>
      <entry><symbol>FillTiled</symbol></entry>
      <entry>Tile</entry>
    </row>
    <row>
      <entry><symbol>FillOpaqueStippled</symbol></entry>
      <entry>A tile with the same width and height as stipple,
      but with background everywhere stipple has a zero
      and with foreground everywhere stipple has a one</entry>
    </row>
    <row>
      <entry><symbol>FillStippled</symbol></entry>
      <entry>Foreground masked by stipple</entry>
    </row>
  </tbody>
  </tgroup>
</informaltable>

<para>
<!-- .LP -->
When drawing lines with line-style
<symbol>LineDoubleDash</symbol>,
the odd dashes are controlled by the fill-style in the following manner:
</para>

<informaltable frame='none'>
  <?dbfo keep-together="always" ?>
  <tgroup cols='2' align='left' colsep='0' rowsep='0'>
  <colspec colname='c1' colwidth='1.0*'/>
  <colspec colname='c2' colwidth='2.0*'/>
  <tbody>
    <row>
      <entry><symbol>FillSolid</symbol></entry>
      <entry>Background</entry>
    </row>
    <row>
      <entry><symbol>FillTiled</symbol></entry>
      <entry>Same as for even dashes</entry>
    </row>
    <row>
      <entry><symbol>FillOpaqueStippled</symbol></entry>
      <entry>Same as for even dashes</entry>
    </row>
    <row>
      <entry><symbol>FillStippled</symbol></entry>
      <entry>Background masked by stipple</entry>
    </row>
  </tbody>
  </tgroup>
</informaltable>

<para>
<!-- .LP -->
Storing a pixmap in a GC might or might not result in a copy
being made.
If the pixmap is later used as the destination for a graphics request,
the change might or might not be reflected in the GC.
If the pixmap is used simultaneously in a graphics request both as
a destination and as a tile or stipple,
the results are undefined.
</para>
<para>
<!-- .LP -->
For optimum performance,
you should draw as much as possible with the same GC 
(without changing its components).
The costs of changing GC components relative to using different GCs
depend on the display hardware and the server implementation.
It is quite likely that some amount of GC information will be
cached in display hardware and that such hardware can only cache a small number
of GCs.
</para>
<para>
<!-- .LP -->
The dashes value is actually a simplified form of the
more general patterns that can be set with 
<xref linkend='XSetDashes' xrefstyle='select: title'/>.
Specifying a
value of N is equivalent to specifying the two-element list [N, N] in 
<xref linkend='XSetDashes' xrefstyle='select: title'/>.
The value must be nonzero,
or a
<errorname>BadValue</errorname>
error results.
</para>
<para>
<!-- .LP -->
The clip-mask restricts writes to the destination drawable.  
If the clip-mask is set to a pixmap,
it must have depth one and have the same root as the GC,
or a
<errorname>BadMatch</errorname>
error results.
If clip-mask is set to
<symbol>None</symbol>,
the pixels are always drawn regardless of the clip origin.
The clip-mask also can be set by calling the
<xref linkend='XSetClipRectangles' xrefstyle='select: title'/>
or
<xref linkend='XSetRegion' xrefstyle='select: title'/>
functions.
Only pixels where the clip-mask has a bit set to 1 are drawn.  
Pixels are not drawn outside the area covered by the clip-mask 
or where the clip-mask has a bit set to 0.
The clip-mask affects all graphics requests.
The clip-mask does not clip sources.
The clip-mask origin is interpreted relative to the origin of whatever
destination drawable is specified in a graphics request.
</para>
<para>
<!-- .LP -->
You can set the subwindow-mode to
<symbol>ClipByChildren</symbol>
or
<symbol>IncludeInferiors</symbol>.
For 
<symbol>ClipByChildren</symbol>,
both source and destination windows are
additionally clipped by all viewable 
<symbol>InputOutput</symbol>
children.  
For 
<symbol>IncludeInferiors</symbol>,
neither source nor destination window is clipped by inferiors. 
This will result in including subwindow contents in the source
and drawing through subwindow boundaries of the destination.
The use of 
<symbol>IncludeInferiors</symbol>
on a window of one depth with mapped
inferiors of differing depth is not illegal, but the semantics are
undefined by the core protocol.
</para>
<para>
<!-- .LP -->
The fill-rule defines what pixels are inside (drawn) for
paths given in 
<xref linkend='XFillPolygon' xrefstyle='select: title'/>
requests and can be set to 
<symbol>EvenOddRule</symbol>
or
<symbol>WindingRule</symbol>.
For
<symbol>EvenOddRule</symbol>,
a point is inside if
an infinite ray with the point as origin crosses the path an odd number
of times.  
For 
<symbol>WindingRule</symbol>,
a point is inside if an infinite ray with the
point as origin crosses an unequal number of clockwise and
counterclockwise directed path segments.
A clockwise directed path segment is one that crosses the ray from left to
right as observed from the point.
A counterclockwise segment is one that crosses the ray from right to left
as observed from the point.
The case where a directed line segment is coincident with the ray is
uninteresting because you can simply choose a different ray that is not
coincident with a segment.
</para>
<para>
<!-- .LP -->
For both 
<symbol>EvenOddRule</symbol>
and
<symbol>WindingRule</symbol>,
a point is infinitely small, 
and the path is an infinitely thin line.  
A pixel is inside if the center point of the pixel is inside
and the center point is not on the boundary.  
If the center point is on the boundary,
the pixel is inside if and only if the polygon interior is immediately to
its right (x increasing direction).  
Pixels with centers on a horizontal edge are a special case 
and are inside if and only if the polygon interior is immediately below 
(y increasing direction).
</para>
<para>
<!-- .LP -->
The arc-mode controls filling in the 
<xref linkend='XFillArcs' xrefstyle='select: title'/>
function and can be set to
<symbol>ArcPieSlice</symbol>
or
<symbol>ArcChord</symbol>.
For
<symbol>ArcPieSlice</symbol>,
the arcs are pie-slice filled.
For
<symbol>ArcChord</symbol>,
the arcs are chord filled.
</para>
<para>
<!-- .LP -->
The graphics-exposure flag controls 
<symbol>GraphicsExpose</symbol>
event generation
for 
<xref linkend='XCopyArea' xrefstyle='select: title'/>
and 
<xref linkend='XCopyPlane' xrefstyle='select: title'/>
requests (and any similar requests defined by extensions).
</para>
<para>
<!-- .LP -->
<!-- .sp -->
To create a new GC that is usable on a given screen with a 
depth of drawable, use
<xref linkend='XCreateGC' xrefstyle='select: title'/>.
</para>
<indexterm><primary>Graphics context</primary><secondary>initializing</secondary></indexterm>
<indexterm significance="preferred"><primary>XCreateGC</primary></indexterm>
<!-- .sM -->
<funcsynopsis id='XCreateGC'>
<funcprototype>
  <funcdef>GC <function>XCreateGC</function></funcdef>
  <paramdef>Display <parameter> *display</parameter></paramdef>
  <paramdef>Drawable<parameter> d</parameter></paramdef>
  <paramdef>unsignedlong<parameter> valuemask</parameter></paramdef>
  <paramdef>XGCValues *<parameter>values</parameter></paramdef>
</funcprototype>
</funcsynopsis>
<!-- .FN -->
<variablelist>
  <varlistentry>
    <term>
      <emphasis remap='I'>display</emphasis>
    </term>
    <listitem>
      <para>
Specifies the connection to the X server.
      </para>
    </listitem>
  </varlistentry>
  <varlistentry>
    <term>
      <emphasis remap='I'>d</emphasis>
    </term>
    <listitem>
      <para>
Specifies the drawable. 
      </para>
    </listitem>
  </varlistentry>
  <varlistentry>
    <term>
      <emphasis remap='I'>valuemask</emphasis>
    </term>
    <listitem>
      <para>
Specifies which components in the GC are to be set using the information in
the specified values structure.
This argument is the bitwise inclusive OR of zero or more of the valid
GC component mask bits.
      </para>
    </listitem>
  </varlistentry>
  <varlistentry>
    <term>
      <emphasis remap='I'>values</emphasis>
    </term>
    <listitem>
      <para>
Specifies any values as specified by the valuemask.
    </para>
  </listitem>
  </varlistentry>
</variablelist>
<para>
<!-- .LP -->
<!-- .eM -->
The
<xref linkend='XCreateGC' xrefstyle='select: title'/>
function creates a graphics context and returns a GC.
The GC can be used with any destination drawable having the same root
and depth as the specified drawable.
Use with other drawables results in a
<errorname>BadMatch</errorname>
error.
</para>
<para>
<!-- .LP -->
<xref linkend='XCreateGC' xrefstyle='select: title'/>
can generate
<errorname>BadAlloc</errorname>,
<errorname>BadDrawable</errorname>,
<errorname>BadFont</errorname>,
<errorname>BadMatch</errorname>,
<errorname>BadPixmap</errorname>,
and
<errorname>BadValue</errorname>
errors.
</para>
<para>
<!-- .LP -->
<!-- .sp -->
To copy components from a source GC to a destination GC, use
<xref linkend='XCopyGC' xrefstyle='select: title'/>.
</para>
<indexterm significance="preferred"><primary>XCopyGC</primary></indexterm>
<!-- .sM -->
<funcsynopsis id='XCopyGC'>
<funcprototype>
  <funcdef><function>XCopyGC</function></funcdef>
  <paramdef>Display<parameter> *display</parameter></paramdef>
  <paramdef>GCsrc,<parameter> dest</parameter></paramdef>
  <paramdef>unsignedlong<parameter> valuemask</parameter></paramdef>
</funcprototype>
</funcsynopsis>
<!-- .FN -->
<variablelist>
  <varlistentry>
    <term>
      <emphasis remap='I'>display</emphasis>
    </term>
    <listitem>
      <para>
Specifies the connection to the X server.
      </para>
    </listitem>
  </varlistentry>
  <varlistentry>
    <term>
      <emphasis remap='I'>src</emphasis>
    </term>
    <listitem>
      <para>
Specifies the components of the source GC.
      </para>
    </listitem>
  </varlistentry>
  <varlistentry>
    <term>
      <emphasis remap='I'>valuemask</emphasis>
    </term>
    <listitem>
      <para>
Specifies which components in the GC are to be copied to the destination
GC.
This argument is the bitwise inclusive OR of zero or more of the valid
GC component mask bits.
      </para>
    </listitem>
  </varlistentry>
  <varlistentry>
    <term>
      <emphasis remap='I'>dest</emphasis>
    </term>
    <listitem>
      <para>
Specifies the destination GC.
    </para>
  </listitem>
  </varlistentry>
</variablelist>
<para>
<!-- .LP -->
<!-- .eM  -->
The
<xref linkend='XCopyGC' xrefstyle='select: title'/>
function copies the specified components from the source GC
to the destination GC.
The source and destination GCs must have the same root and depth,
or a
<errorname>BadMatch</errorname>
error results.
The valuemask specifies which component to copy, as for
<xref linkend='XCreateGC' xrefstyle='select: title'/>.
</para>
<para>
<!-- .LP -->
<xref linkend='XCopyGC' xrefstyle='select: title'/>
can generate
<errorname>BadAlloc</errorname>,
<errorname>BadGC</errorname>,
and
<errorname>BadMatch</errorname>
errors.
</para>
<para>
<!-- .LP -->
<!-- .sp -->
To change the components in a given GC, use
<xref linkend='XChangeGC' xrefstyle='select: title'/>.
</para>
<indexterm significance="preferred"><primary>XChangeGC</primary></indexterm>
<!-- .sM -->
<funcsynopsis id='XChangeGC'>
<funcprototype>
  <funcdef><function>XChangeGC</function></funcdef>
  <paramdef>Display<parameter> *display</parameter></paramdef>
  <paramdef>GC<parameter> gc</parameter></paramdef>
  <paramdef>unsignedlong<parameter> valuemask</parameter></paramdef>
  <paramdef>XGCValues<parameter> *values</parameter></paramdef>
</funcprototype>
</funcsynopsis>
<!-- .FN -->
<variablelist>
  <varlistentry>
    <term>
      <emphasis remap='I'>display</emphasis>
    </term>
    <listitem>
      <para>
Specifies the connection to the X server.
      </para>
    </listitem>
  </varlistentry>
  <varlistentry>
    <term>
      <emphasis remap='I'>gc</emphasis>
    </term>
    <listitem>
      <para>
Specifies the GC.
      </para>
    </listitem>
  </varlistentry>
  <varlistentry>
    <term>
      <emphasis remap='I'>valuemask</emphasis>
    </term>
    <listitem>
      <para>
Specifies which components in the GC are to be changed using information in
the specified values structure.
This argument is the bitwise inclusive OR of zero or more of the valid
GC component mask bits.
      </para>
    </listitem>
  </varlistentry>
  <varlistentry>
    <term>
      <emphasis remap='I'>values</emphasis>
    </term>
    <listitem>
      <para>
Specifies any values as specified by the valuemask.
    </para>
  </listitem>
  </varlistentry>
</variablelist>
<para>
<!-- .LP -->
<!-- .eM -->
The
<xref linkend='XChangeGC' xrefstyle='select: title'/>
function changes the components specified by valuemask for
the specified GC.
The values argument contains the values to be set.
The values and restrictions are the same as for 
<xref linkend='XCreateGC' xrefstyle='select: title'/>.
Changing the clip-mask overrides any previous 
<xref linkend='XSetClipRectangles' xrefstyle='select: title'/>
request on the context. 
Changing the dash-offset or dash-list
overrides any previous 
<xref linkend='XSetDashes' xrefstyle='select: title'/>
request on the context.
The order in which components are verified and altered is server dependent.
If an error is generated, a subset of the components may have been altered.
</para>
<para>
<!-- .LP -->
<xref linkend='XChangeGC' xrefstyle='select: title'/>
can generate
<errorname>BadAlloc</errorname>,
<errorname>BadFont</errorname>,
<errorname>BadGC</errorname>,
<errorname>BadMatch</errorname>,
<errorname>BadPixmap</errorname>,
and
<errorname>BadValue</errorname>
errors.
</para>
<para>
<!-- .LP -->
<!-- .sp -->
To obtain components of a given GC, use
<xref linkend='XGetGCValues' xrefstyle='select: title'/>.
</para>
<indexterm significance="preferred"><primary>XGetGCValues</primary></indexterm>
<!-- .sM -->
<funcsynopsis id='XGetGCValues'>
<funcprototype>
  <funcdef>Status <function>XGetGCValues</function></funcdef>
  <paramdef>Display<parameter> *display</parameter></paramdef>
  <paramdef>GC<parameter> gc</parameter></paramdef>
  <paramdef>unsignedlong<parameter> valuemask</parameter></paramdef>
  <paramdef>XGCValues<parameter> *values_return</parameter></paramdef>
</funcprototype>
</funcsynopsis>
<!-- .FN -->
<variablelist>
  <varlistentry>
    <term>
      <emphasis remap='I'>display</emphasis>
    </term>
    <listitem>
      <para>
Specifies the connection to the X server.
      </para>
    </listitem>
  </varlistentry>
  <varlistentry>
    <term>
      <emphasis remap='I'>gc</emphasis>
    </term>
    <listitem>
      <para>
Specifies the GC.
      </para>
    </listitem>
  </varlistentry>
  <varlistentry>
    <term>
      <emphasis remap='I'>valuemask</emphasis>
    </term>
    <listitem>
      <para>
Specifies which components in the GC are to be returned in the
values_return argument.
This argument is the bitwise inclusive OR of zero or more of the valid
GC component mask bits.
      </para>
    </listitem>
  </varlistentry>
  <varlistentry>
    <term>
      <emphasis remap='I'>values_return</emphasis>
    </term>
    <listitem>
      <para>
Returns the GC values in the specified
<structname>XGCValues</structname>
structure.
    </para>
  </listitem>
  </varlistentry>
</variablelist>
<para>
<!-- .LP -->
<!-- .eM -->
The
<xref linkend='XGetGCValues' xrefstyle='select: title'/>
function returns the components specified by valuemask for the specified GC.
If the valuemask contains a valid set of GC mask bits
(<symbol>GCFunction</symbol>,
<symbol>GCPlaneMask</symbol>,
<symbol>GCForeground</symbol>,
<symbol>GCBackground</symbol>,
<symbol>GCLineWidth</symbol>,
<symbol>GCLineStyle</symbol>,
<symbol>GCCapStyle</symbol>,
<symbol>GCJoinStyle</symbol>,
<symbol>GCFillStyle</symbol>,
<symbol>GCFillRule</symbol>,
<symbol>GCTile</symbol>,
<symbol>GCStipple</symbol>,
<symbol>GCTileStipXOrigin</symbol>,
<symbol>GCTileStipYOrigin</symbol>,
<symbol>GCFont</symbol>,
<symbol>GCSubwindowMode</symbol>,
<symbol>GCGraphicsExposures</symbol>,
<symbol>GCClipXOrigin</symbol>,
<symbol>GCClipYOrigin</symbol>,
<symbol>GCDashOffset</symbol>,
or
<symbol>GCArcMode</symbol>)
and no error occurs,
<xref linkend='XGetGCValues' xrefstyle='select: title'/>
sets the requested components in values_return and returns a nonzero status.
Otherwise, it returns a zero status.
Note that the clip-mask and dash-list (represented by the
<symbol>GCClipMask</symbol>
and 
<symbol>GCDashList</symbol>
bits, respectively, in the valuemask)
cannot be requested.
Also note that an invalid resource ID (with one or more of the three
most significant bits set to 1) will be returned for
<symbol>GCFont</symbol>,
<symbol>GCTile</symbol>,
and
<symbol>GCStipple</symbol>
if the component has never been explicitly set by the client.
</para>
<para>
<!-- .LP -->
<!-- .sp -->
To free a given GC, use
<xref linkend='XFreeGC' xrefstyle='select: title'/>.
</para>
<indexterm significance="preferred"><primary>XFreeGC</primary></indexterm>
<!-- .sM -->
<funcsynopsis id='XFreeGC'>
<funcprototype>
  <funcdef><function>XFreeGC</function></funcdef>
  <paramdef>Display<parameter> *display</parameter></paramdef>
  <paramdef>GC<parameter> gc</parameter></paramdef>
</funcprototype>
</funcsynopsis>
<!-- .FN -->
<variablelist>
  <varlistentry>
    <term>
      <emphasis remap='I'>display</emphasis>
    </term>
    <listitem>
      <para>
Specifies the connection to the X server.
      </para>
    </listitem>
  </varlistentry>
  <varlistentry>
    <term>
      <emphasis remap='I'>gc</emphasis>
    </term>
    <listitem>
      <para>
Specifies the GC.
    </para>
  </listitem>
  </varlistentry>
</variablelist>
<para>
<!-- .LP -->
<!-- .eM -->
The
<xref linkend='XFreeGC' xrefstyle='select: title'/>
function destroys the specified GC as well as all the associated storage.
</para>
<para>
<!-- .LP -->
<xref linkend='XFreeGC' xrefstyle='select: title'/>
can generate a
<errorname>BadGC</errorname>
error.
</para>
<para>
<!-- .LP -->
<!-- .sp -->
To obtain the 
<type>GContext</type>
resource ID for a given GC, use 
<xref linkend='XGContextFromGC' xrefstyle='select: title'/>.
</para>
<indexterm significance="preferred"><primary>XGContextFromGC</primary></indexterm>
<!-- .sM -->
<funcsynopsis id='XGContextFromGC'>
<funcprototype>
  <funcdef>GContext <function>XGContextFromGC</function></funcdef>
  <paramdef>GC<parameter> gc</parameter></paramdef>
</funcprototype>
</funcsynopsis>
<!-- .FN -->
<variablelist>
  <varlistentry>
    <term>
      <emphasis remap='I'>gc</emphasis>
    </term>
    <listitem>
      <para>
Specifies the GC for which you want the resource ID.
    </para>
  </listitem>
  </varlistentry>
</variablelist>
<para>
<!-- .LP -->
<!-- .eM -->
<!-- .sp -->
Xlib usually defers sending changes to the components of a GC to the server
until a graphics function is actually called with that GC.
This permits batching of component changes into a single server request.
In some circumstances, however, it may be necessary for the client
to explicitly force sending the changes to the server.
An example might be when a protocol extension uses the GC indirectly,
in such a way that the extension interface cannot know what GC will be used.
To force sending GC component changes, use
<xref linkend='XFlushGC' xrefstyle='select: title'/>.
</para>
<indexterm significance="preferred"><primary>XFlushGC</primary></indexterm>
<!-- .sM -->
<funcsynopsis id='XFlushGC'>
<funcprototype>
  <funcdef>void <function>XFlushGC</function></funcdef>
  <paramdef>Display<parameter> *display</parameter></paramdef>
  <paramdef>GC<parameter> gc</parameter></paramdef>
</funcprototype>
</funcsynopsis>
<!-- .FN -->
<variablelist>
  <varlistentry>
    <term>
      <emphasis remap='I'>display</emphasis>
    </term>
    <listitem>
      <para>
Specifies the connection to the X server.
      </para>
    </listitem>
  </varlistentry>
  <varlistentry>
    <term>
      <emphasis remap='I'>gc</emphasis>
    </term>
    <listitem>
      <para>
Specifies the GC.
    </para>
  </listitem>
  </varlistentry>
</variablelist>
<para>
<!-- .LP -->
<!-- .eM -->
</para>
</sect1>
<sect1 id="Using_Graphics_Context_Convenience_Routines">
<title>Using Graphics Context Convenience Routines</title>
<!-- .XS -->
<!-- (SN Using Graphics Context Convenience Routines  -->
<!-- .XE -->
<para>
<!-- .LP -->
This section discusses how to set the:
</para>
<itemizedlist>
  <listitem>
    <para>
Foreground, background, plane mask, or function components
    </para>
  </listitem>
  <listitem>
    <para>
Line attributes and dashes components
    </para>
  </listitem>
  <listitem>
    <para>
Fill style and fill rule components
    </para>
  </listitem>
  <listitem>
    <para>
Fill tile and stipple components
    </para>
  </listitem>
  <listitem>
    <para>
Font component
    </para>
  </listitem>
  <listitem>
    <para>
Clip region component
    </para>
  </listitem>
  <listitem>
    <para>
Arc mode, subwindow mode, and graphics exposure components
    </para>
  </listitem>
</itemizedlist>
<sect2 id="Setting_the_Foreground_Background_Function_or_Plane_Mask">
<title>Setting the Foreground, Background, Function, or Plane Mask</title>
<!-- .XS -->
<!-- (SN Setting the Foreground, Background, Function, or Plane Mask -->
<!-- .XE -->
<para>
<!-- .LP -->
To set the foreground, background, plane mask, and function components
for a given GC, use
<xref linkend='XSetState' xrefstyle='select: title'/>.
</para>
<indexterm significance="preferred"><primary>XSetState</primary></indexterm>
<!-- .sM -->
<funcsynopsis id='XSetState'>
<funcprototype>
  <funcdef><function>XSetState</function></funcdef>
  <paramdef>Display<parameter> *display</parameter></paramdef>
  <paramdef>GC<parameter> gc</parameter></paramdef>
  <paramdef>unsignedlongforeground,<parameter> background</parameter></paramdef>
  <paramdef>int<parameter> function</parameter></paramdef>
  <paramdef>unsignedlong<parameter> plane_mask</parameter></paramdef>
</funcprototype>
</funcsynopsis>
<!-- .FN -->
<variablelist>
  <varlistentry>
    <term>
      <emphasis remap='I'>display</emphasis>
    </term>
    <listitem>
      <para>
Specifies the connection to the X server.
      </para>
    </listitem>
  </varlistentry>
  <varlistentry>
    <term>
      <emphasis remap='I'>gc</emphasis>
    </term>
    <listitem>
      <para>
Specifies the GC.
      </para>
    </listitem>
  </varlistentry>
  <varlistentry>
    <term>
      <emphasis remap='I'>foreground</emphasis>
    </term>
    <listitem>
      <para>
Specifies the foreground you want to set for the specified GC.
      </para>
    </listitem>
  </varlistentry>
  <varlistentry>
    <term>
      <emphasis remap='I'>background</emphasis>
    </term>
    <listitem>
      <para>
Specifies the background you want to set for the specified GC.
      </para>
    </listitem>
  </varlistentry>
  <varlistentry>
    <term>
      <emphasis remap='I'>function</emphasis>
    </term>
    <listitem>
      <para>
Specifies the function you want to set for the specified GC.
      </para>
    </listitem>
  </varlistentry>
  <varlistentry>
    <term>
      <emphasis remap='I'>plane_mask</emphasis>
    </term>
    <listitem>
      <para>
Specifies the plane mask.
<!-- .\" *** JIM: NEED MORE INFO FOR THIS. *** -->
    </para>
  </listitem>
  </varlistentry>
</variablelist>
<para>
<!-- .LP -->
<!-- .eM -->
<xref linkend='XSetState' xrefstyle='select: title'/>
can generate
<errorname>BadAlloc</errorname>,
<errorname>BadGC</errorname>,
and
<errorname>BadValue</errorname>
errors.
</para>
<para>
<!-- .LP -->
<!-- .sp -->
To set the foreground of a given GC, use
<xref linkend='XSetForeground' xrefstyle='select: title'/>.
</para>
<indexterm significance="preferred"><primary>XSetForeground</primary></indexterm>
<!-- .sM -->
<funcsynopsis id='XSetForeground'>
<funcprototype>
  <funcdef><function>XSetForeground</function></funcdef>
  <paramdef>Display<parameter> *display</parameter></paramdef>
  <paramdef>GC<parameter> gc</parameter></paramdef>
  <paramdef>unsignedlong<parameter> foreground</parameter></paramdef>
</funcprototype>
</funcsynopsis>
<!-- .FN -->
<variablelist>
  <varlistentry>
    <term>
      <emphasis remap='I'>display</emphasis>
    </term>
    <listitem>
      <para>
Specifies the connection to the X server.
      </para>
    </listitem>
  </varlistentry>
  <varlistentry>
    <term>
      <emphasis remap='I'>gc</emphasis>
    </term>
    <listitem>
      <para>
Specifies the GC.
      </para>
    </listitem>
  </varlistentry>
  <varlistentry>
    <term>
      <emphasis remap='I'>foreground</emphasis>
    </term>
    <listitem>
      <para>
Specifies the foreground you want to set for the specified GC.
    </para>
  </listitem>
  </varlistentry>
</variablelist>
<para>
<!-- .LP -->
<!-- .eM -->
<xref linkend='XSetForeground' xrefstyle='select: title'/>
can generate
<errorname>BadAlloc</errorname>
and
<errorname>BadGC</errorname>
errors.
</para>
<para>
<!-- .LP -->
<!-- .sp -->
To set the background of a given GC, use
<xref linkend='XSetBackground' xrefstyle='select: title'/>.
</para>
<indexterm significance="preferred"><primary>XSetBackground</primary></indexterm>
<!-- .sM -->
<funcsynopsis id='XSetBackground'>
<funcprototype>
  <funcdef><function>XSetBackground</function></funcdef>
  <paramdef>Display<parameter> *display</parameter></paramdef>
  <paramdef>GC<parameter> gc</parameter></paramdef>
  <paramdef>unsignedlong<parameter> background</parameter></paramdef>
</funcprototype>
</funcsynopsis>
<!-- .FN -->
<variablelist>
  <varlistentry>
    <term>
      <emphasis remap='I'>display</emphasis>
    </term>
    <listitem>
      <para>
Specifies the connection to the X server.
      </para>
    </listitem>
  </varlistentry>
  <varlistentry>
    <term>
      <emphasis remap='I'>gc</emphasis>
    </term>
    <listitem>
      <para>
Specifies the GC.
      </para>
    </listitem>
  </varlistentry>
  <varlistentry>
    <term>
      <emphasis remap='I'>background</emphasis>
    </term>
    <listitem>
      <para>
Specifies the background you want to set for the specified GC.
    </para>
  </listitem>
  </varlistentry>
</variablelist>
<para>
<!-- .LP -->
<!-- .eM -->
<xref linkend='XSetBackground' xrefstyle='select: title'/>
can generate
<errorname>BadAlloc</errorname>
and
<errorname>BadGC</errorname>
errors.
</para>
<para>
<!-- .LP -->
<!-- .sp -->
To set the display function in a given GC, use
<xref linkend='XSetFunction' xrefstyle='select: title'/>.
</para>
<indexterm significance="preferred"><primary>XSetFunction</primary></indexterm>
<!-- .sM -->
<funcsynopsis id='XSetFunction'>
<funcprototype>
  <funcdef><function>XSetFunction</function></funcdef>
  <paramdef>Display<parameter> *display</parameter></paramdef>
  <paramdef>GC<parameter> gc</parameter></paramdef>
  <paramdef>int<parameter> function</parameter></paramdef>
</funcprototype>
</funcsynopsis>
<!-- .FN -->
<variablelist>
  <varlistentry>
    <term>
      <emphasis remap='I'>display</emphasis>
    </term>
    <listitem>
      <para>
Specifies the connection to the X server.
      </para>
    </listitem>
  </varlistentry>
  <varlistentry>
    <term>
      <emphasis remap='I'>gc</emphasis>
    </term>
    <listitem>
      <para>
Specifies the GC.
      </para>
    </listitem>
  </varlistentry>
  <varlistentry>
    <term>
      <emphasis remap='I'>function</emphasis>
    </term>
    <listitem>
      <para>
Specifies the function you want to set for the specified GC.
    </para>
  </listitem>
  </varlistentry>
</variablelist>
<para>
<!-- .LP -->
<!-- .eM -->
<xref linkend='XSetFunction' xrefstyle='select: title'/>
can generate
<errorname>BadAlloc</errorname>,
<errorname>BadGC</errorname>,
and
<errorname>BadValue</errorname>
errors.
</para>
<para>
<!-- .LP -->
<!-- .sp -->
To set the plane mask of a given GC, use
<xref linkend='XSetPlaneMask' xrefstyle='select: title'/>.
</para>
<indexterm significance="preferred"><primary>XSetPlaneMask</primary></indexterm>
<!-- .sM -->
<funcsynopsis id='XSetPlaneMask'>
<funcprototype>
  <funcdef><function>XSetPlaneMask</function></funcdef>
  <paramdef>Display<parameter> *display</parameter></paramdef>
  <paramdef>GC<parameter> gc</parameter></paramdef>
  <paramdef>unsignedlong<parameter> plane_mask</parameter></paramdef>
</funcprototype>
</funcsynopsis>
<!-- .FN -->
<variablelist>
  <varlistentry>
    <term>
      <emphasis remap='I'>display</emphasis>
    </term>
    <listitem>
      <para>
Specifies the connection to the X server.
      </para>
    </listitem>
  </varlistentry>
  <varlistentry>
    <term>
      <emphasis remap='I'>gc</emphasis>
    </term>
    <listitem>
      <para>
Specifies the GC.
      </para>
    </listitem>
  </varlistentry>
  <varlistentry>
    <term>
      <emphasis remap='I'>plane_mask</emphasis>
    </term>
    <listitem>
      <para>
Specifies the plane mask.
<!-- .\" *** JIM: NEED MORE INFO FOR THIS. *** -->
    </para>
  </listitem>
  </varlistentry>
</variablelist>
<para>
<!-- .LP -->
<!-- .eM -->
<xref linkend='XSetPlaneMask' xrefstyle='select: title'/>
can generate
<errorname>BadAlloc</errorname>
and
<errorname>BadGC</errorname>
errors.
</para>
</sect2>
<sect2 id="Setting_the_Line_Attributes_and_Dashes">
<title>Setting the Line Attributes and Dashes</title>
<!-- .XS -->
<!-- (SN Setting the Line Attributes and Dashes  -->
<!-- .XE -->
<para>
<!-- .LP -->
To set the line drawing components of a given GC, use
<xref linkend='XSetLineAttributes' xrefstyle='select: title'/>.
</para>
<indexterm significance="preferred"><primary>XSetLineAttributes</primary></indexterm>
<!-- .sM -->
<funcsynopsis id='XSetLineAttributes'>
<funcprototype>
  <funcdef><function>XSetLineAttributes</function></funcdef>
  <paramdef>Display<parameter> *display</parameter></paramdef>
  <paramdef>GC<parameter> gc</parameter></paramdef>
  <paramdef>unsignedint<parameter> line_width</parameter></paramdef>
  <paramdef>int<parameter> line_style</parameter></paramdef>
  <paramdef>int<parameter> cap_style</parameter></paramdef>
  <paramdef>int<parameter> join_style</parameter></paramdef>
</funcprototype>
</funcsynopsis>
<!-- .FN -->
<variablelist>
  <varlistentry>
    <term>
      <emphasis remap='I'>display</emphasis>
    </term>
    <listitem>
      <para>
Specifies the connection to the X server.
      </para>
    </listitem>
  </varlistentry>
  <varlistentry>
    <term>
      <emphasis remap='I'>gc</emphasis>
    </term>
    <listitem>
      <para>
Specifies the GC.
      </para>
    </listitem>
  </varlistentry>
  <varlistentry>
    <term>
      <emphasis remap='I'>line_width</emphasis>
    </term>
    <listitem>
      <para>
Specifies the line-width you want to set for the specified GC.
      </para>
    </listitem>
  </varlistentry>
  <varlistentry>
    <term>
      <emphasis remap='I'>line_style</emphasis>
    </term>
    <listitem>
      <para>
Specifies the line-style you want to set for the specified GC.
You can pass
<symbol>LineSolid</symbol>,
<symbol>LineOnOffDash</symbol>,
or
<symbol>LineDoubleDash</symbol>.
      </para>
    </listitem>
  </varlistentry>
  <varlistentry>
    <term>
      <emphasis remap='I'>cap_style</emphasis>
    </term>
    <listitem>
      <para>
Specifies the line-style and cap-style you want to set for the specified GC.
You can pass
<symbol>CapNotLast</symbol>,
<symbol>CapButt</symbol>,
<symbol>CapRound</symbol>,
or
<symbol>CapProjecting</symbol>.
      </para>
    </listitem>
  </varlistentry>
  <varlistentry>
    <term>
      <emphasis remap='I'>join_style</emphasis>
    </term>
    <listitem>
      <para>
Specifies the line join-style you want to set for the specified GC.
You can pass
<symbol>JoinMiter</symbol>,
<symbol>JoinRound</symbol>,
or
<symbol>JoinBevel</symbol>.
    </para>
  </listitem>
  </varlistentry>
</variablelist>
<para>
<!-- .LP -->
<!-- .eM -->
<xref linkend='XSetLineAttributes' xrefstyle='select: title'/>
can generate
<errorname>BadAlloc</errorname>,
<errorname>BadGC</errorname>,
and
<errorname>BadValue</errorname>
errors.
</para>
<para>
<!-- .LP -->
<!-- .sp -->
To set the dash-offset and dash-list for dashed line styles of a given GC, use
<xref linkend='XSetDashes' xrefstyle='select: title'/>.
</para>
<indexterm significance="preferred"><primary>XSetDashes</primary></indexterm>
<!-- .sM -->
<funcsynopsis id='XSetDashes'>
<funcprototype>
  <funcdef><function>XSetDashes</function></funcdef>
  <paramdef>Display<parameter> *display</parameter></paramdef>
  <paramdef>GC<parameter> gc</parameter></paramdef>
  <paramdef>int<parameter> dash_offset</parameter></paramdef>
  <paramdef>char<parameter> dash_list[]</parameter></paramdef>
  <paramdef>int<parameter> n</parameter></paramdef>
</funcprototype>
</funcsynopsis>
<!-- .FN -->
<variablelist>
  <varlistentry>
    <term>
      <emphasis remap='I'>display</emphasis>
    </term>
    <listitem>
      <para>
Specifies the connection to the X server.
      </para>
    </listitem>
  </varlistentry>
  <varlistentry>
    <term>
      <emphasis remap='I'>gc</emphasis>
    </term>
    <listitem>
      <para>
Specifies the GC.
      </para>
    </listitem>
  </varlistentry>
  <varlistentry>
    <term>
      <emphasis remap='I'>dash_offset</emphasis>
    </term>
    <listitem>
      <para>
Specifies the phase of the pattern for the dashed line-style you want to set
for the specified GC. 
      </para>
    </listitem>
  </varlistentry>
  <varlistentry>
    <term>
      <emphasis remap='I'>dash_list</emphasis>
    </term>
    <listitem>
      <para>
Specifies the dash-list for the dashed line-style
you want to set for the specified GC. 
      </para>
    </listitem>
  </varlistentry>
  <varlistentry>
    <term>
      <emphasis remap='I'>n</emphasis>
    </term>
    <listitem>
      <para>
Specifies the number of elements in dash_list. 
    </para>
  </listitem>
  </varlistentry>
</variablelist>
<para>
<!-- .LP -->
<!-- .eM  -->
The
<xref linkend='XSetDashes' xrefstyle='select: title'/>
function sets the dash-offset and dash-list attributes for dashed line styles
in the specified GC.
There must be at least one element in the specified dash_list,
or a
<errorname>BadValue</errorname>
error results. 
The initial and alternating elements (second, fourth, and so on) 
of the dash_list are the even dashes, and
the others are the odd dashes.
Each element specifies a dash length in pixels.
All of the elements must be nonzero,
or a
<errorname>BadValue</errorname>
error results.
Specifying an odd-length list is equivalent to specifying the same list
concatenated with itself to produce an even-length list.
</para>
<para>
<!-- .LP -->
The dash-offset defines the phase of the pattern,
specifying how many pixels into the dash-list the pattern
should actually begin in any single graphics request.
Dashing is continuous through path elements combined with a join-style
but is reset to the dash-offset between each sequence of joined lines.
</para>
<para>
<!-- .LP -->
The unit of measure for dashes is the same for the ordinary coordinate system.
Ideally, a dash length is measured along the slope of the line, but implementations
are only required to match this ideal for horizontal and vertical lines.
Failing the ideal semantics, it is suggested that the length be measured along the
major axis of the line.
The major axis is defined as the x axis for lines drawn at an angle of between
&minus;45 and +45 degrees or between 135 and 225 degrees from the x axis.
For all other lines, the major axis is the y axis.
</para>
<para>
<!-- .LP -->
<xref linkend='XSetDashes' xrefstyle='select: title'/>
can generate
<errorname>BadAlloc</errorname>,
<errorname>BadGC</errorname>,
and
<errorname>BadValue</errorname>
errors.
</para>
</sect2>
<sect2 id='Setting_the_Fill_Style_and_Fill_Rule'>
<title>Setting the Fill Style and Fill Rule</title>
<!-- .XS -->
<!-- (SN Setting the Fill Style and Fill Rule  -->
<!-- .XE -->
<para>
<!-- .LP -->
To set the fill-style of a given GC, use
<xref linkend='XSetFillStyle' xrefstyle='select: title'/>.
</para>
<indexterm significance="preferred"><primary>XSetFillStyle</primary></indexterm>
<!-- .sM -->
<funcsynopsis id='XSetFillStyle'>
<funcprototype>
  <funcdef><function>XSetFillStyle</function></funcdef>
  <paramdef>Display<parameter> *display</parameter></paramdef>
  <paramdef>GC<parameter> gc</parameter></paramdef>
  <paramdef>int<parameter> fill_style</parameter></paramdef>
</funcprototype>
</funcsynopsis>
<!-- .FN -->
<variablelist>
  <varlistentry>
    <term>
      <emphasis remap='I'>display</emphasis>
    </term>
    <listitem>
      <para>
Specifies the connection to the X server.
      </para>
    </listitem>
  </varlistentry>
  <varlistentry>
    <term>
      <emphasis remap='I'>gc</emphasis>
    </term>
    <listitem>
      <para>
Specifies the GC.
      </para>
    </listitem>
  </varlistentry>
  <varlistentry>
    <term>
      <emphasis remap='I'>fill_style</emphasis>
    </term>
    <listitem>
      <para>
Specifies the fill-style you want to set for the specified GC.
You can pass
<symbol>FillSolid</symbol>,
<symbol>FillTiled</symbol>,
<symbol>FillStippled</symbol>,
or
<symbol>FillOpaqueStippled</symbol>.
    </para>
  </listitem>
  </varlistentry>
</variablelist>
<para>
<!-- .LP -->
<!-- .eM -->
<xref linkend='XSetFillStyle' xrefstyle='select: title'/>
can generate
<errorname>BadAlloc</errorname>,
<errorname>BadGC</errorname>,
and
<errorname>BadValue</errorname>
errors.
</para>
<para>
<!-- .LP -->
<!-- .sp -->
To set the fill-rule of a given GC, use
<xref linkend='XSetFillRule' xrefstyle='select: title'/>.
</para>
<indexterm significance="preferred"><primary>XSetFillRule</primary></indexterm>
<!-- .sM -->
<funcsynopsis id='XSetFillRule'>
<funcprototype>
  <funcdef><function>XSetFillRule</function></funcdef>
  <paramdef>Display<parameter> *display</parameter></paramdef>
  <paramdef>GC<parameter> gc</parameter></paramdef>
  <paramdef>int<parameter> fill_rule</parameter></paramdef>
</funcprototype>
</funcsynopsis>
<!-- .FN -->
<variablelist>
  <varlistentry>
    <term>
      <emphasis remap='I'>display</emphasis>
    </term>
    <listitem>
      <para>
Specifies the connection to the X server.
      </para>
    </listitem>
  </varlistentry>
  <varlistentry>
    <term>
      <emphasis remap='I'>gc</emphasis>
    </term>
    <listitem>
      <para>
Specifies the GC.
      </para>
    </listitem>
  </varlistentry>
  <varlistentry>
    <term>
      <emphasis remap='I'>fill_rule</emphasis>
    </term>
    <listitem>
      <para>
Specifies the fill-rule you want to set for the specified GC.
You can pass 
<symbol>EvenOddRule</symbol>
or
<symbol>WindingRule</symbol>.
    </para>
  </listitem>
  </varlistentry>
</variablelist>
<para>
<!-- .LP -->
<!-- .eM -->
<xref linkend='XSetFillRule' xrefstyle='select: title'/>
can generate
<errorname>BadAlloc</errorname>,
<errorname>BadGC</errorname>,
and
<errorname>BadValue</errorname>
errors.
</para>
</sect2>
<sect2 id='Setting_the_Fill_Tile_and_Stipple'>
<title>Setting the Fill Tile and Stipple</title>
<!-- .XS -->
<!-- (SN Setting the Fill Tile and Stipple  -->
<!-- .XE -->
<para>
<!-- .LP -->
Some displays have hardware support for tiling or
stippling with patterns of specific sizes.
Tiling and stippling operations that restrict themselves to those specific
sizes run much faster than such operations with arbitrary size patterns.
Xlib provides functions that you can use to determine the best size, 
tile, or stipple for the display
as well as to set the tile or stipple shape and the tile or stipple origin.
</para>
<para>
<!-- .LP -->
<!-- .sp -->
To obtain the best size of a tile, stipple, or cursor, use
<xref linkend='XQueryBestSize' xrefstyle='select: title'/>.
</para>
<indexterm significance="preferred"><primary>XQueryBestSize</primary></indexterm>
<!-- .sM -->
<funcsynopsis id='XQueryBestSize'>
<funcprototype>
  <funcdef>Status <function>XQueryBestSize</function></funcdef>
  <paramdef>Display<parameter> *display</parameter></paramdef>
  <paramdef>int<parameter> class</parameter></paramdef>
  <paramdef>Drawable<parameter> which_screen</parameter></paramdef>
  <paramdef>unsignedintwidth,<parameter> height</parameter></paramdef>
  <paramdef>unsignedint*width_return,<parameter> *height_return</parameter></paramdef>
</funcprototype>
</funcsynopsis>
<!-- .FN -->
<variablelist>
  <varlistentry>
    <term>
      <emphasis remap='I'>display</emphasis>
    </term>
    <listitem>
      <para>
Specifies the connection to the X server.
      </para>
    </listitem>
  </varlistentry>
  <varlistentry>
    <term>
      <emphasis remap='I'>class</emphasis>
    </term>
    <listitem>
      <para>
Specifies the class that you are interested in.
You can pass 
<symbol>TileShape</symbol>,
<symbol>CursorShape</symbol>,
or 
<symbol>StippleShape</symbol>.
      </para>
    </listitem>
  </varlistentry>
  <varlistentry>
    <term>
      <emphasis remap='I'>which_screen</emphasis>
    </term>
    <listitem>
      <para>
Specifies any drawable on the screen.
      </para>
    </listitem>
  </varlistentry>
  <varlistentry>
    <term>
      <emphasis remap='I'>width</emphasis>
    </term>
    <listitem>
      <para>
<!-- .br -->
<!-- .ns -->
      </para>
    </listitem>
  </varlistentry>
  <varlistentry>
    <term>
      <emphasis remap='I'>height</emphasis>
    </term>
    <listitem>
      <para>
Specify the width and height.
      </para>
    </listitem>
  </varlistentry>
  <varlistentry>
    <term>
      <emphasis remap='I'>width_return</emphasis>
    </term>
    <listitem>
      <para>
<!-- .br -->
<!-- .ns -->
      </para>
    </listitem>
  </varlistentry>
  <varlistentry>
    <term>
      <emphasis remap='I'>height_return</emphasis>
    </term>
    <listitem>
      <para>
Return the width and height of the object best supported 
by the display hardware.
    </para>
  </listitem>
  </varlistentry>
</variablelist>
<para>
<!-- .LP -->
<!-- .eM -->
The
<xref linkend='XQueryBestSize' xrefstyle='select: title'/>
function returns the best or closest size to the specified size.
For 
<symbol>CursorShape</symbol>,
this is the largest size that can be fully displayed on the screen specified by
which_screen.
For 
<symbol>TileShape</symbol>,
this is the size that can be tiled fastest.
For 
<symbol>StippleShape</symbol>,
this is the size that can be stippled fastest.
For 
<symbol>CursorShape</symbol>,
the drawable indicates the desired screen.
For 
<symbol>TileShape</symbol>
and 
<symbol>StippleShape</symbol>,
the drawable indicates the screen and possibly the window class and depth.
An 
<symbol>InputOnly</symbol>
window cannot be used as the drawable for 
<symbol>TileShape</symbol>
or 
<symbol>StippleShape</symbol>,
or a
<errorname>BadMatch</errorname>
error results.
</para>
<para>
<!-- .LP -->
<xref linkend='XQueryBestSize' xrefstyle='select: title'/>
can generate
<errorname>BadDrawable</errorname>,
<errorname>BadMatch</errorname>,
and 
<errorname>BadValue</errorname>
errors.
</para>
<para>
<!-- .LP -->
<!-- .sp -->
To obtain the best fill tile shape, use
<xref linkend='XQueryBestTile' xrefstyle='select: title'/>.
</para>
<indexterm significance="preferred"><primary>XQueryBestTile</primary></indexterm>
<!-- .sM -->
<funcsynopsis id='XQueryBestTile'>
<funcprototype>
  <funcdef>Status <function>XQueryBestTile</function></funcdef>
  <paramdef>Display<parameter> *display</parameter></paramdef>
  <paramdef>Drawable<parameter> which_screen</parameter></paramdef>
  <paramdef>unsignedintwidth,<parameter> height</parameter></paramdef>
  <paramdef>unsignedint*width_return,<parameter> *height_return</parameter></paramdef>
</funcprototype>
</funcsynopsis>
<!-- .FN -->
<variablelist>
  <varlistentry>
    <term>
      <emphasis remap='I'>display</emphasis>
    </term>
    <listitem>
      <para>
Specifies the connection to the X server.
      </para>
    </listitem>
  </varlistentry>
  <varlistentry>
    <term>
      <emphasis remap='I'>which_screen</emphasis>
    </term>
    <listitem>
      <para>
Specifies any drawable on the screen.
      </para>
    </listitem>
  </varlistentry>
  <varlistentry>
    <term>
      <emphasis remap='I'>width</emphasis>
    </term>
    <listitem>
      <para>
<!-- .br -->
<!-- .ns -->
      </para>
    </listitem>
  </varlistentry>
  <varlistentry>
    <term>
      <emphasis remap='I'>height</emphasis>
    </term>
    <listitem>
      <para>
Specify the width and height.
      </para>
    </listitem>
  </varlistentry>
  <varlistentry>
    <term>
      <emphasis remap='I'>width_return</emphasis>
    </term>
    <listitem>
      <para>
<!-- .br -->
<!-- .ns -->
      </para>
    </listitem>
  </varlistentry>
  <varlistentry>
    <term>
      <emphasis remap='I'>height_return</emphasis>
    </term>
    <listitem>
      <para>
Return the width and height of the object best supported 
by the display hardware.
    </para>
  </listitem>
  </varlistentry>
</variablelist>
<para>
<!-- .LP -->
<!-- .eM -->
The
<xref linkend='XQueryBestTile' xrefstyle='select: title'/>
function returns the best or closest size, that is, the size that can be
tiled fastest on the screen specified by which_screen.
The drawable indicates the screen and possibly the window class and depth.
If an 
<symbol>InputOnly</symbol>
window is used as the drawable, a 
<errorname>BadMatch</errorname>
error results.
</para>
<para>
<!-- .LP -->
<xref linkend='XQueryBestTile' xrefstyle='select: title'/>
can generate
<errorname>BadDrawable</errorname>
and
<errorname>BadMatch</errorname>
errors.
</para>
<para>
<!-- .LP -->
<!-- .sp -->
To obtain the best stipple shape, use
<xref linkend='XQueryBestStipple' xrefstyle='select: title'/>.
</para>
<indexterm significance="preferred"><primary>XQueryBestStipple</primary></indexterm>
<!-- .sM -->
<funcsynopsis id='XQueryBestStipple'>
<funcprototype>
  <funcdef>Status <function>XQueryBestStipple</function></funcdef>
  <paramdef>Display<parameter> *display</parameter></paramdef>
  <paramdef>Drawable<parameter> which_screen</parameter></paramdef>
  <paramdef>unsignedintwidth,<parameter> height</parameter></paramdef>
  <paramdef>unsignedint*width_return,<parameter> *height_return</parameter></paramdef>
</funcprototype>
</funcsynopsis>
<!-- .FN -->
<variablelist>
  <varlistentry>
    <term>
      <emphasis remap='I'>display</emphasis>
    </term>
    <listitem>
      <para>
Specifies the connection to the X server.
      </para>
    </listitem>
  </varlistentry>
  <varlistentry>
    <term>
      <emphasis remap='I'>which_screen</emphasis>
    </term>
    <listitem>
      <para>
Specifies any drawable on the screen.
      </para>
    </listitem>
  </varlistentry>
  <varlistentry>
    <term>
      <emphasis remap='I'>width</emphasis>
    </term>
    <listitem>
      <para>
<!-- .br -->
<!-- .ns -->
      </para>
    </listitem>
  </varlistentry>
  <varlistentry>
    <term>
      <emphasis remap='I'>height</emphasis>
    </term>
    <listitem>
      <para>
Specify the width and height.
      </para>
    </listitem>
  </varlistentry>
  <varlistentry>
    <term>
      <emphasis remap='I'>width_return</emphasis>
    </term>
    <listitem>
      <para>
<!-- .br -->
<!-- .ns -->
      </para>
    </listitem>
  </varlistentry>
  <varlistentry>
    <term>
      <emphasis remap='I'>height_return</emphasis>
    </term>
    <listitem>
      <para>
Return the width and height of the object best supported 
by the display hardware.
    </para>
  </listitem>
  </varlistentry>
</variablelist>
<para>
<!-- .LP -->
<!-- .eM -->
The
<xref linkend='XQueryBestStipple' xrefstyle='select: title'/>
function returns the best or closest size, that is, the size that can be
stippled fastest on the screen specified by which_screen.
The drawable indicates the screen and possibly the window class and depth.
If an
<symbol>InputOnly</symbol>
window is used as the drawable, a
<errorname>BadMatch</errorname>
error results.
</para>
<para>
<!-- .LP -->
<xref linkend='XQueryBestStipple' xrefstyle='select: title'/>
can generate
<errorname>BadDrawable</errorname>
and
<errorname>BadMatch</errorname>
errors.
</para>
<para>
<!-- .LP -->
<!-- .sp -->
To set the fill tile of a given GC, use
<xref linkend='XSetTile' xrefstyle='select: title'/>.
</para>
<indexterm significance="preferred"><primary>XSetTile</primary></indexterm>
<!-- .sM -->
<funcsynopsis id='XSetTile'>
<funcprototype>
  <funcdef><function>XSetTile</function></funcdef>
  <paramdef>Display<parameter> *display</parameter></paramdef>
  <paramdef>GC<parameter> gc</parameter></paramdef>
  <paramdef>Pixmap<parameter> tile</parameter></paramdef>
</funcprototype>
</funcsynopsis>
<!-- .FN -->
<variablelist>
  <varlistentry>
    <term>
      <emphasis remap='I'>display</emphasis>
    </term>
    <listitem>
      <para>
Specifies the connection to the X server.
      </para>
    </listitem>
  </varlistentry>
  <varlistentry>
    <term>
      <emphasis remap='I'>gc</emphasis>
    </term>
    <listitem>
      <para>
Specifies the GC.
      </para>
    </listitem>
  </varlistentry>
  <varlistentry>
    <term>
      <emphasis remap='I'>tile</emphasis>
    </term>
    <listitem>
      <para>
Specifies the fill tile you want to set for the specified GC. 
    </para>
  </listitem>
  </varlistentry>
</variablelist>
<para>
<!-- .LP -->
<!-- .eM -->
The tile and GC must have the same depth,
or a
<errorname>BadMatch</errorname>
error results.
</para>
<para>
<!-- .LP -->
<xref linkend='XSetTile' xrefstyle='select: title'/>
can generate
<errorname>BadAlloc</errorname>,
<errorname>BadGC</errorname>,
<errorname>BadMatch</errorname>,
and
<errorname>BadPixmap</errorname>
errors.
</para>
<para>
<!-- .LP -->
<!-- .sp -->
To set the stipple of a given GC, use
<xref linkend='XSetStipple' xrefstyle='select: title'/>.
</para>
<indexterm significance="preferred"><primary>XSetStipple</primary></indexterm>
<!-- .sM -->
<funcsynopsis id='XSetStipple'>
<funcprototype>
  <funcdef><function>XSetStipple</function></funcdef>
  <paramdef>Display<parameter> *display</parameter></paramdef>
  <paramdef>GC<parameter> gc</parameter></paramdef>
  <paramdef>Pixmap<parameter> stipple</parameter></paramdef>
</funcprototype>
</funcsynopsis>
<!-- .FN -->
<variablelist>
  <varlistentry>
    <term>
      <emphasis remap='I'>display</emphasis>
    </term>
    <listitem>
      <para>
Specifies the connection to the X server.
      </para>
    </listitem>
  </varlistentry>
  <varlistentry>
    <term>
      <emphasis remap='I'>gc</emphasis>
    </term>
    <listitem>
      <para>
Specifies the GC.
      </para>
    </listitem>
  </varlistentry>
  <varlistentry>
    <term>
      <emphasis remap='I'>stipple</emphasis>
    </term>
    <listitem>
      <para>
Specifies the stipple you want to set for the specified GC.
    </para>
  </listitem>
  </varlistentry>
</variablelist>
<para>
<!-- .LP -->
<!-- .eM -->
The stipple must have a depth of one,
or a
<errorname>BadMatch</errorname>
error results.
</para>
<para>
<!-- .LP -->
<xref linkend='XSetStipple' xrefstyle='select: title'/>
can generate
<errorname>BadAlloc</errorname>,
<errorname>BadGC</errorname>,
<errorname>BadMatch</errorname>,
and
<errorname>BadPixmap</errorname>
errors.
</para>
<para>
<!-- .LP -->
<!-- .sp -->
To set the tile or stipple origin of a given GC, use
<xref linkend='XSetTSOrigin' xrefstyle='select: title'/>.
</para>
<indexterm significance="preferred"><primary>XSetTSOrigin</primary></indexterm>
<!-- .sM -->
<funcsynopsis id='XSetTSOrigin'>
<funcprototype>
  <funcdef><function>XSetTSOrigin</function></funcdef>
  <paramdef>Display<parameter> *display</parameter></paramdef>
  <paramdef>GC<parameter> gc</parameter></paramdef>
  <paramdef>intts_x_origin,<parameter> ts_y_origin</parameter></paramdef>
</funcprototype>
</funcsynopsis>
<!-- .FN -->
<variablelist>
  <varlistentry>
    <term>
      <emphasis remap='I'>display</emphasis>
    </term>
    <listitem>
      <para>
Specifies the connection to the X server.
      </para>
    </listitem>
  </varlistentry>
  <varlistentry>
    <term>
      <emphasis remap='I'>gc</emphasis>
    </term>
    <listitem>
      <para>
Specifies the GC.
      </para>
    </listitem>
  </varlistentry>
  <varlistentry>
    <term>
      <emphasis remap='I'>ts_x_origin</emphasis>
    </term>
    <listitem>
      <para>
<!-- .br -->
<!-- .ns -->
      </para>
    </listitem>
  </varlistentry>
  <varlistentry>
    <term>
      <emphasis remap='I'>ts_y_origin</emphasis>
    </term>
    <listitem>
      <para>
Specify the x and y coordinates of the tile and stipple origin.
    </para>
  </listitem>
  </varlistentry>
</variablelist>
<para>
<!-- .LP -->
<!-- .eM -->
When graphics requests call for tiling or stippling,
the parent's origin will be interpreted relative to whatever destination 
drawable is specified in the graphics request.
</para>
<para>
<!-- .LP -->
<xref linkend='XSetTSOrigin' xrefstyle='select: title'/>
can generate
<errorname>BadAlloc</errorname>
and
<errorname>BadGC</errorname>
errors.
</para>
</sect2>
<sect2 id='Setting_the_Current_Font'>
<title>Setting the Current Font</title>
<!-- .XS -->
<!-- (SN Setting the Current Font  -->
<!-- .XE -->
<para>
<!-- .LP -->
To set the current font of a given GC, use
<xref linkend='XSetFont' xrefstyle='select: title'/>.
</para>
<indexterm significance="preferred"><primary>XSetFont</primary></indexterm>
<!-- .sM -->
<funcsynopsis id='XSetFont'>
<funcprototype>
  <funcdef><function>XSetFont</function></funcdef>
  <paramdef>Display<parameter> *display</parameter></paramdef>
  <paramdef>GC<parameter> gc</parameter></paramdef>
  <paramdef>Font<parameter> font</parameter></paramdef>
</funcprototype>
</funcsynopsis>
<!-- .FN -->
<variablelist>
  <varlistentry>
    <term>
      <emphasis remap='I'>display</emphasis>
    </term>
    <listitem>
      <para>
Specifies the connection to the X server.
      </para>
    </listitem>
  </varlistentry>
  <varlistentry>
    <term>
      <emphasis remap='I'>gc</emphasis>
    </term>
    <listitem>
      <para>
Specifies the GC.
      </para>
    </listitem>
  </varlistentry>
  <varlistentry>
    <term>
      <emphasis remap='I'>font</emphasis>
    </term>
    <listitem>
      <para>
Specifies the font.
    </para>
  </listitem>
  </varlistentry>
</variablelist>
<para>
<!-- .LP -->
<!-- .eM -->
<xref linkend='XSetFont' xrefstyle='select: title'/>
can generate
<errorname>BadAlloc</errorname>,
<errorname>BadFont</errorname>,
and 
<errorname>BadGC</errorname>
errors.
</para>
</sect2>
<sect2 id="Setting_the_Clip_Region">
<title>Setting the Clip Region</title>
<!-- .XS -->
<!-- (SN Setting the Clip Region  -->
<!-- .XE -->
<para>
<!-- .LP -->
Xlib provides functions that you can use to set the clip-origin 
and the clip-mask or set the clip-mask to a list of rectangles.
</para>
<para>
<!-- .LP -->
<!-- .sp -->
To set the clip-origin of a given GC, use
<xref linkend='XSetClipOrigin' xrefstyle='select: title'/>.
</para>
<indexterm significance="preferred"><primary>XSetClipOrigin</primary></indexterm>
<!-- .sM -->
<funcsynopsis id='XSetClipOrigin'>
<funcprototype>
  <funcdef><function>XSetClipOrigin</function></funcdef>
  <paramdef>Display<parameter> *display</parameter></paramdef>
  <paramdef>GC<parameter> gc</parameter></paramdef>
  <paramdef>intclip_x_origin,<parameter> clip_y_origin</parameter></paramdef>
</funcprototype>
</funcsynopsis>
<!-- .FN -->
<variablelist>
  <varlistentry>
    <term>
      <emphasis remap='I'>display</emphasis>
    </term>
    <listitem>
      <para>
Specifies the connection to the X server.
      </para>
    </listitem>
  </varlistentry>
  <varlistentry>
    <term>
      <emphasis remap='I'>gc</emphasis>
    </term>
    <listitem>
      <para>
Specifies the GC.
      </para>
    </listitem>
  </varlistentry>
  <varlistentry>
    <term>
      <emphasis remap='I'>clip_x_origin</emphasis>
    </term>
    <listitem>
      <para>
<!-- .br -->
<!-- .ns -->
      </para>
    </listitem>
  </varlistentry>
  <varlistentry>
    <term>
      <emphasis remap='I'>clip_y_origin</emphasis>
    </term>
    <listitem>
      <para>
Specify the x and y coordinates of the clip-mask origin.
    </para>
  </listitem>
  </varlistentry>
</variablelist>
<para>
<!-- .LP -->
<!-- .eM -->
The clip-mask origin is interpreted relative to the origin of whatever 
destination drawable is specified in the graphics request.
</para>
<para>
<!-- .LP -->
<xref linkend='XSetClipOrigin' xrefstyle='select: title'/>
can generate
<errorname>BadAlloc</errorname>
and
<errorname>BadGC</errorname>
errors.
</para>
<para>
<!-- .LP -->
<!-- .sp -->
To set the clip-mask of a given GC to the specified pixmap, use
<xref linkend='XSetClipMask' xrefstyle='select: title'/>.
</para>
<indexterm significance="preferred"><primary>XSetClipMask</primary></indexterm>
<!-- .sM -->
<funcsynopsis id='XSetClipMask'>
<funcprototype>
  <funcdef><function>XSetClipMask</function></funcdef>
  <paramdef>Display<parameter> *display</parameter></paramdef>
  <paramdef>GC<parameter> gc</parameter></paramdef>
  <paramdef>Pixmap<parameter> pixmap</parameter></paramdef>
</funcprototype>
</funcsynopsis>
<!-- .FN -->
<variablelist>
  <varlistentry>
    <term>
      <emphasis remap='I'>display</emphasis>
    </term>
    <listitem>
      <para>
Specifies the connection to the X server.
      </para>
    </listitem>
  </varlistentry>
  <varlistentry>
    <term>
      <emphasis remap='I'>gc</emphasis>
    </term>
    <listitem>
      <para>
Specifies the GC.
      </para>
    </listitem>
  </varlistentry>
  <varlistentry>
    <term>
      <emphasis remap='I'>pixmap</emphasis>
    </term>
    <listitem>
      <para>
Specifies the pixmap or
<symbol>None</symbol>.
    </para>
  </listitem>
  </varlistentry>
</variablelist>
<para>
<!-- .LP -->
<!-- .eM -->
If the clip-mask is set to
<symbol>None</symbol>,
the pixels are always drawn (regardless of the clip-origin).
</para>
<para>
<!-- .LP -->
<xref linkend='XSetClipMask' xrefstyle='select: title'/>
can generate
<errorname>BadAlloc</errorname>,
<errorname>BadGC</errorname>,
<errorname>BadMatch</errorname>,
and
<errorname>BadPixmap</errorname>
errors.
</para>
<para>
<!-- .LP -->
<!-- .sp -->
To set the clip-mask of a given GC to the specified list of rectangles, use
<xref linkend='XSetClipRectangles' xrefstyle='select: title'/>.
</para>
<indexterm significance="preferred"><primary>XSetClipRectangles</primary></indexterm>
<!-- .sM -->
<funcsynopsis id='XSetClipRectangles'>
<funcprototype>
  <funcdef><function>XSetClipRectangles</function></funcdef>
  <paramdef>Display<parameter> *display</parameter></paramdef>
  <paramdef>GC<parameter> gc</parameter></paramdef>
  <paramdef>intclip_x_origin,<parameter> clip_y_origin</parameter></paramdef>
  <paramdef>XRectangle<parameter> rectangles[]</parameter></paramdef>
  <paramdef>int<parameter> n</parameter></paramdef>
  <paramdef>int<parameter> ordering</parameter></paramdef>
</funcprototype>
</funcsynopsis>
<!-- .FN -->
<variablelist>
  <varlistentry>
    <term>
      <emphasis remap='I'>display</emphasis>
    </term>
    <listitem>
      <para>
Specifies the connection to the X server.
      </para>
    </listitem>
  </varlistentry>
  <varlistentry>
    <term>
      <emphasis remap='I'>gc</emphasis>
    </term>
    <listitem>
      <para>
Specifies the GC.
      </para>
    </listitem>
  </varlistentry>
  <varlistentry>
    <term>
      <emphasis remap='I'>clip_x_origin</emphasis>
    </term>
    <listitem>
      <para>
<!-- .br -->
<!-- .ns -->
      </para>
    </listitem>
  </varlistentry>
  <varlistentry>
    <term>
      <emphasis remap='I'>clip_y_origin</emphasis>
    </term>
    <listitem>
      <para>
Specify the x and y coordinates of the clip-mask origin.
      </para>
    </listitem>
  </varlistentry>
  <varlistentry>
    <term>
      <emphasis remap='I'>rectangles</emphasis>
    </term>
    <listitem>
      <para>
Specifies an array of rectangles that define the clip-mask.
      </para>
    </listitem>
  </varlistentry>
  <varlistentry>
    <term>
      <emphasis remap='I'>n</emphasis>
    </term>
    <listitem>
      <para>
Specifies the number of rectangles. 
      </para>
    </listitem>
  </varlistentry>
  <varlistentry>
    <term>
      <emphasis remap='I'>ordering</emphasis>
    </term>
    <listitem>
      <para>
Specifies the ordering relations on the rectangles.
You can pass
<symbol>Unsorted</symbol>,
<symbol>YSorted</symbol>,
<symbol>YXSorted</symbol>,
or
<symbol>YXBanded</symbol>.
    </para>
  </listitem>
  </varlistentry>
</variablelist>
<para>
<!-- .LP -->
<!-- .eM -->
The
<xref linkend='XSetClipRectangles' xrefstyle='select: title'/>
function changes the clip-mask in the specified GC 
to the specified list of rectangles and sets the clip origin.
The output is clipped to remain contained within the
rectangles.
The clip-origin is interpreted relative to the origin of
whatever destination drawable is specified in a graphics request.  
The rectangle coordinates are interpreted relative to the clip-origin.  
The rectangles should be nonintersecting, or the graphics results will be
undefined.
Note that the list of rectangles can be empty, 
which effectively disables output.
This is the opposite of passing
<symbol>None</symbol>
as the clip-mask in
<xref linkend='XCreateGC' xrefstyle='select: title'/>,
<xref linkend='XChangeGC' xrefstyle='select: title'/>,
and
<xref linkend='XSetClipMask' xrefstyle='select: title'/>.
</para>
<para>
<!-- .LP -->
If known by the client, ordering relations on the rectangles can be
specified with the ordering argument. 
This may provide faster operation
by the server. 
If an incorrect ordering is specified, the X server may generate a
<errorname>BadMatch</errorname>
error, but it is not required to do so.
If no error is generated, the graphics
results are undefined.
<symbol>Unsorted</symbol>
means the rectangles are in arbitrary order.
<symbol>YSorted</symbol>
means that the rectangles are nondecreasing in their Y origin.
<symbol>YXSorted</symbol>
additionally constrains 
<symbol>YSorted</symbol>
order in that all
rectangles with an equal Y origin are nondecreasing in their X
origin.  
<symbol>YXBanded</symbol>
additionally constrains 
<symbol>YXSorted</symbol>
by requiring that,
for every possible Y scanline, all rectangles that include that
scanline have an identical Y origins and Y extents.
</para>
<para>
<!-- .LP -->
<xref linkend='XSetClipRectangles' xrefstyle='select: title'/>
can generate
<errorname>BadAlloc</errorname>,
<errorname>BadGC</errorname>,
<errorname>BadMatch</errorname>,
and
<errorname>BadValue</errorname>
errors.
</para>
<para>
<!-- .LP -->
Xlib provides a set of basic functions for performing
region arithmetic.
For information about these functions,
see <link linkend="Manipulating_Regions">section 16.5</link>.
</para>
</sect2>
<sect2 id='Setting_the_Arc_Mode_Subwindow_Mode_and_Graphics_Exposure'>
<title>Setting the Arc Mode, Subwindow Mode, and Graphics Exposure</title>
<!-- .XS -->
<!-- (SN Setting the Arc Mode, Subwindow Mode, and Graphics Exposure  -->
<!-- .XE -->
<para>
<!-- .LP -->
To set the arc mode of a given GC, use
<xref linkend='XSetArcMode' xrefstyle='select: title'/>.
</para>
<indexterm significance="preferred"><primary>XSetArcMode</primary></indexterm>
<!-- .sM -->
<funcsynopsis id='XSetArcMode'>
<funcprototype>
  <funcdef><function>XSetArcMode</function></funcdef>
  <paramdef>Display<parameter> *display</parameter></paramdef>
  <paramdef>GC<parameter> gc</parameter></paramdef>
  <paramdef>int<parameter> arc_mode</parameter></paramdef>
</funcprototype>
</funcsynopsis>
<!-- .FN -->
<variablelist>
  <varlistentry>
    <term>
      <emphasis remap='I'>display</emphasis>
    </term>
    <listitem>
      <para>
Specifies the connection to the X server.
      </para>
    </listitem>
  </varlistentry>
  <varlistentry>
    <term>
      <emphasis remap='I'>gc</emphasis>
    </term>
    <listitem>
      <para>
Specifies the GC.
      </para>
    </listitem>
  </varlistentry>
  <varlistentry>
    <term>
      <emphasis remap='I'>arc_mode</emphasis>
    </term>
    <listitem>
      <para>
Specifies the arc mode.
You can pass
<symbol>ArcChord</symbol>
or
<symbol>ArcPieSlice</symbol>.
    </para>
  </listitem>
  </varlistentry>
</variablelist>
<para>
<!-- .LP -->
<!-- .eM -->
<xref linkend='XSetArcMode' xrefstyle='select: title'/>
can generate
<errorname>BadAlloc</errorname>,
<errorname>BadGC</errorname>,
and
<errorname>BadValue</errorname>
errors.
</para>
<para>
<!-- .LP -->
<!-- .sp -->
To set the subwindow mode of a given GC, use
<xref linkend='XSetSubwindowMode' xrefstyle='select: title'/>.
</para>
<indexterm significance="preferred"><primary>XSetSubwindowMode</primary></indexterm>
<!-- .sM -->
<funcsynopsis id='XSetSubwindowMode'>
<funcprototype>
  <funcdef><function>XSetSubwindowMode</function></funcdef>
  <paramdef>Display<parameter> *display</parameter></paramdef>
  <paramdef>GC<parameter> gc</parameter></paramdef>
  <paramdef>int<parameter> subwindow_mode</parameter></paramdef>
</funcprototype>
</funcsynopsis>
<!-- .FN -->
<variablelist>
  <varlistentry>
    <term>
      <emphasis remap='I'>display</emphasis>
    </term>
    <listitem>
      <para>
Specifies the connection to the X server.
      </para>
    </listitem>
  </varlistentry>
  <varlistentry>
    <term>
      <emphasis remap='I'>gc</emphasis>
    </term>
    <listitem>
      <para>
Specifies the GC.
      </para>
    </listitem>
  </varlistentry>
  <varlistentry>
    <term>
      <emphasis remap='I'>subwindow_mode</emphasis>
    </term>
    <listitem>
      <para>
Specifies the subwindow mode.
You can pass
<symbol>ClipByChildren</symbol>
or
<symbol>IncludeInferiors</symbol>.
    </para>
  </listitem>
  </varlistentry>
</variablelist>
<para>
<!-- .LP -->
<!-- .eM -->
<xref linkend='XSetSubwindowMode' xrefstyle='select: title'/>
can generate
<errorname>BadAlloc</errorname>,
<errorname>BadGC</errorname>,
and
<errorname>BadValue</errorname>
errors.
</para>
<para>
<!-- .LP -->
<!-- .sp -->
To set the graphics-exposures flag of a given GC, use
<xref linkend='XSetGraphicsExposures' xrefstyle='select: title'/>.
</para>
<indexterm significance="preferred"><primary>XSetGraphicsExposures</primary></indexterm>
<!-- .sM -->
<funcsynopsis id='XSetGraphicsExposures'>
<funcprototype>
  <funcdef><function>XSetGraphicsExposures</function></funcdef>
  <paramdef>Display<parameter> *display</parameter></paramdef>
  <paramdef>GC<parameter> gc</parameter></paramdef>
  <paramdef>Bool<parameter> graphics_exposures</parameter></paramdef>
</funcprototype>
</funcsynopsis>
<!-- .FN -->
<variablelist>
  <varlistentry>
    <term>
      <emphasis remap='I'>display</emphasis>
    </term>
    <listitem>
      <para>
Specifies the connection to the X server.
      </para>
    </listitem>
  </varlistentry>
  <varlistentry>
    <term>
      <emphasis remap='I'>gc</emphasis>
    </term>
    <listitem>
      <para>
Specifies the GC.
      </para>
    </listitem>
  </varlistentry>
  <varlistentry>
    <term>
      <emphasis remap='I'>graphics_exposures</emphasis>
    </term>
    <listitem>
      <para>
Specifies a Boolean value that indicates whether you want
<symbol>GraphicsExpose</symbol>
and
<symbol>NoExpose</symbol>
events to be reported when calling
<xref linkend='XCopyArea' xrefstyle='select: title'/>
and
<xref linkend='XCopyPlane' xrefstyle='select: title'/>
with this GC.
    </para>
  </listitem>
  </varlistentry>
</variablelist>
<para>
<!-- .LP -->
<!-- .eM -->
<xref linkend='XSetGraphicsExposures' xrefstyle='select: title'/>
can generate
<errorname>BadAlloc</errorname>,
<errorname>BadGC</errorname>,
and
<errorname>BadValue</errorname>
errors.
<!-- .bp -->

</para>
</sect2>
</sect1>
</chapter>