summaryrefslogtreecommitdiff
path: root/xts5/Xlib4/XMapSubwindows/XMapSubwindows.m
blob: cca65f6055dad3ba3c83fc9175f60d93f7e34bd4 (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
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.
$Header: /cvs/xtest/xtest/xts5/tset/Xlib4/XMapSubwindows/XMapSubwindows.m,v 1.2 2005-11-03 08:43:34 jmichael Exp $

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

>># Project: VSW5
>># 
>># File: xts5/tset/Xlib4/XMapSubwindows/XMapSubwindows.m
>># 
>># Description:
>># 	Tests for XMapSubwindows()
>># 
>># Modifications:
>># $Log: mpsbws.m,v $
>># Revision 1.2  2005-11-03 08:43:34  jmichael
>># clean up all vsw5 paths to use xts5 instead.
>>#
>># Revision 1.1.1.2  2005/04/15 14:05:25  anderson
>># Reimport of the base with the legal name in the copyright fixed.
>>#
>># Revision 8.0  1998/12/23 23:26:28  mar
>># Branch point for Release 5.0.2
>>#
>># Revision 7.0  1998/10/30 22:44:44  mar
>># Branch point for Release 5.0.2b1
>>#
>># Revision 6.0  1998/03/02 05:18:43  tbr
>># Branch point for Release 5.0.1
>>#
>># Revision 5.0  1998/01/26 03:15:15  tbr
>># Branch point for Release 5.0.1b1
>>#
>># Revision 4.0  1995/12/15 08:47:44  tbr
>># Branch point for Release 5.0.0
>>#
>># Revision 3.1  1995/12/15  00:46:14  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 XMapSubwindows Xlib4
void

Display	*display = Dsp;
Window	w;
>>EXTERN

>>#	  "A1 A (15, 5) 5x5 unmap",
>>#	  "A2 A (3, 15) 5x5 unmap",
>>#	  "E1 E (10,10) 20x20 unmap",
>>#	  "E1a E1 (10,10) 5x5 unmap",

#define	WINDOW_NOTIFY	001
#define	PARENT_NOTIFY	002

char	*T1[] = {
	".",
	"A . (10,10) 40x40 unmap",
	"B . (3,40) 40x40 unmap",
	"C . (20,22) 40x40 unmap",
	"D . (45,23) 40x40 unmap",
	"E . (30,30) 40x40 unmap",
};

>>ASSERTION Good A
A call to xname maps all subwindows of the specified window in
top to bottom stacking order.
>>STRATEGY
Create unmapped subwindows of a window.
Map subwindows.
Verify map state of each subwindow is IsViewable.
Verify that windows show on screen.
>>CODE
XWindowAttributes	atts;
struct	buildtree	*btlist;
int 	i;

	w = defwin(display);
	btlist = buildtree(display, w, T1, NELEM(T1));

	XCALL;

	for (i = 1; i < NELEM(T1); i++) {
		(void) XGetWindowAttributes(display, btlist[i].wid, &atts);
		if (atts.map_state != IsViewable) {
			report("map state after map was %s, expecting %s",
				mapstatename(atts.map_state), mapstatename(IsViewable));
			report("  Window name was %s", btlist[i].name);
			FAIL;
		} else
			CHECK;
	}

	PIXCHECK(display, w);

	CHECKPASS(1+NELEM(T1)-1);

>>ASSERTION def
When a call to xname is made on a window that is mapped and
has no unmapped ancestors, then the
subwindows become viewable.
>>ASSERTION Good A
When a call to xname is made on a window that is unmapped or
has an unmapped ancester,
then the subwindows do not become viewable.
>>STRATEGY
Create stack of unmapped windows.
Call xname on one of these window that has an unmapped ancestor.
Verify map state of each subwindow is IsUnviewable.
Verify that nothing becomes visible.
>>CODE
Window	base;
struct	buildtree	*btp;
XWindowAttributes	atts;
int 	i;

	base = defwin(display);

	/* Create an unmapped test window */
	w = creunmapchild(display, base, (struct area *)0);
	btp = buildtree(display, w, T1, NELEM(T1));

	XCALL;

	for (i = 1; i < NELEM(T1); i++) {
		(void) XGetWindowAttributes(display, btp[i].wid, &atts);
		if (atts.map_state != IsUnviewable) {
			report("map state after map was %s, expecting %s",
				mapstatename(atts.map_state), mapstatename(IsUnviewable));
			FAIL;
		} else
			CHECK;
	}

	if (checkarea(display, base, (struct area *)0, W_BG, W_BG, CHECK_ALL))
		CHECK;
	else {
		report("Somthing became visible after mapping subwindows with unmapped ancestors");
		FAIL;
	}

	CHECKPASS(1+NELEM(T1)-1);

>>ASSERTION Good A
When all the subwindows are already mapped,
then a call to xname has no effect.
>>STRATEGY
Create subwindows.
Map subwindow.
Enable events.
Attempt to map subwindows again.
Verify that no difference occurred on screen.
Verify that map-state is still IsViewable.
Verify that no events are generated.
>>CODE
Window	base;
XWindowAttributes	atts;
struct	buildtree	*bt;
XImage	*imp;
int 	i;

	base = defwin(display);
	bt = buildtree(display, base, T1, NELEM(T1));

	w = base;
	XCALL;

	imp = savimage(display, base);

	for (i = 0; i < NELEM(T1); i++)
		XSelectInput(display, bt[i].wid, ALLEVENTS);

	XCALL;

	for (i = 0; i < NELEM(T1); i++)
		XSelectInput(display, bt[i].wid, NoEventMask);

	if (compsavimage(display, base, imp))
		CHECK;
	else {
		report("Difference occurred on screen after re-mapping subwindows");
		FAIL;
	}

	for (i = 1; i < NELEM(T1); i++) {
		(void) XGetWindowAttributes(display, bt[i].wid, &atts);
		if (atts.map_state != IsViewable) {
			report("map state after map was %s, expecting %s",
				mapstatename(atts.map_state), mapstatename(IsViewable));
			report("  window name %s", bt[i].name);
			FAIL;
		} else
			CHECK;
	}

	if (XPending(display) != 0) {
		report("Re-mapping subwindow produced event");
		FAIL;
	} else
		CHECK;

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

>>ASSERTION Good A
When the
.M override_redirect
attribute of a subwindow is
.S False 
and some other client has selected
.S SubstructureRedirectMask 
on its parent window, then a
.S MapRequest 
event is generated, and the call to xname does not map the subwindow.
>>STRATEGY
Create base window.
Create unmapped subwindows on base window.
Set override-redirect attribute to False on each subwindow.
Create second client.
Select SubstructureRedirectMask for second client on base window.
Call xname on base window.
Verify that the MapRequest event is generated for each subwindow.
Verify that map-state is still IsUnmapped.
>>CODE
Display	*client2;
XSetWindowAttributes	setatts;
XWindowAttributes	atts;
XMapRequestEvent	good;
XMapRequestEvent	*mrp;
struct	buildtree	*bt;
struct	buildtree	*btp;
XEvent	ev;
int 	i;

	w = defwin(display);
	bt = buildtree(display, w, T1, NELEM(T1));

	for (i = 1; i < NELEM(T1); i++) {
		setatts.override_redirect = False;
		XChangeWindowAttributes(display, bt[i].wid, CWOverrideRedirect, &setatts);
	}

	if (isdeleted())
		return;

	client2 = opendisplay();
	XSelectInput(client2, w, SubstructureRedirectMask);
	XSync(client2, True);

	XCALL;
	XSync(client2, False);

	good.type = MapRequest;
	good.serial = 0;
	good.send_event = False;
	good.display = client2;
	good.parent = w;

	/* Should go through this loop NELEM(T1)-1 times */
	while (getevent(client2, &ev)) {

		mrp = (XMapRequestEvent*)&ev;
		btp = btwtobtp(bt, mrp->window);
		if (btp == NULL) {
			report("Event received for unknown window");
			FAIL;
			continue;
		}
		if (mrp->parent != w) {
			report("Map request received on a window other than the parent");
			FAIL;
		} else
			CHECK;

		btp->uflags++;
		good.window = btp->wid;

		if (checkevent((XEvent *)&good, &ev)) {
			report("Bad event on window '%s'", btp->name);
			FAIL;
		} else
			CHECK;
	}

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

		if (bt[i].uflags == 0) {
			report("No map request for window '%s'", bt[i].name);
			FAIL;
		} else if (bt[i].uflags > 1) {
			report("Repeat map request for window '%s'", bt[i].name);
			FAIL;
		} else
			CHECK;

		(void) XGetWindowAttributes(display, bt[i].wid, &atts);
		if (atts.map_state != IsUnmapped) {
			report("map state after map was %s, expecting %s",
				mapstatename(atts.map_state), mapstatename(IsUnmapped));
			FAIL;
		} else
			CHECK;
	}

	CHECKPASS(4*(NELEM(T1)-1));
