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
|
/**
* Copyright © 2009 Red Hat, Inc.
*
* 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 (including the next
* paragraph) 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.
*/
#ifdef HAVE_DIX_CONFIG_H
#include <dix-config.h>
#endif
#include <stdint.h>
#include <X11/X.h>
#include "misc.h"
#include "resource.h"
#include <X11/Xproto.h>
#include <X11/extensions/XI2proto.h>
#include <X11/Xatom.h>
#include "windowstr.h"
#include "inputstr.h"
#include "eventconvert.h"
#include "exevents.h"
#include "dixgrabs.h"
#include <glib.h>
void __wrap_ErrorF(const char *f, ...)
{
}
/**
* Init a device with axes.
* Verify values set on the device.
*
* Result: All axes set to default values (usually 0).
*/
static void dix_init_valuators(void)
{
DeviceIntRec dev;
ValuatorClassPtr val;
const int num_axes = 2;
int i;
memset(&dev, 0, sizeof(DeviceIntRec));
dev.type = MASTER_POINTER; /* claim it's a master to stop ptracccel */
g_assert(InitValuatorClassDeviceStruct(NULL, 0, 0, 0) == FALSE);
g_assert(InitValuatorClassDeviceStruct(&dev, num_axes, 0, Absolute));
val = dev.valuator;
g_assert(val);
g_assert(val->numAxes == num_axes);
g_assert(val->numMotionEvents == 0);
g_assert(val->mode == Absolute);
g_assert(val->axisVal);
for (i = 0; i < num_axes; i++)
{
g_assert(val->axisVal[i] == 0);
g_assert(val->axes->min_value == NO_AXIS_LIMITS);
g_assert(val->axes->max_value == NO_AXIS_LIMITS);
}
g_assert(dev.last.numValuators == num_axes);
}
/* just check the known success cases, and that error cases set the client's
* error value correctly. */
static void dix_check_grab_values(void)
{
ClientRec client;
GrabParameters param;
int rc;
memset(&client, 0, sizeof(client));
param.grabtype = GRABTYPE_CORE;
param.this_device_mode = GrabModeSync;
param.other_devices_mode = GrabModeSync;
param.modifiers = AnyModifier;
param.ownerEvents = FALSE;
rc = CheckGrabValues(&client, ¶m);
g_assert(rc == Success);
param.this_device_mode = GrabModeAsync;
rc = CheckGrabValues(&client, ¶m);
g_assert(rc == Success);
param.this_device_mode = GrabModeAsync + 1;
rc = CheckGrabValues(&client, ¶m);
g_assert(rc == BadValue);
g_assert(client.errorValue == param.this_device_mode);
g_assert(client.errorValue == GrabModeAsync + 1);
param.this_device_mode = GrabModeSync;
param.other_devices_mode = GrabModeAsync;
rc = CheckGrabValues(&client, ¶m);
g_assert(rc == Success);
param.other_devices_mode = GrabModeAsync + 1;
rc = CheckGrabValues(&client, ¶m);
g_assert(rc == BadValue);
g_assert(client.errorValue == param.other_devices_mode);
g_assert(client.errorValue == GrabModeAsync + 1);
param.other_devices_mode = GrabModeSync;
param.modifiers = 1 << 13;
rc = CheckGrabValues(&client, ¶m);
g_assert(rc == BadValue);
g_assert(client.errorValue == param.modifiers);
g_assert(client.errorValue == (1 << 13));
param.modifiers = AnyModifier;
param.ownerEvents = TRUE;
rc = CheckGrabValues(&client, ¶m);
g_assert(rc == Success);
param.ownerEvents = 3;
rc = CheckGrabValues(&client, ¶m);
g_assert(rc == BadValue);
g_assert(client.errorValue == param.ownerEvents);
g_assert(client.errorValue == 3);
}
/**
* Convert various internal events to the matching core event and verify the
* parameters.
*/
static void dix_event_to_core(int type)
{
DeviceEvent ev;
xEvent core;
int time;
int x, y;
int rc;
int state;
int detail;
/* EventToCore memsets the event to 0 */
#define test_event() \
g_assert(rc == Success); \
g_assert(core.u.u.type == type); \
g_assert(core.u.u.detail == detail); \
g_assert(core.u.keyButtonPointer.time == time); \
g_assert(core.u.keyButtonPointer.rootX == x); \
g_assert(core.u.keyButtonPointer.rootY == y); \
g_assert(core.u.keyButtonPointer.state == state); \
g_assert(core.u.keyButtonPointer.eventX == 0); \
g_assert(core.u.keyButtonPointer.eventY == 0); \
g_assert(core.u.keyButtonPointer.root == 0); \
g_assert(core.u.keyButtonPointer.event == 0); \
g_assert(core.u.keyButtonPointer.child == 0); \
g_assert(core.u.keyButtonPointer.sameScreen == FALSE);
x = 0;
y = 0;
time = 12345;
state = 0;
detail = 0;
ev.header = 0xFF;
ev.length = sizeof(DeviceEvent);
ev.time = time;
ev.root_y = x;
ev.root_x = y;
ev.corestate = state;
ev.detail.key = detail;
ev.type = type;
ev.detail.key = 0;
rc = EventToCore((InternalEvent*)&ev, &core);
test_event();
x = 1;
y = 2;
ev.root_x = x;
ev.root_y = y;
rc = EventToCore((InternalEvent*)&ev, &core);
test_event();
x = 0x7FFF;
y = 0x7FFF;
ev.root_x = x;
ev.root_y = y;
rc = EventToCore((InternalEvent*)&ev, &core);
test_event();
x = 0x8000; /* too high */
y = 0x8000; /* too high */
ev.root_x = x;
ev.root_y = y;
rc = EventToCore((InternalEvent*)&ev, &core);
g_assert(core.u.keyButtonPointer.rootX != x);
g_assert(core.u.keyButtonPointer.rootY != y);
x = 0x7FFF;
y = 0x7FFF;
ev.root_x = x;
ev.root_y = y;
time = 0;
ev.time = time;
rc = EventToCore((InternalEvent*)&ev, &core);
test_event();
detail = 1;
ev.detail.key = detail;
rc = EventToCore((InternalEvent*)&ev, &core);
test_event();
detail = 0xFF; /* highest value */
ev.detail.key = detail;
rc = EventToCore((InternalEvent*)&ev, &core);
test_event();
detail = 0xFFF; /* too big */
ev.detail.key = detail;
rc = EventToCore((InternalEvent*)&ev, &core);
g_assert(rc == BadMatch);
detail = 0xFF; /* too big */
ev.detail.key = detail;
state = 0xFFFF; /* highest value */
ev.corestate = state;
rc = EventToCore((InternalEvent*)&ev, &core);
test_event();
state = 0x10000; /* too big */
ev.corestate = state;
rc = EventToCore((InternalEvent*)&ev, &core);
g_assert(core.u.keyButtonPointer.state != state);
g_assert(core.u.keyButtonPointer.state == (state & 0xFFFF));
#undef test_event
}
static void dix_event_to_core_conversion(void)
{
DeviceEvent ev;
xEvent core;
int rc, i;
ev.header = 0xFF;
ev.length = sizeof(DeviceEvent);
for (i = INT_MIN; i < INT_MAX; i++)
{
switch(i)
{
case ET_KeyPress:
case ET_KeyRelease:
case ET_ButtonPress:
case ET_ButtonRelease:
case ET_Motion:
dix_event_to_core(i);
break;
case ET_Raw:
case ET_ProximityIn:
case ET_ProximityOut:
ev.type = i;
rc = EventToCore((InternalEvent*)&ev, &core);
g_assert(rc == BadMatch);
break;
default:
ev.type = i;
rc = EventToCore((InternalEvent*)&ev, &core);
g_assert(rc == BadImplementation);
break;
}
}
}
static void xi2_struct_sizes(void)
{
#define compare(req) \
g_assert(sizeof(req) == sz_##req);
compare(xXIQueryVersionReq);
compare(xXIWarpPointerReq);
compare(xXIChangeCursorReq);
compare(xXIChangeHierarchyReq);
compare(xXISetClientPointerReq);
compare(xXIGetClientPointerReq);
compare(xXISelectEventsReq);
compare(xXIQueryVersionReq);
compare(xXIQueryDeviceReq);
compare(xXISetFocusReq);
compare(xXIGetFocusReq);
compare(xXIGrabDeviceReq);
compare(xXIUngrabDeviceReq);
compare(xXIAllowEventsReq);
compare(xXIPassiveGrabDeviceReq);
compare(xXIPassiveUngrabDeviceReq);
compare(xXIListPropertiesReq);
compare(xXIChangePropertyReq);
compare(xXIDeletePropertyReq);
compare(xXIGetPropertyReq);
compare(xXIGetSelectedEventsReq);
#undef compare
}
static void dix_grab_matching(void)
{
DeviceIntRec xi_all_devices, xi_all_master_devices, dev1, dev2;
GrabRec a, b;
BOOL rc;
memset(&a, 0, sizeof(a));
memset(&b, 0, sizeof(b));
/* different grabtypes must fail */
a.grabtype = GRABTYPE_CORE;
b.grabtype = GRABTYPE_XI2;
rc = GrabMatchesSecond(&a, &b, FALSE);
g_assert(rc == FALSE);
rc = GrabMatchesSecond(&b, &a, FALSE);
g_assert(rc == FALSE);
a.grabtype = GRABTYPE_XI;
b.grabtype = GRABTYPE_XI2;
rc = GrabMatchesSecond(&a, &b, FALSE);
g_assert(rc == FALSE);
rc = GrabMatchesSecond(&b, &a, FALSE);
g_assert(rc == FALSE);
a.grabtype = GRABTYPE_XI;
b.grabtype = GRABTYPE_CORE;
rc = GrabMatchesSecond(&a, &b, FALSE);
g_assert(rc == FALSE);
rc = GrabMatchesSecond(&b, &a, FALSE);
g_assert(rc == FALSE);
/* XI2 grabs for different devices must fail, regardless of ignoreDevice
* XI2 grabs for master devices must fail against a slave */
memset(&xi_all_devices, 0, sizeof(DeviceIntRec));
memset(&xi_all_master_devices, 0, sizeof(DeviceIntRec));
memset(&dev1, 0, sizeof(DeviceIntRec));
memset(&dev2, 0, sizeof(DeviceIntRec));
xi_all_devices.id = XIAllDevices;
xi_all_master_devices.id = XIAllMasterDevices;
dev1.id = 10;
dev1.type = SLAVE;
dev2.id = 11;
dev2.type = SLAVE;
inputInfo.all_devices = &xi_all_devices;
inputInfo.all_master_devices = &xi_all_master_devices;
a.grabtype = GRABTYPE_XI2;
b.grabtype = GRABTYPE_XI2;
a.device = &dev1;
b.device = &dev2;
rc = GrabMatchesSecond(&a, &b, FALSE);
g_assert(rc == FALSE);
a.device = &dev2;
b.device = &dev1;
rc = GrabMatchesSecond(&a, &b, FALSE);
g_assert(rc == FALSE);
rc = GrabMatchesSecond(&a, &b, TRUE);
g_assert(rc == FALSE);
a.device = inputInfo.all_master_devices;
b.device = &dev1;
rc = GrabMatchesSecond(&a, &b, FALSE);
g_assert(rc == FALSE);
rc = GrabMatchesSecond(&a, &b, TRUE);
g_assert(rc == FALSE);
a.device = &dev1;
b.device = inputInfo.all_master_devices;
rc = GrabMatchesSecond(&a, &b, FALSE);
g_assert(rc == FALSE);
rc = GrabMatchesSecond(&a, &b, TRUE);
g_assert(rc == FALSE);
/* ignoreDevice FALSE must fail for different devices for CORE and XI */
a.grabtype = GRABTYPE_XI;
b.grabtype = GRABTYPE_XI;
a.device = &dev1;
b.device = &dev2;
a.modifierDevice = &dev1;
b.modifierDevice = &dev1;
rc = GrabMatchesSecond(&a, &b, FALSE);
g_assert(rc == FALSE);
a.grabtype = GRABTYPE_CORE;
b.grabtype = GRABTYPE_CORE;
a.device = &dev1;
b.device = &dev2;
a.modifierDevice = &dev1;
b.modifierDevice = &dev1;
rc = GrabMatchesSecond(&a, &b, FALSE);
g_assert(rc == FALSE);
/* ignoreDevice FALSE must fail for different modifier devices for CORE
* and XI */
a.grabtype = GRABTYPE_XI;
b.grabtype = GRABTYPE_XI;
a.device = &dev1;
b.device = &dev1;
a.modifierDevice = &dev1;
b.modifierDevice = &dev2;
rc = GrabMatchesSecond(&a, &b, FALSE);
g_assert(rc == FALSE);
a.grabtype = GRABTYPE_CORE;
b.grabtype = GRABTYPE_CORE;
a.device = &dev1;
b.device = &dev1;
a.modifierDevice = &dev1;
b.modifierDevice = &dev2;
rc = GrabMatchesSecond(&a, &b, FALSE);
g_assert(rc == FALSE);
/* different event type must fail */
a.grabtype = GRABTYPE_XI2;
b.grabtype = GRABTYPE_XI2;
a.device = &dev1;
b.device = &dev1;
a.modifierDevice = &dev1;
b.modifierDevice = &dev1;
a.type = XI_KeyPress;
b.type = XI_KeyRelease;
rc = GrabMatchesSecond(&a, &b, FALSE);
g_assert(rc == FALSE);
rc = GrabMatchesSecond(&a, &b, TRUE);
g_assert(rc == FALSE);
a.grabtype = GRABTYPE_CORE;
b.grabtype = GRABTYPE_CORE;
a.device = &dev1;
b.device = &dev1;
a.modifierDevice = &dev1;
b.modifierDevice = &dev1;
a.type = XI_KeyPress;
b.type = XI_KeyRelease;
rc = GrabMatchesSecond(&a, &b, FALSE);
g_assert(rc == FALSE);
rc = GrabMatchesSecond(&a, &b, TRUE);
g_assert(rc == FALSE);
a.grabtype = GRABTYPE_XI;
b.grabtype = GRABTYPE_XI;
a.device = &dev1;
b.device = &dev1;
a.modifierDevice = &dev1;
b.modifierDevice = &dev1;
a.type = XI_KeyPress;
b.type = XI_KeyRelease;
rc = GrabMatchesSecond(&a, &b, FALSE);
g_assert(rc == FALSE);
rc = GrabMatchesSecond(&a, &b, TRUE);
g_assert(rc == FALSE);
/* different modifiers must fail */
a.grabtype = GRABTYPE_XI2;
b.grabtype = GRABTYPE_XI2;
a.device = &dev1;
b.device = &dev1;
a.modifierDevice = &dev1;
b.modifierDevice = &dev1;
a.type = XI_KeyPress;
b.type = XI_KeyPress;
a.modifiersDetail.exact = 1;
b.modifiersDetail.exact = 2;
rc = GrabMatchesSecond(&a, &b, FALSE);
g_assert(rc == FALSE);
rc = GrabMatchesSecond(&b, &a, FALSE);
g_assert(rc == FALSE);
a.grabtype = GRABTYPE_CORE;
b.grabtype = GRABTYPE_CORE;
rc = GrabMatchesSecond(&a, &b, FALSE);
g_assert(rc == FALSE);
rc = GrabMatchesSecond(&b, &a, FALSE);
g_assert(rc == FALSE);
a.grabtype = GRABTYPE_XI;
b.grabtype = GRABTYPE_XI;
rc = GrabMatchesSecond(&a, &b, FALSE);
g_assert(rc == FALSE);
rc = GrabMatchesSecond(&b, &a, FALSE);
g_assert(rc == FALSE);
/* AnyModifier must fail for XI2 */
a.grabtype = GRABTYPE_XI2;
b.grabtype = GRABTYPE_XI2;
a.modifiersDetail.exact = AnyModifier;
b.modifiersDetail.exact = 1;
rc = GrabMatchesSecond(&a, &b, FALSE);
g_assert(rc == FALSE);
rc = GrabMatchesSecond(&b, &a, FALSE);
g_assert(rc == FALSE);
/* XIAnyModifier must fail for CORE and XI */
a.grabtype = GRABTYPE_XI;
b.grabtype = GRABTYPE_XI;
a.modifiersDetail.exact = XIAnyModifier;
b.modifiersDetail.exact = 1;
rc = GrabMatchesSecond(&a, &b, FALSE);
g_assert(rc == FALSE);
rc = GrabMatchesSecond(&b, &a, FALSE);
g_assert(rc == FALSE);
a.grabtype = GRABTYPE_CORE;
b.grabtype = GRABTYPE_CORE;
a.modifiersDetail.exact = XIAnyModifier;
b.modifiersDetail.exact = 1;
rc = GrabMatchesSecond(&a, &b, FALSE);
g_assert(rc == FALSE);
rc = GrabMatchesSecond(&b, &a, FALSE);
g_assert(rc == FALSE);
/* different detail must fail */
a.grabtype = GRABTYPE_XI2;
b.grabtype = GRABTYPE_XI2;
a.detail.exact = 1;
b.detail.exact = 2;
a.modifiersDetail.exact = 1;
b.modifiersDetail.exact = 1;
rc = GrabMatchesSecond(&a, &b, FALSE);
g_assert(rc == FALSE);
rc = GrabMatchesSecond(&b, &a, FALSE);
g_assert(rc == FALSE);
a.grabtype = GRABTYPE_XI;
b.grabtype = GRABTYPE_XI;
rc = GrabMatchesSecond(&a, &b, FALSE);
g_assert(rc == FALSE);
rc = GrabMatchesSecond(&b, &a, FALSE);
g_assert(rc == FALSE);
a.grabtype = GRABTYPE_CORE;
b.grabtype = GRABTYPE_CORE;
rc = GrabMatchesSecond(&a, &b, FALSE);
g_assert(rc == FALSE);
rc = GrabMatchesSecond(&b, &a, FALSE);
g_assert(rc == FALSE);
/* detail of AnyModifier must fail */
a.grabtype = GRABTYPE_XI2;
b.grabtype = GRABTYPE_XI2;
a.detail.exact = AnyModifier;
b.detail.exact = 1;
a.modifiersDetail.exact = 1;
b.modifiersDetail.exact = 1;
rc = GrabMatchesSecond(&a, &b, FALSE);
g_assert(rc == FALSE);
rc = GrabMatchesSecond(&b, &a, FALSE);
g_assert(rc == FALSE);
a.grabtype = GRABTYPE_CORE;
b.grabtype = GRABTYPE_CORE;
rc = GrabMatchesSecond(&a, &b, FALSE);
g_assert(rc == FALSE);
rc = GrabMatchesSecond(&b, &a, FALSE);
g_assert(rc == FALSE);
a.grabtype = GRABTYPE_XI;
b.grabtype = GRABTYPE_XI;
rc = GrabMatchesSecond(&a, &b, FALSE);
g_assert(rc == FALSE);
rc = GrabMatchesSecond(&b, &a, FALSE);
g_assert(rc == FALSE);
/* detail of XIAnyModifier must fail */
a.grabtype = GRABTYPE_XI2;
b.grabtype = GRABTYPE_XI2;
a.detail.exact = XIAnyModifier;
b.detail.exact = 1;
a.modifiersDetail.exact = 1;
b.modifiersDetail.exact = 1;
rc = GrabMatchesSecond(&a, &b, FALSE);
g_assert(rc == FALSE);
rc = GrabMatchesSecond(&b, &a, FALSE);
g_assert(rc == FALSE);
a.grabtype = GRABTYPE_CORE;
b.grabtype = GRABTYPE_CORE;
rc = GrabMatchesSecond(&a, &b, FALSE);
g_assert(rc == FALSE);
rc = GrabMatchesSecond(&b, &a, FALSE);
g_assert(rc == FALSE);
a.grabtype = GRABTYPE_XI;
b.grabtype = GRABTYPE_XI;
rc = GrabMatchesSecond(&a, &b, FALSE);
g_assert(rc == FALSE);
rc = GrabMatchesSecond(&b, &a, FALSE);
g_assert(rc == FALSE);
/* XIAnyModifier or AnyModifer must succeed */
a.grabtype = GRABTYPE_XI2;
b.grabtype = GRABTYPE_XI2;
a.detail.exact = 1;
b.detail.exact = 1;
a.modifiersDetail.exact = XIAnyModifier;
b.modifiersDetail.exact = 1;
rc = GrabMatchesSecond(&a, &b, FALSE);
g_assert(rc == TRUE);
rc = GrabMatchesSecond(&b, &a, FALSE);
g_assert(rc == TRUE);
a.grabtype = GRABTYPE_CORE;
b.grabtype = GRABTYPE_CORE;
a.detail.exact = 1;
b.detail.exact = 1;
a.modifiersDetail.exact = AnyModifier;
b.modifiersDetail.exact = 1;
rc = GrabMatchesSecond(&a, &b, FALSE);
g_assert(rc == TRUE);
rc = GrabMatchesSecond(&b, &a, FALSE);
g_assert(rc == TRUE);
a.grabtype = GRABTYPE_XI;
b.grabtype = GRABTYPE_XI;
a.detail.exact = 1;
b.detail.exact = 1;
a.modifiersDetail.exact = AnyModifier;
b.modifiersDetail.exact = 1;
rc = GrabMatchesSecond(&a, &b, FALSE);
g_assert(rc == TRUE);
rc = GrabMatchesSecond(&b, &a, FALSE);
g_assert(rc == TRUE);
/* AnyKey or XIAnyKeysym must succeed */
a.grabtype = GRABTYPE_XI2;
b.grabtype = GRABTYPE_XI2;
a.detail.exact = XIAnyKeysym;
b.detail.exact = 1;
a.modifiersDetail.exact = 1;
b.modifiersDetail.exact = 1;
rc = GrabMatchesSecond(&a, &b, FALSE);
g_assert(rc == TRUE);
rc = GrabMatchesSecond(&b, &a, FALSE);
g_assert(rc == TRUE);
a.grabtype = GRABTYPE_CORE;
b.grabtype = GRABTYPE_CORE;
a.detail.exact = AnyKey;
b.detail.exact = 1;
a.modifiersDetail.exact = 1;
b.modifiersDetail.exact = 1;
rc = GrabMatchesSecond(&a, &b, FALSE);
g_assert(rc == TRUE);
rc = GrabMatchesSecond(&b, &a, FALSE);
g_assert(rc == TRUE);
a.grabtype = GRABTYPE_XI;
b.grabtype = GRABTYPE_XI;
a.detail.exact = AnyKey;
b.detail.exact = 1;
a.modifiersDetail.exact = 1;
b.modifiersDetail.exact = 1;
rc = GrabMatchesSecond(&a, &b, FALSE);
g_assert(rc == TRUE);
rc = GrabMatchesSecond(&b, &a, FALSE);
g_assert(rc == TRUE);
}
int main(int argc, char** argv)
{
g_test_init(&argc, &argv,NULL);
g_test_bug_base("https://bugzilla.freedesktop.org/show_bug.cgi?id=");
g_test_add_func("/dix/input/init-valuators", dix_init_valuators);
g_test_add_func("/dix/input/event-core-conversion", dix_event_to_core_conversion);
g_test_add_func("/dix/input/check-grab-values", dix_check_grab_values);
g_test_add_func("/dix/input/xi2-struct-sizes", xi2_struct_sizes);
g_test_add_func("/dix/input/grab_matching", dix_grab_matching);
return g_test_run();
}
|