summaryrefslogtreecommitdiff
path: root/specs/libX11/CH04.xml
blob: 973e7907e95f50fb492363351dfa5b82d41529fd (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
<?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='Window_Information_Functions'>
<title>Window Information Functions</title>

<para>
After you connect the display to the X server and create a window, you can use the Xlib window
information functions to:
</para>
<itemizedlist>
  <listitem><para>Obtain information about a window</para></listitem>
  <listitem><para>Translate screen coordinates</para></listitem>
  <listitem><para>Manipulate property lists</para></listitem>
  <listitem><para>Obtain and change window properties</para></listitem>
  <listitem><para>Manipulate selections</para></listitem>
</itemizedlist>

<sect1 id="Obtaining_Window_Information">
<title>Obtaining Window Information</title>
<!-- .XS -->
<!-- (SN Obtaining Window Information  -->
<!-- .XE -->
<para>
<!-- .LP -->
Xlib provides functions that you can use to obtain information about 
the window tree, the window's current attributes, 
the window's current geometry, or the current pointer coordinates.
Because they are most frequently used by window managers,
these functions all return a status to indicate whether the window still
exists.
</para>
<para>
<!-- .LP -->
<!-- .sp -->
To obtain the parent, a list of children, and number of children for 
a given window, use 
<xref linkend='XQueryTree' xrefstyle='select: title'/>.
</para>
<indexterm><primary>Child Window</primary></indexterm>
<indexterm><primary>Parent Window</primary></indexterm>
<indexterm significance="preferred"><primary>XQueryTree</primary></indexterm>
<!-- .sM -->
<funcsynopsis id='XQueryTree'>
<funcprototype>
  <funcdef>Status <function>XQueryTree</function></funcdef>
  <paramdef>Display<parameter> *display</parameter></paramdef>
  <paramdef>Window<parameter> w</parameter></paramdef>
  <paramdef>Window<parameter> *root_return</parameter></paramdef>
  <paramdef>Window<parameter> *parent_return</parameter></paramdef>
  <paramdef>Window<parameter> **children_return</parameter></paramdef>
  <paramdef>unsignedint<parameter> *nchildren_return</parameter></paramdef>
</funcprototype>
</funcsynopsis>
<!-- .FN -->
<variablelist>
  <varlistentry>
    <term>
      <emphasis remap='I'>display</emphasis>
    </term>
    <listitem>
      <para>
Specifies the connection to the X server.
<!-- .ds Wi whose list of children, root, parent, and number of children \ -->
you want to obtain
      </para>
    </listitem>
  </varlistentry>
  <varlistentry>
    <term>
      <emphasis remap='I'>w</emphasis>
    </term>
    <listitem>
      <para>
Specifies the window (Wi.
      </para>
    </listitem>
  </varlistentry>
  <varlistentry>
    <term>
      <emphasis remap='I'>root_return</emphasis>
    </term>
    <listitem>
      <para>
Returns the root window.
      </para>
    </listitem>
  </varlistentry>
  <varlistentry>
    <term>
      <emphasis remap='I'>parent_return</emphasis>
    </term>
    <listitem>
      <para>
Returns the parent window.
      </para>
    </listitem>
  </varlistentry>
  <varlistentry>
    <term>
      <emphasis remap='I'>children_return</emphasis>
    </term>
    <listitem>
      <para>
Returns the list of children.
      </para>
    </listitem>
  </varlistentry>
  <varlistentry>
    <term>
      <emphasis remap='I'>nchildren_return</emphasis>
    </term>
    <listitem>
      <para>
Returns the number of children.
    </para>
  </listitem>
  </varlistentry>
</variablelist>
<para>
<!-- .LP -->
<!-- .eM -->
The
<xref linkend='XQueryTree' xrefstyle='select: title'/>
function returns the root ID, the parent window ID, 
a pointer to the list of children windows
(NULL when there are no children), 
and the number of children in the list for the specified window.
The children are listed in current stacking order, from bottom-most 
(first) to top-most (last).
<xref linkend='XQueryTree' xrefstyle='select: title'/>
returns zero if it fails and nonzero if it succeeds.
To free a non-NULL children list when it is no longer needed, use 
<xref linkend='XFree' xrefstyle='select: title'/>.
</para>
<para>
<!-- .LP -->
<xref linkend='XQueryTree' xrefstyle='select: title'/>
can generate a
<errorname>BadWindow</errorname>
error.
</para>
<para>
<!-- .LP -->
<!-- .sp -->
To obtain the current attributes of a given window, use 
<xref linkend='XGetWindowAttributes' xrefstyle='select: title'/>.
</para>
<indexterm significance="preferred"><primary>XGetWindowAttributes</primary></indexterm>
<!-- .sM -->
<funcsynopsis id='XGetWindowAttributes'>
<funcprototype>
  <funcdef>Status <function>XGetWindowAttributes</function></funcdef>
  <paramdef>Display<parameter> *display</parameter></paramdef>
  <paramdef>Window<parameter> w</parameter></paramdef>
  <paramdef>XWindowAttributes<parameter> *window_attributes_return</parameter></paramdef>
</funcprototype>
</funcsynopsis>
<!-- .FN -->
<variablelist>
  <varlistentry>
    <term>
      <emphasis remap='I'>display</emphasis>
    </term>
    <listitem>
      <para>
Specifies the connection to the X server.
<!-- .ds Wi whose current attributes you want to obtain -->
      </para>
    </listitem>
  </varlistentry>
  <varlistentry>
    <term>
      <emphasis remap='I'>w</emphasis>
    </term>
    <listitem>
      <para>
Specifies the window (Wi.
      </para>
    </listitem>
  </varlistentry>
  <varlistentry>
    <term>
      <emphasis remap='I'>window_attributes_return</emphasis>
    </term>
    <listitem>
      <para>
Returns the specified window's attributes in the
<structname>XWindowAttributes</structname>
structure.
    </para>
  </listitem>
  </varlistentry>
</variablelist>
<para>
<!-- .LP -->
<!-- .eM -->
The
<xref linkend='XGetWindowAttributes' xrefstyle='select: title'/>
function returns the current attributes for the specified window to an
<structname>XWindowAttributes</structname>
structure.
</para>
<para>
<!-- .LP -->
<indexterm significance="preferred"><primary>XWindowAttributes</primary></indexterm>
<!-- .sM -->
<literallayout class="monospaced">
<!-- .TA .5i 3i -->
<!-- .ta .5i 3i -->
typedef struct {
     int x, y;                     /* location of window */
     int width, height;            /* width and height of window */
     int border_width;             /* border width of window */
     int depth;                    /* depth of window */
     Visual *visual;               /* the associated visual structure */
     Window root;                  /* root of screen containing window */
     int class;                    /* InputOutput, InputOnly*/
     int bit_gravity;              /* one of the bit gravity values */
     int win_gravity;              /* one of the window gravity values */
     int backing_store;            /* NotUseful, WhenMapped, Always */
     unsigned long backing_planes; /* planes to be preserved if possible */
     unsigned long backing_pixel;  /* value to be used when restoring planes */
     Bool save_under;              /* boolean, should bits under be saved? */
     Colormap colormap;            /* color map to be associated with window */
     Bool map_installed;           /* boolean, is color map currently installed*/
     int map_state;                /* IsUnmapped, IsUnviewable, IsViewable */
     long all_event_masks;         /* set of events all people have interest in*/
     long your_event_mask;         /* my event mask */
     long do_not_propagate_mask;   /* set of events that should not propagate */
     Bool override_redirect;       /* boolean value for override-redirect */
     Screen *screen;               /* back pointer to correct screen */
} XWindowAttributes;
</literallayout>
</para>
<para>
<!-- .LP -->
<!-- .eM -->
The x and y members are set to the upper-left outer
corner relative to the parent window's origin.
The width and height members are set to the inside size of the window, 
not including the border.
The border_width member is set to the window's border width in pixels.
The depth member is set to the depth of the window 
(that is, bits per pixel for the object).
The visual member is a pointer to the screen's associated
<structname>Visual</structname>
structure.
The root member is set to the root window of the screen containing the window.
The class member is set to the window's class and can be either
<symbol>InputOutput</symbol>
or
<symbol>InputOnly</symbol>.
</para>
<para>
<!-- .LP -->
The bit_gravity member is set to the window's bit gravity
and can be one of the following:
  <simplelist type="vert" columns="2">
    <member><symbol>ForgetGravity</symbol></member>
    <member><symbol>NorthWestGravity</symbol></member>
    <member><symbol>NorthGravity</symbol></member>
    <member><symbol>NorthEastGravity</symbol></member>
    <member><symbol>WestGravity</symbol></member>

    <member><symbol>EastGravity</symbol></member>
    <member><symbol>SouthWestGravity</symbol></member>
    <member><symbol>SouthGravity</symbol></member>
    <member><symbol>SouthEastGravity</symbol></member>
    <member><symbol>StaticGravity</symbol></member>
  </simplelist>
</para>
<para>
The win_gravity member is set to the window's window gravity
and can be one of the following:
  <simplelist type="vert" columns="2">
    <member><symbol>UnmapGravity</symbol></member>
    <member><symbol>NorthWestGravity</symbol></member>
    <member><symbol>NorthGravity</symbol></member>
    <member><symbol>NorthEastGravity</symbol></member>
    <member><symbol>WestGravity</symbol></member>

    <member><symbol>EastGravity</symbol></member>
    <member><symbol>SouthWestGravity</symbol></member>
    <member><symbol>SouthGravity</symbol></member>
    <member><symbol>SouthEastGravity</symbol></member>
    <member><symbol>StaticGravity</symbol></member>
    <member><symbol>CenterGravity</symbol></member>
  </simplelist>
</para>
<para>
<!-- .LP -->
For additional information on gravity,
see <link linkend="Gravity_Attributes">section 3.2.3</link>.
</para>
<para>
<!-- .LP -->
The backing_store member is set to indicate how the X server should maintain
the contents of a window 
and can be 
<symbol>WhenMapped</symbol>,
<symbol>Always</symbol>,
or
<symbol>NotUseful</symbol>.
The backing_planes member is set to indicate (with bits set to 1) which bit 
planes of the window hold dynamic data that must be preserved in backing_stores 
and during save_unders.
The backing_pixel member is set to indicate what values to use 
for planes not set in backing_planes.
</para>
<para>
<!-- .LP -->
The save_under member is set to 
<symbol>True</symbol>
or
<symbol>False</symbol>.
The colormap member is set to the colormap for the specified window and can be
a colormap ID or 
<symbol>None</symbol>.
The map_installed member is set to indicate whether the colormap is 
currently installed and can be 
<symbol>True</symbol>
or
<symbol>False</symbol>.
The map_state member is set to indicate the state of the window and can be
<symbol>IsUnmapped</symbol>,
<symbol>IsUnviewable</symbol>,
or
<symbol>IsViewable</symbol>.
<symbol>IsUnviewable</symbol>
is used if the window is mapped but some ancestor is unmapped.
</para>
<para>
<!-- .LP -->
The all_event_masks member is set to the bitwise inclusive OR of all event 
masks selected on the window by all clients.
The your_event_mask member is set to the bitwise inclusive OR of all event 
masks selected by the querying client.
The do_not_propagate_mask member is set to the bitwise inclusive OR of the 
set of events that should not propagate.
</para>
<para>
<!-- .LP -->
The override_redirect member is set to indicate whether this window overrides
structure control facilities and can be 
<symbol>True</symbol>
or
<symbol>False</symbol>.
Window manager clients should ignore the window if this member is
<symbol>True</symbol>.
</para>
<para>
<!-- .LP -->
The screen member is set to a screen pointer that gives you a back pointer 
to the correct screen.
This makes it easier to obtain the screen information without
having to loop over the root window fields to see which field matches.
</para>
<para>
<!-- .LP -->
<xref linkend='XGetWindowAttributes' xrefstyle='select: title'/>
can generate
<errorname>BadDrawable</errorname>
and
<errorname>BadWindow</errorname>
errors.
</para>
<para>
<!-- .LP -->
<!-- .sp -->
To obtain the current geometry of a given drawable, use 
<xref linkend='XGetGeometry' xrefstyle='select: title'/>.
</para>
<indexterm significance="preferred"><primary>XGetGeometry</primary></indexterm>
<!-- .sM -->
<funcsynopsis id='XGetGeometry'>
<funcprototype>
  <funcdef>Status <function>XGetGeometry</function></funcdef>
  <paramdef>Display<parameter> *display</parameter></paramdef>
  <paramdef>Drawable<parameter> d</parameter></paramdef>
  <paramdef>Window<parameter> *root_return</parameter></paramdef>
  <paramdef>int*x_return,<parameter> *y_return</parameter></paramdef>
  <paramdef>unsignedint*width_return,<parameter> *height_return</parameter></paramdef>
  <paramdef>unsignedint<parameter> *border_width_return</parameter></paramdef>
  <paramdef>unsignedint<parameter> *depth_return</parameter></paramdef>
</funcprototype>
</funcsynopsis>
<!-- .FN -->
<variablelist>
  <varlistentry>
    <term>
      <emphasis remap='I'>display</emphasis>
    </term>
    <listitem>
      <para>
Specifies the connection to the X server.
<!-- .ds Dr , which can be a window or a pixmap -->
      </para>
    </listitem>
  </varlistentry>
  <varlistentry>
    <term>
      <emphasis remap='I'>d</emphasis>
    </term>
    <listitem>
      <para>
Specifies the drawable(Dr. 
      </para>
    </listitem>
  </varlistentry>
  <varlistentry>
    <term>
      <emphasis remap='I'>root_return</emphasis>
    </term>
    <listitem>
      <para>
Returns the root window.
      </para>
    </listitem>
  </varlistentry>
  <varlistentry>
    <term>
      <emphasis remap='I'>x_return</emphasis>
    </term>
    <listitem>
      <para>
<!-- .br -->
<!-- .ns -->
      </para>
    </listitem>
  </varlistentry>
  <varlistentry>
    <term>
      <emphasis remap='I'>y_return</emphasis>
    </term>
    <listitem>
      <para>
Return the x and y coordinates that define the location of the drawable.
For a window, 
these coordinates specify the upper-left outer corner relative to
its parent's origin.
For pixmaps, these coordinates are always zero.
      </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 drawable's dimensions (width and height).
For a window, 
these dimensions specify the inside size, not including the border.
      </para>
    </listitem>
  </varlistentry>
  <varlistentry>
    <term>
      <emphasis remap='I'>border_width_return</emphasis>
    </term>
    <listitem>
      <para>
Returns the border width in pixels. 
If the drawable is a pixmap, it returns zero.
      </para>
    </listitem>
  </varlistentry>
  <varlistentry>
    <term>
      <emphasis remap='I'>depth_return</emphasis>
    </term>
    <listitem>
      <para>
Returns the depth of the drawable (bits per pixel for the object).
    </para>
  </listitem>
  </varlistentry>
</variablelist>
<para>
<!-- .LP -->
<!-- .eM -->
The
<xref linkend='XGetGeometry' xrefstyle='select: title'/>
function returns the root window and the current geometry of the drawable.
The geometry of the drawable includes the x and y coordinates, width and height,
border width, and depth.
These are described in the argument list.
It is legal to pass to this function a window whose class is
<symbol>InputOnly</symbol>.
</para>
<para>
<!-- .LP -->
<xref linkend='XGetGeometry' xrefstyle='select: title'/>
can generate a
<errorname>BadDrawable</errorname>
error.
</para>
</sect1>
<sect1 id="Translating_Screen_Coordinates">
<title>Translating Screen Coordinates</title>
<!-- .XS -->
<!-- (SN Translating Screen Coordinates  -->
<!-- .XE -->
<para>
<!-- .LP -->
Applications sometimes
need to perform a coordinate transformation from the coordinate
space of one window to another window or need to determine which
window the pointing device is in.
<xref linkend='XTranslateCoordinates' xrefstyle='select: title'/>
and
<xref linkend='XQueryPointer' xrefstyle='select: title'/>
fulfill these needs (and avoid any race conditions) by
asking the X server to perform these operations.
</para>
<para>
<!-- .LP -->
<!-- .sp -->
To translate a coordinate in one window to the coordinate
space of another window, use
<xref linkend='XTranslateCoordinates' xrefstyle='select: title'/>.
</para>
<indexterm significance="preferred"><primary>XTranslateCoordinates</primary></indexterm>
<!-- .sM -->
<funcsynopsis id='XTranslateCoordinates'>
<funcprototype>
  <funcdef>Bool <function>XTranslateCoordinates</function></funcdef>
  <paramdef>Display<parameter> *display</parameter></paramdef>
  <paramdef>Windowsrc_w,<parameter> dest_w</parameter></paramdef>
  <paramdef>intsrc_x,<parameter> src_y</parameter></paramdef>
  <paramdef>int*dest_x_return,<parameter> *dest_y_return</parameter></paramdef>
  <paramdef>Window<parameter> *child_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'>src_w</emphasis>
    </term>
    <listitem>
      <para>
Specifies the source window.
      </para>
    </listitem>
  </varlistentry>
  <varlistentry>
    <term>
      <emphasis remap='I'>dest_w</emphasis>
    </term>
    <listitem>
      <para>
Specifies the destination window.
      </para>
    </listitem>
  </varlistentry>
  <varlistentry>
    <term>
      <emphasis remap='I'>src_x</emphasis>
    </term>
    <listitem>
      <para>
<!-- .br -->
<!-- .ns -->
      </para>
    </listitem>
  </varlistentry>
  <varlistentry>
    <term>
      <emphasis remap='I'>src_y</emphasis>
    </term>
    <listitem>
      <para>
Specify the x and y coordinates within the source window.
      </para>
    </listitem>
  </varlistentry>
  <varlistentry>
    <term>
      <emphasis remap='I'>dest_x_return</emphasis>
    </term>
    <listitem>
      <para>
<!-- .br -->
<!-- .ns -->
      </para>
    </listitem>
  </varlistentry>
  <varlistentry>
    <term>
      <emphasis remap='I'>dest_y_return</emphasis>
    </term>
    <listitem>
      <para>
Return the x and y coordinates within the destination window.
      </para>
    </listitem>
  </varlistentry>
  <varlistentry>
    <term>
      <emphasis remap='I'>child_return</emphasis>
    </term>
    <listitem>
      <para>
Returns the child if the coordinates are contained in a mapped child of the
destination window.
    </para>
  </listitem>
  </varlistentry>
</variablelist>
<para>
<!-- .LP -->
<!-- .eM -->
If
<xref linkend='XTranslateCoordinates' xrefstyle='select: title'/>
returns
<symbol>True</symbol>,
it takes the src_x and src_y coordinates relative
to the source window's origin and returns these coordinates to 
dest_x_return and dest_y_return
relative to the destination window's origin.
If
<xref linkend='XTranslateCoordinates' xrefstyle='select: title'/>
returns 
<symbol>False</symbol>,
src_w and dest_w are on different screens,
and dest_x_return and dest_y_return are zero.
If the coordinates are contained in a mapped child of dest_w,
that child is returned to child_return.
Otherwise, child_return is set to
<symbol>None</symbol>.
</para>
<para>
<!-- .LP -->
<xref linkend='XTranslateCoordinates' xrefstyle='select: title'/>
can generate a
<errorname>BadWindow</errorname>
error.
</para>
<para>
<!-- .LP -->
<!-- .sp -->
To obtain the screen coordinates of the pointer
or to determine the pointer coordinates relative to a specified window, use 
<xref linkend='XQueryPointer' xrefstyle='select: title'/>.
</para>
<indexterm significance="preferred"><primary>XQueryPointer</primary></indexterm>
<!-- .sM -->
<funcsynopsis id='XQueryPointer'>
<funcprototype>
  <funcdef>Bool <function>XQueryPointer</function></funcdef>
  <paramdef>Display<parameter> *display</parameter></paramdef>
  <paramdef>Window<parameter> w</parameter></paramdef>
  <paramdef>Window*root_return,<parameter> *child_return</parameter></paramdef>
  <paramdef>int*root_x_return,<parameter> *root_y_return</parameter></paramdef>
  <paramdef>int*win_x_return,<parameter> *win_y_return</parameter></paramdef>
  <paramdef>unsignedint<parameter> *mask_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'>w</emphasis>
    </term>
    <listitem>
      <para>
Specifies the window.
<!-- .ds Ro that the pointer is in -->
      </para>
    </listitem>
  </varlistentry>
  <varlistentry>
    <term>
      <emphasis remap='I'>root_return</emphasis>
    </term>
    <listitem>
      <para>
Returns the root window (Ro.
      </para>
    </listitem>
  </varlistentry>
  <varlistentry>
    <term>
      <emphasis remap='I'>child_return</emphasis>
    </term>
    <listitem>
      <para>
Returns the child window that the pointer is located in, if any.
      </para>
    </listitem>
  </varlistentry>
  <varlistentry>
    <term>
      <emphasis remap='I'>root_x_return</emphasis>
    </term>
    <listitem>
      <para>
<!-- .br -->
<!-- .ns -->
      </para>
    </listitem>
  </varlistentry>
  <varlistentry>
    <term>
      <emphasis remap='I'>root_y_return</emphasis>
    </term>
    <listitem>
      <para>
Return the pointer coordinates relative to the root window's origin.
      </para>
    </listitem>
  </varlistentry>
  <varlistentry>
    <term>
      <emphasis remap='I'>win_x_return</emphasis>
    </term>
    <listitem>
      <para>
<!-- .br -->
<!-- .ns -->
      </para>
    </listitem>
  </varlistentry>
  <varlistentry>
    <term>
      <emphasis remap='I'>win_y_return</emphasis>
    </term>
    <listitem>
      <para>
Return the pointer coordinates relative to the specified window.
      </para>
    </listitem>
  </varlistentry>
  <varlistentry>
    <term>
      <emphasis remap='I'>mask_return</emphasis>
    </term>
    <listitem>
      <para>
Returns the current state of the modifier keys and pointer buttons.
    </para>
  </listitem>
  </varlistentry>
</variablelist>
<para>
<!-- .LP -->
<!-- .eM -->
The
<xref linkend='XQueryPointer' xrefstyle='select: title'/>
function returns the root window the pointer is logically on and the pointer
coordinates relative to the root window's origin.
If
<xref linkend='XQueryPointer' xrefstyle='select: title'/>
returns 
<symbol>False</symbol>,
the pointer is not on the same screen as the specified window, and
<xref linkend='XQueryPointer' xrefstyle='select: title'/>
returns 
<symbol>None</symbol>
to child_return and zero to win_x_return and win_y_return.
If 
<xref linkend='XQueryPointer' xrefstyle='select: title'/>
returns 
<symbol>True</symbol>,
the pointer coordinates returned to win_x_return and win_y_return
are relative to the origin of the specified window.
In this case, 
<xref linkend='XQueryPointer' xrefstyle='select: title'/>
returns the child that contains the pointer, if any,
or else
<symbol>None</symbol>
to child_return.
</para>
<para>
<!-- .LP -->
<xref linkend='XQueryPointer' xrefstyle='select: title'/>
returns the current logical state of the keyboard buttons 
and the modifier keys in mask_return.
It sets mask_return to the bitwise inclusive OR of one or more
of the button or modifier key bitmasks to match 
the current state of the mouse buttons and the modifier keys.
</para>
<para>
<!-- .LP -->
Note that the logical state of a device (as seen through Xlib)
may lag the physical state if device event processing is frozen
(see <link linkend='Pointer_Grabbing'>section 12.1</link>).
</para>
<para>
<!-- .LP -->
<xref linkend='XQueryPointer' xrefstyle='select: title'/>
can generate a
<errorname>BadWindow</errorname>
error.
</para>
</sect1>
<sect1 id="Properties_and_Atoms">
<title>Properties and Atoms</title>
<!-- .XS -->
<!-- (SN Properties and Atoms  -->
<!-- .XE -->
<para>
<!-- .LP -->
A property is a collection of named, typed data.
The window system has a set of predefined properties
<indexterm><primary>Atom</primary><secondary>predefined</secondary></indexterm>
(for example, the name of a window, size hints, and so on), and users can
define any other arbitrary information and associate it with windows.
Each property has a name,
which is an ISO Latin-1 string.
For each named property,
a unique identifier (atom) is associated with it. 
A property also has a type, for example, string or integer.
These types are also indicated using atoms, so arbitrary new
types can be defined.
Data of only one type may be associated with a single
property name.
Clients can store and retrieve properties associated with windows.
For efficiency reasons,
an atom is used rather than a character string.
<xref linkend='XInternAtom' xrefstyle='select: title'/>
can be used to obtain the atom for property names.
<indexterm><primary>Atom</primary></indexterm>
</para>
<para>
<!-- .LP -->
A property is also stored in one of several possible formats.
The X server can store the information as 8-bit quantities, 16-bit
quantities, or 32-bit quantities.
This permits the X server to present the data in the byte order that the
client expects.
<!-- .NT Note -->
If you define further properties of complex type, 
you must encode and decode them yourself.
These functions must be carefully written if they are to be portable.
For further information about how to write a library extension,
see <link linkend="extensions">appendix C</link>.
<!-- .NE -->
The type of a property is defined by an atom, which allows for
arbitrary extension in this type scheme.
<indexterm><primary>Atom</primary></indexterm>
</para>
<para>
<!-- .LP -->
Certain property names are
predefined in the server for commonly used functions.
The atoms for these properties are defined in 
<filename class="headerfile">&lt;X11/Xatom.h&gt;</filename>.
<indexterm type="file"><primary><filename class="headerfile">X11/Xatom.h</filename></primary></indexterm>
<indexterm><primary>Files</primary><secondary><filename class="headerfile">&lt;X11/Xatom.h&gt;</filename></secondary></indexterm>
<indexterm><primary>Headers</primary><secondary><filename class="headerfile">&lt;X11/Xatom.h&gt;</filename></secondary></indexterm>
To avoid name clashes with user symbols, the 
<code>#define</code>
name for each atom has the XA_ prefix.
For an explanation of the functions that let you get and set
much of the information stored in these predefined properties,
see <link linkend='Inter_Client_Communication_Functions'>chapter 14</link>.
</para>
<para>
<!-- .LP -->
The core protocol imposes no semantics on these property names,
but semantics are specified in other X Consortium standards,
such as the <emphasis remap='I'>Inter-Client Communication Conventions Manual</emphasis>
and the <emphasis remap='I'>X Logical Font Description Conventions</emphasis>.
</para>
<para>
<!-- .LP -->
You can use properties to communicate other information between
applications.
The functions described in this section let you define new properties 
and get the unique atom IDs in your applications.
</para>
<para>
<!-- .LP -->
Although any particular atom can have some client interpretation 
within each of the name spaces, 
atoms occur in five distinct name spaces within the protocol: 
</para>
<itemizedlist>
  <listitem>
    <para>
Selections
    </para>
  </listitem>
  <listitem>
    <para>
Property names
    </para>
  </listitem>
  <listitem>
    <para>
Property types
    </para>
  </listitem>
  <listitem>
    <para>
Font properties 
    </para>
  </listitem>
  <listitem>
    <para>
Type of a 
<symbol>ClientMessage</symbol>
event (none are built into the X server)
    </para>
  </listitem>
</itemizedlist>
<para>
<!-- .LP -->
</para>
<para>
<!-- .LP -->
The built-in selection property names are:
<simplelist type="vert" columns="2">
  <member><property>PRIMARY</property></member>
  <member><property>SECONDARY</property></member>
</simplelist>
</para>
<para>
<!-- .LP -->
The built-in property names are: 
  <simplelist type="vert" columns="2">
    <member><property>CUT_BUFFER0</property></member>
    <member><property>CUT_BUFFER1</property></member>
    <member><property>CUT_BUFFER2</property></member>
    <member><property>CUT_BUFFER3</property></member>
    <member><property>CUT_BUFFER4</property></member>
    <member><property>CUT_BUFFER5</property></member>
    <member><property>CUT_BUFFER6</property></member>
    <member><property>CUT_BUFFER7</property></member>
    <member><property>RGB_BEST_MAP</property></member>
    <member><property>RGB_BLUE_MAP</property></member>
    <member><property>RGB_DEFAULT_MAP</property></member>
    <member><property>RGB_GRAY_MAP</property></member>
    <member><property>RGB_GREEN_MAP</property></member>
    <member><property>RGB_RED_MAP</property></member>

    <member><property>RESOURCE_MANAGER</property></member>
    <member><property>WM_CLASS</property></member>
    <member><property>WM_CLIENT_MACHINE</property></member>
    <member><property>WM_COLORMAP_WINDOWS</property></member>
    <member><property>WM_COMMAND</property></member>
    <member><property>WM_HINTS</property></member>
    <member><property>WM_ICON_NAME</property></member>
    <member><property>WM_ICON_SIZE</property></member>
    <member><property>WM_NAME</property></member>
    <member><property>WM_NORMAL_HINTS</property></member>
    <member><property>WM_PROTOCOLS</property></member>
    <member><property>WM_STATE</property></member>
    <member><property>WM_TRANSIENT_FOR</property></member>
    <member><property>WM_ZOOM_HINTS</property></member>
  </simplelist>
</para>
<para>
The built-in property types are: 
  <simplelist type="vert" columns="2">
    <member><property>ARC</property></member>
    <member><property>ATOM</property></member>
    <member><property>BITMAP</property></member>
    <member><property>CARDINAL</property></member>
    <member><property>COLORMAP</property></member>
    <member><property>CURSOR</property></member>
    <member><property>DRAWABLE</property></member>
    <member><property>FONT</property></member>
    <member><property>INTEGER</property></member>
    <member><property>PIXMAP</property></member>
    <member><property>POINT</property></member>
    <member><property>RGB_COLOR_MAP</property></member>
    <member><property>RECTANGLE</property></member>
    <member><property>STRING</property></member>
    <member><property>VISUALID</property></member>
    <member><property>WINDOW</property></member>
    <member><property>WM_HINTS</property></member>
    <member><property>WM_SIZE_HINTS</property></member>
  </simplelist>
</para>
<para>
The built-in font property names are: 
  <simplelist type="vert" columns="2">
    <member><property>MIN_SPACE</property></member>
    <member><property>NORM_SPACE</property></member>
    <member><property>MAX_SPACE</property></member>
    <member><property>END_SPACE</property></member>
    <member><property>SUPERSCRIPT_X</property></member>
    <member><property>SUPERSCRIPT_Y</property></member>
    <member><property>SUBSCRIPT_X</property></member>
    <member><property>SUBSCRIPT_Y</property></member>
    <member><property>UNDERLINE_POSITION</property></member>
    <member><property>UNDERLINE_THICKNESS</property></member>
    <member><property>FONT_NAME</property></member>
    <member><property>FULL_NAME</property></member>

    <member><property>STRIKEOUT_DESCENT</property></member>
    <member><property>STRIKEOUT_ASCENT</property></member>
    <member><property>ITALIC_ANGLE</property></member>
    <member><property>X_HEIGHT</property></member>
    <member><property>QUAD_WIDTH</property></member>
    <member><property>WEIGHT</property></member>
    <member><property>POINT_SIZE</property></member>
    <member><property>RESOLUTION</property></member>
    <member><property>COPYRIGHT</property></member>
    <member><property>NOTICE</property></member>
    <member><property>FAMILY_NAME</property></member>
    <member><property>CAP_HEIGHT</property></member>
  </simplelist>
</para>
<para>
<!-- .LP -->
For further information about font properties,
see <link linkend="Font_Metrics">section 8.5</link>.
</para>
<para>
<!-- .LP -->
<!-- .sp -->
To return an atom for a given name, use 
<xref linkend='XInternAtom' xrefstyle='select: title'/>.
</para>
<indexterm><primary>Atom</primary><secondary>interning</secondary></indexterm>
<indexterm significance="preferred"><primary>XInternAtom</primary></indexterm>
<!-- .sM -->
<funcsynopsis id='XInternAtom'>
<funcprototype>
  <funcdef>Atom <function>XInternAtom</function></funcdef>
  <paramdef>Display<parameter> *display</parameter></paramdef>
  <paramdef>char<parameter> *atom_name</parameter></paramdef>
  <paramdef>Bool<parameter> only_if_exists</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'>atom_name</emphasis>
    </term>
    <listitem>
      <para>
Specifies the name associated with the atom you want returned.
      </para>
    </listitem>
  </varlistentry>
  <varlistentry>
    <term>
      <emphasis remap='I'>only_if_exists</emphasis>
    </term>
    <listitem>
      <para>
Specifies a Boolean value that indicates whether the atom must be created.
    </para>
  </listitem>
  </varlistentry>
</variablelist>
<para>
<!-- .LP -->
<!-- .eM -->
The
<xref linkend='XInternAtom' xrefstyle='select: title'/>
function returns the atom identifier associated with the specified atom_name
string.
If only_if_exists is 
<symbol>False</symbol>,
the atom is created if it does not exist.
Therefore,
<xref linkend='XInternAtom' xrefstyle='select: title'/>
can return
<symbol>None</symbol>.
If the atom name is not in the Host Portable Character Encoding, 
the result is implementation-dependent.
Uppercase and lowercase matter;
the strings ``thing'', ``Thing'', and ``thinG'' 
all designate different atoms.  
The atom will remain defined even after the client's connection closes.
It will become undefined only when the last connection to
the X server closes.
</para>
<para>
<!-- .LP -->
<xref linkend='XInternAtom' xrefstyle='select: title'/>
can generate
<errorname>BadAlloc</errorname>
and
<errorname>BadValue</errorname>
errors.
</para>
<para>
<!-- .LP -->
<!-- .sp -->
To return atoms for an array of names, use 
<xref linkend='XInternAtoms' xrefstyle='select: title'/>.
</para>
<indexterm><primary>Atom</primary><secondary>interning</secondary></indexterm>
<indexterm significance="preferred"><primary>XInternAtoms</primary></indexterm>
<!-- .sM -->
<funcsynopsis id='XInternAtoms'>
<funcprototype>
  <funcdef>Status <function>XInternAtoms</function></funcdef>
  <paramdef>Display<parameter> *display</parameter></paramdef>
  <paramdef>char<parameter> **names</parameter></paramdef>
  <paramdef>int<parameter> count</parameter></paramdef>
  <paramdef>Bool<parameter> only_if_exists</parameter></paramdef>
  <paramdef>Atom<parameter> *atoms_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'>names</emphasis>
    </term>
    <listitem>
      <para>
Specifies the array of atom names.
<!-- .ds Cn atom names in the array -->
      </para>
    </listitem>
  </varlistentry>
  <varlistentry>
    <term>
      <emphasis remap='I'>count</emphasis>
    </term>
    <listitem>
      <para>
Specifies the number of (Cn.
      </para>
    </listitem>
  </varlistentry>
  <varlistentry>
    <term>
      <emphasis remap='I'>only_if_exists</emphasis>
    </term>
    <listitem>
      <para>
Specifies a Boolean value that indicates whether the atom must be created.
      </para>
    </listitem>
  </varlistentry>
  <varlistentry>
    <term>
      <emphasis remap='I'>atoms_return</emphasis>
    </term>
    <listitem>
      <para>
Returns the atoms.
    </para>
  </listitem>
  </varlistentry>
</variablelist>
<para>
<!-- .LP -->
<!-- .eM -->
The
<xref linkend='XInternAtoms' xrefstyle='select: title'/>
function returns the atom identifiers associated with the specified names.
The atoms are stored in the atoms_return array supplied by the caller.
Calling this function is equivalent to calling
<xref linkend='XInternAtom' xrefstyle='select: title'/>
for each of the names in turn with the specified value of only_if_exists,
but this function minimizes the number of round-trip protocol exchanges
between the client and the X server.
</para>
<para>
<!-- .LP -->
This function returns a nonzero status if atoms are returned for
all of the names;
otherwise, it returns zero.
</para>
<para>
<!-- .LP -->
<xref linkend='XInternAtoms' xrefstyle='select: title'/>
can generate
<errorname>BadAlloc</errorname>
and
<errorname>BadValue</errorname>
errors.
</para>
<para>
<!-- .LP -->
<!-- .sp -->
To return a name for a given atom identifier, use 
<xref linkend='XGetAtomName' xrefstyle='select: title'/>.
</para>
<indexterm><primary>Atom</primary><secondary>getting name</secondary></indexterm>
<indexterm significance="preferred"><primary>XGetAtomName</primary></indexterm>
<!-- .sM -->
<funcsynopsis id='XGetAtomName'>
<funcprototype>
  <funcdef>char *<function>XGetAtomName</function></funcdef>
  <paramdef>Display<parameter> *display</parameter></paramdef>
  <paramdef>Atom<parameter> atom</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'>atom</emphasis>
    </term>
    <listitem>
      <para>
Specifies the atom for the property name you want returned.
    </para>
  </listitem>
  </varlistentry>
</variablelist>
<para>
<!-- .LP -->
<!-- .eM -->
The
<xref linkend='XGetAtomName' xrefstyle='select: title'/>
function returns the name associated with the specified atom.
If the data returned by the server is in the Latin Portable Character Encoding,
then the returned string is in the Host Portable Character Encoding.
Otherwise, the result is implementation-dependent.
To free the resulting string,
call
<xref linkend='XFree' xrefstyle='select: title'/>.
</para>
<para>
<!-- .LP -->
<xref linkend='XGetAtomName' xrefstyle='select: title'/>
can generate a
<errorname>BadAtom</errorname>
error.
</para>
<para>
<!-- .LP -->
<!-- .sp -->
To return the names for an array of atom identifiers, use 
<xref linkend='XGetAtomNames' xrefstyle='select: title'/>.
</para>
<indexterm><primary>Atom</primary><secondary>getting name</secondary></indexterm>
<indexterm significance="preferred"><primary>XGetAtomNames</primary></indexterm>
<!-- .sM -->
<funcsynopsis id='XGetAtomNames'>
<funcprototype>
  <funcdef>Status <function>XGetAtomNames</function></funcdef>
  <paramdef>Display<parameter> *display</parameter></paramdef>
  <paramdef>Atom<parameter> *atoms</parameter></paramdef>
  <paramdef>int<parameter> count</parameter></paramdef>
  <paramdef>char<parameter> **names_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'>atoms</emphasis>
    </term>
    <listitem>
      <para>
Specifies the array of atoms.
<!-- .ds Cn atoms in the array -->
      </para>
    </listitem>
  </varlistentry>
  <varlistentry>
    <term>
      <emphasis remap='I'>count</emphasis>
    </term>
    <listitem>
      <para>
Specifies the number of (Cn.
      </para>
    </listitem>
  </varlistentry>
  <varlistentry>
    <term>
      <emphasis remap='I'>names_return</emphasis>
    </term>
    <listitem>
      <para>
Returns the atom names.
    </para>
  </listitem>
  </varlistentry>
</variablelist>
<para>
<!-- .LP -->
<!-- .eM -->
The
<xref linkend='XGetAtomNames' xrefstyle='select: title'/>
function returns the names associated with the specified atoms.
The names are stored in the names_return array supplied by the caller.
Calling this function is equivalent to calling
<xref linkend='XGetAtomName' xrefstyle='select: title'/>
for each of the atoms in turn,
but this function minimizes the number of round-trip protocol exchanges
between the client and the X server.
</para>
<para>
<!-- .LP -->
This function returns a nonzero status if names are returned for
all of the atoms;
otherwise, it returns zero.
</para>
<para>
<!-- .LP -->
<xref linkend='XGetAtomNames' xrefstyle='select: title'/>
can generate a
<errorname>BadAtom</errorname>
error.
</para>
</sect1>
<sect1 id="Obtaining_and_Changing_Window_Properties">
<title>Obtaining and Changing Window Properties</title>
<!-- .XS -->
<!-- (SN Obtaining and Changing Window Properties  -->
<!-- .XE -->
<para>
<!-- .LP -->
You can attach a property list to every window.
Each property has a name, a type, and a value
(see <link linkend="Properties_and_Atoms">section 4.3</link>).
The value is an array of 8-bit, 16-bit, or 32-bit quantities,
whose interpretation is left to the clients.  The type
<type>char</type>
is used to represent 8-bit quantities, the type
<type>short</type>
is used to represent 16-bit quantities, and the type
<type>long</type>
is used to represent 32-bit quantities.
</para>
<para>
<!-- .LP -->
Xlib provides functions that you can use to obtain, 
change, update, or interchange window properties.
In addition, Xlib provides other utility functions for inter-client
communication
(see <link linkend='Inter_Client_Communication_Functions'>chapter 14</link>).
</para>
<para>
<!-- .LP -->
<!-- .sp -->
To obtain the type, format, and value of a property of a given window, use 
<xref linkend='XGetWindowProperty' xrefstyle='select: title'/>.
<indexterm><primary>Property</primary><secondary>getting</secondary></indexterm>
</para>
<!-- .LP -->
<indexterm significance="preferred"><primary>XGetWindowProperty</primary></indexterm>
<!-- .sM -->
<funcsynopsis id='XGetWindowProperty'>
<funcprototype>
  <funcdef>int <function>XGetWindowProperty</function></funcdef>
  <paramdef><parameter> display</parameter></paramdef>
  <paramdef><parameter> w</parameter></paramdef>
  <paramdef><parameter> property</parameter></paramdef>
  <paramdef><parameter> long_offset</parameter></paramdef>
  <paramdef><parameter> long_length</parameter></paramdef>
  <paramdef><parameter> delete</parameter></paramdef>
  <paramdef><parameter> req_type</parameter></paramdef>
  <paramdef><parameter> actual_type_return</parameter></paramdef>
  <paramdef><parameter> actual_format_return</parameter></paramdef>
  <paramdef><parameter> nitems_return</parameter></paramdef>
  <paramdef><parameter> bytes_after_return</parameter></paramdef>
  <paramdef>.br<parameter> prop_return</parameter></paramdef>
</funcprototype>
</funcsynopsis>
<!-- .FN -->
<variablelist>
  <varlistentry>
    <term>
      <emphasis remap='I'>display</emphasis>
    </term>
    <listitem>
      <para>
Specifies the connection to the X server.
<!-- .ds Wi whose property you want to obtain -->
      </para>
    </listitem>
  </varlistentry>
  <varlistentry>
    <term>
      <emphasis remap='I'>w</emphasis>
    </term>
    <listitem>
      <para>
Specifies the window (Wi.
      </para>
    </listitem>
  </varlistentry>
  <varlistentry>
    <term>
      <emphasis remap='I'>property</emphasis>
    </term>
    <listitem>
      <para>
Specifies the property name.
      </para>
    </listitem>
  </varlistentry>
  <varlistentry>
    <term>
      <emphasis remap='I'>long_offset</emphasis>
    </term>
    <listitem>
      <para>
Specifies the offset in the specified property (in 32-bit quantities) 
where the data is to be retrieved.
      </para>
    </listitem>
  </varlistentry>
  <varlistentry>
    <term>
      <emphasis remap='I'>long_length</emphasis>
    </term>
    <listitem>
      <para>
Specifies the length in 32-bit multiples of the data to be retrieved.
      </para>
    </listitem>
  </varlistentry>
  <varlistentry>
    <term>
      <emphasis remap='I'>delete</emphasis>
    </term>
    <listitem>
      <para>
Specifies a Boolean value that determines whether the property is deleted.
      </para>
    </listitem>
  </varlistentry>
  <varlistentry>
    <term>
      <emphasis remap='I'>req_type</emphasis>
    </term>
    <listitem>
      <para>
Specifies the atom identifier associated with the property type or
<symbol>AnyPropertyType</symbol>.
      </para>
    </listitem>
  </varlistentry>
  <varlistentry>
    <term>
      <emphasis remap='I'>actual_type_return</emphasis>
    </term>
    <listitem>
      <para>
Returns the atom identifier  that defines the actual type of the property.
      </para>
    </listitem>
  </varlistentry>
  <varlistentry>
    <term>
      <emphasis remap='I'>actual_format_return</emphasis>
    </term>
    <listitem>
      <para>
Returns the actual format of the property.
      </para>
    </listitem>
  </varlistentry>
  <varlistentry>
    <term>
      <emphasis remap='I'>nitems_return</emphasis>
    </term>
    <listitem>
      <para>
Returns the actual number of 8-bit, 16-bit, or 32-bit items 
stored in the prop_return data.
      </para>
    </listitem>
  </varlistentry>
  <varlistentry>
    <term>
      <emphasis remap='I'>bytes_after_return</emphasis>
    </term>
    <listitem>
      <para>
Returns the number of bytes remaining to be read in the property if 
a partial read was performed.
      </para>
    </listitem>
  </varlistentry>
  <varlistentry>
    <term>
      <emphasis remap='I'>prop_return</emphasis>
    </term>
    <listitem>
      <para>
Returns the data in the specified format.
    </para>
  </listitem>
  </varlistentry>
</variablelist>
<para>
<!-- .LP -->
<!-- .eM -->
The
<xref linkend='XGetWindowProperty' xrefstyle='select: title'/>
function returns the actual type of the property; the actual format of the property;
the number of 8-bit, 16-bit, or 32-bit items transferred; the number of bytes remaining
to be read in the property; and a pointer to the data actually returned.
<xref linkend='XGetWindowProperty' xrefstyle='select: title'/>
sets the return arguments as follows:
</para>
<itemizedlist>
  <listitem>
    <para>
If the specified property does not exist for the specified window,
<xref linkend='XGetWindowProperty' xrefstyle='select: title'/>
returns 
<symbol>None</symbol>
to actual_type_return and the value zero to 
actual_format_return and bytes_after_return.
The nitems_return argument is empty.
In this case, the delete argument is ignored.
    </para>
  </listitem>
  <listitem>
    <para>
If the specified property exists 
but its type does not match the specified type,
<xref linkend='XGetWindowProperty' xrefstyle='select: title'/>
returns the actual property type to actual_type_return, 
the actual property format (never zero) to actual_format_return, 
and the property length in bytes
(even if the actual_format_return is 16 or 32) 
to bytes_after_return.
It also ignores the delete argument.
The nitems_return argument is empty.
    </para>
  </listitem>
  <listitem>
    <para>
If the specified property exists and either you assign 
<symbol>AnyPropertyType</symbol>
to the req_type argument or the specified type matches the actual property type,
<xref linkend='XGetWindowProperty' xrefstyle='select: title'/>
returns the actual property type to actual_type_return and the actual
property format (never zero) to actual_format_return. 
It also returns a value to bytes_after_return and nitems_return, by 
defining the following
values:
    </para>
  </listitem>
  <listitem>
    <para>
<!-- .nf -->
     N = actual length of the stored property in bytes
          (even if the format is 16 or 32)
     I = 4 * long_offset
     T = N - I
     L = MINIMUM(T, 4 * long_length)
     A = N - (I + L)
<!-- .fi -->
    </para>
  </listitem>
  <listitem>
    <para>
The returned value starts at byte index I in the property (indexing
from zero), and its length in bytes is L.
If the value for long_offset causes L to be negative,
a
<errorname>BadValue</errorname>
error results. 
The value of bytes_after_return is A, 
giving the number of trailing unread bytes in the stored property.
    </para>
  </listitem>
</itemizedlist>
<para>
<!-- .LP -->
If the returned format is 8, the returned data is represented as a
<type>char</type>
array.
If the returned format is 16, the returned data is represented as a
<type>short</type>
array and should be cast to that type to obtain the elements.
If the returned format is 32, the returned data is represented as a
<type>long</type>
array and should be cast to that type to obtain the elements.
</para>
<para>
<!-- .LP -->
<xref linkend='XGetWindowProperty' xrefstyle='select: title'/>
always allocates one extra byte in prop_return 
(even if the property is zero length) 
and sets it to zero so that simple properties consisting of characters
do not have to be copied into yet another string before use.
</para>
<para>
<!-- .LP -->
If delete is 
<symbol>True</symbol>
and bytes_after_return is zero, 
<xref linkend='XGetWindowProperty' xrefstyle='select: title'/>
deletes the property 
from the window and generates a 
<symbol>PropertyNotify</symbol>
event on the window.
</para>
<para>
<!-- .LP -->
The function returns
<symbol>Success</symbol>
if it executes successfully.
To free the resulting data,
use
<xref linkend='XFree' xrefstyle='select: title'/>.
</para>
<para>
<!-- .LP -->
<xref linkend='XGetWindowProperty' xrefstyle='select: title'/>
can generate
<errorname>BadAtom</errorname>,
<errorname>BadValue</errorname>,
and
<errorname>BadWindow</errorname>
errors.
</para>
<para>
<!-- .LP -->
<!-- .sp -->
To obtain a given window's property list, use 
<xref linkend='XListProperties' xrefstyle='select: title'/>.
</para>
<indexterm><primary>Property</primary><secondary>listing</secondary></indexterm>
<indexterm significance="preferred"><primary>XListProperties</primary></indexterm>
<!-- .sM -->
<funcsynopsis id='XListProperties'>
<funcprototype>
  <funcdef>Atom *<function>XListProperties</function></funcdef>
  <paramdef>Display<parameter> *display</parameter></paramdef>
  <paramdef>Window<parameter> w</parameter></paramdef>
  <paramdef>int<parameter> *num_prop_return</parameter></paramdef>
</funcprototype>
</funcsynopsis>
<!-- .FN -->
<variablelist>
  <varlistentry>
    <term>
      <emphasis remap='I'>display</emphasis>
    </term>
    <listitem>
      <para>
Specifies the connection to the X server.
<!-- .ds Wi whose property list you want to obtain -->
      </para>
    </listitem>
  </varlistentry>
  <varlistentry>
    <term>
      <emphasis remap='I'>w</emphasis>
    </term>
    <listitem>
      <para>
Specifies the window (Wi.
      </para>
    </listitem>
  </varlistentry>
  <varlistentry>
    <term>
      <emphasis remap='I'>num_prop_return</emphasis>
    </term>
    <listitem>
      <para>
Returns the length of the properties array.
    </para>
  </listitem>
  </varlistentry>
</variablelist>
<para>
<!-- .LP -->
<!-- .eM -->
The
<xref linkend='XListProperties' xrefstyle='select: title'/>
function returns a pointer to an array of atom properties that are defined for 
the specified window or returns NULL if no properties were found.
To free the memory allocated by this function, use
<xref linkend='XFree' xrefstyle='select: title'/>.
</para>
<para>
<!-- .LP -->
<xref linkend='XListProperties' xrefstyle='select: title'/>
can generate a
<errorname>BadWindow</errorname>
error.
</para>
<para>
<!-- .LP -->
<!-- .sp -->
To change a property of a given window, use
<xref linkend='XChangeProperty' xrefstyle='select: title'/>.
</para>
<indexterm><primary>Property</primary><secondary>changing</secondary></indexterm>
<indexterm><primary>Property</primary><secondary>appending</secondary></indexterm>
<indexterm><primary>Property</primary><secondary>prepending</secondary></indexterm>
<indexterm><primary>Property</primary><secondary>replacing</secondary></indexterm>
<indexterm><primary>Property</primary><secondary>format</secondary></indexterm>
<indexterm><primary>Property</primary><secondary>type</secondary></indexterm>
<indexterm significance="preferred"><primary>XChangeProperty</primary></indexterm>
<!-- .sM -->
<funcsynopsis id='XChangeProperty'>
<funcprototype>
  <funcdef><function>XChangeProperty</function></funcdef>
  <paramdef>Display<parameter> *display</parameter></paramdef>
  <paramdef>Window<parameter> w</parameter></paramdef>
  <paramdef>Atomproperty,<parameter> type</parameter></paramdef>
  <paramdef>int<parameter> format</parameter></paramdef>
  <paramdef>int<parameter> mode</parameter></paramdef>
  <paramdef>unsignedchar<parameter> *data</parameter></paramdef>
  <paramdef>int<parameter> nelements</parameter></paramdef>
</funcprototype>
</funcsynopsis>
<!-- .FN -->
<variablelist>
  <varlistentry>
    <term>
      <emphasis remap='I'>display</emphasis>
    </term>
    <listitem>
      <para>
Specifies the connection to the X server.
<!-- .ds Wi whose property you want to change -->
      </para>
    </listitem>
  </varlistentry>
  <varlistentry>
    <term>
      <emphasis remap='I'>w</emphasis>
    </term>
    <listitem>
      <para>
Specifies the window (Wi.
      </para>
    </listitem>
  </varlistentry>
  <varlistentry>
    <term>
      <emphasis remap='I'>property</emphasis>
    </term>
    <listitem>
      <para>
Specifies the property name.
      </para>
    </listitem>
  </varlistentry>
  <varlistentry>
    <term>
      <emphasis remap='I'>type</emphasis>
    </term>
    <listitem>
      <para>
Specifies the type of the property.
The X server does not interpret the type but simply
passes it back to an application that later calls 
<xref linkend='XGetWindowProperty' xrefstyle='select: title'/>.
      </para>
    </listitem>
  </varlistentry>
  <varlistentry>
    <term>
      <emphasis remap='I'>format</emphasis>
    </term>
    <listitem>
      <para>
Specifies whether the data should be viewed as a list
of 8-bit, 16-bit, or 32-bit quantities.
Possible values are 8, 16, and 32.
This information allows the X server to correctly perform
byte-swap operations as necessary.
If the format is 16-bit or 32-bit,
you must explicitly cast your data pointer to an (unsigned char *) in the call
to 
<xref linkend='XChangeProperty' xrefstyle='select: title'/>.
<!-- .\" Changed name of this file to prop_mode.a on 1/13/87 -->
      </para>
    </listitem>
  </varlistentry>
  <varlistentry>
    <term>
      <emphasis remap='I'>mode</emphasis>
    </term>
    <listitem>
      <para>
Specifies the mode of the operation.
You can pass
<symbol>PropModeReplace</symbol>,
<symbol>PropModePrepend</symbol>,
or
<symbol>PropModeAppend</symbol>.
      </para>
    </listitem>
  </varlistentry>
  <varlistentry>
    <term>
      <emphasis remap='I'>data</emphasis>
    </term>
    <listitem>
      <para>
Specifies the property data.
      </para>
    </listitem>
  </varlistentry>
  <varlistentry>
    <term>
      <emphasis remap='I'>nelements</emphasis>
    </term>
    <listitem>
      <para>
Specifies the number of elements of the specified data format.
    </para>
  </listitem>
  </varlistentry>
</variablelist>
<para>
<!-- .LP -->
<!-- .eM -->
The
<xref linkend='XChangeProperty' xrefstyle='select: title'/>
function alters the property for the specified window and
causes the X server to generate a
<symbol>PropertyNotify</symbol>
event on that window.
<xref linkend='XChangeProperty' xrefstyle='select: title'/>
performs the following:
</para>
<itemizedlist>
  <listitem>
    <para>
If mode is
<symbol>PropModeReplace</symbol>,
<xref linkend='XChangeProperty' xrefstyle='select: title'/>
discards the previous property value and stores the new data.
    </para>
  </listitem>
  <listitem>
    <para>
If mode is
<symbol>PropModePrepend</symbol>
or
<symbol>PropModeAppend</symbol>,
<xref linkend='XChangeProperty' xrefstyle='select: title'/>
inserts the specified data before the beginning of the existing data
or onto the end of the existing data, respectively.
The type and format must match the existing property value,
or a
<errorname>BadMatch</errorname>
error results.
If the property is undefined, 
it is treated as defined with the correct type and
format with zero-length data.
    </para>
  </listitem>
</itemizedlist>
<para>
<!-- .LP -->
If the specified format is 8, the property data must be a
<type>char</type>
array.
If the specified format is 16, the property data must be a
<type>short</type>
array.
If the specified format is 32, the property data must be a
<type>long</type>
array.
</para>
<para>
<!-- .LP -->
The lifetime of a property is not tied to the storing client.
Properties remain until explicitly deleted, until the window is destroyed,
or until the server resets.
For a discussion of what happens when the connection to the X server is closed,
see <link linkend='Using_X_Server_Connection_Close_Operations'>section 2.6</link>.
The maximum size of a property is server dependent and can vary dynamically
depending on the amount of memory the server has available.
(If there is insufficient space, a
<errorname>BadAlloc</errorname>
error results.)
</para>
<para>
<!-- .LP -->
<xref linkend='XChangeProperty' xrefstyle='select: title'/>
can generate
<errorname>BadAlloc</errorname>,
<errorname>BadAtom</errorname>,
<errorname>BadMatch</errorname>,
<errorname>BadValue</errorname>,
and
<errorname>BadWindow</errorname>
errors.
</para>
<para>
<!-- .LP -->
<!-- .sp -->
To rotate a window's property list, use
<xref linkend='XRotateWindowProperties' xrefstyle='select: title'/>.
</para>
<!-- .LP -->
<indexterm significance="preferred"><primary>XRotateWindowProperties</primary></indexterm>
<!-- .sM -->
<funcsynopsis id='XRotateWindowProperties'>
<funcprototype>
  <funcdef><function>XRotateWindowProperties</function></funcdef>
  <paramdef>Display<parameter> *display</parameter></paramdef>
  <paramdef>Window<parameter> w</parameter></paramdef>
  <paramdef>Atom<parameter> properties[]</parameter></paramdef>
  <paramdef>int<parameter> num_prop</parameter></paramdef>
  <paramdef>int<parameter> npositions</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'>w</emphasis>
    </term>
    <listitem>
      <para>
Specifies the window.
      </para>
    </listitem>
  </varlistentry>
  <varlistentry>
    <term>
      <emphasis remap='I'>properties</emphasis>
    </term>
    <listitem>
      <para>
Specifies the array of properties that are to be rotated.
      </para>
    </listitem>
  </varlistentry>
  <varlistentry>
    <term>
      <emphasis remap='I'>num_prop</emphasis>
    </term>
    <listitem>
      <para>
Specifies the length of the properties array.
      </para>
    </listitem>
  </varlistentry>
  <varlistentry>
    <term>
      <emphasis remap='I'>npositions</emphasis>
    </term>
    <listitem>
      <para>
Specifies the rotation amount.
    </para>
  </listitem>
  </varlistentry>
</variablelist>
<para>
<!-- .LP -->
<!-- .eM -->
The
<xref linkend='XRotateWindowProperties' xrefstyle='select: title'/>
function allows you to rotate properties on a window and causes
the X server to generate
<symbol>PropertyNotify</symbol>
events.
If the property names in the properties array are viewed as being numbered 
starting from zero and if there are num_prop property names in the list,
then the value associated with property name I becomes the value associated 
with property name (I + npositions) mod N for all I from zero to N &minus; 1.
The effect is to rotate the states by npositions places around the virtual ring
of property names (right for positive npositions, 
left for negative npositions).
If npositions mod N is nonzero,
the X server generates a
<symbol>PropertyNotify</symbol>
event for each property in the order that they are listed in the array.
If an atom occurs more than once in the list or no property with that 
name is defined for the window,
a 
<errorname>BadMatch</errorname>
error results.
If a 
<errorname>BadAtom</errorname>
or 
<errorname>BadMatch</errorname>
error results,
no properties are changed.
</para>
<para>
<!-- .LP -->
<xref linkend='XRotateWindowProperties' xrefstyle='select: title'/>
can generate
<errorname>BadAtom</errorname>,
<errorname>BadMatch</errorname>,
and
<errorname>BadWindow</errorname>
errors.
</para>
<para>
<!-- .LP -->
<!-- .sp -->
To delete a property on a given window, use 
<xref linkend='XDeleteProperty' xrefstyle='select: title'/>.
</para>
<indexterm><primary>Property</primary><secondary>deleting</secondary></indexterm>
<indexterm significance="preferred"><primary>XDeleteProperty</primary></indexterm>
<!-- .sM -->
<funcsynopsis id='XDeleteProperty'>
<funcprototype>
  <funcdef><function>XDeleteProperty</function></funcdef>
  <paramdef>Display<parameter> *display</parameter></paramdef>
  <paramdef>Window<parameter> w</parameter></paramdef>
  <paramdef>Atom<parameter> property</parameter></paramdef>
</funcprototype>
</funcsynopsis>
<!-- .FN -->
<variablelist>
  <varlistentry>
    <term>
      <emphasis remap='I'>display</emphasis>
    </term>
    <listitem>
      <para>
Specifies the connection to the X server.
<!-- .ds Wi whose property you want to delete -->
      </para>
    </listitem>
  </varlistentry>
  <varlistentry>
    <term>
      <emphasis remap='I'>w</emphasis>
    </term>
    <listitem>
      <para>
Specifies the window (Wi.
      </para>
    </listitem>
  </varlistentry>
  <varlistentry>
    <term>
      <emphasis remap='I'>property</emphasis>
    </term>
    <listitem>
      <para>
Specifies the property name.
    </para>
  </listitem>
  </varlistentry>
</variablelist>
<para>
<!-- .LP -->
<!-- .eM -->
The
<xref linkend='XDeleteProperty' xrefstyle='select: title'/>
function deletes the specified property only if the
property was defined on the specified window
and causes the X server to generate a
<symbol>PropertyNotify</symbol>
event on the window unless the property does not exist.
</para>
<para>
<!-- .LP -->
<xref linkend='XDeleteProperty' xrefstyle='select: title'/>
can generate
<errorname>BadAtom</errorname>
and
<errorname>BadWindow</errorname>
errors.
</para>
</sect1>
<sect1 id="Selections">
<title>Selections</title>
<!-- .XS -->
<!-- (SN Selections -->
<!-- .XE -->
<para>
<!-- .LP -->
<indexterm><primary>Selection</primary></indexterm>
Selections are one method used by applications to exchange data.
By using the property mechanism,
applications can exchange data of arbitrary types and can negotiate
the type of the data.
A selection can be thought of as an indirect property with a dynamic type.
That is, rather than having the property stored in the X server,
the property is maintained by some client (the owner).
A selection is global in nature (considered to belong to the user 
but be maintained by clients) rather than being private to a particular 
window subhierarchy or a particular set of clients.
</para>
<para>
<!-- .LP -->
Xlib provides functions that you can use to set, get, or request conversion
of selections.
This allows applications to implement the notion of current selection,
which requires that notification be sent to applications when they no 
longer own the selection.
Applications that support selection often highlight the current selection
and so must be informed when another application has
acquired the selection so that they can unhighlight the selection.
</para>
<para>
<!-- .LP -->
When a client asks for the contents of
a selection, it specifies a selection target type.
This target type
can be used to control the transmitted representation of the contents.
For example, if the selection is ``the last thing the user clicked on''
and that is currently an image, then the target type might specify
whether the contents of the image should be sent in XY format or Z format.
</para>
<para>
<!-- .LP -->
The target type can also be used to control the class of
contents transmitted, for example, 
asking for the ``looks'' (fonts, line
spacing, indentation, and so forth) of a paragraph selection, not the
text of the paragraph.
The target type can also be used for other
purposes.
The protocol does not constrain the semantics.
</para>
<para>
<!-- .LP -->
<!-- .sp -->
To set the selection owner, use 
<xref linkend='XSetSelectionOwner' xrefstyle='select: title'/>.
</para>
<indexterm><primary>Selection</primary><secondary>setting the owner</secondary></indexterm>
<indexterm significance="preferred"><primary>XSetSelectionOwner</primary></indexterm>
<!-- .sM -->
<funcsynopsis id='XSetSelectionOwner'>
<funcprototype>
  <funcdef><function>XSetSelectionOwner</function></funcdef>
  <paramdef>Display<parameter> *display</parameter></paramdef>
  <paramdef>Atom<parameter> selection</parameter></paramdef>
  <paramdef>Window<parameter> owner</parameter></paramdef>
  <paramdef>Time<parameter> time</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'>selection</emphasis>
    </term>
    <listitem>
      <para>
Specifies the selection atom.
      </para>
    </listitem>
  </varlistentry>
  <varlistentry>
    <term>
      <emphasis remap='I'>owner</emphasis>
    </term>
    <listitem>
      <para>
Specifies the owner of the specified selection atom.
You can pass a window or
<symbol>None</symbol>.
      </para>
    </listitem>
  </varlistentry>
  <varlistentry>
    <term>
      <emphasis remap='I'>time</emphasis>
    </term>
    <listitem>
      <para>
Specifies the time.
You can pass either a timestamp or
<symbol>CurrentTime</symbol>.
    </para>
  </listitem>
  </varlistentry>
</variablelist>
<para>
<!-- .LP -->
<!-- .eM -->
The
<xref linkend='XSetSelectionOwner' xrefstyle='select: title'/>
function changes the owner and last-change time for the specified selection
and has no effect if the specified time is earlier than the current
last-change time of the specified selection 
or is later than the current X server time.
Otherwise, the last-change time is set to the specified time,
with
<symbol>CurrentTime</symbol>
replaced by the current server time.
If the owner window is specified as
<symbol>None</symbol>,
then the owner of the selection becomes 
<symbol>None</symbol>
(that is, no owner).
Otherwise, the owner of the selection becomes the client executing
the request.
</para>
<para>
<!-- .LP  -->
If the new owner (whether a client or
<symbol>None</symbol>)
is not
the same as the current owner of the selection and the current
owner is not
<symbol>None</symbol>,
the current owner is sent a 
<symbol>SelectionClear</symbol>
event.
If the client that is the owner of a selection is later
terminated (that is, its connection is closed)
or if the owner window it has specified in the request is later
destroyed,
the owner of the selection automatically
reverts to
<symbol>None</symbol>,
but the last-change time is not affected.
The selection atom is uninterpreted by the X server.
<xref linkend='XGetSelectionOwner' xrefstyle='select: title'/>
returns the owner window, which is reported in 
<symbol>SelectionRequest</symbol>
and
<symbol>SelectionClear</symbol>
events.
Selections are global to the X server.
</para>
<para>
<!-- .LP -->
<xref linkend='XSetSelectionOwner' xrefstyle='select: title'/>
can generate
<errorname>BadAtom</errorname>
and
<errorname>BadWindow</errorname>
errors.
</para>
<para>
<!-- .LP -->
<!-- .sp -->
To return the selection owner, use 
<xref linkend='XGetSelectionOwner' xrefstyle='select: title'/>.
</para>
<indexterm><primary>Selection</primary><secondary>getting the owner</secondary></indexterm>
<indexterm significance="preferred"><primary>XGetSelectionOwner</primary></indexterm>
<!-- .sM -->
<funcsynopsis id='XGetSelectionOwner'>
<funcprototype>
  <funcdef>Window <function>XGetSelectionOwner</function></funcdef>
  <paramdef>Display<parameter> *display</parameter></paramdef>
  <paramdef>Atom<parameter> selection</parameter></paramdef>
</funcprototype>
</funcsynopsis>
<!-- .FN -->
<variablelist>
  <varlistentry>
    <term>
      <emphasis remap='I'>display</emphasis>
    </term>
    <listitem>
      <para>
Specifies the connection to the X server.
<!-- .ds Se whose owner you want returned -->
      </para>
    </listitem>
  </varlistentry>
  <varlistentry>
    <term>
      <emphasis remap='I'>selection</emphasis>
    </term>
    <listitem>
      <para>
Specifies the selection atom (Se.
    </para>
  </listitem>
  </varlistentry>
</variablelist>
<para>
<!-- .LP -->
<!-- .eM -->
The
<xref linkend='XGetSelectionOwner' xrefstyle='select: title'/>
function
returns the window ID associated with the window that currently owns the
specified selection.
If no selection was specified, the function returns the constant
<symbol>None</symbol>.
If
<symbol>None</symbol>
is returned,
there is no owner for the selection.
</para>
<para>
<!-- .LP -->
<xref linkend='XGetSelectionOwner' xrefstyle='select: title'/>
can generate a
<errorname>BadAtom</errorname>
error.
</para>
<para>
<!-- .LP -->
<!-- .sp -->
To request conversion of a selection, use 
<xref linkend='XConvertSelection' xrefstyle='select: title'/>.
</para>
<indexterm><primary>Selection</primary><secondary>converting</secondary></indexterm>
<indexterm significance="preferred"><primary>XConvertSelection</primary></indexterm>
<!-- .sM -->
<funcsynopsis id='XConvertSelection'>
<funcprototype>
  <funcdef><function>XConvertSelection</function></funcdef>
  <paramdef>Display<parameter> *display</parameter></paramdef>
  <paramdef>Atomselection,<parameter> target</parameter></paramdef>
  <paramdef>Atom<parameter> property</parameter></paramdef>
  <paramdef>Window<parameter> requestor</parameter></paramdef>
  <paramdef>Time<parameter> time</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'>selection</emphasis>
    </term>
    <listitem>
      <para>
Specifies the selection atom.
      </para>
    </listitem>
  </varlistentry>
  <varlistentry>
    <term>
      <emphasis remap='I'>target</emphasis>
    </term>
    <listitem>
      <para>
Specifies the target atom.
      </para>
    </listitem>
  </varlistentry>
  <varlistentry>
    <term>
      <emphasis remap='I'>property</emphasis>
    </term>
    <listitem>
      <para>
Specifies the property name.
You also can pass 
<symbol>None</symbol>.
      </para>
    </listitem>
  </varlistentry>
  <varlistentry>
    <term>
      <emphasis remap='I'>requestor</emphasis>
    </term>
    <listitem>
      <para>
Specifies the requestor.
      </para>
    </listitem>
  </varlistentry>
  <varlistentry>
    <term>
      <emphasis remap='I'>time</emphasis>
    </term>
    <listitem>
      <para>
Specifies the time.
You can pass either a timestamp or
<symbol>CurrentTime</symbol>.
    </para>
  </listitem>
  </varlistentry>
</variablelist>
<para>
<!-- .LP -->
<!-- .eM -->
<xref linkend='XConvertSelection' xrefstyle='select: title'/>
requests that the specified selection be converted to the specified target
type:
</para>
<itemizedlist>
  <listitem>
    <para>
If the specified selection has an owner, the X server sends a
<symbol>SelectionRequest</symbol>
event to that owner.
    </para>
  </listitem>
  <listitem>
    <para>
If no owner for the specified
selection exists, the X server generates a
<symbol>SelectionNotify</symbol>
event to the
requestor with property
<symbol>None</symbol>.
    </para>
  </listitem>
</itemizedlist>
<para>
<!-- .LP -->
The arguments are passed on unchanged in either of the events.
There are two predefined selection atoms: PRIMARY and SECONDARY.
</para>
<para>
<!-- .LP -->
<xref linkend='XConvertSelection' xrefstyle='select: title'/>
can generate
<errorname>BadAtom</errorname>
and
<errorname>BadWindow</errorname>
errors.
<!-- .bp -->


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