>>ASSERTION Good A
When the
.M override-redirect
attribute of a subwindow is
.S True
and the subwindow is not already mapped,
then the window is mapped and a
.S MapNotify 
event is generated.
>>STRATEGY
Create base window.
Create unmapped subwindows on base window.
Set override-redirect attribute to True on each subwindow.
Select StructureNotify events on each subwindow.
Create second client.
Select SubstructureRedirect and SubstructureNotify for second client on base window.
Call xname on base window.
Verify that a MapNotify event is generated on parent for each subwindow.
Verify that a MapNotify event is generated on each subwindow.
Verify that the map_state of each subwindow is IsViewable.
>>CODE
Display	*client2;
Window	base;
XSetWindowAttributes	setatts;
XWindowAttributes	atts;
XMapEvent	good;
XMapEvent	*mp;
struct	buildtree	*bt;
struct	buildtree	*btp;
XEvent	ev;
int 	i;

	base = defwin(display);
	bt = buildtree(display, base, T1, NELEM(T1));

	w = base;

	for (i = 1; i < NELEM(T1); i++) {
		setatts.override_redirect = True;
		XChangeWindowAttributes(display, bt[i].wid, CWOverrideRedirect, &setatts);
		/*
		 * Would normally select ALLEVENTS to test for spurious events.
		 * This cannot be done here, since we would possibly get valid 
		 * EnterNotify's etc.
		 */
		XSelectInput(display, bt[i].wid, StructureNotifyMask);
	}

	if (isdeleted())
		return;

	client2 = opendisplay();
	XSelectInput(client2, base,SubstructureRedirectMask|SubstructureNotifyMask);
	XSync(client2, True);

	XCALL;
	XSync(client2, False);

	/*
	 * Check for Map event on parent.
	 */
	good.type = MapNotify;
	good.serial = 0;
	good.send_event = False;
	good.display = client2;
	good.event = base;
	good.window = w;
	good.override_redirect = True;

	/* Should go through this loop NELEM(T1)-1 times */
	while (getevent(client2, &ev)) {

		mp = (XMapEvent*)&ev;
		btp = btwtobtp(bt, mp->window);
		if (btp == NULL) {
			report("Event received for unknown window");
			FAIL;
			continue;
		}
		if (mp->event != base) {
			report("Map request received on a window other than the parent");
			FAIL;
		} else
			CHECK;

		if (btp->uflags & PARENT_NOTIFY) {
			report("Repeat event received on parent for window '%s'", btp->name);
			FAIL;
		} else {
			btp->uflags |= PARENT_NOTIFY;
			CHECK;
		}

		good.window = btp->wid;

		if (checkevent((XEvent *)&good, &ev)) {
			report("Bad event on window '%s'", btp->name);
			FAIL;
		} else
			CHECK;
	}

	/*
	 * Now check for map notify on the window itself.
	 */
	good.display = display;

	/* Should go through this loop NELEM(T1)-1 times */
	while (getevent(display, &ev)) {

		mp = (XMapEvent*)&ev;
		btp = btwtobtp(bt, mp->window);
		if (btp == NULL) {
			report("Event received for unknown window");
			FAIL;
			continue;
		}

		if (btp->uflags & WINDOW_NOTIFY) {
			report("Repeat map notify event received on window '%s'", btp->name);
			FAIL;
		} else {
			btp->uflags |= WINDOW_NOTIFY;
			CHECK;
		}

		good.window = btp->wid;
		good.event = btp->wid;

		if (checkevent((XEvent *)&good, &ev)) {
			report("Bad event on window '%s'", btp->name);
			FAIL;
		} else
			CHECK;
	}

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

		if (bt[i].uflags & WINDOW_NOTIFY)
			CHECK;
		else {
			report("No map notify received on window '%s'", bt[i].name);
			FAIL;
		}
		if (bt[i].uflags & PARENT_NOTIFY)
			CHECK;
		else {
			report("No map notify received on parent of window '%s'", bt[i].name);
			FAIL;
		}
		(void) XGetWindowAttributes(display, w, &atts);
		if (atts.map_state != IsViewable) {
			report("map state after map was %s, expecting %s",
				mapstatename(atts.map_state), mapstatename(IsViewable));
			FAIL;
		} else
			CHECK;
	}

	CHECKPASS(8*(NELEM(T1)-1));
