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
|
/*
* Copyright 1990, 1991 by the Massachusetts Institute of Technology and
* 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 MIT and UniSoft not be
* used in advertising or publicity pertaining to distribution of the
* software without specific, written prior permission. MIT and UniSoft
* make no representations about the suitability of this software for any
* purpose. It is provided "as is" without express or implied warranty.
*
* $XConsortium$
*/
>>TITLE XResizeWindow CH03
void
Display *display = Dsp;
Window w;
unsigned int width;
unsigned int height;
>>EXTERN
/*
* Convenience routine that sets the 'w' argument to be simple window
* with a background of W_FG at position (10,8) and * size 23x9.
* The border width is 0.
*/
#define OW_X 10
#define OW_Y 8
#define OW_WIDTH 23
#define OW_HEIGHT 9
static Window
onewin()
{
Window base;
struct area area;
base = defwin(display);
setarea(&area, OW_X, OW_Y, OW_WIDTH, OW_HEIGHT);
w = crechild(display, base, &area);
XSetWindowBackground(display, w, W_FG);
XClearWindow(display, w);
return(base);
}
/*
* A window with subwindows.
*/
static char *Tsub[] = {
".",
"top . (5, 5) 40x40",
"sub1 top (1,3) 4x6",
"sub2 top (8,3) 7x6",
"sub3 top (3,14) 12x9",
"sub4 top (28,10) 7x20",
"sub5 top (14,25) 11x12",
};
#define NTsub (NELEM(Tsub))
#define NTsubInf (NTsub-1) /* Number of inferiors excluding base */
>>ASSERTION Good A
A call to xname changes the inside size of the specified window
to
.A width
and
.A height .
>>STRATEGY
Create test window with background of W_FG.
Set width and height.
Call xname.
Verify new size on screen with checkarea().
>>CODE
Window base;
struct area area;
base = onewin();
setarea(&area, OW_X, OW_Y, 23, 47);
width = area.width;
height = area.height;
XCALL;
if (checkarea(display, base, &area, W_FG, W_BG, CHECK_ALL))
CHECK;
else {
report("Error in resizing window");
FAIL;
}
CHECKPASS(1);
>>ASSERTION Good A
When a call to xname actually changes the size of the window, then
the subwindows of the window are repositioned according to their win-gravity
attribute and a
.S GravityNotify
event is generated for each repositioned subwindow after the
.S ConfigureNotify
event.
>>STRATEGY
For each win-gravity attribute (apart from UnmapGravity)
Create window with subwindows.
Enable SubstructureNotify|StructureNotify events on all windows.
Set win-gravity on window.
Call xname to resize window.
Verify window positions by pixel check.
Verify ConfigureNotify on resized window.
Verify ConfigureNotify on parent of resized window.
If NorthWestGravity || StaticGravity
Verify that no gravity events are received.
else
Verify GravityNotify events received on each repositioned subwindow.
Verify gravity events are received on the parent of each subwindow.
Verify that configure events arrive before gravity events.
>>EXTERN
extern struct valname S_wingravity[];
extern int NS_wingravity;
/* Values to resize onewin to (odd and even) */
#define NEW_WIDTH 70
#define NEW_HEIGHT 61
#define BORDERW 1
>>CODE
Window base;
struct buildtree *bt;
struct buildtree *topbtp;
struct valname *wgrav;
XSetWindowAttributes setatts;
int i;
width = NEW_WIDTH;
height = NEW_HEIGHT;
for (wgrav = S_wingravity; wgrav < S_wingravity+NS_wingravity; wgrav++) {
if (wgrav->val == UnmapGravity)
continue;
trace("-- Testing win-gravity %s", wgrav->name);
base = defwin(display);
bt = buildtree(display, base, Tsub, NTsub);
topbtp = btntobtp(bt, "top");
/* Select for all structure events on all windows */
for (i = 0; i < NTsub; i++) {
XSelectInput(display, bt[i].wid,
SubstructureNotifyMask|StructureNotifyMask);
}
/*
* Set the win_gravity on windows below 'top'. Also set the
* borderwidths to make things more interesting, esp on mono
* displays.
*/
setatts.win_gravity = wgrav->val;
for (i = 2; i < NTsub; i++) {
XChangeWindowAttributes(display, bt[i].wid, CWWinGravity, &setatts);
XSetWindowBorderWidth(display, bt[i].wid, BORDERW);
XSetWindowBorder(display, bt[i].wid, W_BG); /* to show up */
}
w = topbtp->wid;
XCALL;
PIXCHECK(display, base);
#ifndef GENERATE_PIXMAPS
if (wingravevents(display, bt, wgrav->val))
CHECK;
#endif
}
/*
* In the GENERATE_PIXMAPS case there will be a path-check error here,
* this is intentional. (To prove that wingravevents() is used in
* the verification case)
*/
CHECKPASS(2*(NS_wingravity-1)); /* -1 for UnmapGravity */
>>EXTERN
/*
* Flags to say that we received particular events.
*/
#define WIN_CONFIG 001
#define WIN_GRAVITY 002
#define PAR_CONFIG 004
#define PAR_GRAVITY 010
static void
calcxy(top, evtype, x, y)
struct buildtree *top;
int evtype;
int *x;
int *y;
{
int dx = NEW_WIDTH-top->width;
int dy = NEW_HEIGHT-top->height;
switch (evtype) {
case NorthWestGravity:
break;
case NorthGravity:
*x += dx/2;
break;
case NorthEastGravity:
*x += dx;
break;
case WestGravity:
*y += dy/2;
break;
case CenterGravity:
*x += dx/2;
*y += dy/2;
break;
case EastGravity:
*x += dx;
*y += dy/2;
break;
case SouthWestGravity:
*y += dy;
break;
case SouthGravity:
*x += dx/2;
*y += dy;
break;
case SouthEastGravity:
*x += dx;
*y += dy;
break;
case StaticGravity:
break;
default:
delete("Internal error -- Unknown gravity in calcxy");
}
}
/*
* Routine that does the event checking for the gravity notify
* test.
*/
static
wingravevents(display, bt, evtype)
Display *display;
struct buildtree *bt;
int evtype;
{
XEvent ev;
XConfigureEvent confgood;
XGravityEvent gravgood;
XConfigureEvent *cnp;
XGravityEvent *gnp;
struct buildtree *btp;
struct buildtree *top;
int gotgrav = 0;
int i;
int pass = 0, fail = 0;
top = btntobtp(bt, "top");
/* Set up events */
confgood.type = ConfigureNotify;
confgood.serial = 0L;
confgood.send_event = False;
confgood.display = display;
confgood.above = None; /* XXX */
confgood.override_redirect = False;
confgood.x = top->x;
confgood.y = top->y;
confgood.width = NEW_WIDTH;
confgood.height = NEW_HEIGHT;
confgood.border_width = 0;
gravgood.type = GravityNotify;
gravgood.serial = 0L;
gravgood.send_event = False;
gravgood.display = display;
while (getevent(display, &ev) > 0) {
switch (ev.type) {
case ConfigureNotify:
cnp = (XConfigureEvent*)&ev;
btp = btwtobtp(bt, cnp->window);
if (btp == NULL) {
report("Event received on unknown window");
FAIL;
continue;
}
trace("Event received for window '%s'", btp->name);
if (gotgrav) {
report("Configure event received after gravity event");
FAIL;
} else
CHECK;
/*
* Work out if this event occurred on the parent or the window.
*/
if (cnp->window != cnp->event) {
if (!btp->parent || btp->parent->wid != cnp->event) {
report("Event received on other than the parent window");
FAIL;
} else
btp->uflags |= PAR_CONFIG;
} else {
btp->uflags |= WIN_CONFIG;
}
confgood.event = cnp->event;
confgood.window = cnp->window;
if (checkevent((XEvent*)&confgood, &ev) == 0)
CHECK;
else
FAIL;
break;
case GravityNotify:
gnp = (XGravityEvent*)&ev;
gotgrav = 1;
btp = btwtobtp(bt, gnp->window);
if (btp == NULL) {
report("Event received on unknown window");
FAIL;
continue;
}
trace("Event received for window '%s'", btp->name);
/*
* Work out if this event occurred on the parent or the window.
*/
if (gnp->window != gnp->event) {
if (!btp->parent || btp->parent->wid != gnp->event) {
report("Event received on other than the parent window");
FAIL;
} else
btp->uflags |= PAR_GRAVITY;
} else {
btp->uflags |= WIN_GRAVITY;
}
gravgood.event = gnp->event;
gravgood.window = gnp->window;
gravgood.x = btp->x;
gravgood.y = btp->y;
(void) calcxy(top, evtype, &gravgood.x, &gravgood.y);
if (checkevent((XEvent*)&gravgood, &ev) == 0)
CHECK;
else
FAIL;
break;
default:
report("Unexpected event type %s", eventname(ev.type));
FAIL;
}
}
/*
* Since the previous loop is executed a variable number of times
* check that it was executed at least once and reset the pass count.
*/
if (pass > 0)
pass = 1;
else
delete("No CHECK marks in wingravevents() loop");
/*
* Check correct events on the top (resized) window.
*/
if (top->uflags & WIN_CONFIG)
CHECK;
else {
report("Configure event not received on window 'top'");
FAIL;
}
if (top->uflags & PAR_CONFIG)
CHECK;
else {
report("Configure event not received on parent of window 'top'");
FAIL;
}
if (top->uflags & (PAR_GRAVITY|WIN_GRAVITY)) {
report("Gravity events unexpectedly received on window 'top'");
FAIL;
} else
CHECK;
for (i = 2; i < NTsub; i++) {
if (evtype == NorthWestGravity || evtype == StaticGravity) {
if (bt[i].uflags & WIN_GRAVITY) {
report("Gravity event unexpectedly received on window '%s'", bt[i].name);
FAIL;
} else
CHECK;
if (bt[i].uflags & PAR_GRAVITY) {
report("Gravity event unexpectedly received on parent of window '%s'", bt[i].name);
FAIL;
} else
CHECK;
} else {
if (bt[i].uflags & WIN_GRAVITY)
CHECK;
else {
report("Gravity event not received on window '%s'", bt[i].name);
FAIL;
}
if (bt[i].uflags & PAR_GRAVITY)
CHECK;
else {
report("Gravity event not received on parent of window '%s'", bt[i].name);
FAIL;
}
}
if (bt[i].uflags & (PAR_CONFIG|WIN_CONFIG)) {
report("Configure event unexpectedly received on window '%s'", bt[i].name);
FAIL;
}
}
if (fail == 0 && pass != 14)
delete("Path check error in wingravevents got %d, expecting 14", pass);
if (fail == 0)
return(True);
else
return(False);
}
>>ASSERTION Good A
When a call to xname actually changes the size of the window
and the win-gravity of a subwindow is
.S UnmapGravity
and the subwindow is already mapped,
then the subwindow is unmapped without being moved and an
.S UnmapNotify
event is generated.
>>STRATEGY
Create window with subwindows.
Enable events on all subwindows.
Enable events on window.
Set win-gravity to UnmapGravity.
Call xname to resize window.
Verify windows are removed from screen.
Verify window positions are unchanged.
Verify that UnmapNotify events received on each subwindow.
Verify that UnmapNotify events received on parent of each subwindow.
>>EXTERN
#define ON_PARENT 0x01
#define ON_WINDOW 0x02
>>CODE
Window base;
struct buildtree *bt;
struct buildtree *topbtp;
struct buildtree *btp;
XEvent ev;
XUnmapEvent good;
XUnmapEvent *ump;
XSetWindowAttributes setatts;
XWindowAttributes atts;
int i;
/* Set up good unmap event struct */
good.type = UnmapNotify;
good.serial = 0L;
good.send_event = False;
good.display = display;
good.from_configure = True;
width = NEW_WIDTH;
height = NEW_HEIGHT;
base = defwin(display);
bt = buildtree(display, base, Tsub, NTsub);
topbtp = btntobtp(bt, "top");
/* Select for all structure events on all windows */
for (i = 0; i < NTsub; i++) {
XSelectInput(display, bt[i].wid,
SubstructureNotifyMask|StructureNotifyMask);
}
/*
* Set the win_gravity on windows below 'top'. Also set the
* borderwidths to make things more interesting, esp on mono
* displays.
*/
setatts.win_gravity = UnmapGravity;
for (i = 2; i < NTsub; i++) {
XChangeWindowAttributes(display, bt[i].wid, CWWinGravity, &setatts);
XSetWindowBorderWidth(display, bt[i].wid, BORDERW);
}
w = topbtp->wid;
XCALL;
if (checkarea(display, w, (struct area *)0, W_FG, W_FG, CHECK_ALL))
CHECK;
else {
report("UnmapGravity did not appear to remove subwindows");
FAIL;
}
while (getevent(display, &ev) > 0) {
if (ev.type != UnmapNotify)
continue;
ump = (XUnmapEvent*)&ev;
btp = btwtobtp(bt, ump->window);
if (btp == NULL) {
report("Event received on unknown window");
FAIL;
continue;
}
trace("Event received for window '%s'", btp->name);
/*
* Work out if this event occurred on the parent or the window.
*/
if (ump->window != ump->event) {
if (!btp->parent || btp->parent->wid != ump->event) {
report("Event received on other than the parent window");
FAIL;
} else
btp->uflags |= ON_PARENT;
} else {
btp->uflags |= ON_WINDOW;
}
good.event = ump->event;
good.window = ump->window;
if (checkevent((XEvent*)&good, &ev) == 0)
CHECK;
else
FAIL;
}
/*
* Go through the subwindows below top and check for events received
* and map_state and position unchanged.
*/
for (i = 2; i < NTsub; i++) {
if (bt[i].uflags & ON_WINDOW)
CHECK;
else {
report("Unmap event not received on window '%s'", bt[i].name);
FAIL;
}
if (bt[i].uflags & ON_PARENT)
CHECK;
else {
report("Unmap event not received on parent of window '%s'", bt[i].name);
FAIL;
}
XGetWindowAttributes(display, bt[i].wid, &atts);
if (atts.map_state != IsUnmapped) {
report("map_state was %s, expecting IsUnmapped",
mapstatename(atts.map_state));
FAIL;
} else
CHECK;
if (atts.x != bt[i].x || atts.y != bt[i].y) {
report("Subwindow was moved after UnmapGravity used");
FAIL;
} else
CHECK;
}
CHECKPASS(1+6*(NTsub-2));
>>ASSERTION Good A
>># This assumes that the server either always does this or not.
>># If the server is allowed to do this on some windows and not on
>># others then the assertion needs re-wording.
If the server uses the window's bit-gravity attribute:
When a call to xname actually changes the size of the window, then
the contents of the window are repositioned or discarded
according to the bit-gravity attribute.
Otherwise:
When a call to xname actually changes the size of the window, then
the contents of the window are discarded.
>>STRATEGY
For each value of bit-gravity.
Create window.
Draw into window.
Call xname to resize window.
Verify that either:
Window is clear.
else
Contents have been repositioned correctly.
>>CODE
struct valname *bitgrav;
Window base;
XSetWindowAttributes setatts;
struct area area;
extern struct valname S_bitgravity[];
extern int NS_bitgravity;
for (bitgrav = S_bitgravity; bitgrav < S_bitgravity+NS_bitgravity; bitgrav++) {
trace("-- Trying bitgravity of %s", bitgrav->name);
setarea(&area, OW_X, OW_Y, OW_WIDTH, OW_HEIGHT);
base = onewin();
XSetWindowBackground(display, w, W_BG);
dset(display, w, W_FG);
setatts.bit_gravity = bitgrav->val;
XChangeWindowAttributes(display, w, CWBitGravity, &setatts);
width = NEW_WIDTH;
height = NEW_HEIGHT;
XCALL;
switch (bitgrav->val) {
case NorthGravity: case CenterGravity: case SouthGravity:
area.x += (NEW_WIDTH-OW_WIDTH)/2;
break;
case NorthEastGravity: case EastGravity: case SouthEastGravity:
area.x += (NEW_WIDTH-OW_WIDTH);
break;
}
switch (bitgrav->val) {
case CenterGravity: case WestGravity: case EastGravity:
area.y += (NEW_HEIGHT-OW_HEIGHT)/2;
break;
case SouthGravity: case SouthEastGravity: case SouthWestGravity:
area.y += (NEW_HEIGHT-OW_HEIGHT);
break;
}
if (checkarea(display, base, (struct area *)0, W_BG, W_BG, CHECK_ALL|CHECK_DIFFER)) {
/*
* The whole base window was clear, the server is not using
* bit-gravity, or else we are trying ForgetGravity.
*/
if (bitgrav->val != ForgetGravity)
trace("server not using bit-gravity");
CHECK;
} else {
/*
* For ForgetGravity then we must not get here.
*/
if (bitgrav->val == ForgetGravity) {
report("Contents were not discarded with ForgetGravity");
FAIL;
} else if (checkarea(display, base, &area, W_FG, W_BG, CHECK_ALL)) {
CHECK;
} else {
report("bits positioned incorrectly for bit-gravity of %s",
bitgrav->name);
FAIL;
}
}
}
CHECKPASS(NS_bitgravity);
>>ASSERTION Good A
When the window
is a root window, then a call to xname has no effect.
>>STRATEGY
Call xname on root window.
Touch test only.
>>CODE
w = DefaultRootWindow(display);
width = NEW_WIDTH;
height = NEW_HEIGHT;
XCALL;
if (fail == 0)
PASS;
>>ASSERTION Good A
When the override-redirect attribute of the window is
.S False
and some
other client has selected
.S SubstructureRedirectMask
on the parent window, then a
.S ConfigureRequest
event is generated, and the window size is not changed.
>>STRATEGY
Create windows.
Set override-redirect to False.
Create second client.
Select SubstructureRedirectMask for second client on parent of window.
Call xname.
Verify that a ConfigureRequest event is generated.
Verify that window configuration has not changed on the screen.
>>CODE
Window base;
XConfigureRequestEvent good;
XSetWindowAttributes setatts;
Display *client2;
XEvent ev;
XImage *imp;
int n;
base = onewin();
setatts.override_redirect = False;
XChangeWindowAttributes(display, w, CWOverrideRedirect, &setatts);
client2 = opendisplay();
XSelectInput(client2, base, SubstructureRedirectMask);
XSync(client2, False);
width = NEW_WIDTH;
height = NEW_HEIGHT;
good.type = ConfigureRequest;
good.serial = 0L;
good.send_event = False;
good.display = client2;
good.parent = base;
good.window = w;
good.x = OW_X;
good.y = OW_Y;
good.width = NEW_WIDTH;
good.height = NEW_HEIGHT;
good.border_width = 0;
good.above = None;
good.detail = Above;
good.value_mask = CWWidth | CWHeight;
imp = savimage(display, base);
XCALL;
XSync(client2, False);
n = getevent(client2, &ev);
if (n != 1) {
report("Expecting 1 event");
FAIL;
} else
CHECK;
if (n > 0 && checkevent((XEvent*)&good, &ev) == 0)
CHECK;
else
FAIL;
if (compsavimage(display, base, imp))
CHECK;
else {
report("Screen contents changed");
FAIL;
}
CHECKPASS(3);
>>ASSERTION Good A
When another client has selected
.S ResizeRedirectMask
on the window and the size would be changed, then a
.S ResizeRequest
event is generated and the size is not changed.
>># Other changes take place though.
>>STRATEGY
Create windows.
Set override-redirect to False.
Create second client.
Select ResizeRedirectMask for second client on window.
Set parameters to move and resize window.
Call xname.
Verify that a ResizeRequest event is generated.
Verify that window has not changed size but that other changes have occurred.
>>CODE
Window base;
XResizeRequestEvent good;
XSetWindowAttributes setatts;
Display *client2;
XEvent ev;
struct area area;
int n;
base = onewin();
setatts.override_redirect = False;
XChangeWindowAttributes(display, w, CWOverrideRedirect, &setatts);
client2 = opendisplay();
XSelectInput(client2, w, ResizeRedirectMask);
XSync(client2, False);
width = NEW_WIDTH;
height = NEW_HEIGHT;
good.type = ResizeRequest;
good.serial = 0L;
good.send_event = False;
good.display = client2;
good.window = w;
good.width = NEW_WIDTH;
good.height = NEW_HEIGHT;
XCALL;
XSync(client2, False);
n = getevent(client2, &ev);
if (n != 1) {
report("Expecting 1 event");
report("Received %d", n);
FAIL;
} else
CHECK;
if (n > 0 && checkevent((XEvent*)&good, &ev) == 0)
CHECK;
else
FAIL;
/* Window does not change size */
setarea(&area, OW_X, OW_Y, OW_WIDTH, OW_HEIGHT);
if (checkarea(display, base, &area, W_FG, W_BG, CHECK_ALL))
CHECK;
else {
report("Size of window not as expected");
FAIL;
}
CHECKPASS(3);
>>ASSERTION Good A
When another client has selected
.S ResizeRedirectMask
on the window and another client has selected
.S SubstructureRedirectMask
on the parent window
and the override-redirect attribute of the window is
.S False ,
then a
.S ConfigureRequest
event is generated, and the window size is not changed.
>>STRATEGY
Create windows.
Set override-redirect to False.
Create second client.
Select ResizeRedirectMask for second client on window.
Create third client.
Select SubstructureRedirectMask for third client on parent of window.
Call xname.
Verify that a ConfigureRequest event is generated for client 3.
Verify that no ResizeRequest event is generated for client 2.
Verify that window configuration is not changed.
>>CODE
Window base;
XConfigureRequestEvent good;
XSetWindowAttributes setatts;
Display *client2;
Display *client3;
XEvent ev;
XImage *imp;
int n;
base = onewin();
setatts.override_redirect = False;
XChangeWindowAttributes(display, w, CWOverrideRedirect, &setatts);
client2 = opendisplay();
XSelectInput(client2, w, ResizeRedirectMask);
XSync(client2, False);
client3 = opendisplay();
XSelectInput(client3, base, SubstructureRedirectMask);
XSync(client3, False);
width = NEW_WIDTH;
height = NEW_HEIGHT;
imp = savimage(display, base);
XCALL;
XSync(client2, False);
XSync(client3, False);
n = getevent(client2, &ev);
if (n != 0) {
report("Got an event unexpectedly for client selecting ResizeRedirect");
report(" Event type was %s", eventname(ev.type));
FAIL;
} else
CHECK;
good.type = ConfigureRequest;
good.serial = 0L;
good.send_event = False;
good.display = client3;
good.parent = base;
good.window = w;
good.x = OW_X;
good.y = OW_Y;
good.width = NEW_WIDTH;
good.height = NEW_HEIGHT;
good.border_width = 0;
good.above = None;
good.detail = Above;
good.value_mask = CWWidth | CWHeight;
n = getevent(client3, &ev);
if (n != 1) {
report("Expecting one configure events");
FAIL;
} else
CHECK;
if (n > 0 && checkevent((XEvent*)&good, &ev) == 0)
CHECK;
else
FAIL;
if (compsavimage(display, base, imp))
CHECK;
else {
report("Window changed when client was selecting SubstructureRedirect");
FAIL;
}
CHECKPASS(4);
>>ASSERTION Good A
When the size actually changes, then a
.S ConfigureNotify
event is generated.
>>STRATEGY
Create windows.
Enable SubstructureNotify events.
Call xname such that the window configuration changes.
Verify that a ConfigureNotify event is generated.
Call xname again with the same parameters.
Verify that no ConfigureNotify event is generated.
>>CODE
XConfigureEvent good;
XEvent ev;
int n;
(void) onewin();
XSelectInput(display, w, StructureNotifyMask);
width = NEW_WIDTH;
height = NEW_HEIGHT;
XCALL;
good.type = ConfigureNotify;
good.serial = 0L;
good.send_event = False;
good.display = display;
good.event = w;
good.window = w;
good.x = OW_X;
good.y = OW_Y;
good.width = NEW_WIDTH;
good.height = NEW_HEIGHT;
good.border_width = 0;
good.above = None;
good.override_redirect = False;
n = getevent(display, &ev);
if (n != 1) {
report("Expecting 1 event, got %d", n);
FAIL;
} else
CHECK;
if (n > 0 && checkevent((XEvent*)&good, &ev) == 0)
CHECK;
else
FAIL;
/* Call again */
XCALL;
if ((n = XPending(display)) == 0)
CHECK;
else {
report("Received event when configuration was not changed");
FAIL;
}
CHECKPASS(3);
>># ASSERTION
>># There are Expose events to consider here.
>># Also any window that is uncovered etc.
>>ASSERTION Good A
When a call to xname actually changes the size of the window, then
.S Expose
events are generated for regions that are newly visible or for
which the contents have been lost.
>>STRATEGY
Create windows.
Set test window background to W_BG.
Set up window with setforexpose().
Enable expose events.
Resize window with xname.
Verify that correct expose events were received with exposecheck().
>>CODE
(void) onewin();
XSetWindowBackground(display, w, W_BG);
XClearWindow(display, w);
setforexpose(display, w);
XSelectInput(display, w, ExposureMask);
width = NEW_WIDTH;
height = NEW_HEIGHT;
XCALL;
if (exposecheck(display, w))
CHECK;
else {
report("Correct expose events not received after resize");
FAIL;
}
CHECKPASS(1);
>>ASSERTION Good A
When a call to xname
uncovers part of any window that was formerly obscured, then
either
.S Expose
events are generated or the contents are restored from backing store.
>>STRATEGY
Create window.
Call setforexpose() on unobscured window.
Create second window to partially obscure this window.
Create second client to receive events on.
Resize window with xname, ensuring that first window is now unobscured.
Verify for correct expose or backing store behaviour with exposecheck().
>>CODE
Window base, one , two;
struct area area;
Display *client2;
/* Create windows. */
base = defwin(display);
setarea(&area, OW_X+5, OW_Y+5, OW_WIDTH, OW_HEIGHT);
one = crechild(display, base, &area);
setforexpose(display, one);
setarea(&area, OW_X, OW_Y, OW_WIDTH, OW_HEIGHT);
two = crechild(display, base, &area);
client2 = opendisplay();
XSelectInput(client2, one, ExposureMask);
XSync(client2, False);
w = two;
width = 3;
height = 3;
XCALL;
XSync(client2, False);
if (exposecheck(client2, one))
CHECK;
else {
report("Neither Expose events or backing store processing");
report(" could correctly restore the window contents.");
FAIL;
}
CHECKPASS(1);
>># ASSERTION
>># -- I don't know when this applies ..sr
>># When backing store is being maintained for the window, its
>># inferiors, or other newly visible windows, then the contents
>># are either discarded or changed to reflect the current screen contents.
>>ASSERTION Bad A
When
.M width
or
.M height
is zero, then a
.S BadValue
error occurs.
>>STRATEGY
Create a test window.
Call xname with width of zero.
Verify a BadValue error occurred.
Call xname with height of zero.
Verify a BadValue error occurred.
Call xname with height and width of zero.
Verify a BadValue error occurred.
>>CODE BadValue
/* Create a test window. */
w = defwin(display);
/* Call xname with width of zero. */
width = 0;
height = OW_HEIGHT;
XCALL;
/* Verify a BadValue error occurred. */
if (geterr() != BadValue)
FAIL;
else
CHECK;
/* Call xname with height of zero. */
width = OW_WIDTH;
height = 0;
XCALL;
/* Verify a BadValue error occurred. */
if (geterr() != BadValue)
FAIL;
else
CHECK;
/* Call xname with height and width of zero. */
width = 0;
height = 0;
XCALL;
/* Verify a BadValue error occurred. */
if (geterr() != BadValue)
FAIL;
else
CHECK;
CHECKPASS(3);
>>ASSERTION Bad A
.ER BadWindow
|