summaryrefslogtreecommitdiff
path: root/xts5/XI/SendExtensionEvent.m
blob: 0db5c0573e5d311dd539800f740262ff399a09bf (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
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/XI/sndextnsne/sndextnsne.m
>># 
>># Description:
>># 	Tests for XSendExtensionEvent()
>># 
>># Modifications:
>># $Log: sndextevnt.m,v $
>># Revision 1.2  2005-11-03 08:42:09  jmichael
>># clean up all vsw5 paths to use xts5 instead.
>>#
>># Revision 1.1.1.2  2005/04/15 14:05:14  anderson
>># Reimport of the base with the legal name in the copyright fixed.
>>#
>># Revision 8.0  1998/12/23 23:32:10  mar
>># Branch point for Release 5.0.2
>>#
>># Revision 7.0  1998/10/30 22:52:28  mar
>># Branch point for Release 5.0.2b1
>>#
>># Revision 6.0  1998/03/02 05:23:42  tbr
>># Branch point for Release 5.0.1
>>#
>># Revision 5.0  1998/01/26 03:20:14  tbr
>># Branch point for Release 5.0.1b1
>>#
>># Revision 4.0  1995/12/15 09:04:15  tbr
>># Branch point for Release 5.0.0
>>#
>># Revision 3.2  1995/12/15  01:02:34  andy
>># Prepare for GA Release
>>#
/*
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.

Copyright 1993 by the Hewlett-Packard Company.

Copyright 1990, 1991 UniSoft Group Limited.

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 names of HP, and UniSoft not be
used in advertising or publicity pertaining to distribution of the
software without specific, written prior permission.  HP, and UniSoft
make no representations about the suitability of this software for any
purpose.  It is provided "as is" without express or implied warranty.
*/
>>TITLE XSendExtensionEvent XI
Status
XSendExtensionEvent(display, device, w, propagate, count, event_list, event_send)
Display *display = Dsp;
XDevice *device;
Window w = (Window) 0xffffffff;
Bool propagate = False;
int count=1;
XEventClass *event_list;
XEvent	*event_send = &_event;
>>SET startup focusstartup
>>SET cleanup focuscleanup
>>EXTERN
#define XInputNumEvents 15
extern ExtDeviceInfo Devs;
extern	int	nclass, nevent, event_types[];
extern XEventClass classes[];
extern XInputFirstEvent;
/*
 * Can not use "xcall" because it empties the event queue.
 */
#define	_xcall_(rvalue)	\
		_startcall(display);\
		((XAnyEvent *) event_send)->send_event = False;\
		rvalue = XSendExtensionEvent(display, device, w, propagate, count, event_list,event_send);\
		_endcall(display)
static XEvent _event;

>>ASSERTION Good B 3
A call to xname
sends
.A event_send
to window
.A w .
>>STRATEGY
Create window.
Discard all events in the event queue.
Call XSendExtensionEvent to send a KeyPress event to creator of window.
Verify that XSendExtensionEvent returned non-zero.
Verify that event was received.
Verify that send_event was not set to False.
Repeat for each event-type.
>>CODE
int	i;
Window	w;
XAnyEvent *event;
XEvent	event_return;
int	return_value;
XEventClass noextensioneventclass;

/* Create window. */
	if (!Setup_Extension_DeviceInfo(BtnMask))
	    {
	    untested("%s: No input extension button device.\n", TestName);
	    return;
	    }
	device = Devs.Button;
	NoExtensionEvent(device, unused, noextensioneventclass);
	w = mkwin(display, (XVisualInfo *) NULL, (struct area *) NULL, False);
	propagate = False;
	event_list = &noextensioneventclass;
	event = (XAnyEvent *) &event_return;
	for (i = 0; i < nevent; i++) {

/* Discard all events in the event queue. */
		XSync(display, True);

/* Call XSendExtensionEvent to send a KeyPress event to creator of window. */
		event_send->type = event_types[i];
		_xcall_(return_value);

/* Verify that XSendExtensionEvent returned non-zero. */
		if (return_value == 0) {
			report("Returned zero, expected non-zero.");
			FAIL;
		}
		else
			CHECK;

/* Verify that event was received. */
		XSync(display, False);
		if (XCheckTypedEvent(display, event_send->type, &event_return) == False) {
			report("Expected event (%s) not received.", eventname(event_send->type));
			FAIL;
			continue;
		}
		else
			CHECK;

/* Verify that send_event was not set to False. */
		if (event->send_event == False) {
			report("send_event not set to True");
			FAIL;
		}
		else
			CHECK;

/* Repeat for each event-type. */
	}
	CHECKPASS(3*nevent);
>>ASSERTION Good B 3
When
.A w
is
.S PointerWindow ,
then the destination window is the window that contains the pointer.
>>STRATEGY
Create window.
Select KeyPress-type events on window.
Grab server.
Enable synchronization.
Save initial pointer location.
Warp pointer to window.
Get new pointer location.
Discard all events in the event queue.
Call XSendExtensionEvent to send a KeyPress event to window containing pointer.
Get current pointer location.
Check to see if pointer moved.
Warp pointer back to where it started.
Disable synchronization.
Ungrab server.
Verify that XSendExtensionEvent returned non-zero.
Verify that event was received.
Verify that send_event was not set to False.
>>CODE
XVisualInfo *vp;
Window	ptrwin;
XAnyEvent *event;
XEvent	event_return;
int	return_value;
int root_x, root_y;	/* pointer location after XSendExtensionEvent */
int oroot_x, oroot_y;	/* pointer location before XSendExtensionEvent */
int sroot_x, sroot_y;	/* initial pointer location */
Window oldroot;		/* initial root window */
int itmp;		/* useless XQueryPointer return values */
unsigned int uitmp;	/* useless XQueryPointer return values */
Window wtmp;		/* useless XQueryPointer return values */
int dbp;
XEventClass dbpc;

/* Create window. */
	if (!Setup_Extension_DeviceInfo(BtnMask))
	    {
	    untested("%s: No input extension button device.\n", TestName);
	    return;
	    }
	device = Devs.Button;
	DeviceButtonPress(Devs.Button, dbp, dbpc);
	resetvinf(VI_WIN);
	nextvinf(&vp);
	ptrwin = makewin(display, vp);
/* Select KeyPress-type events on window. */
	XSelectExtensionEvent(display, ptrwin, &dbpc, 1);
/* Grab server. */
	XGrabServer(display);
/* Enable synchronization. */
	XSynchronize(display, True);
/* Save initial pointer location. */
	XQueryPointer(display, ptrwin, &oldroot, &wtmp, &sroot_x, &sroot_y, &itmp, &itmp, &uitmp);
/* Warp pointer to window. */
	XWarpPointer(display, None, ptrwin, 0, 0, 0, 0, 0, 0);
/* Get new pointer location. */
	if (XQueryPointer(display, ptrwin, &wtmp, &wtmp, &oroot_x, &oroot_y, &itmp, &itmp, &uitmp) == False) {
		delete("Pointer on wrong root.");
		XSynchronize(display, False);
		XUngrabServer(display);
		return;
	} else
		CHECK;
/* Discard all events in the event queue. */
	XSync(display, True);
/* Call XSendExtensionEvent to send a KeyPress event to window containing pointer. */
	w = (Window) PointerWindow;
	propagate = False;
	event_list = &dbpc;
	event_send->type = dbp;
	_xcall_(return_value);
/* Get current pointer location. */
	if (XQueryPointer(display, ptrwin, &wtmp, &wtmp, &root_x, &root_y, &itmp, &itmp, &uitmp) == False) {
		delete("Pointer moved.");
		XSynchronize(display, False);
		XUngrabServer(display);
		return;
	}
	else
		CHECK;
/* Check to see if pointer moved. */
	if (oroot_x != root_x || oroot_y != root_y) {
		delete("Pointer moved.");
		/*
		 * if this is ever changed to be a return, take care to
		 * also turn off synchronization and ungrab the server...
		 */
	}
	else
		CHECK;
/* Warp pointer back to where it started. */
	XWarpPointer(display, None, oldroot, 0, 0, 0, 0, sroot_x, sroot_y);
/* Disable synchronization. */
	XSynchronize(display, False);
/* Ungrab server. */
	XUngrabServer(display);
/* Verify that XSendExtensionEvent returned non-zero. */
	if (return_value == 0) {
		report("Returned zero, expected non-zero.");
		FAIL;
	}
	else
		CHECK;
/* Verify that event was received. */
	XSync(display, False);
	if (XCheckTypedEvent(display, event_send->type, &event_return) == False) {
		report("Expected event (%s) not received.", eventname(event_send->type));
		FAIL;
	}
	else
		CHECK;
/* Verify that send_event was not set to False. */
	event = (XAnyEvent *) &event_return;
	if (event->send_event == False) {
		report("send_event not set to True");
		FAIL;
	}
	else
		CHECK;
	CHECKPASS(6);
>>ASSERTION Good B 3
When
.A w
is
.S InputFocus
and an inferior of the focus window contains the pointer,
then
the destination window is that inferior.
>>STRATEGY
Create client2.
Create parent window.
Create inferior window.
Select KeyPress-type events on parent window with client2.
Flush client2 requests.
Select KeyPress-type events on child window.
Grab server.
Enable synchronization.
Set input focus to parent window.
Save initial pointer location.
Warp pointer to inferior of focus window.
Get new pointer location.
Discard all events in the event queue.
Call XSendExtensionEvent to send a KeyPress event to inferior of the focus window.
Get current pointer location.
Check to see if pointer moved.
Warp pointer back to where it started.
Disable synchronization.
Ungrab server.
Verify that XSendExtensionEvent returned non-zero.
Verify that event was received for inferior of focus window.
Verify that send_event was not set to False.
Verify that event was not received for focus window.
>>CODE
Display	*client2;
XVisualInfo *vp;
Window	parent;
Window	child;
XAnyEvent *event;
XEvent	event_return;
int	return_value;
int root_x, root_y;	/* pointer location after XSendExtensionEvent */
int oroot_x, oroot_y;	/* pointer location before XSendExtensionEvent */
int sroot_x, sroot_y;	/* initial pointer location */
Window oldroot;		/* initial root window */
int itmp;		/* useless XQueryPointer return values */
unsigned int uitmp;	/* useless XQueryPointer return values */
Window wtmp;		/* useless XQueryPointer return values */
unsigned int width;
unsigned int height;
struct area a;
int dbp;
XEventClass dbpc;

/* Create client2. */
	if (!Setup_Extension_DeviceInfo(BtnMask))
	    {
	    untested("%s: No input extension button device.\n", TestName);
	    return;
	    }
	device = Devs.Button;
	DeviceButtonPress(Devs.Button, dbp, dbpc);
	client2 = opendisplay();
	if (client2 == (Display *) NULL) {
		delete("Can't create new client.");
		return;
	}
	else
		CHECK;
/* Create parent window. */
	resetvinf(VI_WIN);
	nextvinf(&vp);
	parent = makewin(display, vp);
/* Create inferior window. */
	getsize(display, (Drawable) parent, &width, &height);
	a.x = 0;
	a.y = 0;
	a.width = width/2;
	a.height = height/2;
	child = crechild(display, parent, &a);
/* Select KeyPress-type events on parent window with client2. */
	XSelectExtensionEvent(client2, parent, &dbpc, 1);
/* Flush client2 requests. */
	XFlush(client2);
/* Select KeyPress-type events on child window. */
	XSelectExtensionEvent(display, child, &dbpc, 1);
/* Grab server. */
	XGrabServer(display);
/* Enable synchronization. */
	XSynchronize(display, True);
/* Set input focus to parent window. */
	XSetDeviceFocus(display, device, parent, RevertToPointerRoot, CurrentTime);
/* Save initial pointer location. */
	XQueryPointer(display, child, &oldroot, &wtmp, &sroot_x, &sroot_y, &itmp, &itmp, &uitmp);
/* Warp pointer to inferior of focus window. */
	XWarpPointer(display, None, child, 0, 0, 0, 0, 0, 0);

/* Get new pointer location. */
	if (XQueryPointer(display, child, &wtmp, &wtmp, &oroot_x, &oroot_y, &itmp, &itmp, &uitmp) == False) {
		delete("Pointer on wrong root.");
		XSynchronize(display, False);
		XUngrabServer(display);
		return;
	} else
		CHECK;
/* Discard all events in the event queue. */
	XSync(display, True);
/* Call XSendExtensionEvent to send a KeyPress event to inferior of the focus window. */
	w = (Window) InputFocus;
	propagate = False;
	event_list = &dbpc;
	event_send->type = dbp;
	((XAnyEvent *) event_send)->window = child;
	_xcall_(return_value);
/* Get current pointer location. */
	if (XQueryPointer(display, child, &wtmp, &wtmp, &root_x, &root_y, &itmp, &itmp, &uitmp) == False) {
		delete("Pointer moved.");
		XSynchronize(display, False);
		XUngrabServer(display);
		return;
	}
	else
		CHECK;
/* Check to see if pointer moved. */
	if (oroot_x != root_x || oroot_y != root_y) {
		delete("Pointer moved.");
		/*
		 * if this is ever changed to be a return, take care to
		 * also turn off synchronization and ungrab the server...
		 */
	}
	else
		CHECK;
/* Warp pointer back to where it started. */
	XWarpPointer(display, None, oldroot, 0, 0, 0, 0, sroot_x, sroot_y);
/* Disable synchronization. */
	XSynchronize(display, False);
/* Ungrab server. */
	XUngrabServer(display);
/* Verify that XSendExtensionEvent returned non-zero. */
	if (return_value == 0) {
		report("Returned zero, expected non-zero.");
		FAIL;
	}
	else
		CHECK;
/* Verify that event was received for inferior of focus window. */
	XSync(display, False);
	if (XCheckTypedWindowEvent(display, child, event_send->type, &event_return) == False) {
		report("Expected event (%s) on inferior not received.", eventname(event_send->type));
		FAIL;
	}
	else
		CHECK;
/* Verify that send_event was not set to False. */
	event = (XAnyEvent *) &event_return;
	if (event->send_event == False) {
		report("send_event not set to True");
		FAIL;
	}
	else
		CHECK;
/* Verify that event was not received for focus window. */
	XSync(client2, False);
	if (XCheckTypedWindowEvent(client2, child, event_send->type, &event_return) != False) {
		report("Focus window received event.", eventname(event_send->type));
		FAIL;
	}
	else
		CHECK;
	CHECKPASS(8);
>>ASSERTION Good B 3
When
.A w
is
.S InputFocus
and an inferior of the focus window does not contain the pointer,
then
the destination window is the focus window.
>>STRATEGY
Create window.
Select KeyPress-type events on new focus window.
Set input focus to new focus window.
Discard all events in the event queue.
Call XSendExtensionEvent to send a KeyPress event to inferior of the focus window.
Verify that XSendExtensionEvent returned non-zero.
Verify that event was received for inferior of focus window.
Verify that send_event was not set to False.
>>CODE
XVisualInfo *vp;
Window	nfocus;
XAnyEvent *event;
XEvent	event_return;
int	return_value;
int	dbp;
XEventClass dbpc;

/* Create window. */
	if (!Setup_Extension_DeviceInfo(BtnMask))
	    {
	    untested("%s: No input extension button device.\n", TestName);
	    return;
	    }
	device = Devs.Button;
	DeviceButtonPress(Devs.Button, dbp, dbpc);
	resetvinf(VI_WIN);
	nextvinf(&vp);
	nfocus = makewin(display, vp);
/* Select KeyPress-type events on new focus window. */
	XSelectExtensionEvent(display, nfocus, &dbpc, 1);
/* Set input focus to new focus window. */
	XSetDeviceFocus(display, device, nfocus, RevertToPointerRoot, CurrentTime);
/* Discard all events in the event queue. */
	XSync(display, True);
/* Call XSendExtensionEvent to send a KeyPress event to inferior of the focus window. */
	w = (Window) InputFocus;
	propagate = False;
	event_list = &dbpc;
	event_send->type = dbp;
	((XAnyEvent *) event_send)->window = nfocus;
	_xcall_(return_value);
/* Verify that XSendExtensionEvent returned non-zero. */
	if (return_value == 0) {
		report("Returned zero, expected non-zero.");
		FAIL;
	}
	else
		CHECK;
/* Verify that event was received for inferior of focus window. */
	XSync(display, False);
	if (XCheckTypedWindowEvent(display, nfocus, event_send->type, &event_return) == False) {
		report("Expected event (%s) not received.", eventname(event_send->type));
		FAIL;
	}
	else
		CHECK;
/* Verify that send_event was not set to False. */
	event = (XAnyEvent *) &event_return;
	if (event->send_event == False) {
		report("send_event not set to True");
		FAIL;
	}
	else
		CHECK;
	CHECKPASS(3);
>>ASSERTION def
When
.A event_list
is set to noextensioneventclass
then a call to xname results in
.A event_send
being sent to the client that created the destination window.
>>ASSERTION Good B 3
When
.A event_list
is set to noextensioneventclass
and the client that created the destination window
.A w
no longer exists,
then no event is sent.
>>STRATEGY
Create client2.
Call XSetCloseDownMode with RetainPermanent for client2.
Create window for client2.
Call XCloseDisplay for client2.
Select ALLEVENTS on window.
Call XSendExtensionEvent to send event to window.
Verify that XSendExtensionEvent returned non-zero.
Verify that no events were received.
>>CODE
Display	*client2 = NULL;
int	return_value;
int dbp;
XEventClass dbpc, noextensioneventclass;

	if (!Setup_Extension_DeviceInfo(BtnMask))
	    {
	    untested("%s: No input extension button device.\n", TestName);
	    return;
	    }
	device = Devs.Button;
	NoExtensionEvent(device, unused, noextensioneventclass);
	DeviceButtonPress(Devs.Button, dbp, dbpc);
/* Create client2. */

	/* We must disable resource registration here to prevent attempted
	   deallocation of closed connections and deleted resources. */
	regdisable(); 

	if (config.display)
		client2 = XOpenDisplay(config.display);
	if (client2 == (Display *) NULL) {
		delete("Can not open display");
		regenable();
		return;
	}
	else
		CHECK;
/* Call XSetCloseDownMode with RetainPermanent for client2. */
	XSetCloseDownMode(client2, RetainPermanent);
/* Create window for client2. */
	w = mkwin(client2, (XVisualInfo *) NULL, (struct area *) NULL, False);
/* Call XCloseDisplay for client2. */
	XCloseDisplay(client2);

	/* re-enable resource registration */
	regenable();

/* Select ALLEVENTS on window. */
	XSelectExtensionEvent(display, w, classes, nclass);
/* Call XSendExtensionEvent to send event to window. */
	propagate = False;
	event_list = &noextensioneventclass;
	event_send->type = dbp;
	_xcall_(return_value);
/* Verify that XSendExtensionEvent returned non-zero. */
	XSync(display, False);
	if (return_value == 0) {
		report("Returned zero, expected non-zero.");
		FAIL;
	}
	else
		CHECK;
/* Verify that no events were received. */
	if (XPending(display) > 0) {
		XEvent	event;

		XNextEvent(display, &event);
		report("Event(s) delivered unexpectedly (%s)", eventname(event.type));
		FAIL;
	}
	else
		CHECK;
	CHECKPASS(3);
>>ASSERTION Good B 3
When
.A event_list
is not set to noextensioneventclass
and no clients have selected on the destination window
and
.A propagate
is
.S False ,
then
a call to xname
results in no event being sent.
>>STRATEGY
Create window.
Select no events on window.
Set propagate to False.
Set event_list to something other than noextensioneventclass.
Discard all events in the event queue.
Call XSendExtensionEvent.
Verify that XSendExtensionEvent returned non-zero.
Verify that no events were received.
>>CODE
XVisualInfo *vp;
XEvent	event_return;
int	return_value;
int dbp;
XEventClass dbpc, noextensioneventclass;

/* Create window. */
	if (!Setup_Extension_DeviceInfo(BtnMask))
	    {
	    untested("%s: No input extension button device.\n", TestName);
	    return;
	    }
	device = Devs.Button;
	NoExtensionEvent(device, unused, noextensioneventclass);
	DeviceButtonPress(device, dbp, dbpc);
	resetvinf(VI_WIN);
	nextvinf(&vp);
	w = mkwin(display, (XVisualInfo *) NULL, (struct area *) NULL, False);
/* Select no events on window. */
	XSelectExtensionEvent(display, w, &noextensioneventclass, 1);
	XSync(display, True);
/* Set propagate to False. */
	propagate = False;
/* Set event_list to something other than NULL */
	count = 1;
	event_list = &dbpc;
/* Discard all events in the event queue. */
	XSync(display, True);
/* Call XSendExtensionEvent. */
	event_send->type = dbp;
	((XAnyEvent *) event_send)->window = w;
	_xcall_(return_value);
/* Verify that XSendExtensionEvent returned non-zero. */
	if (return_value == 0) {
		report("Returned zero, expected non-zero.");
		FAIL;
	}
	else
		CHECK;
/* Verify that no events were received. */
	XSync(display, False);
	if (XCheckTypedWindowEvent(display, w, event_send->type, &event_return) != False) {
		report("Unexpected event (%s) received.", eventname(event_send->type));
		FAIL;
	}
	else
		CHECK;
	CHECKPASS(2);
>>ASSERTION Good B 3
When
.A event_list
is not set to noextensioneventclass
and no clients have selected on the destination
.A w
and
.A propagate
is
.S True
and there is no matching ancestor of the destination
.A w
for which no intervening window has that type in its
do-not-propagate-mask,
then
a call to xname
results in no event being sent.
>>STRATEGY
Create a window hierarchy.
Create a hierarchy member with KeyPressMask set in do_not_propagate_mask.
Create a child of this member without setting do_not_propagate_mask.
Create the hierarchy.
Select no events on the destination w.
Select for KeyPress on the grandparent window of this member.
Set w to the window corresponding to child node.
Set propagate to True.
Set event_list to KeyPressMask.
Set event type to KeyPress.
Call XSendExtensionEvent.
Verify that XSendExtensionEvent returned non-zero.
Verify that no events were received.
Select for no events on the grandparent window of this member.
Call XSendExtensionEvent.
Verify that XSendExtensionEvent returned non-zero.
Verify that no events were received.
Change the do_not_propagate_mask from KeyPressMask to noextensioneventclass.
Call XSendExtensionEvent.
Verify that XSendExtensionEvent returned non-zero.
Verify that no events were received.
>>CODE
Winh	*grandparent;
Winh	*parent;
Winh	*child;
XSetWindowAttributes attrs;
int	return_value;
int dbp;
XEventClass dbpc, noextensioneventclass;

/* Create a window hierarchy. */
	if (!Setup_Extension_DeviceInfo(BtnMask))
	    {
	    untested("%s: No input extension button device.\n", TestName);
	    return;
	    }
	device = Devs.Button;
	DeviceButtonPress(Devs.Button, dbp, dbpc);
	NoExtensionEvent(device, unused, noextensioneventclass);
	grandparent = winh_adopt(display, (Winh *) NULL, 0L, (XSetWindowAttributes *) NULL, (Winhg *) NULL, WINH_NOMASK);
	if (grandparent == (Winh *) NULL) {
		delete("Could not create grandparent");
		return;
	}
	else
		CHECK;
/* Create a hierarchy member with KeyPressMask set in do_not_propagate_mask. */
	attrs.do_not_propagate_mask = KeyPressMask;
	parent = winh_adopt(display, grandparent, CWDontPropagate, &attrs, (Winhg *) NULL, WINH_NOMASK);
	if (parent == (Winh *) NULL) {
		delete("Could not create parent");
		return;
	}
	else
		CHECK;
/* Create a child of this member without setting do_not_propagate_mask. */
	child = winh_adopt(display, parent, 0L, (XSetWindowAttributes *) NULL, (Winhg *) NULL, WINH_NOMASK);
	if (child == (Winh *) NULL) {
		delete("Could not create child");
		return;
	}
	else
		CHECK;
/* Create the hierarchy. */
	if (winh_create(display, (Winh *) NULL, WINH_NOMASK)) {
		return;
	}
	else
		CHECK;
	XSync(display, True);
/* Select no events on the destination w. */
	XChangeDeviceDontPropagateList (display, parent->window, 1, &dbpc, AddToList);
	if (XSelectExtensionEvent(display, child->window, &noextensioneventclass, 1))
		return;
	else
		CHECK;
/* Select no events on the parent of w. */
	if (XSelectExtensionEvent(display, parent->window, &noextensioneventclass, 1))
		return;
	else
		CHECK;
/* Select for devicebuttonPress on the grandparent window of this member. */
	if (XSelectExtensionEvent(display, grandparent->window, &dbpc, 1))
		return;
	else
		CHECK;
	XSync(display, True);
/* Set w to the window corresponding to child node. */
	w = child->window;
/* Set propagate to True. */
	propagate = True;
/* Set event_list to KeyPressMask. */
	event_list = &dbpc;
	count = 1;
/* Set event type to KeyPress. */
	event_send->type = dbp;
/* Call XSendExtensionEvent. */
	_xcall_(return_value);
	XSync(display, False);
/* Verify that XSendExtensionEvent returned non-zero. */
	if (return_value == 0) {
		report("Returned zero, expected non-zero.");
		FAIL;
	}
	else
		CHECK;
/* Verify that no events were received. */
	if (XPending(display) > 0) {
		XEvent	event;

		XNextEvent(display, &event);
		report("Event(s) delivered unexpectedly (%s) through do_not_propagate_mask", eventname(event.type));
		FAIL;
	}
	else
		CHECK;
/* Select for no events on the grandparent window of this member. */
	if (XSelectExtensionEvent(display, grandparent->window, &noextensioneventclass, 1))
		return;
	else
		CHECK;
	XSync(display, True);
/* Call XSendExtensionEvent. */
	_xcall_(return_value);
	XSync(display, False);
/* Verify that XSendExtensionEvent returned non-zero. */
	if (return_value == 0) {
		report("Returned zero, expected non-zero.");
		FAIL;
	}
	else
		CHECK;
/* Verify that no events were received. */
	if (XPending(display) > 0) {
		XEvent	event;

		XNextEvent(display, &event);
		report("Event(s) delivered unexpectedly (%s) while none selected and do_not_propagate_mask on", eventname(event.type));
		FAIL;
	}
	else
		CHECK;
/* Change the do_not_propagate_mask from KeyPressMask to noextensioneventclass.*/
	if (XChangeDeviceDontPropagateList (display, parent->window, 1, &dbpc, DeleteFromList))
		return;
	else
		CHECK;
	XSync(display, True);
/* Call XSendExtensionEvent. */
	_xcall_(return_value);
	XSync(display, False);
/* Verify that XSendExtensionEvent returned non-zero. */
	if (return_value == 0) {
		report("Returned zero, expected non-zero.");
		FAIL;
	}
	else
		CHECK;
/* Verify that no events were received. */
	if (XPending(display) > 0) {
		XEvent	event;

		XNextEvent(display, &event);
		report("Event(s) delivered unexpectedly (%s) with none selected", eventname(event.type));
		FAIL;
	}
	else
		CHECK;
	CHECKPASS(15);
>>ASSERTION Good B 3
When
.A event_list
is not set to noextensioneventclass
and
.A w
is set to
.S InputFocus
and an inferior of the focus window contains the pointer
and no clients have selected on that inferior,
then
a call to xname
results in no event being sent.
>>STRATEGY
Create client2.
Create parent window.
Create inferior window.
Select KeyPress-type events on parent window with client2.
Flush client2 requests.
Select no events on child window.
Grab server.
Enable synchronization.
Set input focus to parent window.
Save initial pointer location.
Warp pointer to inferior of focus window.
Get new pointer location.
Discard all events in the event queue.
Call XSendExtensionEvent to send a KeyPress event to inferior of the focus window.
Get current pointer location.
Check to see if pointer moved.
Warp pointer back to where it started.
Disable synchronization.
Ungrab server.
Verify that XSendExtensionEvent returned non-zero.
Verify that no event was received for focus window.
Verify that event was not received for client2.
>>CODE
Display	*client2;
XVisualInfo *vp;
Window	parent;
Window	child;
int	return_value;
int root_x, root_y;	/* pointer location after XSendExtensionEvent */
int oroot_x, oroot_y;	/* pointer location before XSendExtensionEvent */
int sroot_x, sroot_y;	/* initial pointer location */
Window oldroot;		/* initial root window */
int itmp;		/* useless XQueryPointer return values */
unsigned int uitmp;	/* useless XQueryPointer return values */
Window wtmp;		/* useless XQueryPointer return values */
unsigned int width;
unsigned int height;
struct area a;
int dbp;
XEventClass noextensioneventclass, dbpc;

/* Create client2. */
	if (!Setup_Extension_DeviceInfo(BtnMask))
	    {
	    untested("%s: No input extension button device.\n", TestName);
	    return;
	    }
	device = Devs.Button;
	DeviceButtonPress(device, dbp, dbpc);
	NoExtensionEvent(device, unused, noextensioneventclass);
	client2 = opendisplay();
	if (client2 == (Display *) NULL) {
		delete("Can't create new client.");
		return;
	}
	else
		CHECK;
/* Create parent window. */
	resetvinf(VI_WIN);
	nextvinf(&vp);
	parent = makewin(display, vp);
/* Create inferior window. */
	getsize(display, (Drawable) parent, &width, &height);
	a.x = 0;
	a.y = 0;
	a.width = width/2;
	a.height = height/2;
	child = crechild(display, parent, &a);
/* Select KeyPress-type events on parent window with client2. */
	XSelectExtensionEvent(client2, parent, &noextensioneventclass, 1);
/* Flush client2 requests. */
	XFlush(client2);
/* Select no events on child window. */
	XSelectExtensionEvent(display, child, &noextensioneventclass, 1);
/* Grab server. */
	XGrabServer(display);
/* Enable synchronization. */
	XSynchronize(display, True);
/* Set input focus to parent window. */
	XSetDeviceFocus(display, Devs.Button, parent, RevertToPointerRoot, CurrentTime);
/* Save initial pointer location. */
	XQueryPointer(display, child, &oldroot, &wtmp, &sroot_x, &sroot_y, &itmp, &itmp, &uitmp);
/* Warp pointer to inferior of focus window. */
	XWarpPointer(display, None, child, 0, 0, 0, 0, 0, 0);

/* Get new pointer location. */
	if (XQueryPointer(display, child, &wtmp, &wtmp, &oroot_x, &oroot_y, &itmp, &itmp, &uitmp) == False) {
		delete("Pointer on wrong root.");
		XSynchronize(display, False);
		XUngrabServer(display);
		return;
	} else
		CHECK;
/* Discard all events in the event queue. */
	XSync(display, True);
/* Call XSendExtensionEvent to send a KeyPress event to inferior of the focus window. */
	w = (Window) InputFocus;
	propagate = False;
	count = 1;
	event_list = &dbpc;
	event_send->type = dbp;
	((XAnyEvent *) event_send)->window = child;
	_xcall_(return_value);
/* Get current pointer location. */
	if (XQueryPointer(display, child, &wtmp, &wtmp, &root_x, &root_y, &itmp, &itmp, &uitmp) == False) {
		delete("Pointer moved.");
		XSynchronize(display, False);
		XUngrabServer(display);
		return;
	}
	else
		CHECK;
/* Check to see if pointer moved. */
	if (oroot_x != root_x || oroot_y != root_y) {
		delete("Pointer moved.");
		/*
		 * if this is ever changed to be a return, take care to
		 * also turn off synchronization and ungrab the server...
		 */
	}
	else
		CHECK;
/* Warp pointer back to where it started. */
	XWarpPointer(display, None, oldroot, 0, 0, 0, 0, sroot_x, sroot_y);
/* Disable synchronization. */
	XSynchronize(display, False);
/* Ungrab server. */
	XUngrabServer(display);
/* Verify that XSendExtensionEvent returned non-zero. */
	if (return_value == 0) {
		report("Returned zero, expected non-zero.");
		FAIL;
	}
	else
		CHECK;
	XSync(display, False);
	XSync(client2, False);
/* Verify that no event was received for focus window. */
	if (XPending(display) > 0) {
		XEvent	event;

		XNextEvent(display, &event);
		report("Event(s) delivered unexpectedly (%s) to focus window", eventname(event.type));
		FAIL;
	}
	else
		CHECK;
/* Verify that event was not received for client2. */
	if (XPending(client2) > 0) {
		XEvent	event;

		XNextEvent(client2, &event);
		report("Event(s) delivered unexpectedly (%s)", eventname(event.type));
		FAIL;
	}
	else
		CHECK;
	CHECKPASS(7);
>>ASSERTION Good B 3
When
.A event_list
is not set to noextensioneventclass
and
.A w
is set to
.S InputFocus
and an inferior of the focus window does not contain the pointer
and no clients have selected on the focus window,
then
a call to xname
results in no event being sent.
>>STRATEGY
Create window.
Grab server.
Enable synchronization.
Set input focus to new focus window.
Save initial pointer location.
Warp pointer away from inferior of focus window; to root.
Get new pointer location.
Select no events on new focus window.
Discard all events in the event queue.
Call xname with propagate == False, w == InputFocus & event_list == 
devicebuttonpressclass.
Get current pointer location.
Check to see if pointer moved.
Warp pointer back to where it started.
Disable synchronization.
Ungrab server.
Verify that XSendExtensionEvent returned non-zero.
Verify that no event was received.
Grab server.
Enable synchronization.
Set input focus to new focus window.
Save initial pointer location.
Warp pointer away from inferior of focus window; to root.
Get new pointer location.
Call XSendExtensionEvent again with propagate set to True.
Get current pointer location.
Check to see if pointer moved.
Warp pointer back to where it started.
Disable synchronization.
Ungrab server.
Verify that XSendExtensionEvent returned non-zero.
Verify that no event was received.
>>CODE
XVisualInfo *vp;
Window	nfocus;
int	return_value;
int root_x, root_y;	/* pointer location after XSendExtensionEvent */
int oroot_x, oroot_y;	/* pointer location before XSendExtensionEvent */
int sroot_x, sroot_y;	/* initial pointer location */
Window oldroot;		/* initial root window */
int itmp;		/* useless XQueryPointer return values */
unsigned int uitmp;	/* useless XQueryPointer return values */
Window wtmp;		/* useless XQueryPointer return values */
int dbp;
XEventClass noextensioneventclass, dbpc;

/* Create window. */
	if (!Setup_Extension_DeviceInfo(BtnMask))
	    {
	    untested("%s: No input extension button device.\n", TestName);
	    return;
	    }
	device = Devs.Button;
	DeviceButtonPress(device, dbp, dbpc);
	NoExtensionEvent(device, unused, noextensioneventclass);
	resetvinf(VI_WIN);
	nextvinf(&vp);
	nfocus = makewin(display, vp);
/* Grab server. */
	XGrabServer(display);
/* Enable synchronization. */
	XSynchronize(display, True);
/* Set input focus to new focus window. */
	XSetInputFocus(display, nfocus, RevertToPointerRoot, CurrentTime);
/* Save initial pointer location. */
	XQueryPointer(display, nfocus, &oldroot, &wtmp, &sroot_x, &sroot_y, &itmp, &itmp, &uitmp);
/* Warp pointer away from inferior of focus window; to root. */
	XWarpPointer(display, None, DRW(display), 0, 0, 0, 0, 0, 0);

/* Get new pointer location. */
	if (XQueryPointer(display, nfocus, &wtmp, &wtmp, &oroot_x, &oroot_y, &itmp, &itmp, &uitmp) == False) {
		delete("Pointer on wrong root.");
		XSynchronize(display, False);
		XUngrabServer(display);
		return;
	} else
		CHECK;
/* Select no events on new focus window. */
	XSelectExtensionEvent(display, nfocus, &noextensioneventclass, 1);
/* Discard all events in the event queue. */
	XSync(display, True);
	w = (Window) InputFocus;
	event_list = &dbpc;
	event_send->type = dbp;
	((XAnyEvent *) event_send)->window = nfocus;
	propagate = False;
/* Call xname with propagate == False, w == InputFocus & event_list == 
   devicebuttonpressclass. */
	_xcall_(return_value);
/* Get current pointer location. */
	if (XQueryPointer(display, nfocus, &wtmp, &wtmp, &root_x, &root_y, &itmp, &itmp, &uitmp) == False) {
		delete("Pointer moved.");
		XSynchronize(display, False);
		XUngrabServer(display);
		return;
	}
	else
		CHECK;
/* Check to see if pointer moved. */
	if (oroot_x != root_x || oroot_y != root_y) {
		delete("Pointer moved.");
		/*
		 * if this is ever changed to be a return, take care to
		 * also turn off synchronization and ungrab the server...
		 */
	}
	else
		CHECK;
/* Warp pointer back to where it started. */
	XWarpPointer(display, None, oldroot, 0, 0, 0, 0, sroot_x, sroot_y);
/* Disable synchronization. */
	XSynchronize(display, False);
/* Ungrab server. */
	XUngrabServer(display);
/* Verify that XSendExtensionEvent returned non-zero. */
	if (return_value == 0) {
		report("Returned zero, expected non-zero.");
		FAIL;
	}
	else
		CHECK;
	XSync(display, False);
/* Verify that no event was received. */
	XSync(display, False);
	if (XPending(display) > 0) {
		XEvent	event;

		XNextEvent(display, &event);
		report("Event(s) delivered unexpectedly (%s)", eventname(event.type));
		FAIL;
	}
	else
		CHECK;
/* Grab server. */
	XGrabServer(display);
/* Enable synchronization. */
	XSynchronize(display, True);
/* Set input focus to new focus window. */
	XSetInputFocus(display, nfocus, RevertToPointerRoot, CurrentTime);
/* Save initial pointer location. */
	XQueryPointer(display, nfocus, &oldroot, &wtmp, &sroot_x, &sroot_y, &itmp, &itmp, &uitmp);
/* Warp pointer away from inferior of focus window; to root. */
	XWarpPointer(display, None, DRW(display), 0, 0, 0, 0, 0, 0);

/* Get new pointer location. */
	if (XQueryPointer(display, nfocus, &wtmp, &wtmp, &oroot_x, &oroot_y, &itmp, &itmp, &uitmp) == False) {
		delete("Pointer on wrong root.");
		XSynchronize(display, False);
		XUngrabServer(display);
		return;
	} else
		CHECK;
/* Call XSendExtensionEvent again with propagate set to True. */
	propagate = True;
	_xcall_(return_value);
/* Get current pointer location. */
	if (XQueryPointer(display, nfocus, &wtmp, &wtmp, &root_x, &root_y, &itmp, &itmp, &uitmp) == False) {
		delete("Pointer moved.");
		XSynchronize(display, False);
		XUngrabServer(display);
		return;
	}
	else
		CHECK;
/* Check to see if pointer moved. */
	if (oroot_x != root_x || oroot_y != root_y) {
		delete("Pointer moved.");
		/*
		 * if this is ever changed to be a return, take care to
		 * also turn off synchronization and ungrab the server...
		 */
	}
	else
		CHECK;
/* Warp pointer back to where it started. */
	XWarpPointer(display, None, oldroot, 0, 0, 0, 0, sroot_x, sroot_y);
/* Disable synchronization. */
	XSynchronize(display, False);
/* Ungrab server. */
	XUngrabServer(display);
/* Verify that XSendExtensionEvent returned non-zero. */
	if (return_value == 0) {
		report("Returned zero, expected non-zero.");
		FAIL;
	}
	else
		CHECK;
	XSync(display, False);
/* Verify that no event was received. */
	XSync(display, False);
	if (XPending(display) > 0) {
		XEvent	event;

		XNextEvent(display, &event);
		report("Event(s) delivered unexpectedly (%s)", eventname(event.type));
		FAIL;
	}
	else
		CHECK;
	CHECKPASS(10);
>>ASSERTION Good B 3
When
.A event_list
is not set to noextensioneventclass
and no clients have selected on the destination
.A w
and
.A propagate
is
.S True
and there is a matching ancestor of the destination
.A w
for which no intervening window has that type in its
do-not-propagate-mask
and that ancestor is an ancestor of the focus window
and
.S InputFocus
was not specified as the destination,
then
a call to xname
results in the event being sent to all clients selecting
a type in
.A event_list
on the first matching ancestor.
>>STRATEGY
Set event_list to devicebuttonpressclass;
Set propagate to True.
Create window hierarchy with depth of three and with all windows
have no bits set in their do-not-propagate-mask.
Set focus window to window mid-level in window hierarchy.
Set w to window at bottom of window hierarchy.
Create client2.
Select no events on w.
Select no events on w with client2.
Select KeyPress events on top-level window in window hierarchy.
Select KeyPress events on top-level window in window hierarchy
with client2.
Call XSendExtensionEvent to send a KeyPress event to w.
Verify that XSendExtensionEvent returned non-zero.
Verify that event was received for top-level window in window hierarchy.
Verify that send_event was not set to False.
Verify that event was received for top-level window in window hierarchy
for client2.
Verify that send_event was not set to False for client2.
>>CODE
Display	*client2;
Winh	*grandparent;
Winh	*parent;
Winh	*child;
int	return_value;
XEvent	event_return;
XAnyEvent *event;
int dbp;
XEventClass noextensioneventclass, dbpc;

/* Set event_list to devicebuttonpressclass. */
	if (!Setup_Extension_DeviceInfo(BtnMask))
	    {
	    untested("%s: No input extension button device.\n", TestName);
	    return;
	    }
	device = Devs.Button;
	DeviceButtonPress(device, dbp, dbpc);
	NoExtensionEvent(device, unused, noextensioneventclass);
	event_list = &dbpc;
/* Set propagate to True. */
	propagate = True;
/* Create window hierarchy with depth of three and with all windows */
/* have no bits set in their do-not-propagate-mask. */
	grandparent = winh_adopt(display, (Winh *) NULL, 0L, (XSetWindowAttributes *) NULL, (Winhg *) NULL, WINH_NOMASK);
	if (grandparent == (Winh *) NULL) {
		delete("Could not create grandparent");
		return;
	}
	else
		CHECK;
	parent = winh_adopt(display, grandparent, 0L, (XSetWindowAttributes *) NULL, (Winhg *) NULL, WINH_NOMASK);
	if (parent == (Winh *) NULL) {
		delete("Could not create parent");
		return;
	}
	else
		CHECK;
	child = winh_adopt(display, parent, 0L, (XSetWindowAttributes *) NULL, (Winhg *) NULL, WINH_NOMASK);
	if (child == (Winh *) NULL) {
		delete("Could not create child");
		return;
	}
	else
		CHECK;
	if (winh_create(display, (Winh *) NULL, WINH_MAP)) {
		return;
	}
	else
		CHECK;
/* Set focus window to window mid-level in window hierarchy. */
	XSetInputFocus(display, parent->window, RevertToPointerRoot, CurrentTime);
/* Set w to window at bottom of window hierarchy. */
	w = child->window;
/* Create client2. */
	client2 = opendisplay();
	if (client2 == (Display *) NULL) {
		delete("Can't create new client.");
		return;
	}
	else
		CHECK;
/* Select no events on w. */
	if(XSelectExtensionEvent(display, child->window, &noextensioneventclass, 1)){
		return;
	}
	else
		CHECK;
/* Select no events on w with client2. */
	if(XSelectExtensionEvent(client2, child->window, &noextensioneventclass, 1)){
		return;
	}
	else
		CHECK;
/* Select KeyPress events on top-level window in window hierarchy. */
	if(XSelectExtensionEvent(display, grandparent->window, &dbpc, 1)){
		return;
	}
	else
		CHECK;
/* Select KeyPress events on top-level window in window hierarchy */
/* with client2. */
	if(XSelectExtensionEvent(client2, grandparent->window, &dbpc, 1)){
		return;
	}
	else
		CHECK;
	XSync(display, True);
	XSync(client2, True);
/* Call XSendExtensionEvent to send a KeyPress event to w. */
	count = 1;
	event_list = &dbpc;
	event_send->type = dbp;
	((XAnyEvent *) event_send)->window = grandparent->window;
	_xcall_(return_value);
/* Verify that XSendExtensionEvent returned non-zero. */
	if (return_value == 0) {
		report("Returned zero, expected non-zero.");
		FAIL;
	}
	else
		CHECK;
/* Verify that event was received for top-level window in window hierarchy. */
	XSync(display, False);
	if (XCheckTypedWindowEvent(display, grandparent->window, event_send->type, &event_return) != True) {
		report("Expected event (%s) not received.", eventname(event_send->type));
		FAIL;
	}
	else
		CHECK;
/* Verify that send_event was not set to False. */
	event = (XAnyEvent *) &event_return;
	if (event->send_event == False) {
		report("send_event not set to True");
		FAIL;
	}
	else
		CHECK;
/* Verify that event was received for top-level window in window hierarchy */
/* for client2. */
	XSync(client2, False);
	if (XCheckTypedWindowEvent(client2, grandparent->window, event_send->type, &event_return) != True) {
		report("Expected event (%s) not received.", eventname(event_send->type));
		FAIL;
	}
	else
		CHECK;
/* Verify that send_event was not set to False for client2. */
	event = (XAnyEvent *) &event_return;
	if (event->send_event == False) {
		report("send_event not set to True");
		FAIL;
	}
	else
		CHECK;
	CHECKPASS(14);
>>ASSERTION Good B 3
When
.A event_list
is not set to noextensioneventclass
and no clients have selected on the destination
.A w
and
.A propagate
is
.S True
and there is a matching ancestor of the destination
.A w
for which no intervening window has that type in its
do-not-propagate-mask
and this ancestor is not an ancestor of the focus window,
then
a call to xname
results in the event being sent to all clients selecting
a type in
.A event_list
on the first matching ancestor.
>>STRATEGY
Set event_list to devicebuttonpressclass.
Set propagate to True.
Create window hierarchy with depth of three and with all windows
have no bits set in their do-not-propagate-mask.
Set focus window to top window in window hierarchy.
Set w to window at bottom of window hierarchy.
Create client2.
Select no events on w.
Select no events on w with client2.
Select KeyPress events on mid-level window in window hierarchy.
Select KeyPress events on mid-level window in window hierarchy
with client2.
Call XSendExtensionEvent to send a KeyPress event to w.
Verify that XSendExtensionEvent returned non-zero.
Verify that event was received for mid-level window in window hierarchy.
Verify that send_event was not set to False.
Verify that event was received for mid-level window in window hierarchy
for client2.
Verify that send_event was not set to False for client2.
>>CODE
Display	*client2;
Winh	*grandparent;
Winh	*parent;
Winh	*child;
int	return_value;
XEvent	event_return;
XAnyEvent *event;
int dbp;
XEventClass noextensioneventclass, dbpc;

/* Set event_list to devicebuttonpressclass.*/
	if (!Setup_Extension_DeviceInfo(BtnMask))
	    {
	    untested("%s: No input extension button device.\n", TestName);
	    return;
	    }
	device = Devs.Button;
	DeviceButtonPress(device, dbp, dbpc);
	NoExtensionEvent(device, unused, noextensioneventclass);
	count = 1;
	event_list = &dbpc;
/* Set propagate to True. */
	propagate = True;
/* Create window hierarchy with depth of three and with all windows */
/* have no bits set in their do-not-propagate-mask. */
	grandparent = winh_adopt(display, (Winh *) NULL, 0L, (XSetWindowAttributes *) NULL, (Winhg *) NULL, WINH_NOMASK);
	if (grandparent == (Winh *) NULL) {
		delete("Could not create grandparent");
		return;
	}
	else
		CHECK;
	parent = winh_adopt(display, grandparent, 0L, (XSetWindowAttributes *) NULL, (Winhg *) NULL, WINH_NOMASK);
	if (parent == (Winh *) NULL) {
		delete("Could not create parent");
		return;
	}
	else
		CHECK;
	child = winh_adopt(display, parent, 0L, (XSetWindowAttributes *) NULL, (Winhg *) NULL, WINH_NOMASK);
	if (child == (Winh *) NULL) {
		delete("Could not create child");
		return;
	}
	else
		CHECK;
	if (winh_create(display, (Winh *) NULL, WINH_MAP)) {
		return;
	}
	else
		CHECK;
/* Set focus window to top window in window hierarchy. */
	XSetDeviceFocus(display, Devs.Button, grandparent->window, RevertToPointerRoot, CurrentTime);
/* Set w to window at bottom of window hierarchy. */
	w = child->window;
/* Create client2. */
	client2 = opendisplay();
	if (client2 == (Display *) NULL) {
		delete("Can't create new client.");
		return;
	}
	else
		CHECK;
/* Select no events on w. */
	if(XSelectExtensionEvent(display, child->window, &noextensioneventclass, 1)){
		return;
	}
	else
		CHECK;
/* Select no events on w with client2. */
	if(XSelectExtensionEvent(client2, child->window, &noextensioneventclass, 1)){
		return;
	}
	else
		CHECK;
/* Select KeyPress events on mid-level window in window hierarchy. */
	if(XSelectExtensionEvent(display, parent->window, &dbpc, 1)){
		return;
	}
	else
		CHECK;
/* Select KeyPress events on mid-level window in window hierarchy */
/* with client2. */
	if(XSelectExtensionEvent(client2, parent->window, &dbpc, 1)){
		return;
	}
	else
		CHECK;
	XSync(display, True);
	XSync(client2, True);
/* Call XSendExtensionEvent to send a KeyPress event to w. */
	count = 1;
	event_list = &dbpc;
	event_send->type = dbp;
	((XAnyEvent *) event_send)->window = parent->window;
	_xcall_(return_value);
/* Verify that XSendExtensionEvent returned non-zero. */
	if (return_value == 0) {
		report("Returned zero, expected non-zero.");
		FAIL;
	}
	else
		CHECK;
/* Verify that event was received for mid-level window in window hierarchy. */
	XSync(display, False);
	if (XCheckTypedWindowEvent(display, parent->window, event_send->type, &event_return) != True) {
		report("Expected event (%s) not received.", eventname(event_send->type));
		FAIL;
	}
	else
		CHECK;
/* Verify that send_event was not set to False. */
	event = (XAnyEvent *) &event_return;
	if (event->send_event == False) {
		report("send_event not set to True");
		FAIL;
	}
	else
		CHECK;
/* Verify that event was received for mid-level window in window hierarchy */
/* for client2. */
	XSync(client2, False);
	if (XCheckTypedWindowEvent(client2, parent->window, event_send->type, &event_return) != True) {
		report("Expected event (%s) not received.", eventname(event_send->type));
		FAIL;
	}
	else
		CHECK;
/* Verify that send_event was not set to False for client2. */
	event = (XAnyEvent *) &event_return;
	if (event->send_event == False) {
		report("send_event not set to True");
		FAIL;
	}
	else
		CHECK;
	CHECKPASS(14);
>>ASSERTION Good B 3
A call to xname
ignores active grabs.
>>STRATEGY
Create window.
Select ALLEVENTS on this window.
Set propagate to False.
Create client2.
Create window with client2.
Grab the pointer with client2 using client2's window as the grab window,
owner_events set to False, event_list set to PointerMotionMask,
pointer_mode set to GrabModeSync, and keyboard_mode set to GrabModeSync.
Verify that XGrabPointer returned GrabSuccess.
Grab AnyButton with client2 using client2's window as the grab window,
owner_events set to False, event_list set to ButtonPressMask,
pointer_mode set to GrabModeSync, and keyboard_mode set to GrabModeSync.
Grab the keyboard with client2 using client2's window as the grab window,
owner_events set to False, pointer_mode set to GrabModeSync,
and keyboard_mode set to GrabModeSync.
Verify that XGrabKeyboard returned GrabSuccess.
Set event_list to PointerMotionMask.
Flush display, discarding events.
Flush client2, discarding events.
Call XSendExtensionEvent to send a MotionNotify event.
Verify that XSendExtensionEvent returned non-zero.
Flush display, not discarding events.
Flush client2, not discarding events.
Verify that event was received.
Verify that send_event was not set to False.
Verify that client2 received no events.
Set event_list to ButtonPressMask.
Flush display, discarding events.
Flush client2, discarding events.
Call XSendExtensionEvent to send a ButtonPress event.
Verify that XSendExtensionEvent returned non-zero.
Flush display, not discarding events.
Flush client2, not discarding events.
Verify that event was received.
Verify that send_event was not set to False.
Verify that client2 received no events.
Set event_list to KeyPressMask.
Flush display, discarding events.
Flush client2, discarding events.
Call XSendExtensionEvent to send a KeyPress event.
Flush display, not discarding events.
Flush client2, not discarding events.
Verify that XSendExtensionEvent returned non-zero.
Verify that event was received.
Verify that send_event was not set to False.
Verify that client2 received no events.
Ungrab the keyboard with client2.
Ungrab buttons with client2.
Ungrab the pointer with client2.
>>CODE
Display	*client2;
Window	w2;
int	status;
XAnyEvent *event;
XEvent	event_return;
int	return_value;
int devicemotionnotify, dbp;
XEventClass devicemotionnotifyclass, dbpc;
XEventClass classes[2];

/* Create window. */
	if (!Setup_Extension_DeviceInfo(BtnMask))
	    {
	    untested("%s: No input extension button device.\n", TestName);
	    return;
	    }
	device = Devs.Button;
	DeviceButtonPress(device, dbp, dbpc);
	w = mkwin(display, (XVisualInfo *) NULL, (struct area *) NULL, False);
	((XAnyEvent *) event_send)->window = w;
/* Select ALLEVENTS on this window. */
	DeviceMotionNotify(device,devicemotionnotify, devicemotionnotifyclass);
	classes[0] = devicemotionnotifyclass;
	classes[1] = dbpc;
	XSelectExtensionEvent(display, w, classes, 2);
/* Set propagate to False. */
	propagate = False;
/* Create client2. */
	client2 = opendisplay();
	if (client2 == (Display *) NULL) {
		delete("Can't create new client.");
		return;
	}
	else
		CHECK;
/* Create window with client2. */
	w2 = mkwin(client2, (XVisualInfo *) NULL, (struct area *) NULL, True);
/* Grab the pointer with client2 using */
/* client2's window as the grab window, */
/* owner_events set to False, */
/* event_list set to PointerMotionMask, */
/* pointer_mode set to GrabModeSync, */
/* and keyboard_mode set to GrabModeSync. */
	status = XGrabPointer(client2, w2, False, PointerMotionMask, GrabModeSync, GrabModeSync, None, None, CurrentTime);
/* Verify that XGrabPointer returned GrabSuccess. */
	if (status != GrabSuccess) {
		delete("Can't grab pointer (%d).", status);
		return;
	}
	else
		CHECK;
/* Grab AnyButton with client2 using */
/* client2's window as the grab window, */
/* owner_events set to False, */
/* event_list set to ButtonPressMask, */
/* pointer_mode set to GrabModeSync, */
/* and keyboard_mode set to GrabModeSync. */
	XGrabButton(client2, AnyButton, AnyModifier, w2, False, ButtonPressMask, GrabModeSync, GrabModeSync, None, None);
/* Grab the keyboard with client2 using */
/* client2's window as the grab window, */
/* owner_events set to False, */
/* pointer_mode set to GrabModeSync, */
/* and keyboard_mode set to GrabModeSync. */
	status = XGrabKeyboard(client2, w2, False, GrabModeSync, GrabModeSync, CurrentTime);
/* Verify that XGrabKeyboard returned GrabSuccess. */
	if (status != GrabSuccess) {
		delete("Can't grab keyboard (%d).", status);
		return;
	}
	else
		CHECK;
/* Set event_mask to PointerMotionMask. */
	event_list = &devicemotionnotifyclass;
	event_send->type = devicemotionnotify;
/* Flush display, discarding events. */
	XSync(display, True);
/* Flush client2, discarding events. */
	XSync(client2, True);
/* Call XSendExtensionEvent to send a MotionNotify event. */
	_xcall_(return_value);
/* Verify that XSendExtensionEvent returned non-zero. */
	if (return_value == 0) {
		report("Returned zero, expected non-zero.");
		FAIL;
	}
	else
		CHECK;
/* Flush display, not discarding events. */
	XSync(display, False);
/* Flush client2, not discarding events. */
	XSync(client2, False);
/* Verify that event was received. */
	if (XCheckTypedWindowEvent(display, w, event_send->type, &event_return) == False) {
		report("Expected event (%s) not received.", eventname(event_send->type));
		FAIL;
	}
	else
		CHECK;
/* Verify that send_event was not set to False. */
	event = (XAnyEvent *) &event_return;
	if (event->send_event == False) {
		report("send_event not set to True");
		FAIL;
	}
	else
		CHECK;
/* Verify that client2 received no events. */
	status = XPending(client2);
	if (status != 0) {
		report("Client2 received %d events, expected %d", status, 0);
		FAIL;
	}
	else
		CHECK;
/* Set event_mask to ButtonPressMask. */
	event_list = &dbpc;
	event_send->type = dbp;
/* Flush display, discarding events. */
	XSync(display, True);
/* Flush client2, discarding events. */
	XSync(client2, True);
/* Call XSendExtensionEvent to send a ButtonPress event. */
	_xcall_(return_value);
/* Verify that XSendExtensionEvent returned non-zero. */
	if (return_value == 0) {
		report("Returned zero, expected non-zero.");
		FAIL;
	}
	else
		CHECK;
/* Flush display, not discarding events. */
	XSync(display, False);
/* Flush client2, not discarding events. */
	XSync(client2, False);
/* Verify that event was received. */
	if (XCheckTypedWindowEvent(display, w, event_send->type, &event_return) == False) {
		report("Expected event (%s) not received.", eventname(event_send->type));
		FAIL;
	}
	else
		CHECK;
/* Verify that send_event was not set to False. */
	event = (XAnyEvent *) &event_return;
	if (event->send_event == False) {
		report("send_event not set to True");
		FAIL;
	}
	else
		CHECK;
/* Verify that client2 received no events. */
	status = XPending(client2);
	if (status != 0) {
		report("Client2 received %d events, expected %d", status, 0);
		FAIL;
	}
	else
		CHECK;
/* Set event_mask to KeyPressMask. */
	event_list = &dbpc;
	event_send->type = dbp;
/* Flush display, discarding events. */
	XSync(display, True);
/* Flush client2, discarding events. */
	XSync(client2, True);
/* Call XSendExtensionEvent to send a KeyPress event. */
	_xcall_(return_value);
/* Flush display, not discarding events. */
	XSync(display, False);
/* Flush client2, not discarding events. */
	XSync(client2, False);
/* Verify that XSendExtensionEvent returned non-zero. */
	if (return_value == 0) {
		report("Returned zero, expected non-zero.");
		FAIL;
	}
	else
		CHECK;
/* Verify that event was received. */
	if (XCheckTypedWindowEvent(display, w, event_send->type, &event_return) == False) {
		report("Expected event (%s) not received.", eventname(event_send->type));
		FAIL;
	}
	else
		CHECK;
/* Verify that send_event was not set to False. */
	event = (XAnyEvent *) &event_return;
	if (event->send_event == False) {
		report("send_event not set to True");
		FAIL;
	}
	else
		CHECK;
/* Verify that client2 received no events. */
	status = XPending(client2);
	if (status != 0) {
		report("Client2 received %d events, expected %d", status, 0);
		FAIL;
	}
	else
		CHECK;
/* Ungrab the keyboard with client2. */
	XUngrabKeyboard(client2, CurrentTime);
/* Ungrab buttons with client2. */
	XUngrabButton(client2, AnyButton, AnyModifier, w2);
/* Ungrab the pointer with client2. */
	XUngrabPointer(client2, CurrentTime);
	CHECKPASS(15);
>>ASSERTION Good B 3
On a call to xname
the only fields in the forwarded event which are changed
are the
.M send_event
and
.M serial
fields.
>>STRATEGY
Create window.
Set type member of event to KeyPress.
Set serial member of event to 0.
Set send_event member of event to False.
Ignore display member of event, as it's filled in by Xlib.
Set window member of event to 0xffffffff.
Discard all events in the event queue.
Call XSendExtensionEvent to send event to creator of window.
Verify that XSendExtensionEvent returned non-zero.
Verify that event was received.
Verify that type was set to KeyPress.
Verify that serial was not set to 0.
Verify that send_event was not set to False.
Check display member of event was filled in by Xlib properly.
Verify that window was set to 0.
Repeat for each event-type.
>>CODE
int	i;
XAnyEvent *event;
XEvent	event_return;
int	return_value;
int cdn, dmn, dsn;
XEventClass noextensioneventclass, cdnc, dmnc, dsnc;

/* Create window. */
	if (!Setup_Extension_DeviceInfo(BtnMask))
	    {
	    untested("%s: No input extension button device.\n", TestName);
	    return;
	    }
	device = Devs.Button;
	ChangeDeviceNotify(Devs.Button, cdn, cdnc);
	DeviceMappingNotify(Devs.Button, dmn, dmnc);
	DeviceStateNotify(Devs.Button, dsn, dsnc);
	NoExtensionEvent(device, unused, noextensioneventclass);
	w = mkwin(display, (XVisualInfo *) NULL, (struct area *) NULL, False);
	propagate = False;
	count=1;
	event_list = &noextensioneventclass;
	event = (XAnyEvent *) &event_return;
	for (i = 0; i < nevent; i++) {
		char *en = eventname(event_types[i]);

/* Set type member of event to KeyPress. */
		event_send->type = event_types[i];

/* Set serial member of event to 0. */
		event_send->xany.serial = 0;

/* Set send_event member of event to False. */
		event_send->xany.send_event = False;

/* Ignore display member of event, as it's filled in by Xlib. */
		event_send->xany.display = (Display *) NULL;

/* Set window member of event to 0xffffffff. */
		event_send->xany.window = (Window) 0xffffffff;

/* Discard all events in the event queue. */
		XSync(display, True);

/* Call XSendExtensionEvent to send event to creator of window. */
		_xcall_(return_value);

/* Verify that XSendExtensionEvent returned non-zero. */
		if (return_value == 0) {
			report("%s: Returned zero, expected non-zero.",en);
			FAIL;
		}
		else
			CHECK;

/* Verify that event was received. */
		XSync(display, False);
		if (XPending(display) == 0) {
			report("%s: No events received.",en);
			FAIL;
			continue;
		}
		else
			CHECK;
		if (XCheckTypedEvent(display, event_send->type, &event_return) == False) {
			report("Expected event (%s) not received.", en);
			FAIL;
			continue;
		}
		else
			CHECK;

/* Verify that type was set to KeyPress. */
		if (event->type != event_types[i]) {
			report("type set to %s, expected %s", eventname(event->type), en);
			FAIL;
		}
		else
			CHECK;

/* Verify that serial was not set to 0. */
		if (event->serial == 0) {
			report("%s: serial set to zero, expected non-zero",en);
			FAIL;
		}
		else
			CHECK;

/* Verify that send_event was not set to False. */
		if (event->send_event == False) {
			report("%s: send_event not set to True", en);
			FAIL;
		}
		else
			CHECK;

/* Check display member of event was filled in by Xlib properly. */
		if (event->display != display) {
			report("%s: display not set to my display", en);
			FAIL;
		}
		else
			CHECK;

/* Verify that window was set to 0. */
		if (event->window != (Window) 0xffffffff &&
			 event->type != dmn &&
			 event->type != cdn &&
			 event->type != dsn) {
			report("%s: window set to 0x%x, expected 0x%x", en, event->window, (Window) 0xffffffff);
			FAIL;
		}
		else
			CHECK;

/* Repeat for each event-type. */
	}
	CHECKPASS(8*nevent);
>>ASSERTION def
On a call to xname
the
.M send_event
field in the forwarded event is set to
.S True .
>>ASSERTION Good B 3
On a call to xname
the
.M serial
field in the forwarded event is set correctly.
>>STRATEGY
Create window.
Set serial to zero.
Call NextRequest to get correct serial.
Call XSendExtensionEvent.
Verify that XSendExtensionEvent returned non-zero.
Verify that event was received.
Verify that serial in delivered event is set correctly.
>>CODE
int	correctserial;
XAnyEvent *event;
XEvent	event_return;
int	return_value;
int dbp;
XEventClass noextensioneventclass, dbpc;

/* Create window. */
	if (!Setup_Extension_DeviceInfo(BtnMask))
	    {
	    untested("%s: No input extension button device.\n", TestName);
	    return;
	    }
	/* Force the extension version to be initialized.  Otherwise, the call
	   to XSendExtensionEvent will result in two calls, one to 
	   XGetExtensionVersion and another to XSendExtensionEvent. */

	XGetExtensionVersion(display,"XInputExtension");
	device = Devs.Button;
	DeviceButtonPress(device, dbp, dbpc);
	NoExtensionEvent(device, unused, noextensioneventclass);
	w = mkwin(display, (XVisualInfo *) NULL, (struct area *) NULL, False);
	propagate = False;
	count = 1;
	event_list = &noextensioneventclass;
/* Set serial to zero. */
	event = (XAnyEvent *) event_send;
	event->serial = 0;
	event_send->type = dbp;
/* Call NextRequest to get correct serial. */
	XSync(display,0);
	correctserial = NextRequest(display);
/* Call XSendExtensionEvent. */
	_xcall_(return_value);
/* Verify that XSendExtensionEvent returned non-zero. */
	if (return_value == 0) {
		report("Returned zero, expected non-zero.");
		FAIL;
	}
	else
		CHECK;
/* Verify that event was received. */
	XFlush(display);
	XSync(display, False);
	if (XPending(display) == 0) {
		report("No events received.");
		FAIL;
		return;
	}
	else
		CHECK;
	if (XCheckTypedEvent(display, event_send->type, &event_return) == False) {
		report("Expected event (%s) not received.", eventname(event_send->type));
		FAIL;
		return;
	}
	else
		CHECK;
/* Verify that serial in delivered event is set correctly. */
	event = (XAnyEvent *) &event_return;
	if (event->serial != correctserial) {
		report("Serial set to %d, expected %d", event->serial, correctserial);
		FAIL;
	}
	else
		CHECK;
	CHECKPASS(4);
>>ASSERTION Bad B 3
>>#NOTE How does one determine events associated with an extension?
>>#NOTE Responses to this question include:
>>#NOTE 	Use XListExtensions?
>>#NOTE 	Use testing extension?
>>#NOTE 	Use values which don't correspond to known event types?
>>#NOTE At present, the strategy chooses the last option.
When the event in
.A event_send
is not one of the core events or one of the events defined by an extension,
>># Next line altered at the request of MIT (bug report 60).
>># then a
then either xname returns zero or a
.S BadValue
error occurs.
>>STRATEGY
Create window.
Use notmember() to get some bad event types.
Make sure this list also includes 0 and 1 which are specifically for errors and replies.
Call XSendExtensionEvent to send bad event type.
Verify that XSendExtensionEvent either returned zero and no error occurs,
	or returned non-zero and a BadValue error occurs.
>>CODE BadValue
int	i;
int	n;
int	return_value;
int	good_event_types[XInputNumEvents];
long	bad_event_types[NM_LEN+2];
XEventClass noextensioneventclass;

	if (!Setup_Extension_DeviceInfo(BtnMask))
	    {
	    untested("%s: No input extension button device.\n", TestName);
	    return;
	    }
	device = Devs.Button;
	NoExtensionEvent(device, unused, noextensioneventclass);
	propagate = False;
	event_list = &noextensioneventclass;

/* Create window. */
	w = mkwin(display, (XVisualInfo *) NULL, (struct area *) NULL, False);

/* Use notmember() to get some bad event types. */
	for(i=0; i<XInputNumEvents; i++)
	    good_event_types[i]=XInputFirstEvent+i;
	n = notmember(good_event_types, XInputNumEvents, &bad_event_types[2]);

/* Make sure this list also includes 0 and 1 which are specifically for errors and replies. */
	n += 2;
	bad_event_types[0] = 0;
	bad_event_types[1] = 1;
	for (i = 0; i < n; i++) {

/* Call XSendExtensionEvent to send bad event type. */
		event_send->type = bad_event_types[i];
		trace("Using known bad event type %d.", event_send->type);
>>SET no-error-status-check
		return_value = XCALL;

/* Verify that XSendExtensionEvent either returned zero and no error occurs, */
/* 	or returned non-zero and a BadValue error occurs. */
		if (return_value == 0) {
			if(geterr() != Success) {
				FAIL;
				report("%s returned zero, but got %s when expecting no error.",
					TestName, errorname(geterr()));
			} else {
				trace("%s returned zero and no error", TestName);
				CHECK;
			}
		} else {
			if (geterr() != BadValue) {
				FAIL;
				report("%s returned non-zero, but got %s when expecting %s",
					TestName, errorname(geterr()), errorname(BadValue));
			} else {
				trace("%s returned non-zero and BadValue", TestName);
				CHECK;
			}
		}
	}

	CHECKPASS(n);
>>ASSERTION Bad B 3
When a window argument does not name a valid window, then a 
.S BadWindow
error occurs.
>>STRATEGY
Create a bad window by creating and destroying a window.
Initialise the event structure for the call.
Verify that a BadWindow error occurs.
>>CODE BadWindow
int	dbp, return_value;
XEventClass dbpc;

	if (!Setup_Extension_DeviceInfo(BtnMask))
	    {
	    untested("%s: No input extension button device.\n", TestName);
	    return;
	    }
	device = Devs.Button;
	DeviceButtonPress(device, dbp, dbpc);
	event_list = &dbpc;
	seterrdef();

/* Create a bad window by creating and destroying a window. */
	w = badwin(display);

/* Initialise the event structure for the call. */
	propagate = False;
	event_send->type = dbp;

/* Call xname using bad window as the window argument.*/
	return_value = XCALL;
	if (return_value == 0) {
		FAIL;
		report("%s returned zero, expecting a non-zero result.",
			TestName);
	} else
		CHECK;

/* Verify that a BadWindow error occurs. */
	if (geterr() == BadWindow)
		CHECK;
	else
		FAIL;

	CHECKPASS(2);
>>ASSERTION Bad B 3
When a device argument does not name a valid device, then a 
baddevice error occurs.
>>STRATEGY
Specify a bad device.
Initialise the event structure for the call.
Verify that a baddevice error occurs.
>>CODE baddevice
int baddevice;
int	 dbp;
XEventClass dbpc;
XDevice bogus;
int	return_value;

	if (!Setup_Extension_DeviceInfo(BtnMask))
	    {
	    untested("%s: No input extension button device.\n", TestName);
	    return;
	    }
	DeviceButtonPress(Devs.Button, dbp, dbpc);
	event_list = &dbpc;
/* Create window. */
	w = mkwin(display, (XVisualInfo *) NULL, (struct area *) NULL, False);
	BadDevice(display,baddevice);
	bogus.device_id = -1;
	device = &bogus;
	seterrdef();

/* Initialise the event structure for the call. */
	propagate = False;
	event_send->type = dbp;

	return_value = XCALL;
	if (return_value == 0) {
		FAIL;
		report("%s returned zero, expecting a non-zero result.",
			TestName);
	} else
		CHECK;

/* Verify that a baddevice error occurs. */
	if (geterr() == baddevice)
		CHECK;
	else
		FAIL;
	CHECKPASS(2);

>>ASSERTION Bad B 3
When an eventclass argument does not name a valid device, then a 
badclass error occurs.
>>STRATEGY
Specify a bad event class;
Initialise the event structure for the call.
Verify that a badclass error occurs.
>>CODE badclass
int badclass;
int	dbp;
XEventClass bogus=-1, dbpc;
int	return_value;

	if (!Setup_Extension_DeviceInfo(BtnMask))
	    {
	    untested("%s: No input extension button device.\n", TestName);
	    return;
	    }
	BadClass(display,badclass);
	device = Devs.Button;
	DeviceButtonPress(device, dbp, dbpc);
	seterrdef();
	event_list = &bogus;

/* Initialise the event structure for the call. */
	propagate = False;
	event_send->type = dbp;

/* Call xname using bad window as the window argument.*/
	return_value = XCALL;
	if (return_value == 0) {
		FAIL;
		report("%s returned zero, expecting a non-zero result.",
			TestName);
	} else
		CHECK;

/* Verify that a badclass error occurs. */
	if (geterr() == badclass)
		CHECK;
	else
		FAIL;

	CHECKPASS(2);