>>ASSERTION Good A
When no other client has selected
.S SubstructureRedirectMask
on the parent window and the window is not already mapped,
then the window is mapped and a
.S MapNotify
event is generated.
>>STRATEGY
Create base window.
Create unmapped subwindows on base window.
Set override-redirect attribute to False on each subwindow.
Select StructureNotify events on each subwindow.
Create second client.
Select SubstructureNotify for second client on base window.
Call xname on base window.
Verify that a MapNotify event is generated on parent for each subwindow.
Verify that a MapNotify event is generated on each subwindow.
Verify that the map_state of each subwindow is IsViewable.
>>CODE
Display	*client2;
Window	base;
XSetWindowAttributes	setatts;
XWindowAttributes	atts;
XMapEvent	good;
XMapEvent	*mp;
struct	buildtree	*bt;
struct	buildtree	*btp;
XEvent	ev;
int 	i;

	base = defwin(display);
	bt = buildtree(display, base, T1, NELEM(T1));

	w = base;

	for (i = 1; i < NELEM(T1); i++) {
		setatts.override_redirect = False;
		XChangeWindowAttributes(display, bt[i].wid, CWOverrideRedirect, &setatts);
		/*
		 * Would normally select ALLEVENTS to test for spurious events.
		 * This cannot be done here, since we would possibly get valid 
		 * EnterNotify's etc.
		 */
		XSelectInput(display, bt[i].wid, StructureNotifyMask);
	}

	if (isdeleted())
		return;

	client2 = opendisplay();
	XSelectInput(client2, base, SubstructureNotifyMask);
	XSync(client2, True);

	XCALL;
	XSync(client2, False);

	/*
	 * Check for Map event on parent.
	 */
	good.type = MapNotify;
	good.serial = 0;
	good.send_event = False;
	good.display = client2;
	good.event = base;
	good.window = w;
	good.override_redirect = False;

	/* Should go through this loop NELEM(T1)-1 times */
	while (getevent(client2, &ev)) {

		mp = (XMapEvent*)&ev;
		btp = btwtobtp(bt, mp->window);
		if (btp == NULL) {
			report("Event received for unknown window");
			FAIL;
			continue;
		}
		if (mp->event != base) {
			report("Map request received on a window other than the parent");
			FAIL;
		} else
			CHECK;

		if (btp->uflags & PARENT_NOTIFY) {
			report("Repeat event received on parent for window '%s'", btp->name);
			FAIL;
		} else {
			btp->uflags |= PARENT_NOTIFY;
			CHECK;
		}

		good.window = btp->wid;

		if (checkevent((XEvent *)&good, &ev)) {
			report("Bad event on window '%s'", btp->name);
			FAIL;
		} else
			CHECK;
	}

	/*
	 * Now check for map notify on the window itself.
	 */
	good.display = display;

	/* Should go through this loop NELEM(T1)-1 times */
	while (getevent(display, &ev)) {

		mp = (XMapEvent*)&ev;
		btp = btwtobtp(bt, mp->window);
		if (btp == NULL) {
			report("Event received for unknown window");
			FAIL;
			continue;
		}

		if (btp->uflags & WINDOW_NOTIFY) {
			report("Repeat map notify event received on window '%s'", btp->name);
			FAIL;
		} else {
			btp->uflags |= WINDOW_NOTIFY;
			CHECK;
		}

		good.window = btp->wid;
		good.event = btp->wid;

		if (checkevent((XEvent *)&good, &ev)) {
			report("Bad event on window '%s'", btp->name);
			FAIL;
		} else
			CHECK;
	}

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

		if (bt[i].uflags & WINDOW_NOTIFY)
			CHECK;
		else {
			report("No map notify received on window '%s'", bt[i].name);
			FAIL;
		}
		if (bt[i].uflags & PARENT_NOTIFY)
			CHECK;
		else {
			report("No map notify received on parent of window '%s'", bt[i].name);
			FAIL;
		}
		(void) XGetWindowAttributes(display, w, &atts);
		if (atts.map_state != IsViewable) {
			report("map state after map was %s, expecting %s",
				mapstatename(atts.map_state), mapstatename(IsViewable));
			FAIL;
		} else
			CHECK;
	}

	CHECKPASS(8*(NELEM(T1)-1));
