summaryrefslogtreecommitdiff
path: root/xts5/Xlib3/XCloseDisplay.m
blob: 355c344864d14ac15a516efdde4a41b5f9e0bee1 (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
Copyright (c) 2005 X.Org Foundation L.L.C.

Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
of the Software, and to permit persons to whom the Software is furnished to do
so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

Copyright (c) Applied Testing and Technology, Inc. 1995
All Rights Reserved.

>># Project: VSW5
>># 
>># File: xts5/Xlib3/XCloseDisplay.m
>># 
>># Description:
>># 	Tests for XCloseDisplay()
>># 
>># Modifications:
>># $Log: clsdsply.m,v $
>># Revision 1.3  2006-05-12 10:41:58  gwc
>># In test 6 avoid using client2 in both parent and child by
>># calling XOpenDisplay() instead of opendisplay() and moving
>># the XCheckWindowEvent() on client2 into the child.
>>#
>># Revision 1.2  2005/11/03 08:43:17  jmichael
>># clean up all vsw5 paths to use xts5 instead.
>>#
>># Revision 1.1.1.2  2005/04/15 14:05:24  anderson
>># Reimport of the base with the legal name in the copyright fixed.
>>#
>># Revision 8.0  1998/12/23 23:35:02  mar
>># Branch point for Release 5.0.2
>>#
>># Revision 7.0  1998/10/30 22:57:28  mar
>># Branch point for Release 5.0.2b1
>>#
>># Revision 6.0  1998/03/02 05:26:18  tbr
>># Branch point for Release 5.0.1
>>#
>># Revision 5.0  1998/01/26 03:22:51  tbr
>># Branch point for Release 5.0.1b1
>>#
>># Revision 4.1  1996/05/09 00:29:59  andy
>># Corrected Xatom include
>>#
>># Revision 4.0  1995/12/15  09:12:10  tbr
>># Branch point for Release 5.0.0
>>#
>># Revision 3.1  1995/12/15  01:15:04  andy
>># Prepare for GA Release
>>#
>>#:
/*
Portions of this software are based on Xlib and X Protocol Test Suite.
We have used this material under the terms of its copyright, which grants
free use, subject to the conditions below.  Note however that those
portions of this software that are based on the original Test Suite have
been significantly revised and that all such revisions are copyright (c)
1995 Applied Testing and Technology, Inc.  Insomuch as the proprietary
revisions cannot be separated from the freely copyable material, the net
result is that use of this software is governed by the ApTest copyright.

Copyright (c) 1990, 1991  X Consortium

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE
X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Except as contained in this notice, the name of the X Consortium shall not be
used in advertising or otherwise to promote the sale, use or other dealings
in this Software without prior written authorization from the X Consortium.

Permission to use, copy, modify, distribute, and sell this software and
its documentation for any purpose is hereby granted without fee,
provided that the above copyright notice appear in all copies and that
both that copyright notice and this permission notice appear in
supporting documentation, and that the name of UniSoft not be
used in advertising or publicity pertaining to distribution of the
software without specific, written prior permission.  UniSoft
makes no representations about the suitability of this software for any
purpose.  It is provided "as is" without express or implied warranty.
*/
>>TITLE XCloseDisplay Xlib3

XCloseDisplay(display)
Display	*display = Dsp;
>>EXTERN

#include	"string.h"
#include	"X11/Xatom.h"

#define PROTECT(x)	_startcall(display);\
			x;\
			_endcall(display);\
			if(geterr() != Success) {\
				report("Got %s, Expecting %s.", errorname(geterr()), errorname(Success));\
				FAIL;\
			} else\
				CHECK;

#define OPEN(disp, closemode)	\
	if((disp = XOpenDisplay(config.display)) == (Display *) NULL) { \
		delete("XOpenDisplay() returned NULL."); \
		return; \
	} else \
		CHECK; \
	XSetCloseDownMode(disp, closemode);

#define DELETE_ONERR(line, errstr) \
	startcall(display); \
	line; \
	endcall(display); \
	if(geterr() != Success) { \
		delete("%s() generated a %s error.", errstr, errorname(geterr())); \
		return; \
	} else \
		CHECK;

#define FAIL_ONERR(line, errstr, id) \
	startcall(Dsp); \
	line; \
	endcall(Dsp); \
	if(geterr() == Success) { \
		report(errstr, TestName, (long) id); \
		FAIL; \
	} else \
		CHECK;

#define FAIL_ONERR2(line, errstr, id, mode) \
	startcall(Dsp); \
	line; \
	endcall(Dsp); \
	if(geterr() != Success) { \
		report(errstr, TestName, (long) id, mode); \
		report("Error was %s instead of Success", errorname(geterr())); \
		FAIL; \
	} else \
		CHECK;

#define FAIL_ONERR3(line, err, errstr, id) \
	startcall(Dsp); \
	line; \
	endcall(Dsp); \
	if(geterr() != err) { \
		report("Got error %s instead of %s.", errorname(geterr()), errorname(err)); \
		report(errstr, TestName, (long) id); \
		FAIL; \
	} else \
		CHECK;

#define FAIL_ONERR4(line, err, errstr, id, mode) \
	startcall(Dsp); \
	line; \
	endcall(Dsp); \
	if(geterr() != err) { \
		report(errstr, TestName, (long) id, mode); \
		report("Got error %s instead of %s", errorname(geterr()), errorname(err)); \
		FAIL; \
	} else \
		CHECK;

char	*cmode[2] = { 	" for a client with a closedown mode of RetainPermanent",
			" for a client with a closedown mode of RetainTemporary" };

int	closemodes[2] = { RetainPermanent, RetainTemporary };

>>ASSERTION Good B 3
A call to xname flushes the output buffer and waits until each flushed request has
been received and processed by the X server.
>>ASSERTION Good B 3
A call to xname closes the connection specified by the
.A display
argument.
>>STRATEGY
If the system is POSIX compliant:
  Open a display using XOpenDisplay.
  Obtain the file descriptor of the connection using XConnectionNumber.
  Close the display using xname.
  Close the file descriptor using close.
  Verify that the call returned -1.
Otherwise:
  UNTESTED.
>>CODE
int	fd;

	if(config.posix_system == 0) {
		untested("This assertion can only be tested on a POSIX system.");
		return;
	} else
		CHECK;

	if((display = XOpenDisplay(config.display)) == (Display *) NULL) {
		delete("XOpenDisplay() returned NULL.");
		return;
	} else
		CHECK;

	fd = XConnectionNumber(display);

	PROTECT(XCloseDisplay(display))

	if( close(fd) != -1) {
		report("%s() did not close file descriptor %d.", TestName, fd);
		FAIL;
	} else
		CHECK;

	CHECKPASS(4);

>>ASSERTION Good A
A call to xname disowns all selections made by the client.
>>STRATEGY
Open a display using XOpenDisplay.
Create a client window using XCreateWindow.
Acquire the XA_PRIMARY selection using XSetSelectionOwner.
Verify that the client owns the selection with XGetSelectionOwner.
Close the display using xname.
Verify that the XA_PRIMARY selection is not owned with XGetSelectionOwner.
>>CODE
Window	client;
Atom	selection = XA_PRIMARY;

	if((display = XOpenDisplay(config.display)) == (Display *) NULL) {
		delete("XOpenDisplay() returned NULL.");
		return;
	} else
		CHECK;

	regdisable();
	client = defwin(display);
	regenable();

	XSetSelectionOwner(display, selection, client, CurrentTime);
	
	if(XGetSelectionOwner(display, selection) != client) {
		delete("Failed to get selection XA_PRIMARY.");
		XCloseDisplay(display);
		return;
	} else
		CHECK;

	PROTECT(XCloseDisplay(display))
	sleep(config.speedfactor);

	if(XGetSelectionOwner(Dsp, selection) != (Window) None) {
		report("%s() did not disown selection XA_PRIMARY.", TestName);
		return;
	} else
		CHECK;

	CHECKPASS(4);


>>ASSERTION Good A
When the client has actively grabbed the pointer, then a call to xname
performs a
.S XUngrabPointer .
>>STRATEGY
Open a display using XOpenDisplay.
Grab the pointer using XGrabPointer.
Verify that the call returned GrabSuccess.
Close the display using xname.
Grab the pointer using XGrabPointer.
Verify that the call returned GrabSuccess.
>>CODE
Window	gw, ow;

	if( (display = XOpenDisplay(config.display)) == (Display *) NULL) {
		delete("XOpenDisplay() returned NULL.");
		return;
	} else
		CHECK;

	regdisable();
	gw = defwin(display);
	ow = defwin(Dsp);
	regenable();

	if(XGrabPointer(display, gw, True, 0L, GrabModeAsync, GrabModeAsync, None, None, CurrentTime) != GrabSuccess) {
		delete("XGrabPointer did not return GrabSuccess.");
		XCloseDisplay(display);
		return;
	} else
		CHECK;

	XSync(display, False);

	if(XGrabPointer(Dsp, ow, True, 0L, GrabModeAsync, GrabModeAsync, None, None, CurrentTime) != AlreadyGrabbed) {
		delete("XGrabPointer did not return AlreadyGrabbed.");
		XCloseDisplay(display);
		return;
	} else
		CHECK;

	PROTECT(XCloseDisplay(display))
	sleep(config.speedfactor);

	if(XGrabPointer(Dsp, ow, True, 0L, GrabModeAsync, GrabModeAsync, None, None, CurrentTime) != GrabSuccess) {
		report("%s() did not ungrab the pointer.", TestName);
		FAIL;
	} else
		CHECK;

	CHECKPASS(5);

	XUngrabPointer(Dsp, CurrentTime);
	
>>ASSERTION Good A
When the client has actively grabbed the keyboard, then a call to xname
performs a
.S XUngrabKeyboard .
>>STRATEGY
Open a display using XOpenDisplay.
Grab the keyboard using XGrabKeyboard.
Verify that the call returned GrabSuccess.
Close the display using xname.
Grab the keyboard using XGrabKeyboard.
Verify that the call returned GrabSuccess.
>>CODE
Window	gw, ow;

	if( (display = XOpenDisplay(config.display)) == (Display *) NULL) {
		delete("XOpenDisplay() returned NULL.");
		return;
	} else
		CHECK;

	regdisable();
	gw = defwin(display);
	ow = defwin(Dsp);
	regenable();

	if(XGrabKeyboard(display, gw, True, GrabModeAsync, GrabModeAsync, CurrentTime) != GrabSuccess) {
		delete("XGrabKeyboard did not return GrabSuccess.");
		XCloseDisplay(display);
		return;
	} else
		CHECK;

	XSync(display, False);

	if(XGrabKeyboard(Dsp, ow, True, GrabModeAsync, GrabModeAsync, CurrentTime) != AlreadyGrabbed) {
		delete("XGrabKeyboard did not return AlreadyGrabbed.");
		XCloseDisplay(display);
		return;
	} else
		CHECK;

	PROTECT(XCloseDisplay(display))
	sleep(config.speedfactor);

	if(XGrabKeyboard(Dsp, ow, True, GrabModeAsync, GrabModeAsync, CurrentTime) != GrabSuccess) {
		report("%s() did not ungrab the keyboard.", TestName);
		FAIL;
	} else
		CHECK;

	CHECKPASS(5);

	XUngrabKeyboard(Dsp, CurrentTime);
	
>>ASSERTION Good A
When the client has grabbed the server, then
a call to xname performs a
.S XUngrabServer .
>>STRATEGY
Create a connection for client1 using XOpenDisplay.
Create a connection for client2 using XOpenDisplay.
Create a window using XCreateWindow.
Grab the server for the default display using XGrabServer.
Create a process using tet_fork.
In child process:
   Generate a ChangeProperty request using XChangeProperty.
Wait sufficient time for the ChangeProperty request to be processed.
Verify that no PropertyChange event has been generated by client2 using XCheckWindowEvent.
Close the client1 connection using xname.
In child process:
    Wait suffient time for the ChangeProperty request to be processed.
    Verify that a ChangeProperty request was generated by client2.
>>EXTERN
int	waittime = -1;
Atom	at;
Window	win;
Display	*client2;
char	*atname = "XT_TEST_Atom";
static int t006p_pass = 0;
static void
t006p()
{
XEvent	ev;
int	pass=0;

	sleep(waittime);

	if(XCheckWindowEvent(display, win, PropertyChangeMask, &ev) == True) {
		delete("A request was processed for a non-grabbing client.");
		return;
	} else
		CHECK;

	XCloseDisplay(display);
	
	sleep(waittime);	
	
	t006p_pass = pass;
}

static void
t006c()
{
XEvent	ev;
long	val;

	val = 666;
	settimeout(waittime * 3);
	XChangeProperty(client2, win, at, XA_INTEGER, 32, PropModeReplace, (unsigned char *) &val, 1);
	XFlush(client2);
	cleartimeout();
	
	sleep(2*waittime);	
	
	if(XCheckWindowEvent(client2, win, PropertyChangeMask, &ev) == False) {
		exit(2);
	}

	exit(0);
}
>>CODE

	waittime = 2*config.speedfactor + 5;

	win = defwin(Dsp);


	if((display = XOpenDisplay(config.display)) == (Display *) NULL) {
		delete("XOpenDisplay() returned NULL.");
		return;
	}

	client2 = XOpenDisplay(config.display);
	
	if(client2 == (Display *) NULL) {
		delete("XOpenDisplay() returned NULL.");
		XCloseDisplay(display);
		return;
	}

	XSelectInput(client2, win, PropertyChangeMask);
	XSelectInput(display, win, PropertyChangeMask);
	at = XInternAtom(display, atname, False);
	XGrabServer(display);
	XSync(display, False);
	XFlush(client2);

	switch(tet_fork(t006c, t006p, waittime, TIMEOUT_EXIT|2))
	{
	case TIMEOUT_EXIT:
		delete("Child process timed out.");
		break;
	case 2:
		report("%s() did not ungrab the server.", TestName);
		FAIL;
		break;
	case 0:
		CHECK;
		break;
	default:
		/* tet_fork() failed */
		return;
	}

	if (t006p_pass == 1)
		CHECK;

	/*
	 * We need to close client2 otherwise it interferes with
	 * later "last close" tests.  On POSIX systems we can
	 * directly close the underlying fd.  On other systems
	 * we use XCloseDisplay() and hope that the fact it was
	 * used in the child doesn't cause a problem.
	 */
	if(config.posix_system == 1) {
		close(ConnectionNumber(client2));
	}
	else {
		XCloseDisplay(client2);
	}

	CHECKPASS(2);

>>ASSERTION Good B 1
A call to xname releases all passive grabs made by the client.
>>ASSERTION Good A
A call to xname frees the default GC for the client.
>>STRATEGY
Open a connection using XOpenDisplay.
Obtain the default gc id using XDefaultGC.
Close the display using xname.
Call XDrawPoint using the default gc id.
Verify that a BadGC error occurred.
>>CODE
GC		gc;

	if((display = XOpenDisplay(config.display)) == (Display *) NULL) {
		delete("XOpenDisplay() returned NULL.");
		return;
	} else
		CHECK;

	gc = XDefaultGC(display, DefaultScreen(display));

	PROTECT(XCloseDisplay(display))
	sleep(config.speedfactor);

	startcall(Dsp);
	XDrawPoint(Dsp, DRW(Dsp), gc, 0,0);
	endcall(Dsp);

	if(geterr() != BadGC) {
		report("%s() did not free the default GC.", TestName);
		FAIL;
	} else
		CHECK;

	CHECKPASS(3);

>>ASSERTION Good B 1
When the closedown mode of the client is
.S RetainPermanent ,
then all resources allocated by the client are marked as permanent.
>>ASSERTION Good B 1
When the closedown mode of the client is
.S RetainTemporary ,
then all resources allocated by the client are marked as temporary.
>>#
>># Close-down mode of DestroyAll section.
>>#
>>ASSERTION Good A
When the closedown mode of the client is
.S DestroyAll ,
then on a call to xname all windows in the client's save-set that are
inferiors of a window created by the client are reparented, 
with no change in position relative to the root window,
to the closest ancestor such that it is not an inferior of a client's window.
>>STRATEGY
Open a display using XOpenDisplay.
Set the closedown mode of the display to DestroyAll using XSetCloseDownMode.
Create save set with setupsaveset.
Close the display using xname.
Verify reparenting for the save-set occurs and positioning is correct.
>>EXTERN
/*
 * This code is identical to that in addtsvst.m, and should stay that way.
 */

/*
 * These windows are created by client1.
 */
char	*T1[] = {
	"base borders",
	"client1-A base (10,40) 9x4",
	"client1-C base (50,60) 60x60",
	"client1-D base (5,50) 35x70",
	"client1-B base (30,6) 60x30",
};

/*
 * These windows are created by client2 using client1's windows as parent.
 * This will lead to some windows being clipped by their (client1) parent,
 * when the client2 windows are reparented then these should reappear.
 */
char	*T2[] = {
	". borders",
	"client2-a-noadd-nomap . (15, 5) 12x4 unmap",
	"client2-b-noadd . (10, 10) 12x6",
#define	NOADD	2	/* Number not added */
	"client2-c-unmap . (30, 28) 14x7 unmap",
	"client2-d . (45, 15) 9x7",
	"client2-e . (15, 23) 9x7",
};

/*
 * The number of windows that should be reparented.  NOADD of the client2
 * windows is not added to the save set.
 */
#define	NUM_REPARENT ((NELEM(T1)-1)*(NELEM(T2)-NOADD-1))

/* Flags used in uflags */
#define	IN_SAVE_SET	0x01
#define	CLIENT1_INFERIOR	0x02
#define	ON_PARENT	0x04
#define	ON_WINDOW	0x10

/*
 * Create a bunch of windows.  Some are created by client1.  Others are
 * created by client2.  Of the latter some are inferiors of client1 and
 * are marked CLIENT1_INFERIOR.  Some of client2's windows are added to
 * client1's save-set - these are marked IN_SAVE_SET.
 * Client2 windows that are originally unmapped will be marked BT_UNMAP.
 * Structure events are selected for on display Dsp for all appropriate
 * windows.
 * Before returning, client1 is destroyed.
 */
void
setupsaveset(btret, client1, client2)
struct	buildtree	*btret[NELEM(T1)];
Display			*client1;
Display			*client2;
{
Window	base;
Window	w;
XWindowAttributes	batts;
struct	buildtree	*bt1;
struct	buildtree	*btp;
int 	i, j;
int 	pass = 0, fail = 0;

	display = client1;
	base = defwin(Dsp);
	XSync(Dsp, False);

	/*
	 * Build a tree for client1, build a tree for client2 on each of
	 * the client1 windows + the base window.
	 */
	bt1 = buildtree(client1, base, T1, NELEM(T1));
	for (i = 0; i < NELEM(T1); i++) {
		btret[i] = buildtree(client2, bt1[i].wid, T2, NELEM(T2));
		/*
		 * Transfer some of the information down from the client1 windows
		 * into the returned array.  This means that all the positions
		 * in the returned array will be relative to base.
		 */
		btret[i][0].x = bt1[i].x;
		btret[i][0].y = bt1[i].y;
		btret[i][0].borderwidth = bt1[i].borderwidth;
	}

	XSync(client2, False);

	for (i = 0; i < NELEM(T1); i++) {
		for (j = 0; j < NELEM(T2); j++) {

			btp = &btret[i][j];
			w = btp->wid;

			/*
			 * For j==0 --> client1 window.
			 * The window at j==1 is not added to the save-set;
			 * the rest are.
			 */
			if (j > NOADD) {
				btp->uflags |= IN_SAVE_SET;
				XAddToSaveSet(display, w);
			} /* else not added to save set */

			/*
			 * The windows with i=0 are inferiors of the base window
			 * and not one of client1's window.
			 */
			if (i != 0)
				btp->uflags |= CLIENT1_INFERIOR;

			XSelectInput(Dsp, w, StructureNotifyMask);
		}
	}
	XSelectInput(Dsp, base, SubstructureNotifyMask);

/* Store base window coordinates to allow for absolute coordinate checking */
	XGetWindowAttributes(Dsp, base, &batts);
	btret[0][0].x = batts.x;
	btret[0][0].y = batts.y;
	btret[0][0].borderwidth = batts.border_width;

	XSync(Dsp, False);

	PROTECT(XCloseDisplay(display));
	sleep(config.speedfactor);

	XSync(Dsp, False);
	XSync(client2, False);

}
>>CODE
Display	*client1, *client2;
struct	buildtree *bt[NELEM(T1)];
struct	buildtree *btp;
Window	parent;
Window	dummy;
Window	*children;
Window	base;
unsigned int 	nchild;
int 	i, j;
struct	buildtree *cli1btp;
int 	oldx, oldy;
int 	newx, newy;
XWindowAttributes	atts, batts;


	client1 = XOpenDisplay(config.display);
	client2 = opendisplay();

	if(client1 == (Display *) NULL || client2 == (Display *) NULL) {
		delete("Could not open the display.");
		if(client1)
			XCloseDisplay(client1);
		return;
	} else
		CHECK;

	XSetCloseDownMode(client1, DestroyAll);
	setupsaveset(bt, client1, client2);

	/*
	 * Base will be stored in bt[0][0] all the windows should be reparented
	 * to there.
	 */
	base = bt[0][0].wid;

/* Get the current base window coordinates for absolute calculations */
	XGetWindowAttributes(Dsp, base, &batts);
	if (batts.x != bt[0][0].x || batts.y != bt[0][0].y) {
		report("Window reparenting caused the base window to move");
		report("Pre-reparenting  (%d,%d)" , bt[0][0].x, bt[0][0].y);
		report("Post-reparenting (%d,%d)" , batts.x, batts.y);
		FAIL;
	} else
		CHECK;

	for (i = 0; i < NELEM(T1); i++) {
		for (j = 1; j < NELEM(T2); j++) {

			btp = bt[i] + j;

			/*
			 * Skip if it shouldn't have been reparented.
			 */
			btp->uflags &= (IN_SAVE_SET|CLIENT1_INFERIOR);
			if (btp->uflags != (IN_SAVE_SET|CLIENT1_INFERIOR))
				continue;

			/* Get new parent */
			XQueryTree(Dsp, btp->wid, &dummy, &parent, &children, &nchild);
			if (children && nchild > 0)
				XFree((char*)children);
				
			if (parent != base) {
				report("Window not reparented to correct parent");
				FAIL;
			} else
				CHECK;
		}
	}

	for (i = 0; i < NELEM(T1); i++) {

		/*
		 * Get the information relating to the original client1 window
		 * (that no longer exists).
		 */
		cli1btp = bt[i];

		for (j = 1; j < NELEM(T2); j++) {
			btp = bt[i] + j;

			/*
			 * Skip if it shouldn't have been reparented.
			 */
			btp->uflags &= (IN_SAVE_SET|CLIENT1_INFERIOR);
			if (btp->uflags != (IN_SAVE_SET|CLIENT1_INFERIOR))
				continue;

			debug(1, "window %s", btp->name);

			oldx = bt[0][0].x + bt[0][0].borderwidth + cli1btp->x + cli1btp->borderwidth + btp->x;
			oldy = bt[0][0].y + bt[0][0].borderwidth + cli1btp->y + cli1btp->borderwidth + btp->y;

			XGetWindowAttributes(Dsp, btp->wid, &atts);

			newx = batts.x + batts.border_width + atts.x;
			newy = batts.y + batts.border_width + atts.y;

			/*
			 * Most R4 servers seem to have a bug here.  When the window
			 * to which the windows are being reparented is not at the
			 * origin, then the windows get displaced by an amount equal
			 * to the position of the window.
			 */
			if (oldx != newx || oldy != newy) {
				report("Coords relative to root changed after reparenting");
				report(" (%d, %d), expecting (%d, %d)"
					, newx, newy, oldx, oldy);
				FAIL;
			} else
				CHECK;
		}
	}


	CHECKPASS(2 + NUM_REPARENT + NUM_REPARENT);

>>ASSERTION Good A
When the closedown mode of the client is
.S DestroyAll ,
then a call to xname performs a
.S XMapWindow
request on all unmapped windows in the client's save-set.
>># The strategy and code is very similar to a test for addtsvst.m, and it 
>># should stay that way.
>>STRATEGY
Open a display using XOpenDisplay.
Create save set with setupsaveset.
Close the display using xname.
Get all map events.
Compare each event against expected values.
Verify that map events were received for all save-set windows that
were inferiors of client1 or were not originally mapped.
Verify that map events were received for the parents of all save-set
windows that were inferiors of client1 or were not originally mapped.
>>CODE
Display		*client1, *client2;
XEvent	ev;
XMapEvent	good;
XMapEvent	*mp;
Window	base;
struct	buildtree *bt[NELEM(T1)];
struct	buildtree *btp;
int 	loop;
int 	i, j;


	client1 = XOpenDisplay(config.display);
	client2 = opendisplay();

	if(client1 == (Display *) NULL || client1 == (Display *) NULL) {
		delete("Could not open the display.");
		if(client1)
			XCloseDisplay(client1);
		return;
	} else
		CHECK;

	XSetCloseDownMode(client1, DestroyAll);
	setupsaveset(bt, client1, client2);

	base = bt[0][0].wid;

	defsetevent(good, Dsp, MapNotify);
	good.override_redirect = False;

	loop = 0;
	while (getevent(Dsp, &ev)) {
		if (ev.type != MapNotify)
			continue;
		mp = (XMapEvent*)&ev;

		/*
		 * Find the window that this event refers to.
		 */
		for (i = 0, btp = NULL; btp == NULL && i < NELEM(T1); i++)
			btp = btwtobtp(bt[i], mp->window);

		if (btp == NULL) {
			report("Map event received for unrecognised window");
			FAIL;
			XCloseDisplay(client1);
			return;
		}

		if (mp->event == mp->window) {
			/* On window itself */
			if (btp->uflags & ON_WINDOW) {
				report("Repeated map event on window");
				FAIL;
			} else if (loop == 0)
				CHECK;
			btp->uflags |= ON_WINDOW;
			good.event = btp->wid;
		} else {
			if (btp->uflags & ON_PARENT) {
				report("Repeated map event on parent of window");
				FAIL;
			} else if (loop == 0)
				CHECK;
			btp->uflags |= ON_PARENT;
			good.event = base;
		}

		good.window = btp->wid;

		if (checkevent((XEvent*)&good, &ev))
			FAIL;
		else if (loop == 0)
			CHECK;

		loop++;
	}

	for (i = 0; i < NELEM(T1); i++) {
		for (j = 1; j < NELEM(T2); j++) {
			btp = bt[i] + j;

			debug(1, "window %s", btp->name);

			/*
			 * A map should be received when:
			 *    IN_SAVE_SET && CLIENT1_INFERIOR
			 * || IN_SAVE_SET && BT_UNMAP
			 */
			if (( (btp->uflags & IN_SAVE_SET) &&
				(btp->uflags & CLIENT1_INFERIOR) )
			|| ( (btp->uflags & IN_SAVE_SET) &&
				(btp->opts & BT_UNMAP) ))
			{

				if (btp->uflags & ON_WINDOW) {
					CHECK;
				} else {
					report("Map event was not received on window");
					FAIL;
				}
				if (btp->uflags & ON_PARENT) {
					CHECK;
				} else {
					report("Map event was not received on parent of window");
					FAIL;
				}
			} else if (btp->uflags & (ON_WINDOW|ON_PARENT)) {

				if ((btp->uflags & IN_SAVE_SET) == 0) {
					report("Map event was received for window that was not in save-set");
					FAIL;
				}
				if ((btp->opts & BT_UNMAP) == 0) {
					report("Map event was received for window that was already mapped");
					FAIL;
				}
			} else {
				CHECK;
				CHECK;	/* For balance with above */
			}

		}
	}

	CHECKPASS(1 + 2 + (2*NELEM(T1)*(NELEM(T2)-1)));

>>SET startup fontfocusstartup
>>SET cleanup fontfocuscleanup
>>ASSERTION Good A
When the closedown mode of the client is
.S DestroyAll ,
then a call to xname destroys all
.S Window ,
.S Font ,
.S Pixmap ,
>># COMMENT : .S Bitmap ,
>># COMMENT : Removed since Pixmap is a bitmap.
>># - Cal.
.S Colormap ,
.S Cursor
and
.S GContext
resources allocated by the client.
>>STRATEGY
Open a display using XOpenDisplay.
Set the closedown mode of the display to DestroyAll using XSetCloseDownMode.
Create a font using XLoadFont.
Create a window using XCreateSimpleWindow.
Create a pixmap using XCreatePixmap.
Create a colormap using XCreateColormap.
Create a cursor using XCreateFontCursor.
Create a GC using XCreateGC.
Close the display using xname.
Free the GC using XFreeGC.
Verify that a BadGC error occurred.
Free the cursor using XFreeCursor.
Verify that a BadCursor error occurred.
Free the colormap using XFreeColormap.
Verify that a BadColor error occurred.
Draw on the pixmap with XDrawPoint.
Verify that a BadDrawable error occurred.
Draw on the window using XDrawPoint.
Verify that a BadDrawable error occurred.
Free the font using XUnloadFont.
Verify that a BadFont error occurred.
>>CODE
Font		font;
Window		win;
Pixmap		pm;
Colormap	cmap;
Cursor		curse;
GC		gc;
char		*fontname = "xtfont1";

	/* 
	 * Only really need to set up test font path if a later test purpose
	 * (which resets font path on close of last client with mode DestroyAll)
	 * has been executed before this test purpose.
	 */
	setxtfontpath();

	OPEN(display, DestroyAll)

	
	DELETE_ONERR(font = XLoadFont(display, fontname),
			"XLoadFont");

	DELETE_ONERR(win = XCreateSimpleWindow(display, DRW(display), 0,0, 5,5, 1, 1, 1), 
			"XCreateSimpleWindow");

	DELETE_ONERR(pm = XCreatePixmap(display, DRW(display), 5,6, DefaultDepth(display, DefaultScreen(display))),
			"XCreatePixmap");

	DELETE_ONERR(cmap = XCreateColormap(display, DRW(display), DefaultVisual(display, DefaultScreen(display)), AllocNone),
			"XCreateColormap");

	DELETE_ONERR(curse = XCreateFontCursor(display, config.fontcursor_good),
			"XCreateFontCursor");

	DELETE_ONERR(gc = XCreateGC(display, DRW(display), 0L, 0L),
			"XCreateGC.");

	PROTECT(XCloseDisplay(display))
	sleep(config.speedfactor);

	FAIL_ONERR3(XFreeGC(Dsp, gc), BadGC,
			"%s() did not destroy GC id %lx", gc);

	FAIL_ONERR3(XFreeCursor(Dsp, curse), BadCursor,
			"%s() did not destroy cursor id %lx", curse);

	FAIL_ONERR3(XFreeColormap(Dsp, cmap), BadColor,
			"%s() did not destroy colormap id %lx.", cmap);


	FAIL_ONERR3(XDrawPoint(Dsp, pm, DefaultGC(Dsp, DefaultScreen(Dsp)), 0,0), BadDrawable,
			"%s() did not destroy pixmap id %lx.", pm)


	FAIL_ONERR3(XDrawPoint(Dsp, win, DefaultGC(Dsp, DefaultScreen(Dsp)), 0,0), BadDrawable,
			"%s() did not destroy window id %lx.", win)

	FAIL_ONERR3(XUnloadFont(Dsp, font), BadFont,
			"%s() did not unload font id %ld.", font)

	CHECKPASS(14);

>>ASSERTION Good A
When the last connection to the X server closes with a closedown mode of
.S DestroyAll ,
then the server destroys all lingering resources from clients that have
terminated in
.S RetainPermanent
or
.S RetainTemporary
mode.
>>STRATEGY
Set the closedown mode of client Dsp to DestroyAll using XSetCloseDownMode.
Open 2 clients with XOpenDisplay.
Set the closedown mode of the first to RetainPermanent using XSetCloseDownMode.
Set the closedown mode of the second to RetainTemporary using XSetCloseDownMode.
Create a font for each client using XLoadFont.
Create a window for each client using XCreateSimpleWindow.
Create a pixmap for each client using XCreatePixmap.
Create a colormap for each client using XCreateColormap.
Create a cursor for each client using XCreateFontCursor.
Create a gc for each client using XCreateGC.
Close the 2 clients.
Close client Dsp using xname.

Open client Dsp using XOpenDisplay.
Free the GCs using XFreeGC.
Verify that a BadGC error occurred.
Free the cursors using XFreeCursor.
Verify that a BadCursor error occurred.
Free the colormaps using XFreeColormap.
Verify that a BadColor occurred.
Draw on the pixmaps with XDrawPoint.
Verify that a BadDrawable error occurred.
Draw on the windows using XDrawPoint.
Verify that a BadDrawable error occurred.
Free the fonts using XUnloadFont.
Verify that a BadFont error occurred.
>>CODE
Display		*d[2];
Font		font[2];
Window		win[2];
Pixmap		pm[2];
Colormap	cm[2];
Cursor		curse[2];
GC		gc[2];
int		i;
char		*fontname = "xtfont1";

	/* 
	 * Only really need to set up test font path if a later test purpose
	 * (which resets font path on close of last client with mode DestroyAll)
	 * has been executed before this test purpose.
	 */
	setxtfontpath();

	XSetCloseDownMode(Dsp, DestroyAll);

	OPEN(d[0], RetainPermanent);   /* CHECK */
	OPEN(d[1], RetainTemporary);   /* CHECK */

	for(i=0; i<2; i++) {
		display = d[i];
		DELETE_ONERR(font[i] = XLoadFont(display, fontname), "XLoadFont");
		DELETE_ONERR(win[i] = XCreateSimpleWindow(display, DRW(display), 0,0, 5,5, 1, 1, 1), "XCreateSimpleWindow");
		DELETE_ONERR(pm[i] = XCreatePixmap(display, DRW(display), 5,6, DefaultDepth(display, DefaultScreen(display))),	"XCreatePixmap");
		DELETE_ONERR(cm[i] = XCreateColormap(d[i], DRW(d[i]), DefaultVisual(d[i], DefaultScreen(d[i])), AllocNone), "XCreateColormap");
		DELETE_ONERR(curse[i] = XCreateFontCursor(display, config.fontcursor_good), "XCreateFontCursor");
		DELETE_ONERR(gc[i] = XCreateGC(display, DRW(display), 0L, 0L), "XCreateGC.");
	}
		 /* 12 CHECKS */

	PROTECT(XCloseDisplay(d[0]));   /* CHECK */
	PROTECT(XCloseDisplay(d[1]));   /* CHECK */
	PROTECT(XCloseDisplay(Dsp));    /* CHECK */

	/*
	 * Pause whilst the X server is resetting.
	 */
	reset_delay();

	OPEN(Dsp, DestroyAll);          /* CHECK */

	for(i=0; i<2; i++) {

		FAIL_ONERR4(XUnloadFont(Dsp, font[i]), BadFont,
			"%s() did not unload font id %lx%s.", font[i], cmode[i])

		FAIL_ONERR4(XDrawPoint(Dsp, pm[i], DefaultGC(Dsp, DefaultScreen(Dsp)), 0,0), BadDrawable,
			"%s() did not destroy pixmap id %lx%s.", pm[i], cmode[i])

		FAIL_ONERR4(XDrawPoint(Dsp, win[i], DefaultGC(Dsp, DefaultScreen(Dsp)), 0,0), BadDrawable,
			"%s() did not destroy window id %lx%s.", win[i], cmode[i])

		FAIL_ONERR4(XFreeColormap(Dsp, cm[i]), BadColor,
			"%s() did not destroy colourmap %lx%s.", cm[i], cmode[i]);

		FAIL_ONERR4(XFreeCursor(Dsp, curse[i]), BadCursor,
			"%s() did not destroy cursor id %lx%s.", curse[i], cmode[i]);

		FAIL_ONERR4(XFreeGC(Dsp, gc[i]), BadGC,
			"%s() did not destroy GC id %lx%s", gc[i], cmode[i]);

	}

		/* 12 CHECKS */

	CHECKPASS(2 + 12 + 4 + 12);

>>EXTERN
Atom	predefd[] = {	XA_PRIMARY,
			XA_SECONDARY,
			XA_ARC,
			XA_ATOM,
			XA_BITMAP,
			XA_CARDINAL,
			XA_COLORMAP,
			XA_CURSOR,
			XA_CUT_BUFFER0,
			XA_CUT_BUFFER1,
			XA_CUT_BUFFER2,
			XA_CUT_BUFFER3,
			XA_CUT_BUFFER4,
			XA_CUT_BUFFER5,
			XA_CUT_BUFFER6,
			XA_CUT_BUFFER7,
			XA_DRAWABLE,
			XA_FONT,
			XA_INTEGER,
			XA_PIXMAP,
			XA_POINT,
			XA_RECTANGLE,
			XA_RESOURCE_MANAGER,
			XA_RGB_COLOR_MAP,
			XA_RGB_BEST_MAP,
			XA_RGB_BLUE_MAP,
			XA_RGB_DEFAULT_MAP,
			XA_RGB_GRAY_MAP,
			XA_RGB_GREEN_MAP,
			XA_RGB_RED_MAP,
			XA_STRING,
			XA_VISUALID,
			XA_WINDOW,
			XA_WM_COMMAND,
			XA_WM_HINTS,
			XA_WM_CLIENT_MACHINE,
			XA_WM_ICON_NAME,
			XA_WM_ICON_SIZE,
			XA_WM_NAME,
			XA_WM_NORMAL_HINTS,
			XA_WM_SIZE_HINTS,
			XA_WM_ZOOM_HINTS,
			XA_MIN_SPACE,
			XA_NORM_SPACE,
			XA_MAX_SPACE,
			XA_END_SPACE,
			XA_SUPERSCRIPT_X,
			XA_SUPERSCRIPT_Y,
			XA_SUBSCRIPT_X,
			XA_SUBSCRIPT_Y,
			XA_UNDERLINE_POSITION,
			XA_UNDERLINE_THICKNESS,
			XA_STRIKEOUT_ASCENT,
			XA_STRIKEOUT_DESCENT,
			XA_ITALIC_ANGLE,
			XA_X_HEIGHT,
			XA_QUAD_WIDTH,
			XA_WEIGHT,
			XA_POINT_SIZE,
			XA_RESOLUTION,
			XA_COPYRIGHT,
			XA_NOTICE,
			XA_FONT_NAME,
			XA_FAMILY_NAME,
			XA_FULL_NAME,
			XA_CAP_HEIGHT,
			XA_WM_CLASS,
			XA_WM_TRANSIENT_FOR,
			XA_LAST_PREDEFINED
};

>>ASSERTION Good A
When the last connection to the X server closes with a closedown mode of
.S DestroyAll ,
then the server deletes all but the predefined atom IDs.
>>STRATEGY
Set the closedown mode to DestroyAll using XSetCloseDownMode.
Create and intern the atom XT_TEST_Atom using XInternAtom.
Close all the server displays.
Open the display.
Verify that the atom XT_TEST_Atom no longer exists.
Verify that each of the predefined atoms exists.
>>CODE
int	i;

	display = Dsp;
	XSetCloseDownMode(display, DestroyAll);
	XInternAtom(display, atname, False);
	PROTECT(XCloseDisplay(display));

	/*
	 * Pause whilst the X server is resetting.
	 */
	reset_delay();

	OPEN(Dsp, DestroyAll);
	display = Dsp;

	if(XInternAtom(display, atname, True) != None) {
		report("The atom XT_TEST_Atom was not destroyed.");
		FAIL;
	} else
		CHECK;

	for(i = 0; i< NELEM(predefd); i++) {
	char *name;

		startcall(display);
		name = XGetAtomName(display, predefd[i]);
		endcall(display);
		if((name == (char *) NULL) || (geterr() != Success)) {
			report("Predefined atom number %ld was destroyed.", (long) predefd[i]);
			FAIL;
		} else {
			CHECK;
			XFree((char*)name);
		}
	}

	CHECKPASS(3 + NELEM(predefd));
>>ASSERTION Good A
When the last connection to the server closes with a closedown mode of
.S DestroyAll ,
then the server deletes all properties on all the root windows.
>>STRATEGY
For each screen:
  Obtain the root window of the screen using RootWindow.
  Set the XA_PRIMARY property on the window using XChangeProperty.
Close all connections to the server using xname.
Open a server connection using XOpenDisplay.
For each screen: 
  Obtain the value of the XA_PRIMARY property using XGetWindowProperty.
  Verify that returned type was None, the returned format was 0 and 
  that the bytes_after_return was 0.
>>CODE
int			i;
int			scount;
Atom			at;
unsigned char		*data = (unsigned char *) "XT_property data.";
unsigned char		*rprop= (unsigned char *) ".................";
int			len = 1 + strlen((char*)data);
Atom			type;
int			format = -1;
unsigned long		nitems;
unsigned long		ba;

	scount = ScreenCount(Dsp);
	XSetCloseDownMode(Dsp, DestroyAll);
	if((at = XInternAtom(Dsp, atname, False)) == None) {
		delete("XInternAtom() returned None.");
		return;
	}

	at = XA_PRIMARY;

	for(i=0; i< scount; i++)
		XChangeProperty(Dsp, RootWindow(Dsp, i), at, XA_STRING, 8, PropModeReplace, data, len);	


	PROTECT(XCloseDisplay(Dsp));

	/*
	 * Pause whilst the X server is resetting.
	 */
	reset_delay();

	OPEN(Dsp, DestroyAll);

	for(i=0; i<scount; i++) {
		/* Set to non-zero values to show that they are being written to */
		type = None+1;
		format = 1;
		ba = 1;
		if( XGetWindowProperty(Dsp, RootWindow(Dsp, i), at , 0L, (long) len, False, AnyPropertyType, &type, &format, &nitems, &ba, &rprop) != Success ) {
			delete("XGetWindowProperty() did not return Success for atom XA_PRIMARY.");
			return;
		} else
			CHECK;

		if((type != None) || (format != 0) || (ba != 0) ) {
			report("%s() did not destroy all properties on root window of screen %d.", TestName, i);
			FAIL;
		} else
			CHECK;
	}

	CHECKPASS( 2 * scount + 2);


>>ASSERTION Good B 1
When the last connection to the server closes with a closedown mode of
.S DestroyAll ,
then the server resets all device maps, attributes and the access control list.
>>ASSERTION Good B 1
When the last connection to the server closes with a closedown mode of
.S DestroyAll ,
then the server restores the standard root tiles and cursors.
>>ASSERTION Good A
When the last connection to the server closes with a closedown mode of
.S DestroyAll ,
then the server restores the default font path.
>>STRATEGY
Set the closedown mode of a connection to DestroyAll.
Set the font path to XT_FONTPATH using XSetFontPath
Close all connections to the server using xname.
Open a connection using XOpenDisplay.
Set the closedown mode of the connection to DestroyAll.
Set the font path to XT_FONTPATH_GOOD using XSetFontPath
Close all connections to the server using xname.
Verify that the font path is restored in each case to the same font path.
Set the font path to the restored font path using XSetFontPath.
Verify that no error occurs.
Verify that the cursor font can be accessed.
>>EXTERN
int
setfontpath(disp, fpathlist, var)
Display	*disp;
char	*fpathlist;
char	*var;
{
char	*fpathtmp;
char	*ndir_array[MAX_DIRS];
char	*strtok();
int 	ndirs;
int 	i;

	/*
	 * Set font path to specified list.
	 */
	if (fpathlist == NULL || *fpathlist == '\0') {
		delete("%s not set in config file", var);
		return(0);
	}
	fpathtmp = (char *)calloc(strlen(fpathlist)+1, sizeof(char));
	strcpy(fpathtmp, fpathlist);

	for (i = 0; i < MAX_DIRS; i++) {
		ndir_array[i] = strtok((i==0)? fpathtmp: (char*)0, SEP);
		if (ndir_array[i] == NULL)
			break;
		debug(1, "ndir_array entry %d - '%s'", i, ndir_array[i]);
	}
	ndirs = i;

	if (ndirs <= 0) {
		delete("No components in supplied parameter %s", var);
		return(0);
	}
	XSetFontPath(disp, ndir_array, ndirs);

	/*
	 * Sync and clear out queue.
	 */
	XSync(disp, True);
	return(1);
}
>>CODE
char	**path1;
char	**path2;
int 	nret1;
int 	nret2;
int 	i;
Cursor	qstat;
unsigned int shape;

	shape = config.fontcursor_good;
	if (shape == -1) {
		delete("A value of UNSUPPORTED is not allowed for XT_FONTCURSOR_GOOD");
		return;
	}
	if (config.fontpath == NULL || *config.fontpath == '\0') {
		delete("XT_FONTPATH not set");
		return;
	}
	if (config.fontpath_good == NULL || *config.fontpath_good == '\0') {
		delete("XT_FONTPATH_GOOD not set");
		return;
	}
	if(!strcmp(config.fontpath, config.fontpath_good)) {
		delete("XT_FONTPATH and XT_FONTPATH_GOOD must not be identical");
		return;
	}
	XSetCloseDownMode(Dsp, DestroyAll);
	if(!setfontpath(Dsp, config.fontpath, "XT_FONTPATH"))
		return;
	PROTECT(XCloseDisplay(Dsp));

	/*
	 * Pause whilst the X server is resetting.
	 */
	reset_delay();

	OPEN(Dsp, DestroyAll);

	/* Save font path, hypothesise that this is the default */
	path1 = XGetFontPath(Dsp, &nret1);

	XSetCloseDownMode(Dsp, DestroyAll);
	if(!setfontpath(Dsp, config.fontpath_good, "XT_FONTPATH_GOOD"))
		return;
	PROTECT(XCloseDisplay(Dsp));

	/*
	 * Pause whilst the X server is resetting.
	 */
	reset_delay();

	OPEN(Dsp, DestroyAll);

	/* Check saved fontpaths are the same */
	path2 = XGetFontPath(Dsp, &nret2);

	if (nret1 == nret2)
		CHECK;
	else {
		report("Number of directories was not set to default");
		report("  was %d, expecting %d", nret2, nret1);
		FAIL;
	}

	if(nret1 < nret2)
		nret2 = nret1;
	for (i = 0; i < nret2; i++) {
		debug(1, "Using XT_FONTPATH, got list item '%s'", path1[i]);
		debug(1, "Using XT_FONTPATH_GOOD, got list item '%s'", path2[i]);
		if (strcmp(path1[i], path2[i]) == 0)
			CHECK;
		else {
			report("Font path component was not set to default");
			report("  was '%s', expecting '%s'", path2[i], path1[i]);
			FAIL;
		}
	}
	
	startcall(Dsp);
	XSetFontPath(Dsp, path1, nret1);
	endcall(Dsp);
	if (geterr() != Success) {
		report("When XSetFontPath() is used with restored font path,");
		report("got %s, Expecting Success", errorname(geterr()));
		FAIL;
	} else
		CHECK;

	startcall(Dsp);
	qstat = XCreateFontCursor(Dsp, shape);
	endcall(Dsp);

	/* Verify that XCreateFontCursor returns non-zero. */
	if (qstat == 0) {
		report("When XCreateFontCursor() is used with restored font path,");
		report("returned wrong value %ld", (long) qstat);
		FAIL;
	} else
		CHECK;
	if (geterr() != Success) {
		report("When XCreateFontCursor() is used with restored font path,");
		report("got %s, Expecting Success", errorname(geterr()));
		FAIL;
	} else
		CHECK;

	XFreeFontPath(path1);
	XFreeFontPath(path2);
	CHECKPASS(8+nret1);

>>ASSERTION Good A
When the last connection to the server closes with a closedown mode of
.S DestroyAll ,
then the server restores the input focus to
.S PointerRoot .
>>STRATEGY
Set the closedown mode of a connection to DestroyAll.
Set the input focus of a connection to None with XSetInputFocus.
Close all connections to the server using xname.
Open a connection using XOpenDisplay.
Obtain the current input focus using XGetInputFocus.
Verify that the input focus is PointerRoot.
>>CODE
Window	fr;
int	rr;

	XSetCloseDownMode(Dsp, DestroyAll);
	XSetInputFocus(Dsp, None, RevertToNone, CurrentTime);
	PROTECT(XCloseDisplay(Dsp));

	/*
	 * Pause whilst the X server is resetting.
	 */
	reset_delay();

	OPEN(Dsp, DestroyAll);
	XGetInputFocus(Dsp, &fr, &rr);	

	if(fr != PointerRoot) {
		report("%s() set the input focus to %lx instead of PointerRoot (%lx).", TestName, (long) fr, (long) PointerRoot);
		FAIL;
	} else
		CHECK;

	CHECKPASS(3);
>>#	
>># Retain
>>#
>>ASSERTION Good A
When the last connection to the server closes with a closedown mode of
.S RetainPermanent
or
.S RetainTemporary ,
then a call to xname does not affect any 
window in the client's save-set.
>>STRATEGY
Open a display using XOpenDisplay.
Set the closedown mode of the display to RetainPermanent using XSetCloseDownMode.
Create save set with setupsaveset.
Close the display using xname.
Verify parents and positions of the save-set members stay the same.
Open a display using XOpenDisplay.
Set the closedown mode of the display to RetainTemporary using XSetCloseDownMode.
Create save set with setupsaveset.
Close the display using xname.
Verify parents and positions of the save-set members stay the same.
>>CODE
Display	*client1, *client2;
struct	buildtree *bt[NELEM(T1)];
struct	buildtree *btp;
Window	parent;
Window	dummy;
Window	*children;
Window	base;
char	*modestr[2];
unsigned int 	nchild;
int 	i, j, k;
struct	buildtree *cli1btp;
int 	oldx, oldy;
int 	newx, newy;
XWindowAttributes	atts;


	modestr[0] = "RetainPermanent";
	modestr[1] = "RetainTemporary";

	for(k=0; k<2; k++) {
	
		client1 = XOpenDisplay(config.display);
		client2 = opendisplay();
	
		if(client1 == (Display *) NULL || client1 == (Display *) NULL) {
			delete("Could not open the display.");
			if(client1)
				XCloseDisplay(client1);
			return;
		} else
			CHECK;
	
		XSetCloseDownMode(client1, closemodes[k]);
		setupsaveset(bt, client1, client2);
	
		/*
		 * Base will be stored in bt[0][0] all the windows should be reparented
		 * to there.
		 */
		base = bt[0][0].wid;
	
		for (i = 0; i < NELEM(T1); i++) {
			for (j = 1; j < NELEM(T2); j++) {
	
				btp = bt[i] + j;
	
				/*
				 * Skip if it shouldn't have been reparented.
				 */
				btp->uflags &= (IN_SAVE_SET|CLIENT1_INFERIOR);
				if (btp->uflags != (IN_SAVE_SET|CLIENT1_INFERIOR))
					continue;
	
				/* Get new parent */
				XQueryTree(Dsp, btp->wid, &dummy, &parent, &children, &nchild);
				if (children && nchild > 0)
					XFree((char*)children);
					
				if (parent != btp->parent->wid) {
					report("Closedown mode %s:", modestr[k]);
					report("Window did not retain its original parent.");
					FAIL;
				} else
					CHECK;
			}
		}
	

		for (i = 0; i < NELEM(T1); i++) {
	
			/*
			 * Get the information relating to the original client1 window
			 */
			cli1btp = bt[i];
	
			for (j = 1; j < NELEM(T2); j++) {
				btp = bt[i] + j;
	
				/*
				 * Skip if it shouldn't have been reparented.
				 */
				btp->uflags &= (IN_SAVE_SET|CLIENT1_INFERIOR);
				if (btp->uflags != (IN_SAVE_SET|CLIENT1_INFERIOR))
					continue;
	
				debug(1, "window %s", btp->name);
	
				oldx = btp->x;
				oldy = btp->y;
	
				XGetWindowAttributes(Dsp, btp->wid, &atts);
	
				newx = atts.x;
				newy = atts.y;
	
				if (oldx != newx || oldy != newy) {
					report("Closedown mode %s:", modestr[k]);
					report("Coords relative to parent changed");
					report(" (relative to parent win got (%d, %d), expecting (%d, %d)"
						, newx, newy, oldx, oldy);
					FAIL;
				} else
					CHECK;
			}
		}

	}

	CHECKPASS(2 * (1 + NUM_REPARENT + NUM_REPARENT));

>>ASSERTION Good A
When the last connection to the server closes with a closedown mode of
.S RetainPermanent
or
.S RetainTemporary ,
then a call to xname does not delete any
.S Window ,
.S Font ,
.S Pixmap ,
>># .S Bitmap ,
>>#  Pixmap === Bitmap, anyhow!
.S Colormap ,
.S Cursor
and
.S GContext
resources allocated by the client.
>>STRATEGY
Set the closedown mode of the display to RetainPermanent using XSetCloseDownMode.
Create a font using XLoadFont.
Create a window using XCreateSimpleWindow.
Create a pixmap using XCreatePixmap.
Create a colormap using XCreateColormap.
Create a cursor using XCreateFontCursor.
Create a GC using XCreateGC.

Close the display using xname.
Open the display using XOpenDisplay.
Free the GC using XFreeGC.
Verify that no errors occurred.
Free the cursor using XFreeCursor.
Verify that no errors occurred.
Free the colormap using XFreeColormap.
Verify that no errors occurred.
Draw on the pixmap with XDrawPoint.
Verify that no errors occurred.
Draw on the window using XDrawPoint.
Verify that no errors occurred.
Free the font using XUnloadFont.
Verify that no errors occurred.

Set the closedown mode of the display to RetainTemporary using XSetCloseDownMode.
Create a font using XLoadFont.
Create a window using XCreateSimpleWindow.
Create a pixmap using XCreatePixmap.
Create a colormap using XCreateColormap.
Create a cursor using XCreateFontCursor.
Create a GC using XCreateGC.

Close the display using xname.
Open the display using XOpenDisplay.
Free the GC using XFreeGC.
Verify that no errors occurred.
Free the cursor using XFreeCursor.
Verify that no errors occurred.
Free the colormap using XFreeColormap.
Verify that no errors occurred.
Draw on the pixmap with XDrawPoint.
Verify that no errors occurred.
Draw on the window using XDrawPoint.
Verify that no errors occurred.
Free the font using XUnloadFont.
Verify that no errors occurred.
>>CODE
int		k;
Font		font;
Window		win;
Pixmap		pm;
Colormap	cmap;
Cursor		curse;
GC		gc;
char		*fontname = "xtfont1";

	/* 
	 * Need to set up test font path - when test purposes are all
	 * executed in default order, an earlier test purpose will have 
	 * reset font path on close of last client with mode DestroyAll.
	 */
	setxtfontpath();

	for(k=0; k<2; k++) {
	
		XSetCloseDownMode(display, closemodes[k]);
		
		DELETE_ONERR(font = XLoadFont(display, fontname),
				"XLoadFont");
	
		DELETE_ONERR(win = XCreateSimpleWindow(display, DRW(display), 0,0, 5,5, 1, 1, 1), 
				"XCreateSimpleWindow");
	
		DELETE_ONERR(pm = XCreatePixmap(display, DRW(display), 5,6, DefaultDepth(display, DefaultScreen(display))),
				"XCreatePixmap");
	
		DELETE_ONERR(cmap = XCreateColormap(display, DRW(display), DefaultVisual(display, DefaultScreen(display)), AllocNone),
				"XCreateColormap");
	
		DELETE_ONERR(curse = XCreateFontCursor(display, config.fontcursor_good),
				"XCreateFontCursor");
	
		DELETE_ONERR(gc = XCreateGC(display, DRW(display), 0L, 0L),
				"XCreateGC");
	
		PROTECT(XCloseDisplay(display))

		/*
		 * Pause whilst the X server is resetting.
		 */
		reset_delay();

		OPEN(display, DestroyAll);
		/*
		 * The next line is important - Dsp is used in the macros
		 * for example. Although we could use `display' below, 
		 * rather than Dsp, I think its clearer to use Dsp.
		 */
		Dsp = display;
	
		FAIL_ONERR2(XFreeGC(Dsp, gc),
				"%s() destroyed GC id %lx%s.", gc, cmode[k]);
	
		FAIL_ONERR2(XFreeCursor(Dsp, curse),
				"%s() destroyed cursor id %lx%s.", curse, cmode[k]);
	
		FAIL_ONERR2(XFreeColormap(Dsp, cmap),
				"%s() destroyed colormap id %lx%s.", cmap, cmode[k]);
	
	
		FAIL_ONERR2(XDrawPoint(Dsp, pm, DefaultGC(Dsp, DefaultScreen(Dsp)), 0,0),
				"%s() destroyed pixmap id %lx%s.", pm, cmode[k])
	
		FAIL_ONERR2(XDrawPoint(Dsp, win, DefaultGC(Dsp, DefaultScreen(Dsp)), 0,0),
				"%s() destroyed window id %lx%s.", win, cmode[k])
	
		FAIL_ONERR2(XUnloadFont(Dsp, font),
				"%s() unloaded font id %ld%s.", font, cmode[k])
	}

	CHECKPASS(2 * 14);

>>ASSERTION Good A
When the last connection to the server closes with a closedown mode of
.S RetainPermanent
or
.S RetainTemporary ,
then a call to xname does not delete any of the atom IDs.
>>STRATEGY
Set the closedown mode to RetainPermanent using XSetCloseDownMode.
Create and intern the atom XT_TEST_Atom using XInternAtom.
Close all connections to the server using xname.
Open a server connection using XOpenDisplay.
Verify that the atom XT_TEST_Atom is still interned.
Verify that all the predefined atoms still exist.

Set the closedown mode to RetainTemporary using XSetCloseDownMode.
Create and intern the atom XT_TEST_Atom using XInternAtom.
Close all connections to the server using xname.
Open a server connection using XOpenDisplay.
Verify that the atom XT_TEST_Atom is still interned.
Verify that all the predefined atoms still exist.
>>CODE
int		i;
int		k;
char		*name;

	for(k=0; k<2; k++) {

		XSetCloseDownMode(Dsp, closemodes[k]);
		XInternAtom(Dsp, atname, False);
		PROTECT(XCloseDisplay(Dsp));

		/*
		 * Pause whilst the X server is resetting.
		 */
		reset_delay();

		OPEN(Dsp, closemodes[k]); 	

		if(XInternAtom(Dsp, atname, True) == None) {
			report("The atom XT_TEST_Atom was destroyed.");
			FAIL;
		} else
			CHECK;
	
		for(i = 0; i< NELEM(predefd); i++) {
	
			startcall(Dsp);
			name = XGetAtomName(Dsp, predefd[i]);
			endcall(Dsp);
			if((name == (char *) NULL)  || (geterr() == BadAtom)) {
				report("%s() %s destroyed predefined atom number %ld.",TestName, cmode[k], (long) predefd[i]);
				FAIL;
			} else {
				CHECK;
				XFree((char*)name);
			}
		}
	
	}

	CHECKPASS(2 * (3 + NELEM(predefd)));

>>ASSERTION Good B 1
When the last connection to the server closes with a closedown mode of
.S RetainPermanent
or
.S RetainTemporary ,
then a call to xname does not delete any property on any root window.
>>ASSERTION Good B 1
When the last connection to the server closes with a closedown mode of
.S RetainPermanent
or
.S RetainTemporary ,
then a call to xname does not affect any device map, any attributes or the access control list.
>>ASSERTION Good B 1
When the last connection to the server closes with a closedown mode of
.S RetainPermanent
or
.S RetainTemporary ,
then a call to xname does not affect the standard root tiles and cursors.
>>ASSERTION Good B 1
When the last connection to the server closes with a closedown mode of
.S RetainPermanent
or
.S RetainTemporary ,
then a call to xname does not affect the default font path.
>>ASSERTION Good A
When the last connection to the server closes with a closedown mode of
.S RetainPermanent
or
.S RetainTemporary ,
then a call to xname does not affect the input focus.
>>STRATEGY
Set the closedown mode to RetainPermanent using XSetCloseDownMode.
Set the input focus to None with XSetInputFocus.
Close all connections to the server using xname.
Open a connection using XOpenDisplay.
Obtain the current input focus using XGetInputFocus.
Verify that the input focus is None.

Set the closedown mode to RetainTemporary using XSetCloseDownMode.
Set the input focus to None with XSetInputFocus.
Close all connections to the server using xname.
Open a connection using XOpenDisplay.
Obtain the current input focus using XGetInputFocus.
Verify that the input focus is None.
>>CODE
Window	fr;
int	rr;
int	k;

	for(k=0; k<2; k++) {

		XSetCloseDownMode(Dsp, closemodes[k]);
		XSetInputFocus(Dsp, None, RevertToNone, CurrentTime);
		PROTECT(XCloseDisplay(Dsp));

		/*
		 * Pause whilst the X server is resetting.
		 */
		reset_delay();

		OPEN(Dsp, DestroyAll);
		XGetInputFocus(Dsp, &fr, &rr);	
		
		if(fr != None) {
			report("%s() set the input focus to %lx instead of None (%lx)%s.",
				 TestName, (long) fr, (long) None, cmode[k]);
			FAIL;
		} else
			CHECK;
	}

	CHECKPASS(2 * 3);