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
|
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/Xlib11/ButtonPress/ButtonPress.m,v 1.2 2005-11-03 08:42:20 jmichael Exp $
Copyright (c) Applied Testing and Technology, Inc. 1995
All Rights Reserved.
>># Project: VSW5
>>#
>># File: xts5/tset/Xlib11/ButtonPress/ButtonPress.m
>>#
>># Description:
>># Tests for ButtonPress()
>>#
>># Modifications:
>># $Log: bttnprss.m,v $
>># Revision 1.2 2005-11-03 08:42:20 jmichael
>># clean up all vsw5 paths to use xts5 instead.
>>#
>># Revision 1.1.1.2 2005/04/15 14:05:16 anderson
>># Reimport of the base with the legal name in the copyright fixed.
>>#
>># Revision 8.0 1998/12/23 23:31:06 mar
>># Branch point for Release 5.0.2
>>#
>># Revision 7.0 1998/10/30 22:50:33 mar
>># Branch point for Release 5.0.2b1
>>#
>># Revision 6.0 1998/03/02 05:22:48 tbr
>># Branch point for Release 5.0.1
>>#
>># Revision 5.0 1998/01/26 03:19:21 tbr
>># Branch point for Release 5.0.1b1
>>#
>># Revision 4.0 1995/12/15 09:00:56 tbr
>># Branch point for Release 5.0.0
>>#
>># Revision 3.1 1995/12/15 00:57:12 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 ButtonPress Xlib11
>>EXTERN
#define EVENT ButtonPress
#define EVENTMASK ButtonPressMask
#define PTRX 4
#define PTRY 3
>>SET end-function restoredevstate
>>ASSERTION Good B 1
When any pointer button is pressed,
then a xname event is generated.
>>STRATEGY
If extended testing is enabled:
Create window.
Select for xname events.
Generate xname event.
Verify that a xname event was delivered.
Verify that event member fields are correctly set.
>>CODE
Display *display = Dsp;
Window w;
XEvent event_return;
XButtonPressedEvent good;
PointerPlace *ptr;
if(noext(1))
return;
/* Create window. */
w = defwin(display);
/* Select for events. */
XSelectInput(display, w, EVENTMASK);
XSync(display, True);
/* Generate xname event. */
XSync(display, True);
ptr = warppointer(display, w, PTRX, PTRY);
buttonpress(display, Button1);
/* Verify that event was delivered. */
/* Verify that event member fields are correctly set. */
if (!XCheckTypedWindowEvent(display, w, EVENT, &event_return)) {
report("Expected %s event, got none", eventname(EVENT));
FAIL;
}
else
CHECK;
good = event_return.xbutton;
good.type = EVENT;
good.send_event = False;
good.display = display;
good.window = w;
good.root = DRW(display);
good.subwindow = None;
good.x = PTRX;
good.y = PTRY;
good.x_root = ptr->nx;
good.y_root = ptr->ny;
good.state = 0L;
good.button = Button1;
good.same_screen = True;
if (checkevent((XEvent *) &good, &event_return)) {
report("Unexpected values in delivered event");
FAIL;
}
else
CHECK;
CHECKPASS(2);
>>ASSERTION Good B 1
When a xname event is generated
and no active pointer grab is in progress
and at least one ancestor of the source window has a matching passive grab
on the pressed pointer button,
then the X server activates a passive grab for
the first ancestor of the source window,
searching from the root window down.
>>STRATEGY
If extended testing is enabled :
Create a window.
Create a child window.
Create a child of the child.
Select input on EnterNotify events for all of the windows.
Select passive grabs for all the windows on Button1.
Simulate a ButtonPress event.
Verify that the child windows did not receive EnterNotify events.
Verify that the oldest ancestor window received an EnterNotify with mode NotifyGrab.
Simulate a ButtonRelease event.
Release the passive grabs.
>>CODE
Window w;
Window w1;
Window w2;
XEvent ev;
struct area area;
char *unexpstr = "Unexpected event on a child window.";
if (noext(1))
return;
w = defwin(Dsp);
setarea(&area, 10, 10, 30, 30);
w1 = crechild(Dsp, w, &area);
w2 = crechild(Dsp, w1, &area);
(void) warppointer(Dsp, w2, 1,1);
XSelectInput(Dsp, w, EnterWindowMask);
XSelectInput(Dsp, w1, EnterWindowMask);
XSelectInput(Dsp, w2, EnterWindowMask);
XGrabButton(Dsp, Button1, AnyModifier, w, False, 0L, GrabModeAsync, GrabModeAsync, None, None);
XGrabButton(Dsp, Button1, AnyModifier, w1, False, 0L, GrabModeAsync, GrabModeAsync, None, None);
XGrabButton(Dsp, Button1, AnyModifier, w2, False, 0L, GrabModeAsync, GrabModeAsync, None, None);
XSync(Dsp, True);
buttonpress(Dsp, Button1);
if(XCheckWindowEvent(Dsp, w1, EnterWindowMask, &ev) != False) {
report(unexpstr);
FAIL;
} else
CHECK;
if(XCheckWindowEvent(Dsp, w2, EnterWindowMask, &ev) != False) {
report(unexpstr);
FAIL;
} else
CHECK;
if(XCheckWindowEvent(Dsp, w, EnterWindowMask, &ev) == False) {
report("No event was activated on the oldest ancestor window.");
FAIL;
} else {
CHECK;
if(ev.xcrossing.mode != NotifyGrab) {
report("Passive grab was not activated on oldest ancestor window.");
FAIL;
} else
CHECK;
}
buttonrel(Dsp, Button1);
XUngrabButton(Dsp, Button1, AnyModifier, w);
XUngrabButton(Dsp, Button1, AnyModifier, w1);
XUngrabButton(Dsp, Button1, AnyModifier, w2);
CHECKPASS(4);
>>ASSERTION Good B 1
When a xname event is generated
and no active pointer grab is in progress
and no ancestor of the source window has a matching passive grab
on the pressed pointer button,
then the X server automatically starts an active grab
for the client receiving the event and
sets the last-pointer-grab time to the current server time.
>>ASSERTION Good B 1
When a xname event is generated
and no active pointer grab is in progress
and no ancestor of the source window has a matching passive grab
on the pressed pointer button and
no client has selected for button presses on the event window,
then the event is discarded.
>>STRATEGY
If extended testing is enabled:
Create window.
Select for all events except ButtonPress.
Generate xname event.
Verify that no event was delivered.
>>CODE
Display *display = Dsp;
Window w;
int count;
if(noext(1))
return;
/* Create window. */
w = defwin(display);
(void) warppointer(display, w, PTRX, PTRY);
XSelectInput(display, w, ALLEVENTS & ~ButtonPressMask);
XSync(display, True);
/* Generate xname event. */
XSync(display, True);
buttonpress(display, Button1);
/* Verify no events were delivered. */
count = XPending(display);
if (count != 0) {
report("Got %d unexpected events.", count);
FAIL;
}
else
PASS;
>>ASSERTION Good B 1
When a xname event is generated,
then
all clients having set
.S ButtonPressMask
event mask bits on the event window are delivered
a xname event.
>>#COMMENT
>># This assertion is misleading, there can only ever be one client
>># selecting ButtonPress events on any particular window.
>># For the time-being this test is a copy of the single client test.
>># Cal 12/2/92.
>>#
>>STRATEGY
If extended testing is enabled:
Create window.
Select for xname events.
Generate xname event.
Verify that a xname event was delivered.
Verify that event member fields are correctly set.
Otherwise:
Create window.
Set ButtonPressMask event mask bits on window.
Verify that no error occurred.
>>CODE
Display *display = Dsp;
Window w;
XEvent event_return;
XButtonPressedEvent good;
PointerPlace *ptr;
if(config.extensions) {
if(noext(1))
return;
/* Create window. */
w = defwin(display);
/* Select for events. */
XSelectInput(display, w, EVENTMASK);
XSync(display, True);
/* Generate xname event. */
XSync(display, True);
ptr = warppointer(display, w, PTRX, PTRY);
buttonpress(display, Button1);
/* Verify that event was delivered. */
/* Verify that event member fields are correctly set. */
if (!XCheckTypedWindowEvent(display, w, EVENT, &event_return)) {
report("Expected %s event, got none", eventname(EVENT));
FAIL;
} else
CHECK;
good = event_return.xbutton;
good.type = EVENT;
good.send_event = False;
good.display = display;
good.window = w;
good.root = DRW(display);
good.subwindow = None;
good.x = PTRX;
good.y = PTRY;
good.x_root = ptr->nx;
good.y_root = ptr->ny;
good.state = 0L;
good.button = Button1;
good.same_screen = True;
if (checkevent((XEvent *) &good, &event_return)) {
report("Unexpected values in delivered event");
FAIL;
}
else
CHECK;
CHECKPASS(2);
} else {
/* Create window. */
w = mkwin(display, (XVisualInfo *) NULL, (struct area *) NULL, False);
/* Set ButtonPressMask event mask bits on window. */
XSelectInput(display, w, ButtonPressMask);
XSync(display, True);
/* Verify that no error occurred. */
if (geterr() != Success) {
delete("Error setting up for test.");
return;
}
else
CHECK;
CHECKUNTESTED(1);
}
>>ASSERTION Good B 1
>>#NOTE True for most events (except MappingNotify and selection stuff).
When a xname event is generated,
then
clients not having set
.S ButtonPressMask
event mask bits on the event window are not delivered
a xname event.
>>STRATEGY
If extended testing is enabled:
Create window.
Select for all events except ButtonPress.
Create a second client.
Select for ButtonPress events on the window
Generate xname event.
Verify that a xname event was delivered.
Verify that no event was delivered to the other client.
>>CODE
Display *display = Dsp;
Display *client2;
XEvent ev;
Window w;
int count;
if(noext(1))
return;
client2 = opendisplay();
/* Create window. */
w = defwin(display);
(void) warppointer(display, w, PTRX, PTRY);
XSelectInput(display, w, ALLEVENTS & ~ButtonPressMask);
XSelectInput(client2, w, ButtonPressMask);
XSync(display, True);
XSync(client2, True);
/* Generate xname event. */
buttonpress(display, Button1);
XSync(client2, False);
/* Verify a ButtonPress was generated. */
if(XCheckWindowEvent(client2, w, ButtonPressMask, &ev) == False) {
report("No ButtonPress event was generated.");
FAIL;
} else
CHECK;
/* Verify no events were delivered. */
count = XPending(display);
if (count != 0) {
report("Got %d unexpected events.", count);
FAIL;
} else
CHECK;
CHECKPASS(2);
>>ASSERTION Good B 1
When a xname event is generated
and no client has selected
.S ButtonPressMask
on the source window,
then the event propagates,
with propagation stopping at the root window of the screen or
at the first window with
.S ButtonPressMask
in its do-not-propagate mask,
from the source window to
the first ancestor window for which
some client has selected
for xname events.
>>STRATEGY
If extended testing is required:
Create a window.
Create a child of that window.
Create a child of the child.
Select xname events on the root window.
Simulate a xname event on the youngest child.
Verify that a xname event was generated on the root.
Select xname events on the oldest window.
Set the do_not_propagate mask of its child to xname events.
Simulate a xname event on the youngest child.
Verify that no created window received a xname event.
Clear the do_not_propagate mask on the oldest child.
Set the do_not_propagate mask on the oldest window.
Select for xname events on the oldest child.
Simulate a xname on the youngest child.
Verify that no xname event was sent to the oldest window.
Verify that no xname event was sent to the youngest window.
Verify that a xname event was sent to the oldest child.
>>CODE
XEvent ev;
Window w;
Window w1;
Window w2;
XSetWindowAttributes atts;
if(noext(1))
return;
w = defwin(Dsp);
w1 = crechild(Dsp, w, (struct area *) NULL);
w2 = crechild(Dsp, w1, (struct area *) NULL);
XSelectInput(Dsp, DRW(Dsp), ButtonPressMask);
(void) warppointer(Dsp, w2, 1,1);
XSync(Dsp, True);
buttonpress(Dsp, Button1);
if (XCheckWindowEvent(Dsp, DRW(Dsp), ButtonPressMask, &ev) == False) {
report("Expected event (%s) not received.", eventname(ButtonPress));
FAIL;
} else
CHECK;
XSelectInput(Dsp, DRW(Dsp), NoEventMask);
XSelectInput(Dsp, w, ButtonPressMask);
atts.do_not_propagate_mask = ButtonPressMask;
XChangeWindowAttributes(Dsp, w1, CWDontPropagate, &atts);
buttonrel(Dsp, Button1);
buttonpress(Dsp, Button1);
if (XCheckWindowEvent(Dsp, w2, ButtonPressMask, &ev) != False) {
report("Unexpected event (%s) received.", eventname(ButtonPress));
FAIL;
} else
CHECK;
if (XCheckWindowEvent(Dsp, w1, ButtonPressMask, &ev) != False) {
report("Unexpected event (%s) received.", eventname(ButtonPress));
FAIL;
} else
CHECK;
if (XCheckWindowEvent(Dsp, w, ButtonPressMask, &ev) != False) {
report("Unexpected event (%s) received.", eventname(ButtonPress));
FAIL;
} else
CHECK;
XSelectInput(Dsp, w1, ButtonPressMask);
XChangeWindowAttributes(Dsp, w, CWDontPropagate, &atts);
atts.do_not_propagate_mask = NoEventMask;
XChangeWindowAttributes(Dsp, w1, CWDontPropagate, &atts);
buttonrel(Dsp, Button1);
buttonpress(Dsp, Button1);
if (XCheckWindowEvent(Dsp, w2, ButtonPressMask, &ev) != False) {
report("Unexpected event (%s) received.", eventname(ButtonPress));
FAIL;
} else
CHECK;
if (XCheckWindowEvent(Dsp, w, ButtonPressMask, &ev) != False) {
report("Unexpected event (%s) received.", eventname(ButtonPress));
FAIL;
} else
CHECK;
if (XCheckWindowEvent(Dsp, w1, ButtonPressMask, &ev) == False) {
report("ButtonPress event was not delivered to selecting child window.");
FAIL;
} else
CHECK;
CHECKPASS(7);
>>#NOTEs >>ASSERTION
>>#NOTEs When ARTICLE xname event is delivered,
>>#NOTEs then
>>#NOTEs .M type
>>#NOTEs is set to
>>#NOTEs xname.
>>#NOTEs >>ASSERTION
>>#NOTEs >>#NOTE The method of expansion is not clear.
>>#NOTEs When ARTICLE xname event is delivered,
>>#NOTEs then
>>#NOTEs .M serial
>>#NOTEs is set
>>#NOTEs from the serial number reported in the protocol
>>#NOTEs but expanded from the 16-bit least-significant bits
>>#NOTEs to a full 32-bit value.
>>#NOTEm >>ASSERTION
>>#NOTEm When ARTICLE xname event is delivered
>>#NOTEm and the event came from a
>>#NOTEm .S SendEvent
>>#NOTEm protocol request,
>>#NOTEm then
>>#NOTEm .M send_event
>>#NOTEm is set to
>>#NOTEm .S True .
>>#NOTEs >>ASSERTION
>>#NOTEs When ARTICLE xname event is delivered
>>#NOTEs and the event was not generated by a
>>#NOTEs .S SendEvent
>>#NOTEs protocol request,
>>#NOTEs then
>>#NOTEs .M send_event
>>#NOTEs is set to
>>#NOTEs .S False .
>>#NOTEs >>ASSERTION
>>#NOTEs When ARTICLE xname event is delivered,
>>#NOTEs then
>>#NOTEs .M display
>>#NOTEs is set to
>>#NOTEs a pointer to the display on which the event was read.
>>#NOTEs >>ASSERTION
>>#NOTEs >>#NOTE Global except for MappingNotify and KeymapNotify.
>>#NOTEs When ARTICLE xname event is delivered,
>>#NOTEs then
>>#NOTEs .M window
>>#NOTEs is set to
>>#NOTEs the
>>#NOTEs ifdef(`WINDOWTYPE', WINDOWTYPE, event)
>>#NOTEs window.
>>#NOTEs >>ASSERTION
>>#NOTEs When ARTICLE xname event is delivered,
>>#NOTEs then
>>#NOTEs .M root
>>#NOTEs is set to the source window's root window.
>>ASSERTION Good B 1
>>#
>>#COMMENT
>># This assertion contains a tautology; a child is an inferior.
>># Cal 12/2/92.
>>#
When a xname event is delivered
and the source window is an inferior of the event window
and the source window is a child of the event window,
then
.M subwindow
is set to
the source window.
>>STRATEGY
If extended testing is required:
Create a window.
Select xname events on that window.
Create a child of that window.
Simulate a xname event on the child.
Verify that a xname event was delivered to the parent.
Verify that the subwindow component was the child of the event window.
>>CODE
XEvent ev;
Window w;
Window w1;
if(noext(1))
return;
w = defwin(Dsp);
w1 = crechild(Dsp, w, (struct area *) NULL);
XSelectInput(Dsp, w, ButtonPressMask);
(void) warppointer(Dsp, w1, 1,1);
XSync(Dsp, True);
buttonpress(Dsp, Button1);
if (XCheckWindowEvent(Dsp, w, ButtonPressMask, &ev) == False) {
report("Expected event (%s) not received.", eventname(ButtonPress));
FAIL;
} else {
CHECK;
if(ev.xbutton.subwindow != w1) {
report("The subwindow component of the %s event was not set correctly.", eventname(ButtonPress));
FAIL;
} else
CHECK;
}
CHECKPASS(2);
>>ASSERTION Good B 1
When a xname event is delivered
and the source window is an inferior of the event window
and the source window is not a child of the event window,
then
.M subwindow
is set to
the child of the event window that is
an ancestor of the source window.
>>STRATEGY
If extended testing is required:
Create a window.
Select xname events on that window.
Create a child of that window.
Create a child of the child.
Simulate a xname event on the youngest child.
Verify that a xname event was generated on the oldest parent.
Verify that the subwindow component was the child of the event window.
>>CODE
Window w;
Window w1;
Window w2;
XEvent ev;
struct area area;
if (noext(1))
return;
w = defwin(Dsp);
setarea(&area, 10, 10, 30, 30);
w1 = crechild(Dsp, w, &area);
w2 = crechild(Dsp, w1, &area);
(void) warppointer(Dsp, w2, 1,1);
XSelectInput(Dsp, w, ButtonPressMask);
XSync(Dsp, True);
buttonpress(Dsp, Button1);
if (XCheckWindowEvent(Dsp, w, ButtonPressMask, &ev) == False) {
report("Expected event (%s) not received.", eventname(ButtonPress));
FAIL;
} else {
CHECK;
if(ev.xbutton.subwindow != w1) {
report("The subwindow component of the %s event was not set correctly.", eventname(ButtonPress));
FAIL;
} else
CHECK;
}
CHECKPASS(2);
>>ASSERTION Good B 1
When a xname event is delivered
and the source window is not an inferior of the event window,
then
.M subwindow
is set to
.S None .
>>STRATEGY
If extended testing is required:
Create a window.
Select xname events on that window.
Simulate a xname event on the window.
Verify that a xname event was generated.
Verify that the subwindow component was None.
Create a window.
Grab the pointer with owner_events set to False.
Simulate a xname event on the window.
Verify that a xname event was generated on the grabbing window.
Verify that the subwindow component was None.
>>CODE
Window w;
Window w2;
XEvent ev;
if (noext(1))
return;
w = defwin(Dsp);
(void) warppointer(Dsp, w, 1,1);
XSelectInput(Dsp, w, ButtonPressMask);
XSync(Dsp, True);
buttonpress(Dsp, Button1);
if (XCheckWindowEvent(Dsp, w, ButtonPressMask, &ev) == False) {
report("Expected event (%s) not received.", eventname(ButtonPress));
FAIL;
} else {
CHECK;
if(ev.xbutton.subwindow != None) {
report("The subwindow component of the %s event was not set correctly.", eventname(ButtonPress));
FAIL;
} else
CHECK;
}
w2 = defwin(Dsp);
if( XGrabPointer(Dsp, w, False, ButtonPressMask, GrabModeAsync, GrabModeAsync, None, None, CurrentTime) != GrabSuccess) {
delete("XGrabPointer() did not return GrabSuccess.");
return;
} else
CHECK;
(void) warppointer(Dsp, w2, 1,1);
XSync(Dsp, True);
buttonpress(Dsp, Button1);
if (XCheckWindowEvent(Dsp, w, ButtonPressMask, &ev) == False) {
report("Expected event (%s) not received.", eventname(ButtonPress));
FAIL;
} else {
CHECK;
if(ev.xbutton.subwindow != None) {
report("The subwindow component of the %s event was not set correctly.", eventname(ButtonPress));
FAIL;
} else
CHECK;
}
XUngrabPointer(Dsp, CurrentTime);
CHECKPASS(5);
>>#NOTEs >>ASSERTION
>>#NOTEs When ARTICLE xname event is delivered,
>>#NOTEs then
>>#NOTEs .M time
>>#NOTEs is set to
>>#NOTEs the time in milliseconds at which the event was generated.
>>#NOTEs >>ASSERTION
>>#NOTEs When ARTICLE xname event is delivered
>>#NOTEs and the event window is on the same screen as the root window,
>>#NOTEs then
>>#NOTEs .M x
>>#NOTEs and
>>#NOTEs .M y
>>#NOTEs are set to
>>#NOTEs the coordinates of
>>#NOTEs the final pointer position relative to the event window's origin.
>>ASSERTION Good D 1
If multiple screens are supported:
When a xname event is delivered
and the event and root windows are not on the same screen,
then
.M x
and
.M y
are set to
zero.
>>STRATEGY
If multiple screens are supported:
If extended testing is required:
Create a window.
Select xname events on that window.
Create a window on the alternate screen.
Grab the pointer with owner_events set to False.
Simulate a xname event on the window.
Verify that a xname event was generated on the grabbing window.
Verify that the x and y components are set to zero.
>>CODE
Window w;
Window w2;
XEvent ev;
/* Report unsupported if multiple screens are not supported. */
if (config.alt_screen == -1) {
unsupported("Multiple screens not supported.");
return;
} else
CHECK;
if(noext(1))
return;
w = defwin(Dsp);
(void) warppointer(Dsp, w, 1,1);
XSelectInput(Dsp, w, ButtonPressMask);
w2 = defdraw(Dsp, VI_ALT_WIN);
if( XGrabPointer(Dsp, w, False, ButtonPressMask, GrabModeAsync, GrabModeAsync, None, None, CurrentTime) != GrabSuccess) {
delete("XGrabPointer() did not return GrabSuccess.");
return;
} else
CHECK;
(void) warppointer(Dsp, w2, 1,1);
XSync(Dsp, True);
buttonpress(Dsp, Button1);
if (XCheckWindowEvent(Dsp, w, ButtonPressMask, &ev) == False) {
report("Expected event (%s) not received.", eventname(ButtonPress));
FAIL;
} else {
CHECK;
if(ev.xbutton.x != 0 || ev.xbutton.y != 0) {
report("The x and y components of the %s event were not set correctly.", eventname(ButtonPress));
FAIL;
} else
CHECK;
}
XUngrabPointer(Dsp, CurrentTime);
CHECKPASS(4);
>>#NOTEs >>ASSERTION
>>#NOTEs When ARTICLE xname event is delivered,
>>#NOTEs then
>>#NOTEs .M x_root
>>#NOTEs and
>>#NOTEs .M y_root
>>#NOTEs are set to coordinates of the pointer
>>#NOTEs when the event was generated
>>#NOTEs relative to the root window's origin.
>>#NOTEs >>ASSERTION
>>#NOTEs When ARTICLE xname event is delivered,
>>#NOTEs then
>>#NOTEs .M state
>>#NOTEs is set to
>>#NOTEs indicate the logical state
>>#NOTEs of the pointer buttons,
>>#NOTEs which is the bitwise OR of one or more of
>>#NOTEs the button or modifier key masks
>>#NOTEs .S Button1Mask ,
>>#NOTEs .S Button2Mask ,
>>#NOTEs .S Button3Mask ,
>>#NOTEs .S Button4Mask ,
>>#NOTEs .S Button5Mask ,
>>#NOTEs .S ShiftMask ,
>>#NOTEs .S LockMask ,
>>#NOTEs .S ControlMask ,
>>#NOTEs .S Mod1Mask ,
>>#NOTEs .S Mod2Mask ,
>>#NOTEs .S Mod3Mask ,
>>#NOTEs .S Mod4Mask ,
>>#NOTEs and
>>#NOTEs .S Mod5Mask .
>>#NOTEs >>ASSERTION
>>#NOTEs When ARTICLE xname event is delivered,
>>#NOTEs then
>>#NOTEs .M button
>>#NOTEs represents the pointer button which changed state
>>#NOTEs and is set to either
>>#NOTEs .S Button1 ,
>>#NOTEs .S Button2 ,
>>#NOTEs .S Button3 ,
>>#NOTEs .S Button4 ,
>>#NOTEs or
>>#NOTEs .S Button5 .
>>#NOTEs >>ASSERTION
>>#NOTEs When ARTICLE xname event is delivered
>>#NOTEs and the event and root windows are on the same screen,
>>#NOTEs then
>>#NOTEs .M same_screen
>>#NOTEs is set to
>>#NOTEs .S True .
>>ASSERTION Good D 1
If multiple screens are supported:
When a xname event is delivered
and the event and root windows are not on the same screen,
then
.M same_screen
is set to
.S False .
>>STRATEGY
If multiple screens are supported:
If extended testing is required:
Create a window.
Select xname events on that window.
Create a window on the alternate screen.
Grab the pointer with owner_events set to False.
Simulate a xname event on the window.
Verify that a xname event was generated on the grabbing window.
Verify that the same_screen component is set to zero.
>>CODE
Window w;
Window w2;
XEvent ev;
if (config.alt_screen == -1) {
unsupported("Multiple screens not supported.");
return;
} else
CHECK;
if(noext(1))
return;
w = defwin(Dsp);
(void) warppointer(Dsp, w, 1,1);
XSelectInput(Dsp, w, ButtonPressMask);
w2 = defdraw(Dsp, VI_ALT_WIN);
if( XGrabPointer(Dsp, w, False, ButtonPressMask, GrabModeAsync, GrabModeAsync, None, None, CurrentTime) != GrabSuccess) {
delete("XGrabPointer() did not return GrabSuccess.");
return;
} else
CHECK;
(void) warppointer(Dsp, w2, 1,1);
XSync(Dsp, True);
buttonpress(Dsp, Button1);
if (XCheckWindowEvent(Dsp, w, ButtonPressMask, &ev) == False) {
report("Expected event (%s) not received.", eventname(ButtonPress));
FAIL;
} else {
CHECK;
if(ev.xbutton.same_screen != False ) {
report("The same_screen component of the %s event was not set correctly.", eventname(ButtonPress));
FAIL;
} else
CHECK;
}
XUngrabPointer(Dsp, CurrentTime);
CHECKPASS(4);
|