>>ASSERTION Good A
When one of the subwindows becomes viewable after a call to xname
and no earlier contents for it are remembered, then
the subwindow is tiled with its background.
>>STRATEGY
>># Have already tested this with a plain background, but take the
>># opportunity to test with a background tile.
Create subwindows.
Create tile.
Set background of each subwindow to tile.
Map subwindows.
Verify that subwindows are tiled.
Re-run with an inferior window.
>>CODE
Window	base;
Window	win;
Window	win2;
Pixmap	tile;

	base = defwin(display);

	win = creunmapchild(display, base, (struct area *)0);

	w = base;

	tile = maketile(display, win);
	XSetWindowBackgroundPixmap(display, win, tile);

	XCALL;

	if (checktile(display, win, (struct area *)0, 0, 0, tile))
		CHECK;
	else {
		report("Window not tiled with its background correctly");
		FAIL;
	}

	/*
	 * Create an unmapped window and a mapped inferior of that window.
	 * When we map the window the inferior becomes viewable and so it
	 * should be tiled.
	 */
	base = defwin(display);
	win = creunmapchild(display, base, (struct area *)0);
	win2 = crechild(display, win, (struct area *)0);
	w = base;
	XSetWindowBackgroundPixmap(display, win2, tile);

	XCALL;

	if (checktile(display, win2, (struct area *)0, 0, 0, tile))
		CHECK;
	else {
		report("Inferior window not tiled with its background correctly");
		FAIL;
	}

	CHECKPASS(2);
>>ASSERTION Good A
>># This is inconsistant with other stuff? In create.
When the background of the subwindow is undefined then the existing screen
contents from the parent or an inferior of the parent are not altered,
and zero or more 
.S Expose 
events are generated.
>>STRATEGY
Create window as parent.
Draw pattern on parent.
Create inferior window and draw pattern on that too.
Create unmapped subwindows that overlap inferior.
Set background pixmap to None on each subwindow.
Map subwindows.
Verify that screen contents have not been altered.

Unmap subwindows.
For each subwindow
	Select for expose events.
	Call setforexpose() to draw into window (for if backing store in use)
Call xname to map subwindows.
For each window
	Verify that window was restored from backing store or received expose
	events that cover the window with exposecheck().
>>CODE
Window	base;
Window	ch1;
struct	buildtree	*bt;
struct	area	area;
XImage	*imp;
int 	i;

	base = defwin(display);
	pattern(display, base);

	w = base;

	setarea(&area, 7, 7, 50, 50);
	ch1 = crechild(display, base, &area);
	pattern(display, ch1);

	/* Save original contents */
	imp = savimage(display, base);

	bt = buildtree(display, base, T1, NELEM(T1));

	for (i = 1; i < NELEM(T1); i++)
		XSetWindowBackgroundPixmap(display, bt[i].wid, None);

	XCALL;

	if (compsavimage(display, base, imp))
		CHECK;
	else {
		report("Screen contents altered by mapping window with undefined background");
		FAIL;
	}

	/*
	 * Check expose events.  Unmap the windows and draw into them with
	 * setforexpose(), (this will normally have no effect unless backing
	 * store is active).  Map the window and check that either
	 *  - there are zero expose events and backing store has preserved the
	 *    contents.
	 *  - there are enough expose events to cover the window.
	 */
	XUnmapSubwindows(display, w);

	for (i = 1; i < NELEM(T1); i++) {
		XSelectInput(display, bt[i].wid, ExposureMask);
		setforexpose(display, bt[i].wid);
		/* because setforexpose() changes the background */
		XSetWindowBackgroundPixmap(display, bt[i].wid, None);
		/*
		 * Border width is set to zero, because otherwise the border potentialy
		 * confuses things.
		 */
		XSetWindowBorderWidth(display, bt[i].wid, None);
	}

	XCALL;

	for (i = 1; i < NELEM(T1); i++)
		exposefill(display, bt[i].wid);
	for (i = 1; i < NELEM(T1); i++) {
		if (exposecheck(display, bt[i].wid))
			CHECK;
		else {
			report("Neither Expose events or backing store processing");
			report("could correctly restore the window contents.");
			FAIL;
		}
	}

	CHECKPASS(1 + (NELEM(T1)-1));
>>ASSERTION Good B 3
When the background of the subwindow is undefined then the existing screen
contents not from the parent or an inferior of the parent are undefined,
and zero or more 
.S Expose 
events are generated.
>>ASSERTION Good D 3
If backing store is supported:
When backing store has been maintained while a particular
subwindow was unmapped, then no 
.S Expose 
events are generated for that subwindow.
>>STRATEGY
If backing store is supported
  Create base window.
  Create child of this window to unmap.
  Set backing store hint of child to Always.
  Write into child window.
  Unmap child window.
  Enable Expose events.
  Map child window by calling xname on base window.
  If child window contents are unaltered.
	Backing store was maintained.
	Verify that no Expose events were received.
  else
	Backing store was not maintained.
	Test result is UNTESTED.
else
  Test result is UNSUPPORTED.
>>CODE
XSetWindowAttributes	setatts;
XEvent	ev;
Window	base;
Window	ch;

	if (DoesBackingStore(DefaultScreenOfDisplay(display)) != Always) {
		unsupported("Backing store not supported while unmapped");
		return;
	}

	base = defwin(display);
	ch = crechild(display, base, (struct area *)0);

	setatts.backing_store = Always;
	XChangeWindowAttributes(display, ch, CWBackingStore, &setatts);

	dset(display, ch, W_FG);
	XUnmapWindow(display, ch);
	XSelectInput(display, ch, ExposureMask);

	w = base;
	XCALL;

	XSelectInput(display, ch, NoEventMask);

	if (checkarea(display, ch, (struct area *)0, W_FG, W_FG, CHECK_ALL|CHECK_DIFFER)) {
		/*
		 * Backing store apeared to be active during the unmap.
		 */
		if (XCheckTypedWindowEvent(display, ch, Expose, &ev)) {
			/* Received Exposes */
			report("Expose received when backing store was active");
			FAIL;
		} else
			CHECK;
	} else {
		/*
		 * There is nothing wrong here, but it is possibly of interest.
		 */
		trace("NOTE: Server claims to support backing store but it was not active in the test");
		UNTESTED;
	}

	CHECKPASS(1);
>>ASSERTION Good D 3
If backing store is supported:
When the server elects to now maintain backing store for a subwindow, 
then an
.S Expose
event for the whole window is generated.
>>STRATEGY
If backing store is supported.
  Create small window.
  Ask for backing store when mapped.
  Create (and map) windows that would obscure the test window.
  Enable Expose events.
  Map window.
  If no Expose
	Untested - maybe got backing store always.
  Verify Expose event is for whole window.
else
  Untested.
>>CODE
int 	n;
Window	base;
Window	ch;
Window	ch1;
XEvent	ev;
struct	area	area;
struct	area	charea;
XExposeEvent	*ep;
XSetWindowAttributes	setatts;

	if (DoesBackingStore(DefaultScreenOfDisplay(display)) == NotUseful) {
		unsupported("Backing store is not supported");
		return;
	}

	base = defwin(display);

	setarea(&area, 0, 0, 70, 70);
	ch = creunmapchild(display, base, &area);
	setatts.backing_store = WhenMapped;
	XChangeWindowAttributes(display, ch, CWBackingStore, &setatts);

	/* Create a child that will cover the test window */
	setarea(&charea, 0, 0, 20, 20);
	ch1 = crechild(display, base, &charea);

	XSelectInput(display, ch, ExposureMask);
	w = base;
	XCALL;
	XSelectInput(display, ch, NoEventMask);

	n = XPending(display);
	if (n == 0) {
		trace("No Expose events on mapping window with backing-store WhenMapped");
		UNTESTED;
	} else
		CHECK;

	if (n == 1) {
		(void) getevent(display, &ev);
		if (ev.type != Expose) {
			/* Only Expose events were enabled */
			delete("Unexpected event received (%s)", eventname(ev.type));
		} else {
			ep = (XExposeEvent*)&ev;
			if (ep->x == area.x && ep->y == area.y && ep->width == area.width && ep->height == area.height) {
				/* Full window Expose received */
				CHECK;
			} else {
				/*
				 * Since there was only one event and it does not cover
				 * the whole window then it is incorrect.
				 */
				report("Expose event covered wrong area");
				report("x=%d, y=%d, width=%d, height=%d", ep->x, ep->y, ep->width, ep->height);
				FAIL;
			}
		}
	} else {
		trace("Did not appear to get backing store");
		UNTESTED;
	}
	CHECKPASS(2);

>>ASSERTION Good A
When the server elects to not maintain backing store for a
subwindow, then
.S Expose
events are generated only for visible regions.
>># NOTE: 'are' reported is from ANSI.  Spec says 'may be' reported.
>># stick with 'are'.	kieron
>>STRATEGY
Create small window.
Ask for no backing store.
Create (and map) windows that would obscure the test window.
Map window.
If Expose event is for whole window.
  Untested - maybe got backing store.
else
  Verify that only visible regions got Expose events.
>>CODE
int 	n;
Window	base;
Window	ch;
Window	ch1;
struct	area	area;
struct	area	charea;
XSetWindowAttributes	setatts;

	base = defwin(display);

	setarea(&area, 0, 0, 70, 70);
	ch = creunmapchild(display, base, &area);
	setatts.backing_store = NotUseful;
	XChangeWindowAttributes(display, ch, CWBackingStore, &setatts);

	/* Create a child that will cover the test window */
	setarea(&charea, 0, 0, 20, 20);
	ch1 = crechild(display, base, &charea);

	XSelectInput(display, ch, ExposureMask);
	w = base;
	XCALL;
	XSelectInput(display, ch, NoEventMask);

	n = XPending(display);
	if (n == 0) {
		trace("No Expose events on mapping window with backing-store NotUseful");
		UNTESTED;
	} else
		CHECK;

	if (n == 1) {
		trace("Appeared to get backing store when asked for NotUseful");
		UNTESTED;
	} else {
		/*
		 * Remove the child window.  Clear the test window, and then
		 * redraw it according to the Expose events.  This should leave
		 * the part that was not visible after the map in the background
		 * pixel.
		 */
		XUnmapWindow(display, ch1);
		dclear(display, ch);
		exposefill(display, ch);
		if (checkarea(display, ch, &charea, W_BG, W_FG, CHECK_ALL))
			CHECK;
		else {
			report("Some part of non-visible regions received Expose events");
			report("  or not all visible regions exposed");
			FAIL;
		}
	}

	CHECKPASS(2);

>>ASSERTION Bad A
.ER BadWindow