File: xkb.h

package info (click to toggle)
chromium 138.0.7204.183-1
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 6,071,908 kB
  • sloc: cpp: 34,937,088; ansic: 7,176,967; javascript: 4,110,704; python: 1,419,953; asm: 946,768; xml: 739,971; pascal: 187,324; sh: 89,623; perl: 88,663; objc: 79,944; sql: 50,304; cs: 41,786; fortran: 24,137; makefile: 21,806; php: 13,980; tcl: 13,166; yacc: 8,925; ruby: 7,485; awk: 3,720; lisp: 3,096; lex: 1,327; ada: 727; jsp: 228; sed: 36
file content (3064 lines) | stat: -rw-r--r-- 98,698 bytes parent folder | download | duplicates (8)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
2336
2337
2338
2339
2340
2341
2342
2343
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
2359
2360
2361
2362
2363
2364
2365
2366
2367
2368
2369
2370
2371
2372
2373
2374
2375
2376
2377
2378
2379
2380
2381
2382
2383
2384
2385
2386
2387
2388
2389
2390
2391
2392
2393
2394
2395
2396
2397
2398
2399
2400
2401
2402
2403
2404
2405
2406
2407
2408
2409
2410
2411
2412
2413
2414
2415
2416
2417
2418
2419
2420
2421
2422
2423
2424
2425
2426
2427
2428
2429
2430
2431
2432
2433
2434
2435
2436
2437
2438
2439
2440
2441
2442
2443
2444
2445
2446
2447
2448
2449
2450
2451
2452
2453
2454
2455
2456
2457
2458
2459
2460
2461
2462
2463
2464
2465
2466
2467
2468
2469
2470
2471
2472
2473
2474
2475
2476
2477
2478
2479
2480
2481
2482
2483
2484
2485
2486
2487
2488
2489
2490
2491
2492
2493
2494
2495
2496
2497
2498
2499
2500
2501
2502
2503
2504
2505
2506
2507
2508
2509
2510
2511
2512
2513
2514
2515
2516
2517
2518
2519
2520
2521
2522
2523
2524
2525
2526
2527
2528
2529
2530
2531
2532
2533
2534
2535
2536
2537
2538
2539
2540
2541
2542
2543
2544
2545
2546
2547
2548
2549
2550
2551
2552
2553
2554
2555
2556
2557
2558
2559
2560
2561
2562
2563
2564
2565
2566
2567
2568
2569
2570
2571
2572
2573
2574
2575
2576
2577
2578
2579
2580
2581
2582
2583
2584
2585
2586
2587
2588
2589
2590
2591
2592
2593
2594
2595
2596
2597
2598
2599
2600
2601
2602
2603
2604
2605
2606
2607
2608
2609
2610
2611
2612
2613
2614
2615
2616
2617
2618
2619
2620
2621
2622
2623
2624
2625
2626
2627
2628
2629
2630
2631
2632
2633
2634
2635
2636
2637
2638
2639
2640
2641
2642
2643
2644
2645
2646
2647
2648
2649
2650
2651
2652
2653
2654
2655
2656
2657
2658
2659
2660
2661
2662
2663
2664
2665
2666
2667
2668
2669
2670
2671
2672
2673
2674
2675
2676
2677
2678
2679
2680
2681
2682
2683
2684
2685
2686
2687
2688
2689
2690
2691
2692
2693
2694
2695
2696
2697
2698
2699
2700
2701
2702
2703
2704
2705
2706
2707
2708
2709
2710
2711
2712
2713
2714
2715
2716
2717
2718
2719
2720
2721
2722
2723
2724
2725
2726
2727
2728
2729
2730
2731
2732
2733
2734
2735
2736
2737
2738
2739
2740
2741
2742
2743
2744
2745
2746
2747
2748
2749
2750
2751
2752
2753
2754
2755
2756
2757
2758
2759
2760
2761
2762
2763
2764
2765
2766
2767
2768
2769
2770
2771
2772
2773
2774
2775
2776
2777
2778
2779
2780
2781
2782
2783
2784
2785
2786
2787
2788
2789
2790
2791
2792
2793
2794
2795
2796
2797
2798
2799
2800
2801
2802
2803
2804
2805
2806
2807
2808
2809
2810
2811
2812
2813
2814
2815
2816
2817
2818
2819
2820
2821
2822
2823
2824
2825
2826
2827
2828
2829
2830
2831
2832
2833
2834
2835
2836
2837
2838
2839
2840
2841
2842
2843
2844
2845
2846
2847
2848
2849
2850
2851
2852
2853
2854
2855
2856
2857
2858
2859
2860
2861
2862
2863
2864
2865
2866
2867
2868
2869
2870
2871
2872
2873
2874
2875
2876
2877
2878
2879
2880
2881
2882
2883
2884
2885
2886
2887
2888
2889
2890
2891
2892
2893
2894
2895
2896
2897
2898
2899
2900
2901
2902
2903
2904
2905
2906
2907
2908
2909
2910
2911
2912
2913
2914
2915
2916
2917
2918
2919
2920
2921
2922
2923
2924
2925
2926
2927
2928
2929
2930
2931
2932
2933
2934
2935
2936
2937
2938
2939
2940
2941
2942
2943
2944
2945
2946
2947
2948
2949
2950
2951
2952
2953
2954
2955
2956
2957
2958
2959
2960
2961
2962
2963
2964
2965
2966
2967
2968
2969
2970
2971
2972
2973
2974
2975
2976
2977
2978
2979
2980
2981
2982
2983
2984
2985
2986
2987
2988
2989
2990
2991
2992
2993
2994
2995
2996
2997
2998
2999
3000
3001
3002
3003
3004
3005
3006
3007
3008
3009
3010
3011
3012
3013
3014
3015
3016
3017
3018
3019
3020
3021
3022
3023
3024
3025
3026
3027
3028
3029
3030
3031
3032
3033
3034
3035
3036
3037
3038
3039
3040
3041
3042
3043
3044
3045
3046
3047
3048
3049
3050
3051
3052
3053
3054
3055
3056
3057
3058
3059
3060
3061
3062
3063
3064
// Copyright 2021 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

// This file was automatically generated with:
// ../../ui/gfx/x/gen_xproto.py \
//    ../../third_party/xcbproto/src \
//    gen/ui/gfx/x \
//    bigreq \
//    dri3 \
//    glx \
//    randr \
//    render \
//    screensaver \
//    shape \
//    shm \
//    sync \
//    xfixes \
//    xinput \
//    xkb \
//    xproto \
//    xtest

#ifndef UI_GFX_X_GENERATED_PROTOS_XKB_H_
#define UI_GFX_X_GENERATED_PROTOS_XKB_H_

#include <array>
#include <cstddef>
#include <cstdint>
#include <cstring>
#include <optional>
#include <vector>

#include "base/component_export.h"
#include "base/files/scoped_file.h"
#include "base/memory/scoped_refptr.h"
#include "ui/gfx/x/error.h"
#include "ui/gfx/x/ref_counted_fd.h"
#include "ui/gfx/x/xproto_types.h"
#include "xproto.h"

namespace x11 {

class Connection;

template <typename Reply>
struct Response;

template <typename Reply>
class Future;

class COMPONENT_EXPORT(X11) Xkb {
 public:
  static constexpr unsigned major_version = 1;
  static constexpr unsigned minor_version = 0;

  Xkb(Connection* connection, const x11::QueryExtensionReply& info);

  uint8_t present() const { return info_.present; }
  uint8_t major_opcode() const { return info_.major_opcode; }
  uint8_t first_event() const { return info_.first_event; }
  uint8_t first_error() const { return info_.first_error; }

  Connection* connection() const { return connection_; }

  enum class Const : int {
    MaxLegalKeyCode = 255,
    PerKeyBitArraySize = 32,
    KeyNameLength = 4,
  };

  enum class EventType : int {
    NewKeyboardNotify = 1 << 0,
    MapNotify = 1 << 1,
    StateNotify = 1 << 2,
    ControlsNotify = 1 << 3,
    IndicatorStateNotify = 1 << 4,
    IndicatorMapNotify = 1 << 5,
    NamesNotify = 1 << 6,
    CompatMapNotify = 1 << 7,
    BellNotify = 1 << 8,
    ActionMessage = 1 << 9,
    AccessXNotify = 1 << 10,
    ExtensionDeviceNotify = 1 << 11,
  };

  enum class NKNDetail : int {
    Keycodes = 1 << 0,
    Geometry = 1 << 1,
    DeviceID = 1 << 2,
  };

  enum class AXNDetail : int {
    SKPress = 1 << 0,
    SKAccept = 1 << 1,
    SKReject = 1 << 2,
    SKRelease = 1 << 3,
    BKAccept = 1 << 4,
    BKReject = 1 << 5,
    AXKWarning = 1 << 6,
  };

  enum class MapPart : int {
    KeyTypes = 1 << 0,
    KeySyms = 1 << 1,
    ModifierMap = 1 << 2,
    ExplicitComponents = 1 << 3,
    KeyActions = 1 << 4,
    KeyBehaviors = 1 << 5,
    VirtualMods = 1 << 6,
    VirtualModMap = 1 << 7,
  };

  enum class SetMapFlags : int {
    ResizeTypes = 1 << 0,
    RecomputeActions = 1 << 1,
  };

  enum class StatePart : int {
    ModifierState = 1 << 0,
    ModifierBase = 1 << 1,
    ModifierLatch = 1 << 2,
    ModifierLock = 1 << 3,
    GroupState = 1 << 4,
    GroupBase = 1 << 5,
    GroupLatch = 1 << 6,
    GroupLock = 1 << 7,
    CompatState = 1 << 8,
    GrabMods = 1 << 9,
    CompatGrabMods = 1 << 10,
    LookupMods = 1 << 11,
    CompatLookupMods = 1 << 12,
    PointerButtons = 1 << 13,
  };

  enum class BoolCtrl : int {
    RepeatKeys = 1 << 0,
    SlowKeys = 1 << 1,
    BounceKeys = 1 << 2,
    StickyKeys = 1 << 3,
    MouseKeys = 1 << 4,
    MouseKeysAccel = 1 << 5,
    AccessXKeys = 1 << 6,
    AccessXTimeoutMask = 1 << 7,
    AccessXFeedbackMask = 1 << 8,
    AudibleBellMask = 1 << 9,
    Overlay1Mask = 1 << 10,
    Overlay2Mask = 1 << 11,
    IgnoreGroupLockMask = 1 << 12,
  };

  enum class Control : int {
    GroupsWrap = 1 << 27,
    InternalMods = 1 << 28,
    IgnoreLockMods = 1 << 29,
    PerKeyRepeat = 1 << 30,
    ControlsEnabled = 1 << 31,
  };

  enum class AXOption : int {
    SKPressFB = 1 << 0,
    SKAcceptFB = 1 << 1,
    FeatureFB = 1 << 2,
    SlowWarnFB = 1 << 3,
    IndicatorFB = 1 << 4,
    StickyKeysFB = 1 << 5,
    TwoKeys = 1 << 6,
    LatchToLock = 1 << 7,
    SKReleaseFB = 1 << 8,
    SKRejectFB = 1 << 9,
    BKRejectFB = 1 << 10,
    DumbBell = 1 << 11,
  };

  enum class DeviceSpec : uint16_t {};

  enum class LedClassResult : int {
    KbdFeedbackClass = 0,
    LedFeedbackClass = 4,
  };

  enum class LedClass : int {
    KbdFeedbackClass = 0,
    LedFeedbackClass = 4,
    DfltXIClass = 768,
    AllXIClasses = 1280,
  };

  enum class LedClassSpec : uint16_t {};

  enum class BellClassResult : int {
    KbdFeedbackClass = 0,
    BellFeedbackClass = 5,
  };

  enum class BellClass : int {
    KbdFeedbackClass = 0,
    BellFeedbackClass = 5,
    DfltXIClass = 768,
  };

  enum class BellClassSpec : uint16_t {};

  enum class Id : int {
    UseCoreKbd = 256,
    UseCorePtr = 512,
    DfltXIClass = 768,
    DfltXIId = 1024,
    AllXIClass = 1280,
    AllXIId = 1536,
    XINone = 65280,
  };

  enum class IDSpec : uint16_t {};

  enum class Group : int {
    c_1 = 0,
    c_2 = 1,
    c_3 = 2,
    c_4 = 3,
  };

  enum class Groups : int {
    Any = 254,
    All = 255,
  };

  enum class SetOfGroup : int {
    Group1 = 1 << 0,
    Group2 = 1 << 1,
    Group3 = 1 << 2,
    Group4 = 1 << 3,
  };

  enum class SetOfGroups : int {
    Any = 1 << 7,
  };

  enum class GroupsWrap : int {
    WrapIntoRange = 0,
    ClampIntoRange = 1 << 6,
    RedirectIntoRange = 1 << 7,
  };

  enum class VModsHigh : int {
    c_15 = 1 << 7,
    c_14 = 1 << 6,
    c_13 = 1 << 5,
    c_12 = 1 << 4,
    c_11 = 1 << 3,
    c_10 = 1 << 2,
    c_9 = 1 << 1,
    c_8 = 1 << 0,
  };

  enum class VModsLow : int {
    c_7 = 1 << 7,
    c_6 = 1 << 6,
    c_5 = 1 << 5,
    c_4 = 1 << 4,
    c_3 = 1 << 3,
    c_2 = 1 << 2,
    c_1 = 1 << 1,
    c_0 = 1 << 0,
  };

  enum class VMod : int {
    c_15 = 1 << 15,
    c_14 = 1 << 14,
    c_13 = 1 << 13,
    c_12 = 1 << 12,
    c_11 = 1 << 11,
    c_10 = 1 << 10,
    c_9 = 1 << 9,
    c_8 = 1 << 8,
    c_7 = 1 << 7,
    c_6 = 1 << 6,
    c_5 = 1 << 5,
    c_4 = 1 << 4,
    c_3 = 1 << 3,
    c_2 = 1 << 2,
    c_1 = 1 << 1,
    c_0 = 1 << 0,
  };

  enum class Explicit : int {
    VModMap = 1 << 7,
    Behavior = 1 << 6,
    AutoRepeat = 1 << 5,
    Interpret = 1 << 4,
    KeyType4 = 1 << 3,
    KeyType3 = 1 << 2,
    KeyType2 = 1 << 1,
    KeyType1 = 1 << 0,
  };

  enum class SymInterpretMatch : int {
    NoneOf = 0,
    AnyOfOrNone = 1,
    AnyOf = 2,
    AllOf = 3,
    Exactly = 4,
  };

  enum class SymInterpMatch : int {
    OpMask = 127,
    LevelOneOnly = 1 << 7,
  };

  enum class IMFlag : int {
    NoExplicit = 1 << 7,
    NoAutomatic = 1 << 6,
    LEDDrivesKB = 1 << 5,
  };

  enum class IMModsWhich : int {
    UseCompat = 1 << 4,
    UseEffective = 1 << 3,
    UseLocked = 1 << 2,
    UseLatched = 1 << 1,
    UseBase = 1 << 0,
  };

  enum class IMGroupsWhich : int {
    UseCompat = 1 << 4,
    UseEffective = 1 << 3,
    UseLocked = 1 << 2,
    UseLatched = 1 << 1,
    UseBase = 1 << 0,
  };

  enum class CMDetail : int {
    SymInterp = 1 << 0,
    GroupCompat = 1 << 1,
  };

  enum class NameDetail : int {
    Keycodes = 1 << 0,
    Geometry = 1 << 1,
    Symbols = 1 << 2,
    PhysSymbols = 1 << 3,
    Types = 1 << 4,
    Compat = 1 << 5,
    KeyTypeNames = 1 << 6,
    KTLevelNames = 1 << 7,
    IndicatorNames = 1 << 8,
    KeyNames = 1 << 9,
    KeyAliases = 1 << 10,
    VirtualModNames = 1 << 11,
    GroupNames = 1 << 12,
    RGNames = 1 << 13,
  };

  enum class GBNDetail : int {
    Types = 1 << 0,
    CompatMap = 1 << 1,
    ClientSymbols = 1 << 2,
    ServerSymbols = 1 << 3,
    IndicatorMaps = 1 << 4,
    KeyNames = 1 << 5,
    Geometry = 1 << 6,
    OtherNames = 1 << 7,
  };

  enum class XIFeature : int {
    Keyboards = 1 << 0,
    ButtonActions = 1 << 1,
    IndicatorNames = 1 << 2,
    IndicatorMaps = 1 << 3,
    IndicatorState = 1 << 4,
  };

  enum class PerClientFlag : int {
    DetectableAutoRepeat = 1 << 0,
    GrabsUseXKBState = 1 << 1,
    AutoResetControls = 1 << 2,
    LookupStateWhenGrabbed = 1 << 3,
    SendEventUsesXKBState = 1 << 4,
  };

  enum class BehaviorType : int {
    Default = 0,
    Lock = 1,
    RadioGroup = 2,
    Overlay1 = 3,
    Overlay2 = 4,
    PermamentLock = 129,
    PermamentRadioGroup = 130,
    PermamentOverlay1 = 131,
    PermamentOverlay2 = 132,
  };

  enum class String8 : char {};

  enum class DoodadType : int {
    Outline = 1,
    Solid = 2,
    Text = 3,
    Indicator = 4,
    Logo = 5,
  };

  enum class Error : int {
    BadDevice = 255,
    BadClass = 254,
    BadId = 253,
  };

  enum class Sa : int {
    ClearLocks = 1 << 0,
    LatchToLock = 1 << 1,
    UseModMapMods = 1 << 2,
    GroupAbsolute = 1 << 2,
  };

  enum class SAType : int {
    NoAction = 0,
    SetMods = 1,
    LatchMods = 2,
    LockMods = 3,
    SetGroup = 4,
    LatchGroup = 5,
    LockGroup = 6,
    MovePtr = 7,
    PtrBtn = 8,
    LockPtrBtn = 9,
    SetPtrDflt = 10,
    ISOLock = 11,
    Terminate = 12,
    SwitchScreen = 13,
    SetControls = 14,
    LockControls = 15,
    ActionMessage = 16,
    RedirectKey = 17,
    DeviceBtn = 18,
    LockDeviceBtn = 19,
    DeviceValuator = 20,
  };

  enum class SAMovePtrFlag : int {
    NoAcceleration = 1 << 0,
    MoveAbsoluteX = 1 << 1,
    MoveAbsoluteY = 1 << 2,
  };

  enum class SASetPtrDfltFlag : int {
    DfltBtnAbsolute = 1 << 2,
    AffectDfltButton = 1 << 0,
  };

  enum class SAIsoLockFlag : int {
    NoLock = 1 << 0,
    NoUnlock = 1 << 1,
    UseModMapMods = 1 << 2,
    GroupAbsolute = 1 << 2,
    ISODfltIsGroup = 1 << 3,
  };

  enum class SAIsoLockNoAffect : int {
    Ctrls = 1 << 3,
    Ptr = 1 << 4,
    Group = 1 << 5,
    Mods = 1 << 6,
  };

  enum class SwitchScreenFlag : int {
    Application = 1 << 0,
    Absolute = 1 << 2,
  };

  enum class BoolCtrlsHigh : int {
    AccessXFeedback = 1 << 0,
    AudibleBell = 1 << 1,
    Overlay1 = 1 << 2,
    Overlay2 = 1 << 3,
    IgnoreGroupLock = 1 << 4,
  };

  enum class BoolCtrlsLow : int {
    RepeatKeys = 1 << 0,
    SlowKeys = 1 << 1,
    BounceKeys = 1 << 2,
    StickyKeys = 1 << 3,
    MouseKeys = 1 << 4,
    MouseKeysAccel = 1 << 5,
    AccessXKeys = 1 << 6,
    AccessXTimeout = 1 << 7,
  };

  enum class ActionMessageFlag : int {
    OnPress = 1 << 0,
    OnRelease = 1 << 1,
    GenKeyEvent = 1 << 2,
  };

  enum class LockDeviceFlags : int {
    NoLock = 1 << 0,
    NoUnlock = 1 << 1,
  };

  enum class SAValWhat : int {
    IgnoreVal = 0,
    SetValMin = 1,
    SetValCenter = 2,
    SetValMax = 3,
    SetValRelative = 4,
    SetValAbsolute = 5,
  };

  struct IndicatorMap {
    bool operator==(const IndicatorMap& other) const {
      return flags == other.flags && whichGroups == other.whichGroups &&
             groups == other.groups && whichMods == other.whichMods &&
             mods == other.mods && realMods == other.realMods &&
             vmods == other.vmods && ctrls == other.ctrls;
    }

    IMFlag flags{};
    IMGroupsWhich whichGroups{};
    SetOfGroup groups{};
    IMModsWhich whichMods{};
    ModMask mods{};
    ModMask realMods{};
    VMod vmods{};
    BoolCtrl ctrls{};
  };

  struct ModDef {
    bool operator==(const ModDef& other) const {
      return mask == other.mask && realMods == other.realMods &&
             vmods == other.vmods;
    }

    ModMask mask{};
    ModMask realMods{};
    VMod vmods{};
  };

  struct KeyName {
    bool operator==(const KeyName& other) const { return name == other.name; }

    std::array<char, 4> name{};
  };

  struct KeyAlias {
    bool operator==(const KeyAlias& other) const {
      return real == other.real && alias == other.alias;
    }

    std::array<char, 4> real{};
    std::array<char, 4> alias{};
  };

  struct CountedString16 {
    bool operator==(const CountedString16& other) const {
      return string == other.string && alignment_pad == other.alignment_pad;
    }

    std::string string{};
    scoped_refptr<UnsizedRefCountedMemory> alignment_pad{};
  };

  struct KTMapEntry {
    bool operator==(const KTMapEntry& other) const {
      return active == other.active && mods_mask == other.mods_mask &&
             level == other.level && mods_mods == other.mods_mods &&
             mods_vmods == other.mods_vmods;
    }

    uint8_t active{};
    ModMask mods_mask{};
    uint8_t level{};
    ModMask mods_mods{};
    VMod mods_vmods{};
  };

  struct KeyType {
    bool operator==(const KeyType& other) const {
      return mods_mask == other.mods_mask && mods_mods == other.mods_mods &&
             mods_vmods == other.mods_vmods && numLevels == other.numLevels &&
             hasPreserve == other.hasPreserve && map == other.map &&
             preserve == other.preserve;
    }

    ModMask mods_mask{};
    ModMask mods_mods{};
    VMod mods_vmods{};
    uint8_t numLevels{};
    uint8_t hasPreserve{};
    std::vector<KTMapEntry> map{};
    std::vector<ModDef> preserve{};
  };

  struct KeySymMap {
    bool operator==(const KeySymMap& other) const {
      return kt_index == other.kt_index && groupInfo == other.groupInfo &&
             width == other.width && syms == other.syms;
    }

    std::array<uint8_t, 4> kt_index{};
    uint8_t groupInfo{};
    uint8_t width{};
    std::vector<KeySym> syms{};
  };

  struct CommonBehavior {
    bool operator==(const CommonBehavior& other) const {
      return type == other.type && data == other.data;
    }

    uint8_t type{};
    uint8_t data{};
  };

  struct DefaultBehavior {
    bool operator==(const DefaultBehavior& other) const {
      return type == other.type;
    }

    uint8_t type{};
  };

  struct LockBehavior {
    bool operator==(const LockBehavior& other) const {
      return type == other.type;
    }

    uint8_t type{};
  };

  struct RadioGroupBehavior {
    bool operator==(const RadioGroupBehavior& other) const {
      return type == other.type && group == other.group;
    }

    uint8_t type{};
    uint8_t group{};
  };

  struct OverlayBehavior {
    bool operator==(const OverlayBehavior& other) const {
      return type == other.type && key == other.key;
    }

    uint8_t type{};
    KeyCode key{};
  };

  struct PermamentLockBehavior {
    bool operator==(const PermamentLockBehavior& other) const {
      return type == other.type;
    }

    uint8_t type{};
  };

  struct PermamentRadioGroupBehavior {
    bool operator==(const PermamentRadioGroupBehavior& other) const {
      return type == other.type && group == other.group;
    }

    uint8_t type{};
    uint8_t group{};
  };

  struct PermamentOverlayBehavior {
    bool operator==(const PermamentOverlayBehavior& other) const {
      return type == other.type && key == other.key;
    }

    uint8_t type{};
    KeyCode key{};
  };

  union Behavior {
    Behavior() { memset(this, 0, sizeof(*this)); }

    CommonBehavior common;
    DefaultBehavior c_default;
    LockBehavior lock;
    RadioGroupBehavior radioGroup;
    OverlayBehavior overlay1;
    OverlayBehavior overlay2;
    PermamentLockBehavior permamentLock;
    PermamentRadioGroupBehavior permamentRadioGroup;
    PermamentOverlayBehavior permamentOverlay1;
    PermamentOverlayBehavior permamentOverlay2;
    uint8_t type;
  };
  static_assert(std::is_trivially_copyable<Behavior>::value, "");

  struct SetBehavior {
    KeyCode keycode{};
    Behavior behavior{};
  };

  struct SetExplicit {
    bool operator==(const SetExplicit& other) const {
      return keycode == other.keycode && c_explicit == other.c_explicit;
    }

    KeyCode keycode{};
    Explicit c_explicit{};
  };

  struct KeyModMap {
    bool operator==(const KeyModMap& other) const {
      return keycode == other.keycode && mods == other.mods;
    }

    KeyCode keycode{};
    ModMask mods{};
  };

  struct KeyVModMap {
    bool operator==(const KeyVModMap& other) const {
      return keycode == other.keycode && vmods == other.vmods;
    }

    KeyCode keycode{};
    VMod vmods{};
  };

  struct KTSetMapEntry {
    bool operator==(const KTSetMapEntry& other) const {
      return level == other.level && realMods == other.realMods &&
             virtualMods == other.virtualMods;
    }

    uint8_t level{};
    ModMask realMods{};
    VMod virtualMods{};
  };

  struct SetKeyType {
    bool operator==(const SetKeyType& other) const {
      return mask == other.mask && realMods == other.realMods &&
             virtualMods == other.virtualMods && numLevels == other.numLevels &&
             preserve == other.preserve && entries == other.entries &&
             preserve_entries == other.preserve_entries;
    }

    ModMask mask{};
    ModMask realMods{};
    VMod virtualMods{};
    uint8_t numLevels{};
    uint8_t preserve{};
    std::vector<KTSetMapEntry> entries{};
    std::vector<KTSetMapEntry> preserve_entries{};
  };

  struct Outline {
    bool operator==(const Outline& other) const {
      return cornerRadius == other.cornerRadius && points == other.points;
    }

    uint8_t cornerRadius{};
    std::vector<Point> points{};
  };

  struct Shape {
    bool operator==(const Shape& other) const {
      return name == other.name && primaryNdx == other.primaryNdx &&
             approxNdx == other.approxNdx && outlines == other.outlines;
    }

    Atom name{};
    uint8_t primaryNdx{};
    uint8_t approxNdx{};
    std::vector<Outline> outlines{};
  };

  struct Key {
    bool operator==(const Key& other) const {
      return name == other.name && gap == other.gap &&
             shapeNdx == other.shapeNdx && colorNdx == other.colorNdx;
    }

    std::array<String8, 4> name{};
    int16_t gap{};
    uint8_t shapeNdx{};
    uint8_t colorNdx{};
  };

  struct OverlayKey {
    bool operator==(const OverlayKey& other) const {
      return over == other.over && under == other.under;
    }

    std::array<String8, 4> over{};
    std::array<String8, 4> under{};
  };

  struct OverlayRow {
    bool operator==(const OverlayRow& other) const {
      return rowUnder == other.rowUnder && keys == other.keys;
    }

    uint8_t rowUnder{};
    std::vector<OverlayKey> keys{};
  };

  struct Overlay {
    bool operator==(const Overlay& other) const {
      return name == other.name && rows == other.rows;
    }

    Atom name{};
    std::vector<OverlayRow> rows{};
  };

  struct Row {
    bool operator==(const Row& other) const {
      return top == other.top && left == other.left &&
             vertical == other.vertical && keys == other.keys;
    }

    int16_t top{};
    int16_t left{};
    uint8_t vertical{};
    std::vector<Key> keys{};
  };

  struct Listing {
    bool operator==(const Listing& other) const {
      return flags == other.flags && string == other.string;
    }

    uint16_t flags{};
    std::vector<String8> string{};
  };

  struct DeviceLedInfo {
    bool operator==(const DeviceLedInfo& other) const {
      return ledClass == other.ledClass && ledID == other.ledID &&
             namesPresent == other.namesPresent &&
             mapsPresent == other.mapsPresent &&
             physIndicators == other.physIndicators && state == other.state &&
             names == other.names && maps == other.maps;
    }

    LedClass ledClass{};
    IDSpec ledID{};
    uint32_t namesPresent{};
    uint32_t mapsPresent{};
    uint32_t physIndicators{};
    uint32_t state{};
    std::vector<Atom> names{};
    std::vector<IndicatorMap> maps{};
  };

  struct KeyboardError : public x11::Error {
    uint16_t sequence{};
    uint32_t value{};
    uint16_t minorOpcode{};
    uint8_t majorOpcode{};

    std::string ToString() const override;
  };

  struct SANoAction {
    bool operator==(const SANoAction& other) const {
      return type == other.type;
    }

    SAType type{};
  };

  struct SASetMods {
    bool operator==(const SASetMods& other) const {
      return type == other.type && flags == other.flags && mask == other.mask &&
             realMods == other.realMods && vmodsHigh == other.vmodsHigh &&
             vmodsLow == other.vmodsLow;
    }

    SAType type{};
    Sa flags{};
    ModMask mask{};
    ModMask realMods{};
    VModsHigh vmodsHigh{};
    VModsLow vmodsLow{};
  };

  struct SALatchMods {
    bool operator==(const SALatchMods& other) const {
      return type == other.type && flags == other.flags && mask == other.mask &&
             realMods == other.realMods && vmodsHigh == other.vmodsHigh &&
             vmodsLow == other.vmodsLow;
    }

    SAType type{};
    Sa flags{};
    ModMask mask{};
    ModMask realMods{};
    VModsHigh vmodsHigh{};
    VModsLow vmodsLow{};
  };

  struct SALockMods {
    bool operator==(const SALockMods& other) const {
      return type == other.type && flags == other.flags && mask == other.mask &&
             realMods == other.realMods && vmodsHigh == other.vmodsHigh &&
             vmodsLow == other.vmodsLow;
    }

    SAType type{};
    Sa flags{};
    ModMask mask{};
    ModMask realMods{};
    VModsHigh vmodsHigh{};
    VModsLow vmodsLow{};
  };

  struct SASetGroup {
    bool operator==(const SASetGroup& other) const {
      return type == other.type && flags == other.flags && group == other.group;
    }

    SAType type{};
    Sa flags{};
    int8_t group{};
  };

  struct SALatchGroup {
    bool operator==(const SALatchGroup& other) const {
      return type == other.type && flags == other.flags && group == other.group;
    }

    SAType type{};
    Sa flags{};
    int8_t group{};
  };

  struct SALockGroup {
    bool operator==(const SALockGroup& other) const {
      return type == other.type && flags == other.flags && group == other.group;
    }

    SAType type{};
    Sa flags{};
    int8_t group{};
  };

  struct SAMovePtr {
    bool operator==(const SAMovePtr& other) const {
      return type == other.type && flags == other.flags &&
             xHigh == other.xHigh && xLow == other.xLow &&
             yHigh == other.yHigh && yLow == other.yLow;
    }

    SAType type{};
    SAMovePtrFlag flags{};
    int8_t xHigh{};
    uint8_t xLow{};
    int8_t yHigh{};
    uint8_t yLow{};
  };

  struct SAPtrBtn {
    bool operator==(const SAPtrBtn& other) const {
      return type == other.type && flags == other.flags &&
             count == other.count && button == other.button;
    }

    SAType type{};
    uint8_t flags{};
    uint8_t count{};
    uint8_t button{};
  };

  struct SALockPtrBtn {
    bool operator==(const SALockPtrBtn& other) const {
      return type == other.type && flags == other.flags &&
             button == other.button;
    }

    SAType type{};
    uint8_t flags{};
    uint8_t button{};
  };

  struct SASetPtrDflt {
    bool operator==(const SASetPtrDflt& other) const {
      return type == other.type && flags == other.flags &&
             affect == other.affect && value == other.value;
    }

    SAType type{};
    SASetPtrDfltFlag flags{};
    SASetPtrDfltFlag affect{};
    int8_t value{};
  };

  struct SAIsoLock {
    bool operator==(const SAIsoLock& other) const {
      return type == other.type && flags == other.flags && mask == other.mask &&
             realMods == other.realMods && group == other.group &&
             affect == other.affect && vmodsHigh == other.vmodsHigh &&
             vmodsLow == other.vmodsLow;
    }

    SAType type{};
    SAIsoLockFlag flags{};
    ModMask mask{};
    ModMask realMods{};
    int8_t group{};
    SAIsoLockNoAffect affect{};
    VModsHigh vmodsHigh{};
    VModsLow vmodsLow{};
  };

  struct SATerminate {
    bool operator==(const SATerminate& other) const {
      return type == other.type;
    }

    SAType type{};
  };

  struct SASwitchScreen {
    bool operator==(const SASwitchScreen& other) const {
      return type == other.type && flags == other.flags &&
             newScreen == other.newScreen;
    }

    SAType type{};
    uint8_t flags{};
    int8_t newScreen{};
  };

  struct SASetControls {
    bool operator==(const SASetControls& other) const {
      return type == other.type && boolCtrlsHigh == other.boolCtrlsHigh &&
             boolCtrlsLow == other.boolCtrlsLow;
    }

    SAType type{};
    BoolCtrlsHigh boolCtrlsHigh{};
    BoolCtrlsLow boolCtrlsLow{};
  };

  struct SALockControls {
    bool operator==(const SALockControls& other) const {
      return type == other.type && boolCtrlsHigh == other.boolCtrlsHigh &&
             boolCtrlsLow == other.boolCtrlsLow;
    }

    SAType type{};
    BoolCtrlsHigh boolCtrlsHigh{};
    BoolCtrlsLow boolCtrlsLow{};
  };

  struct SAActionMessage {
    bool operator==(const SAActionMessage& other) const {
      return type == other.type && flags == other.flags &&
             message == other.message;
    }

    SAType type{};
    ActionMessageFlag flags{};
    std::array<uint8_t, 6> message{};
  };

  struct SARedirectKey {
    bool operator==(const SARedirectKey& other) const {
      return type == other.type && newkey == other.newkey &&
             mask == other.mask && realModifiers == other.realModifiers &&
             vmodsMaskHigh == other.vmodsMaskHigh &&
             vmodsMaskLow == other.vmodsMaskLow &&
             vmodsHigh == other.vmodsHigh && vmodsLow == other.vmodsLow;
    }

    SAType type{};
    KeyCode newkey{};
    ModMask mask{};
    ModMask realModifiers{};
    VModsHigh vmodsMaskHigh{};
    VModsLow vmodsMaskLow{};
    VModsHigh vmodsHigh{};
    VModsLow vmodsLow{};
  };

  struct SADeviceBtn {
    bool operator==(const SADeviceBtn& other) const {
      return type == other.type && flags == other.flags &&
             count == other.count && button == other.button &&
             device == other.device;
    }

    SAType type{};
    uint8_t flags{};
    uint8_t count{};
    uint8_t button{};
    uint8_t device{};
  };

  struct SALockDeviceBtn {
    bool operator==(const SALockDeviceBtn& other) const {
      return type == other.type && flags == other.flags &&
             button == other.button && device == other.device;
    }

    SAType type{};
    LockDeviceFlags flags{};
    uint8_t button{};
    uint8_t device{};
  };

  struct SADeviceValuator {
    bool operator==(const SADeviceValuator& other) const {
      return type == other.type && device == other.device &&
             val1what == other.val1what && val1index == other.val1index &&
             val1value == other.val1value && val2what == other.val2what &&
             val2index == other.val2index && val2value == other.val2value;
    }

    SAType type{};
    uint8_t device{};
    SAValWhat val1what{};
    uint8_t val1index{};
    uint8_t val1value{};
    SAValWhat val2what{};
    uint8_t val2index{};
    uint8_t val2value{};
  };

  struct SIAction {
    bool operator==(const SIAction& other) const {
      return type == other.type && data == other.data;
    }

    SAType type{};
    std::array<uint8_t, 7> data{};
  };

  struct SymInterpret {
    bool operator==(const SymInterpret& other) const {
      return sym == other.sym && mods == other.mods && match == other.match &&
             virtualMod == other.virtualMod && flags == other.flags &&
             action == other.action;
    }

    KeySym sym{};
    ModMask mods{};
    uint8_t match{};
    VModsLow virtualMod{};
    uint8_t flags{};
    SIAction action{};
  };

  union Action {
    Action() { memset(this, 0, sizeof(*this)); }

    SANoAction noaction;
    SASetMods setmods;
    SALatchMods latchmods;
    SALockMods lockmods;
    SASetGroup setgroup;
    SALatchGroup latchgroup;
    SALockGroup lockgroup;
    SAMovePtr moveptr;
    SAPtrBtn ptrbtn;
    SALockPtrBtn lockptrbtn;
    SASetPtrDflt setptrdflt;
    SAIsoLock isolock;
    SATerminate terminate;
    SASwitchScreen switchscreen;
    SASetControls setcontrols;
    SALockControls lockcontrols;
    SAActionMessage message;
    SARedirectKey redirect;
    SADeviceBtn devbtn;
    SALockDeviceBtn lockdevbtn;
    SADeviceValuator devval;
    SAType type;
  };
  static_assert(std::is_trivially_copyable<Action>::value, "");

  struct NewKeyboardNotifyEvent {
    static constexpr uint8_t type_id = 32;
    static constexpr uint8_t opcode = 0;
    uint8_t xkbType{};
    uint16_t sequence{};
    Time time{};
    uint8_t deviceID{};
    uint8_t oldDeviceID{};
    KeyCode minKeyCode{};
    KeyCode maxKeyCode{};
    KeyCode oldMinKeyCode{};
    KeyCode oldMaxKeyCode{};
    uint8_t requestMajor{};
    uint8_t requestMinor{};
    NKNDetail changed{};
  };

  struct MapNotifyEvent {
    static constexpr uint8_t type_id = 33;
    static constexpr uint8_t opcode = 1;
    uint8_t xkbType{};
    uint16_t sequence{};
    Time time{};
    uint8_t deviceID{};
    uint8_t ptrBtnActions{};
    MapPart changed{};
    KeyCode minKeyCode{};
    KeyCode maxKeyCode{};
    uint8_t firstType{};
    uint8_t nTypes{};
    KeyCode firstKeySym{};
    uint8_t nKeySyms{};
    KeyCode firstKeyAct{};
    uint8_t nKeyActs{};
    KeyCode firstKeyBehavior{};
    uint8_t nKeyBehavior{};
    KeyCode firstKeyExplicit{};
    uint8_t nKeyExplicit{};
    KeyCode firstModMapKey{};
    uint8_t nModMapKeys{};
    KeyCode firstVModMapKey{};
    uint8_t nVModMapKeys{};
    VMod virtualMods{};
  };

  struct StateNotifyEvent {
    static constexpr uint8_t type_id = 34;
    static constexpr uint8_t opcode = 2;
    uint8_t xkbType{};
    uint16_t sequence{};
    Time time{};
    uint8_t deviceID{};
    ModMask mods{};
    ModMask baseMods{};
    ModMask latchedMods{};
    ModMask lockedMods{};
    Group group{};
    int16_t baseGroup{};
    int16_t latchedGroup{};
    Group lockedGroup{};
    ModMask compatState{};
    ModMask grabMods{};
    ModMask compatGrabMods{};
    ModMask lookupMods{};
    ModMask compatLoockupMods{};
    KeyButMask ptrBtnState{};
    StatePart changed{};
    KeyCode keycode{};
    uint8_t eventType{};
    uint8_t requestMajor{};
    uint8_t requestMinor{};
  };

  struct ControlsNotifyEvent {
    static constexpr uint8_t type_id = 35;
    static constexpr uint8_t opcode = 3;
    uint8_t xkbType{};
    uint16_t sequence{};
    Time time{};
    uint8_t deviceID{};
    uint8_t numGroups{};
    Control changedControls{};
    BoolCtrl enabledControls{};
    BoolCtrl enabledControlChanges{};
    KeyCode keycode{};
    uint8_t eventType{};
    uint8_t requestMajor{};
    uint8_t requestMinor{};
  };

  struct IndicatorStateNotifyEvent {
    static constexpr uint8_t type_id = 36;
    static constexpr uint8_t opcode = 4;
    uint8_t xkbType{};
    uint16_t sequence{};
    Time time{};
    uint8_t deviceID{};
    uint32_t state{};
    uint32_t stateChanged{};
  };

  struct IndicatorMapNotifyEvent {
    static constexpr uint8_t type_id = 37;
    static constexpr uint8_t opcode = 5;
    uint8_t xkbType{};
    uint16_t sequence{};
    Time time{};
    uint8_t deviceID{};
    uint32_t state{};
    uint32_t mapChanged{};
  };

  struct NamesNotifyEvent {
    static constexpr uint8_t type_id = 38;
    static constexpr uint8_t opcode = 6;
    uint8_t xkbType{};
    uint16_t sequence{};
    Time time{};
    uint8_t deviceID{};
    NameDetail changed{};
    uint8_t firstType{};
    uint8_t nTypes{};
    uint8_t firstLevelName{};
    uint8_t nLevelNames{};
    uint8_t nRadioGroups{};
    uint8_t nKeyAliases{};
    SetOfGroup changedGroupNames{};
    VMod changedVirtualMods{};
    KeyCode firstKey{};
    uint8_t nKeys{};
    uint32_t changedIndicators{};
  };

  struct CompatMapNotifyEvent {
    static constexpr uint8_t type_id = 39;
    static constexpr uint8_t opcode = 7;
    uint8_t xkbType{};
    uint16_t sequence{};
    Time time{};
    uint8_t deviceID{};
    SetOfGroup changedGroups{};
    uint16_t firstSI{};
    uint16_t nSI{};
    uint16_t nTotalSI{};
  };

  struct BellNotifyEvent {
    static constexpr uint8_t type_id = 40;
    static constexpr uint8_t opcode = 8;
    uint8_t xkbType{};
    uint16_t sequence{};
    Time time{};
    uint8_t deviceID{};
    BellClassResult bellClass{};
    uint8_t bellID{};
    uint8_t percent{};
    uint16_t pitch{};
    uint16_t duration{};
    Atom name{};
    Window window{};
    uint8_t eventOnly{};
  };

  struct ActionMessageEvent {
    static constexpr uint8_t type_id = 41;
    static constexpr uint8_t opcode = 9;
    uint8_t xkbType{};
    uint16_t sequence{};
    Time time{};
    uint8_t deviceID{};
    KeyCode keycode{};
    uint8_t press{};
    uint8_t keyEventFollows{};
    ModMask mods{};
    Group group{};
    std::array<String8, 8> message{};
  };

  struct AccessXNotifyEvent {
    static constexpr uint8_t type_id = 42;
    static constexpr uint8_t opcode = 10;
    uint8_t xkbType{};
    uint16_t sequence{};
    Time time{};
    uint8_t deviceID{};
    KeyCode keycode{};
    AXNDetail detailt{};
    uint16_t slowKeysDelay{};
    uint16_t debounceDelay{};
  };

  struct ExtensionDeviceNotifyEvent {
    static constexpr uint8_t type_id = 43;
    static constexpr uint8_t opcode = 11;
    uint8_t xkbType{};
    uint16_t sequence{};
    Time time{};
    uint8_t deviceID{};
    XIFeature reason{};
    LedClassResult ledClass{};
    uint16_t ledID{};
    uint32_t ledsDefined{};
    uint32_t ledState{};
    uint8_t firstButton{};
    uint8_t nButtons{};
    XIFeature supported{};
    XIFeature unsupported{};
  };

  struct UseExtensionRequest {
    uint16_t wantedMajor{};
    uint16_t wantedMinor{};
  };

  struct UseExtensionReply {
    uint8_t supported{};
    uint16_t sequence{};
    uint16_t serverMajor{};
    uint16_t serverMinor{};
  };

  using UseExtensionResponse = Response<UseExtensionReply>;

  Future<UseExtensionReply> UseExtension(const UseExtensionRequest& request);

  Future<UseExtensionReply> UseExtension(const uint16_t& wantedMajor = {},
                                         const uint16_t& wantedMinor = {});

  struct SelectEventsRequest {
    DeviceSpec deviceSpec{};
    EventType affectWhich{};
    EventType clear{};
    EventType selectAll{};
    MapPart affectMap{};
    MapPart map{};
    std::optional<NKNDetail> affectNewKeyboard{};
    std::optional<NKNDetail> newKeyboardDetails{};
    std::optional<StatePart> affectState{};
    std::optional<StatePart> stateDetails{};
    std::optional<Control> affectCtrls{};
    std::optional<Control> ctrlDetails{};
    std::optional<uint32_t> affectIndicatorState{};
    std::optional<uint32_t> indicatorStateDetails{};
    std::optional<uint32_t> affectIndicatorMap{};
    std::optional<uint32_t> indicatorMapDetails{};
    std::optional<NameDetail> affectNames{};
    std::optional<NameDetail> namesDetails{};
    std::optional<CMDetail> affectCompat{};
    std::optional<CMDetail> compatDetails{};
    std::optional<uint8_t> affectBell{};
    std::optional<uint8_t> bellDetails{};
    std::optional<uint8_t> affectMsgDetails{};
    std::optional<uint8_t> msgDetails{};
    std::optional<AXNDetail> affectAccessX{};
    std::optional<AXNDetail> accessXDetails{};
    std::optional<XIFeature> affectExtDev{};
    std::optional<XIFeature> extdevDetails{};
  };

  using SelectEventsResponse = Response<void>;

  Future<void> SelectEvents(const SelectEventsRequest& request);

  Future<void> SelectEvents(
      const DeviceSpec& deviceSpec = {},
      const EventType& affectWhich = {},
      const EventType& clear = {},
      const EventType& selectAll = {},
      const MapPart& affectMap = {},
      const MapPart& map = {},
      const std::optional<NKNDetail>& affectNewKeyboard = std::nullopt,
      const std::optional<NKNDetail>& newKeyboardDetails = std::nullopt,
      const std::optional<StatePart>& affectState = std::nullopt,
      const std::optional<StatePart>& stateDetails = std::nullopt,
      const std::optional<Control>& affectCtrls = std::nullopt,
      const std::optional<Control>& ctrlDetails = std::nullopt,
      const std::optional<uint32_t>& affectIndicatorState = std::nullopt,
      const std::optional<uint32_t>& indicatorStateDetails = std::nullopt,
      const std::optional<uint32_t>& affectIndicatorMap = std::nullopt,
      const std::optional<uint32_t>& indicatorMapDetails = std::nullopt,
      const std::optional<NameDetail>& affectNames = std::nullopt,
      const std::optional<NameDetail>& namesDetails = std::nullopt,
      const std::optional<CMDetail>& affectCompat = std::nullopt,
      const std::optional<CMDetail>& compatDetails = std::nullopt,
      const std::optional<uint8_t>& affectBell = std::nullopt,
      const std::optional<uint8_t>& bellDetails = std::nullopt,
      const std::optional<uint8_t>& affectMsgDetails = std::nullopt,
      const std::optional<uint8_t>& msgDetails = std::nullopt,
      const std::optional<AXNDetail>& affectAccessX = std::nullopt,
      const std::optional<AXNDetail>& accessXDetails = std::nullopt,
      const std::optional<XIFeature>& affectExtDev = std::nullopt,
      const std::optional<XIFeature>& extdevDetails = std::nullopt);

  struct BellRequest {
    DeviceSpec deviceSpec{};
    BellClassSpec bellClass{};
    IDSpec bellID{};
    int8_t percent{};
    uint8_t forceSound{};
    uint8_t eventOnly{};
    int16_t pitch{};
    int16_t duration{};
    Atom name{};
    Window window{};
  };

  using BellResponse = Response<void>;

  Future<void> Bell(const BellRequest& request);

  Future<void> Bell(const DeviceSpec& deviceSpec = {},
                    const BellClassSpec& bellClass = {},
                    const IDSpec& bellID = {},
                    const int8_t& percent = {},
                    const uint8_t& forceSound = {},
                    const uint8_t& eventOnly = {},
                    const int16_t& pitch = {},
                    const int16_t& duration = {},
                    const Atom& name = {},
                    const Window& window = {});

  struct GetStateRequest {
    DeviceSpec deviceSpec{};
  };

  struct GetStateReply {
    uint8_t deviceID{};
    uint16_t sequence{};
    ModMask mods{};
    ModMask baseMods{};
    ModMask latchedMods{};
    ModMask lockedMods{};
    Group group{};
    Group lockedGroup{};
    int16_t baseGroup{};
    int16_t latchedGroup{};
    ModMask compatState{};
    ModMask grabMods{};
    ModMask compatGrabMods{};
    ModMask lookupMods{};
    ModMask compatLookupMods{};
    KeyButMask ptrBtnState{};
  };

  using GetStateResponse = Response<GetStateReply>;

  Future<GetStateReply> GetState(const GetStateRequest& request);

  Future<GetStateReply> GetState(const DeviceSpec& deviceSpec = {});

  struct LatchLockStateRequest {
    DeviceSpec deviceSpec{};
    ModMask affectModLocks{};
    ModMask modLocks{};
    uint8_t lockGroup{};
    Group groupLock{};
    ModMask affectModLatches{};
    uint8_t latchGroup{};
    uint16_t groupLatch{};
  };

  using LatchLockStateResponse = Response<void>;

  Future<void> LatchLockState(const LatchLockStateRequest& request);

  Future<void> LatchLockState(const DeviceSpec& deviceSpec = {},
                              const ModMask& affectModLocks = {},
                              const ModMask& modLocks = {},
                              const uint8_t& lockGroup = {},
                              const Group& groupLock = {},
                              const ModMask& affectModLatches = {},
                              const uint8_t& latchGroup = {},
                              const uint16_t& groupLatch = {});

  struct GetControlsRequest {
    DeviceSpec deviceSpec{};
  };

  struct GetControlsReply {
    uint8_t deviceID{};
    uint16_t sequence{};
    uint8_t mouseKeysDfltBtn{};
    uint8_t numGroups{};
    uint8_t groupsWrap{};
    ModMask internalModsMask{};
    ModMask ignoreLockModsMask{};
    ModMask internalModsRealMods{};
    ModMask ignoreLockModsRealMods{};
    VMod internalModsVmods{};
    VMod ignoreLockModsVmods{};
    uint16_t repeatDelay{};
    uint16_t repeatInterval{};
    uint16_t slowKeysDelay{};
    uint16_t debounceDelay{};
    uint16_t mouseKeysDelay{};
    uint16_t mouseKeysInterval{};
    uint16_t mouseKeysTimeToMax{};
    uint16_t mouseKeysMaxSpeed{};
    int16_t mouseKeysCurve{};
    AXOption accessXOption{};
    uint16_t accessXTimeout{};
    AXOption accessXTimeoutOptionsMask{};
    AXOption accessXTimeoutOptionsValues{};
    BoolCtrl accessXTimeoutMask{};
    BoolCtrl accessXTimeoutValues{};
    BoolCtrl enabledControls{};
    std::array<uint8_t, 32> perKeyRepeat{};
  };

  using GetControlsResponse = Response<GetControlsReply>;

  Future<GetControlsReply> GetControls(const GetControlsRequest& request);

  Future<GetControlsReply> GetControls(const DeviceSpec& deviceSpec = {});

  struct SetControlsRequest {
    DeviceSpec deviceSpec{};
    ModMask affectInternalRealMods{};
    ModMask internalRealMods{};
    ModMask affectIgnoreLockRealMods{};
    ModMask ignoreLockRealMods{};
    VMod affectInternalVirtualMods{};
    VMod internalVirtualMods{};
    VMod affectIgnoreLockVirtualMods{};
    VMod ignoreLockVirtualMods{};
    uint8_t mouseKeysDfltBtn{};
    uint8_t groupsWrap{};
    AXOption accessXOptions{};
    BoolCtrl affectEnabledControls{};
    BoolCtrl enabledControls{};
    Control changeControls{};
    uint16_t repeatDelay{};
    uint16_t repeatInterval{};
    uint16_t slowKeysDelay{};
    uint16_t debounceDelay{};
    uint16_t mouseKeysDelay{};
    uint16_t mouseKeysInterval{};
    uint16_t mouseKeysTimeToMax{};
    uint16_t mouseKeysMaxSpeed{};
    int16_t mouseKeysCurve{};
    uint16_t accessXTimeout{};
    BoolCtrl accessXTimeoutMask{};
    BoolCtrl accessXTimeoutValues{};
    AXOption accessXTimeoutOptionsMask{};
    AXOption accessXTimeoutOptionsValues{};
    std::array<uint8_t, 32> perKeyRepeat{};
  };

  using SetControlsResponse = Response<void>;

  Future<void> SetControls(const SetControlsRequest& request);

  Future<void> SetControls(const DeviceSpec& deviceSpec = {},
                           const ModMask& affectInternalRealMods = {},
                           const ModMask& internalRealMods = {},
                           const ModMask& affectIgnoreLockRealMods = {},
                           const ModMask& ignoreLockRealMods = {},
                           const VMod& affectInternalVirtualMods = {},
                           const VMod& internalVirtualMods = {},
                           const VMod& affectIgnoreLockVirtualMods = {},
                           const VMod& ignoreLockVirtualMods = {},
                           const uint8_t& mouseKeysDfltBtn = {},
                           const uint8_t& groupsWrap = {},
                           const AXOption& accessXOptions = {},
                           const BoolCtrl& affectEnabledControls = {},
                           const BoolCtrl& enabledControls = {},
                           const Control& changeControls = {},
                           const uint16_t& repeatDelay = {},
                           const uint16_t& repeatInterval = {},
                           const uint16_t& slowKeysDelay = {},
                           const uint16_t& debounceDelay = {},
                           const uint16_t& mouseKeysDelay = {},
                           const uint16_t& mouseKeysInterval = {},
                           const uint16_t& mouseKeysTimeToMax = {},
                           const uint16_t& mouseKeysMaxSpeed = {},
                           const int16_t& mouseKeysCurve = {},
                           const uint16_t& accessXTimeout = {},
                           const BoolCtrl& accessXTimeoutMask = {},
                           const BoolCtrl& accessXTimeoutValues = {},
                           const AXOption& accessXTimeoutOptionsMask = {},
                           const AXOption& accessXTimeoutOptionsValues = {},
                           const std::array<uint8_t, 32>& perKeyRepeat = {});

  struct GetMapRequest {
    DeviceSpec deviceSpec{};
    MapPart full{};
    MapPart partial{};
    uint8_t firstType{};
    uint8_t nTypes{};
    KeyCode firstKeySym{};
    uint8_t nKeySyms{};
    KeyCode firstKeyAction{};
    uint8_t nKeyActions{};
    KeyCode firstKeyBehavior{};
    uint8_t nKeyBehaviors{};
    VMod virtualMods{};
    KeyCode firstKeyExplicit{};
    uint8_t nKeyExplicit{};
    KeyCode firstModMapKey{};
    uint8_t nModMapKeys{};
    KeyCode firstVModMapKey{};
    uint8_t nVModMapKeys{};
  };

  struct GetMapReply {
    uint8_t deviceID{};
    uint16_t sequence{};
    KeyCode minKeyCode{};
    KeyCode maxKeyCode{};
    uint8_t firstType{};
    uint8_t nTypes{};
    uint8_t totalTypes{};
    KeyCode firstKeySym{};
    uint16_t totalSyms{};
    uint8_t nKeySyms{};
    KeyCode firstKeyAction{};
    uint16_t totalActions{};
    uint8_t nKeyActions{};
    KeyCode firstKeyBehavior{};
    uint8_t nKeyBehaviors{};
    uint8_t totalKeyBehaviors{};
    KeyCode firstKeyExplicit{};
    uint8_t nKeyExplicit{};
    uint8_t totalKeyExplicit{};
    KeyCode firstModMapKey{};
    uint8_t nModMapKeys{};
    uint8_t totalModMapKeys{};
    KeyCode firstVModMapKey{};
    uint8_t nVModMapKeys{};
    uint8_t totalVModMapKeys{};
    VMod virtualMods{};
    std::optional<std::vector<KeyType>> types_rtrn{};
    std::optional<std::vector<KeySymMap>> syms_rtrn{};
    std::optional<std::vector<uint8_t>> acts_rtrn_count{};
    std::optional<std::vector<Action>> acts_rtrn_acts{};
    std::optional<std::vector<SetBehavior>> behaviors_rtrn{};
    std::optional<std::vector<ModMask>> vmods_rtrn{};
    std::optional<std::vector<SetExplicit>> explicit_rtrn{};
    std::optional<std::vector<KeyModMap>> modmap_rtrn{};
    std::optional<std::vector<KeyVModMap>> vmodmap_rtrn{};
  };

  using GetMapResponse = Response<GetMapReply>;

  Future<GetMapReply> GetMap(const GetMapRequest& request);

  Future<GetMapReply> GetMap(const DeviceSpec& deviceSpec = {},
                             const MapPart& full = {},
                             const MapPart& partial = {},
                             const uint8_t& firstType = {},
                             const uint8_t& nTypes = {},
                             const KeyCode& firstKeySym = {},
                             const uint8_t& nKeySyms = {},
                             const KeyCode& firstKeyAction = {},
                             const uint8_t& nKeyActions = {},
                             const KeyCode& firstKeyBehavior = {},
                             const uint8_t& nKeyBehaviors = {},
                             const VMod& virtualMods = {},
                             const KeyCode& firstKeyExplicit = {},
                             const uint8_t& nKeyExplicit = {},
                             const KeyCode& firstModMapKey = {},
                             const uint8_t& nModMapKeys = {},
                             const KeyCode& firstVModMapKey = {},
                             const uint8_t& nVModMapKeys = {});

  struct SetMapRequest {
    DeviceSpec deviceSpec{};
    SetMapFlags flags{};
    KeyCode minKeyCode{};
    KeyCode maxKeyCode{};
    uint8_t firstType{};
    uint8_t nTypes{};
    KeyCode firstKeySym{};
    uint8_t nKeySyms{};
    uint16_t totalSyms{};
    KeyCode firstKeyAction{};
    uint8_t nKeyActions{};
    uint16_t totalActions{};
    KeyCode firstKeyBehavior{};
    uint8_t nKeyBehaviors{};
    uint8_t totalKeyBehaviors{};
    KeyCode firstKeyExplicit{};
    uint8_t nKeyExplicit{};
    uint8_t totalKeyExplicit{};
    KeyCode firstModMapKey{};
    uint8_t nModMapKeys{};
    uint8_t totalModMapKeys{};
    KeyCode firstVModMapKey{};
    uint8_t nVModMapKeys{};
    uint8_t totalVModMapKeys{};
    VMod virtualMods{};
    std::optional<std::vector<SetKeyType>> types{};
    std::optional<std::vector<KeySymMap>> syms{};
    std::optional<std::vector<uint8_t>> actionsCount{};
    std::optional<std::vector<Action>> actions{};
    std::optional<std::vector<SetBehavior>> behaviors{};
    std::optional<std::vector<uint8_t>> vmods{};
    std::optional<std::vector<SetExplicit>> c_explicit{};
    std::optional<std::vector<KeyModMap>> modmap{};
    std::optional<std::vector<KeyVModMap>> vmodmap{};
  };

  using SetMapResponse = Response<void>;

  Future<void> SetMap(const SetMapRequest& request);

  Future<void> SetMap(
      const DeviceSpec& deviceSpec = {},
      const SetMapFlags& flags = {},
      const KeyCode& minKeyCode = {},
      const KeyCode& maxKeyCode = {},
      const uint8_t& firstType = {},
      const uint8_t& nTypes = {},
      const KeyCode& firstKeySym = {},
      const uint8_t& nKeySyms = {},
      const uint16_t& totalSyms = {},
      const KeyCode& firstKeyAction = {},
      const uint8_t& nKeyActions = {},
      const uint16_t& totalActions = {},
      const KeyCode& firstKeyBehavior = {},
      const uint8_t& nKeyBehaviors = {},
      const uint8_t& totalKeyBehaviors = {},
      const KeyCode& firstKeyExplicit = {},
      const uint8_t& nKeyExplicit = {},
      const uint8_t& totalKeyExplicit = {},
      const KeyCode& firstModMapKey = {},
      const uint8_t& nModMapKeys = {},
      const uint8_t& totalModMapKeys = {},
      const KeyCode& firstVModMapKey = {},
      const uint8_t& nVModMapKeys = {},
      const uint8_t& totalVModMapKeys = {},
      const VMod& virtualMods = {},
      const std::optional<std::vector<SetKeyType>>& types = std::nullopt,
      const std::optional<std::vector<KeySymMap>>& syms = std::nullopt,
      const std::optional<std::vector<uint8_t>>& actionsCount = std::nullopt,
      const std::optional<std::vector<Action>>& actions = std::nullopt,
      const std::optional<std::vector<SetBehavior>>& behaviors = std::nullopt,
      const std::optional<std::vector<uint8_t>>& vmods = std::nullopt,
      const std::optional<std::vector<SetExplicit>>& c_explicit = std::nullopt,
      const std::optional<std::vector<KeyModMap>>& modmap = std::nullopt,
      const std::optional<std::vector<KeyVModMap>>& vmodmap = std::nullopt);

  struct GetCompatMapRequest {
    DeviceSpec deviceSpec{};
    SetOfGroup groups{};
    uint8_t getAllSI{};
    uint16_t firstSI{};
    uint16_t nSI{};
  };

  struct GetCompatMapReply {
    uint8_t deviceID{};
    uint16_t sequence{};
    SetOfGroup groupsRtrn{};
    uint16_t firstSIRtrn{};
    uint16_t nTotalSI{};
    std::vector<SymInterpret> si_rtrn{};
    std::vector<ModDef> group_rtrn{};
  };

  using GetCompatMapResponse = Response<GetCompatMapReply>;

  Future<GetCompatMapReply> GetCompatMap(const GetCompatMapRequest& request);

  Future<GetCompatMapReply> GetCompatMap(const DeviceSpec& deviceSpec = {},
                                         const SetOfGroup& groups = {},
                                         const uint8_t& getAllSI = {},
                                         const uint16_t& firstSI = {},
                                         const uint16_t& nSI = {});

  struct SetCompatMapRequest {
    DeviceSpec deviceSpec{};
    uint8_t recomputeActions{};
    uint8_t truncateSI{};
    SetOfGroup groups{};
    uint16_t firstSI{};
    std::vector<SymInterpret> si{};
    std::vector<ModDef> groupMaps{};
  };

  using SetCompatMapResponse = Response<void>;

  Future<void> SetCompatMap(const SetCompatMapRequest& request);

  Future<void> SetCompatMap(const DeviceSpec& deviceSpec = {},
                            const uint8_t& recomputeActions = {},
                            const uint8_t& truncateSI = {},
                            const SetOfGroup& groups = {},
                            const uint16_t& firstSI = {},
                            const std::vector<SymInterpret>& si = {},
                            const std::vector<ModDef>& groupMaps = {});

  struct GetIndicatorStateRequest {
    DeviceSpec deviceSpec{};
  };

  struct GetIndicatorStateReply {
    uint8_t deviceID{};
    uint16_t sequence{};
    uint32_t state{};
  };

  using GetIndicatorStateResponse = Response<GetIndicatorStateReply>;

  Future<GetIndicatorStateReply> GetIndicatorState(
      const GetIndicatorStateRequest& request);

  Future<GetIndicatorStateReply> GetIndicatorState(
      const DeviceSpec& deviceSpec = {});

  struct GetIndicatorMapRequest {
    DeviceSpec deviceSpec{};
    uint32_t which{};
  };

  struct GetIndicatorMapReply {
    uint8_t deviceID{};
    uint16_t sequence{};
    uint32_t which{};
    uint32_t realIndicators{};
    uint8_t nIndicators{};
    std::vector<IndicatorMap> maps{};
  };

  using GetIndicatorMapResponse = Response<GetIndicatorMapReply>;

  Future<GetIndicatorMapReply> GetIndicatorMap(
      const GetIndicatorMapRequest& request);

  Future<GetIndicatorMapReply> GetIndicatorMap(
      const DeviceSpec& deviceSpec = {},
      const uint32_t& which = {});

  struct SetIndicatorMapRequest {
    DeviceSpec deviceSpec{};
    uint32_t which{};
    std::vector<IndicatorMap> maps{};
  };

  using SetIndicatorMapResponse = Response<void>;

  Future<void> SetIndicatorMap(const SetIndicatorMapRequest& request);

  Future<void> SetIndicatorMap(const DeviceSpec& deviceSpec = {},
                               const uint32_t& which = {},
                               const std::vector<IndicatorMap>& maps = {});

  struct GetNamedIndicatorRequest {
    DeviceSpec deviceSpec{};
    LedClass ledClass{};
    IDSpec ledID{};
    Atom indicator{};
  };

  struct GetNamedIndicatorReply {
    uint8_t deviceID{};
    uint16_t sequence{};
    Atom indicator{};
    uint8_t found{};
    uint8_t on{};
    uint8_t realIndicator{};
    uint8_t ndx{};
    IMFlag map_flags{};
    IMGroupsWhich map_whichGroups{};
    SetOfGroups map_groups{};
    IMModsWhich map_whichMods{};
    ModMask map_mods{};
    ModMask map_realMods{};
    VMod map_vmod{};
    BoolCtrl map_ctrls{};
    uint8_t supported{};
  };

  using GetNamedIndicatorResponse = Response<GetNamedIndicatorReply>;

  Future<GetNamedIndicatorReply> GetNamedIndicator(
      const GetNamedIndicatorRequest& request);

  Future<GetNamedIndicatorReply> GetNamedIndicator(
      const DeviceSpec& deviceSpec = {},
      const LedClass& ledClass = {},
      const IDSpec& ledID = {},
      const Atom& indicator = {});

  struct SetNamedIndicatorRequest {
    DeviceSpec deviceSpec{};
    LedClass ledClass{};
    IDSpec ledID{};
    Atom indicator{};
    uint8_t setState{};
    uint8_t on{};
    uint8_t setMap{};
    uint8_t createMap{};
    IMFlag map_flags{};
    IMGroupsWhich map_whichGroups{};
    SetOfGroups map_groups{};
    IMModsWhich map_whichMods{};
    ModMask map_realMods{};
    VMod map_vmods{};
    BoolCtrl map_ctrls{};
  };

  using SetNamedIndicatorResponse = Response<void>;

  Future<void> SetNamedIndicator(const SetNamedIndicatorRequest& request);

  Future<void> SetNamedIndicator(const DeviceSpec& deviceSpec = {},
                                 const LedClass& ledClass = {},
                                 const IDSpec& ledID = {},
                                 const Atom& indicator = {},
                                 const uint8_t& setState = {},
                                 const uint8_t& on = {},
                                 const uint8_t& setMap = {},
                                 const uint8_t& createMap = {},
                                 const IMFlag& map_flags = {},
                                 const IMGroupsWhich& map_whichGroups = {},
                                 const SetOfGroups& map_groups = {},
                                 const IMModsWhich& map_whichMods = {},
                                 const ModMask& map_realMods = {},
                                 const VMod& map_vmods = {},
                                 const BoolCtrl& map_ctrls = {});

  struct GetNamesRequest {
    DeviceSpec deviceSpec{};
    NameDetail which{};
  };

  struct GetNamesReply {
    uint8_t deviceID{};
    uint16_t sequence{};
    KeyCode minKeyCode{};
    KeyCode maxKeyCode{};
    uint8_t nTypes{};
    SetOfGroup groupNames{};
    VMod virtualMods{};
    KeyCode firstKey{};
    uint8_t nKeys{};
    uint32_t indicators{};
    uint8_t nRadioGroups{};
    uint8_t nKeyAliases{};
    uint16_t nKTLevels{};
    std::optional<Atom> keycodesName{};
    std::optional<Atom> geometryName{};
    std::optional<Atom> symbolsName{};
    std::optional<Atom> physSymbolsName{};
    std::optional<Atom> typesName{};
    std::optional<Atom> compatName{};
    std::optional<std::vector<Atom>> typeNames{};
    std::optional<std::vector<uint8_t>> nLevelsPerType{};
    std::optional<std::vector<Atom>> ktLevelNames{};
    std::optional<std::vector<Atom>> indicatorNames{};
    std::optional<std::vector<Atom>> virtualModNames{};
    std::optional<std::vector<Atom>> groups{};
    std::optional<std::vector<KeyName>> keyNames{};
    std::optional<std::vector<KeyAlias>> keyAliases{};
    std::optional<std::vector<Atom>> radioGroupNames{};
  };

  using GetNamesResponse = Response<GetNamesReply>;

  Future<GetNamesReply> GetNames(const GetNamesRequest& request);

  Future<GetNamesReply> GetNames(const DeviceSpec& deviceSpec = {},
                                 const NameDetail& which = {});

  struct SetNamesRequest {
    DeviceSpec deviceSpec{};
    VMod virtualMods{};
    uint8_t firstType{};
    uint8_t nTypes{};
    uint8_t firstKTLevelt{};
    uint8_t nKTLevels{};
    uint32_t indicators{};
    SetOfGroup groupNames{};
    uint8_t nRadioGroups{};
    KeyCode firstKey{};
    uint8_t nKeys{};
    uint8_t nKeyAliases{};
    uint16_t totalKTLevelNames{};
    std::optional<Atom> keycodesName{};
    std::optional<Atom> geometryName{};
    std::optional<Atom> symbolsName{};
    std::optional<Atom> physSymbolsName{};
    std::optional<Atom> typesName{};
    std::optional<Atom> compatName{};
    std::optional<std::vector<Atom>> typeNames{};
    std::optional<std::vector<uint8_t>> nLevelsPerType{};
    std::optional<std::vector<Atom>> ktLevelNames{};
    std::optional<std::vector<Atom>> indicatorNames{};
    std::optional<std::vector<Atom>> virtualModNames{};
    std::optional<std::vector<Atom>> groups{};
    std::optional<std::vector<KeyName>> keyNames{};
    std::optional<std::vector<KeyAlias>> keyAliases{};
    std::optional<std::vector<Atom>> radioGroupNames{};
  };

  using SetNamesResponse = Response<void>;

  Future<void> SetNames(const SetNamesRequest& request);

  Future<void> SetNames(
      const DeviceSpec& deviceSpec = {},
      const VMod& virtualMods = {},
      const uint8_t& firstType = {},
      const uint8_t& nTypes = {},
      const uint8_t& firstKTLevelt = {},
      const uint8_t& nKTLevels = {},
      const uint32_t& indicators = {},
      const SetOfGroup& groupNames = {},
      const uint8_t& nRadioGroups = {},
      const KeyCode& firstKey = {},
      const uint8_t& nKeys = {},
      const uint8_t& nKeyAliases = {},
      const uint16_t& totalKTLevelNames = {},
      const std::optional<Atom>& keycodesName = std::nullopt,
      const std::optional<Atom>& geometryName = std::nullopt,
      const std::optional<Atom>& symbolsName = std::nullopt,
      const std::optional<Atom>& physSymbolsName = std::nullopt,
      const std::optional<Atom>& typesName = std::nullopt,
      const std::optional<Atom>& compatName = std::nullopt,
      const std::optional<std::vector<Atom>>& typeNames = std::nullopt,
      const std::optional<std::vector<uint8_t>>& nLevelsPerType = std::nullopt,
      const std::optional<std::vector<Atom>>& ktLevelNames = std::nullopt,
      const std::optional<std::vector<Atom>>& indicatorNames = std::nullopt,
      const std::optional<std::vector<Atom>>& virtualModNames = std::nullopt,
      const std::optional<std::vector<Atom>>& groups = std::nullopt,
      const std::optional<std::vector<KeyName>>& keyNames = std::nullopt,
      const std::optional<std::vector<KeyAlias>>& keyAliases = std::nullopt,
      const std::optional<std::vector<Atom>>& radioGroupNames = std::nullopt);

  struct PerClientFlagsRequest {
    DeviceSpec deviceSpec{};
    PerClientFlag change{};
    PerClientFlag value{};
    BoolCtrl ctrlsToChange{};
    BoolCtrl autoCtrls{};
    BoolCtrl autoCtrlsValues{};
  };

  struct PerClientFlagsReply {
    uint8_t deviceID{};
    uint16_t sequence{};
    PerClientFlag supported{};
    PerClientFlag value{};
    BoolCtrl autoCtrls{};
    BoolCtrl autoCtrlsValues{};
  };

  using PerClientFlagsResponse = Response<PerClientFlagsReply>;

  Future<PerClientFlagsReply> PerClientFlags(
      const PerClientFlagsRequest& request);

  Future<PerClientFlagsReply> PerClientFlags(
      const DeviceSpec& deviceSpec = {},
      const PerClientFlag& change = {},
      const PerClientFlag& value = {},
      const BoolCtrl& ctrlsToChange = {},
      const BoolCtrl& autoCtrls = {},
      const BoolCtrl& autoCtrlsValues = {});

  struct ListComponentsRequest {
    DeviceSpec deviceSpec{};
    uint16_t maxNames{};
  };

  struct ListComponentsReply {
    uint8_t deviceID{};
    uint16_t sequence{};
    uint16_t extra{};
    std::vector<Listing> keymaps{};
    std::vector<Listing> keycodes{};
    std::vector<Listing> types{};
    std::vector<Listing> compatMaps{};
    std::vector<Listing> symbols{};
    std::vector<Listing> geometries{};
  };

  using ListComponentsResponse = Response<ListComponentsReply>;

  Future<ListComponentsReply> ListComponents(
      const ListComponentsRequest& request);

  Future<ListComponentsReply> ListComponents(const DeviceSpec& deviceSpec = {},
                                             const uint16_t& maxNames = {});

  struct GetKbdByNameRequest {
    DeviceSpec deviceSpec{};
    GBNDetail need{};
    GBNDetail want{};
    uint8_t load{};
  };

  struct GetKbdByNameReply {
    uint8_t deviceID{};
    uint16_t sequence{};
    KeyCode minKeyCode{};
    KeyCode maxKeyCode{};
    uint8_t loaded{};
    uint8_t newKeyboard{};
    GBNDetail found{};
    struct Types {
      uint8_t getmap_type{};
      uint8_t typeDeviceID{};
      uint16_t getmap_sequence{};
      uint32_t getmap_length{};
      KeyCode typeMinKeyCode{};
      KeyCode typeMaxKeyCode{};
      uint8_t firstType{};
      uint8_t nTypes{};
      uint8_t totalTypes{};
      KeyCode firstKeySym{};
      uint16_t totalSyms{};
      uint8_t nKeySyms{};
      KeyCode firstKeyAction{};
      uint16_t totalActions{};
      uint8_t nKeyActions{};
      KeyCode firstKeyBehavior{};
      uint8_t nKeyBehaviors{};
      uint8_t totalKeyBehaviors{};
      KeyCode firstKeyExplicit{};
      uint8_t nKeyExplicit{};
      uint8_t totalKeyExplicit{};
      KeyCode firstModMapKey{};
      uint8_t nModMapKeys{};
      uint8_t totalModMapKeys{};
      KeyCode firstVModMapKey{};
      uint8_t nVModMapKeys{};
      uint8_t totalVModMapKeys{};
      VMod virtualMods{};
      std::optional<std::vector<KeyType>> types_rtrn{};
      std::optional<std::vector<KeySymMap>> syms_rtrn{};
      std::optional<std::vector<uint8_t>> acts_rtrn_count{};
      std::optional<std::vector<Action>> acts_rtrn_acts{};
      std::optional<std::vector<SetBehavior>> behaviors_rtrn{};
      std::optional<std::vector<ModMask>> vmods_rtrn{};
      std::optional<std::vector<SetExplicit>> explicit_rtrn{};
      std::optional<std::vector<KeyModMap>> modmap_rtrn{};
      std::optional<std::vector<KeyVModMap>> vmodmap_rtrn{};
    };
    struct CompatMap {
      uint8_t compatmap_type{};
      uint8_t compatDeviceID{};
      uint16_t compatmap_sequence{};
      uint32_t compatmap_length{};
      SetOfGroup groupsRtrn{};
      uint16_t firstSIRtrn{};
      uint16_t nTotalSI{};
      std::vector<SymInterpret> si_rtrn{};
      std::vector<ModDef> group_rtrn{};
    };
    struct IndicatorMaps {
      uint8_t indicatormap_type{};
      uint8_t indicatorDeviceID{};
      uint16_t indicatormap_sequence{};
      uint32_t indicatormap_length{};
      uint32_t which{};
      uint32_t realIndicators{};
      std::vector<IndicatorMap> maps{};
    };
    struct KeyNames {
      uint8_t keyname_type{};
      uint8_t keyDeviceID{};
      uint16_t keyname_sequence{};
      uint32_t keyname_length{};
      KeyCode keyMinKeyCode{};
      KeyCode keyMaxKeyCode{};
      uint8_t nTypes{};
      SetOfGroup groupNames{};
      VMod virtualMods{};
      KeyCode firstKey{};
      uint8_t nKeys{};
      uint32_t indicators{};
      uint8_t nRadioGroups{};
      uint8_t nKeyAliases{};
      uint16_t nKTLevels{};
      std::optional<Atom> keycodesName{};
      std::optional<Atom> geometryName{};
      std::optional<Atom> symbolsName{};
      std::optional<Atom> physSymbolsName{};
      std::optional<Atom> typesName{};
      std::optional<Atom> compatName{};
      std::optional<std::vector<Atom>> typeNames{};
      std::optional<std::vector<uint8_t>> nLevelsPerType{};
      std::optional<std::vector<Atom>> ktLevelNames{};
      std::optional<std::vector<Atom>> indicatorNames{};
      std::optional<std::vector<Atom>> virtualModNames{};
      std::optional<std::vector<Atom>> groups{};
      std::optional<std::vector<KeyName>> keyNames{};
      std::optional<std::vector<KeyAlias>> keyAliases{};
      std::optional<std::vector<Atom>> radioGroupNames{};
    };
    struct Geometry {
      uint8_t geometry_type{};
      uint8_t geometryDeviceID{};
      uint16_t geometry_sequence{};
      uint32_t geometry_length{};
      Atom name{};
      uint8_t geometryFound{};
      uint16_t widthMM{};
      uint16_t heightMM{};
      uint16_t nProperties{};
      uint16_t nColors{};
      uint16_t nShapes{};
      uint16_t nSections{};
      uint16_t nDoodads{};
      uint16_t nKeyAliases{};
      uint8_t baseColorNdx{};
      uint8_t labelColorNdx{};
      CountedString16 labelFont{};
    };
    std::optional<Types> types{};
    std::optional<CompatMap> compat_map{};
    std::optional<IndicatorMaps> indicator_maps{};
    std::optional<KeyNames> key_names{};
    std::optional<Geometry> geometry{};
  };

  using GetKbdByNameResponse = Response<GetKbdByNameReply>;

  Future<GetKbdByNameReply> GetKbdByName(const GetKbdByNameRequest& request);

  Future<GetKbdByNameReply> GetKbdByName(const DeviceSpec& deviceSpec = {},
                                         const GBNDetail& need = {},
                                         const GBNDetail& want = {},
                                         const uint8_t& load = {});

  struct GetDeviceInfoRequest {
    DeviceSpec deviceSpec{};
    XIFeature wanted{};
    uint8_t allButtons{};
    uint8_t firstButton{};
    uint8_t nButtons{};
    LedClass ledClass{};
    IDSpec ledID{};
  };

  struct GetDeviceInfoReply {
    uint8_t deviceID{};
    uint16_t sequence{};
    XIFeature present{};
    XIFeature supported{};
    XIFeature unsupported{};
    uint8_t firstBtnWanted{};
    uint8_t nBtnsWanted{};
    uint8_t firstBtnRtrn{};
    uint8_t totalBtns{};
    uint8_t hasOwnState{};
    uint16_t dfltKbdFB{};
    uint16_t dfltLedFB{};
    Atom devType{};
    std::vector<String8> name{};
    std::vector<Action> btnActions{};
    std::vector<DeviceLedInfo> leds{};
  };

  using GetDeviceInfoResponse = Response<GetDeviceInfoReply>;

  Future<GetDeviceInfoReply> GetDeviceInfo(const GetDeviceInfoRequest& request);

  Future<GetDeviceInfoReply> GetDeviceInfo(const DeviceSpec& deviceSpec = {},
                                           const XIFeature& wanted = {},
                                           const uint8_t& allButtons = {},
                                           const uint8_t& firstButton = {},
                                           const uint8_t& nButtons = {},
                                           const LedClass& ledClass = {},
                                           const IDSpec& ledID = {});

  struct SetDeviceInfoRequest {
    DeviceSpec deviceSpec{};
    uint8_t firstBtn{};
    XIFeature change{};
    std::vector<Action> btnActions{};
    std::vector<DeviceLedInfo> leds{};
  };

  using SetDeviceInfoResponse = Response<void>;

  Future<void> SetDeviceInfo(const SetDeviceInfoRequest& request);

  Future<void> SetDeviceInfo(const DeviceSpec& deviceSpec = {},
                             const uint8_t& firstBtn = {},
                             const XIFeature& change = {},
                             const std::vector<Action>& btnActions = {},
                             const std::vector<DeviceLedInfo>& leds = {});

  struct SetDebuggingFlagsRequest {
    uint32_t affectFlags{};
    uint32_t flags{};
    uint32_t affectCtrls{};
    uint32_t ctrls{};
    std::vector<String8> message{};
  };

  struct SetDebuggingFlagsReply {
    uint16_t sequence{};
    uint32_t currentFlags{};
    uint32_t currentCtrls{};
    uint32_t supportedFlags{};
    uint32_t supportedCtrls{};
  };

  using SetDebuggingFlagsResponse = Response<SetDebuggingFlagsReply>;

  Future<SetDebuggingFlagsReply> SetDebuggingFlags(
      const SetDebuggingFlagsRequest& request);

  Future<SetDebuggingFlagsReply> SetDebuggingFlags(
      const uint32_t& affectFlags = {},
      const uint32_t& flags = {},
      const uint32_t& affectCtrls = {},
      const uint32_t& ctrls = {},
      const std::vector<String8>& message = {});

 private:
  Connection* const connection_;
  x11::QueryExtensionReply info_{};
};

}  // namespace x11

inline constexpr x11::Xkb::Const operator|(x11::Xkb::Const l,
                                           x11::Xkb::Const r) {
  using T = std::underlying_type_t<x11::Xkb::Const>;
  return static_cast<x11::Xkb::Const>(static_cast<T>(l) | static_cast<T>(r));
}

inline constexpr x11::Xkb::Const operator&(x11::Xkb::Const l,
                                           x11::Xkb::Const r) {
  using T = std::underlying_type_t<x11::Xkb::Const>;
  return static_cast<x11::Xkb::Const>(static_cast<T>(l) & static_cast<T>(r));
}

inline constexpr x11::Xkb::EventType operator|(x11::Xkb::EventType l,
                                               x11::Xkb::EventType r) {
  using T = std::underlying_type_t<x11::Xkb::EventType>;
  return static_cast<x11::Xkb::EventType>(static_cast<T>(l) |
                                          static_cast<T>(r));
}

inline constexpr x11::Xkb::EventType operator&(x11::Xkb::EventType l,
                                               x11::Xkb::EventType r) {
  using T = std::underlying_type_t<x11::Xkb::EventType>;
  return static_cast<x11::Xkb::EventType>(static_cast<T>(l) &
                                          static_cast<T>(r));
}

inline constexpr x11::Xkb::NKNDetail operator|(x11::Xkb::NKNDetail l,
                                               x11::Xkb::NKNDetail r) {
  using T = std::underlying_type_t<x11::Xkb::NKNDetail>;
  return static_cast<x11::Xkb::NKNDetail>(static_cast<T>(l) |
                                          static_cast<T>(r));
}

inline constexpr x11::Xkb::NKNDetail operator&(x11::Xkb::NKNDetail l,
                                               x11::Xkb::NKNDetail r) {
  using T = std::underlying_type_t<x11::Xkb::NKNDetail>;
  return static_cast<x11::Xkb::NKNDetail>(static_cast<T>(l) &
                                          static_cast<T>(r));
}

inline constexpr x11::Xkb::AXNDetail operator|(x11::Xkb::AXNDetail l,
                                               x11::Xkb::AXNDetail r) {
  using T = std::underlying_type_t<x11::Xkb::AXNDetail>;
  return static_cast<x11::Xkb::AXNDetail>(static_cast<T>(l) |
                                          static_cast<T>(r));
}

inline constexpr x11::Xkb::AXNDetail operator&(x11::Xkb::AXNDetail l,
                                               x11::Xkb::AXNDetail r) {
  using T = std::underlying_type_t<x11::Xkb::AXNDetail>;
  return static_cast<x11::Xkb::AXNDetail>(static_cast<T>(l) &
                                          static_cast<T>(r));
}

inline constexpr x11::Xkb::MapPart operator|(x11::Xkb::MapPart l,
                                             x11::Xkb::MapPart r) {
  using T = std::underlying_type_t<x11::Xkb::MapPart>;
  return static_cast<x11::Xkb::MapPart>(static_cast<T>(l) | static_cast<T>(r));
}

inline constexpr x11::Xkb::MapPart operator&(x11::Xkb::MapPart l,
                                             x11::Xkb::MapPart r) {
  using T = std::underlying_type_t<x11::Xkb::MapPart>;
  return static_cast<x11::Xkb::MapPart>(static_cast<T>(l) & static_cast<T>(r));
}

inline constexpr x11::Xkb::SetMapFlags operator|(x11::Xkb::SetMapFlags l,
                                                 x11::Xkb::SetMapFlags r) {
  using T = std::underlying_type_t<x11::Xkb::SetMapFlags>;
  return static_cast<x11::Xkb::SetMapFlags>(static_cast<T>(l) |
                                            static_cast<T>(r));
}

inline constexpr x11::Xkb::SetMapFlags operator&(x11::Xkb::SetMapFlags l,
                                                 x11::Xkb::SetMapFlags r) {
  using T = std::underlying_type_t<x11::Xkb::SetMapFlags>;
  return static_cast<x11::Xkb::SetMapFlags>(static_cast<T>(l) &
                                            static_cast<T>(r));
}

inline constexpr x11::Xkb::StatePart operator|(x11::Xkb::StatePart l,
                                               x11::Xkb::StatePart r) {
  using T = std::underlying_type_t<x11::Xkb::StatePart>;
  return static_cast<x11::Xkb::StatePart>(static_cast<T>(l) |
                                          static_cast<T>(r));
}

inline constexpr x11::Xkb::StatePart operator&(x11::Xkb::StatePart l,
                                               x11::Xkb::StatePart r) {
  using T = std::underlying_type_t<x11::Xkb::StatePart>;
  return static_cast<x11::Xkb::StatePart>(static_cast<T>(l) &
                                          static_cast<T>(r));
}

inline constexpr x11::Xkb::BoolCtrl operator|(x11::Xkb::BoolCtrl l,
                                              x11::Xkb::BoolCtrl r) {
  using T = std::underlying_type_t<x11::Xkb::BoolCtrl>;
  return static_cast<x11::Xkb::BoolCtrl>(static_cast<T>(l) | static_cast<T>(r));
}

inline constexpr x11::Xkb::BoolCtrl operator&(x11::Xkb::BoolCtrl l,
                                              x11::Xkb::BoolCtrl r) {
  using T = std::underlying_type_t<x11::Xkb::BoolCtrl>;
  return static_cast<x11::Xkb::BoolCtrl>(static_cast<T>(l) & static_cast<T>(r));
}

inline constexpr x11::Xkb::Control operator|(x11::Xkb::Control l,
                                             x11::Xkb::Control r) {
  using T = std::underlying_type_t<x11::Xkb::Control>;
  return static_cast<x11::Xkb::Control>(static_cast<T>(l) | static_cast<T>(r));
}

inline constexpr x11::Xkb::Control operator&(x11::Xkb::Control l,
                                             x11::Xkb::Control r) {
  using T = std::underlying_type_t<x11::Xkb::Control>;
  return static_cast<x11::Xkb::Control>(static_cast<T>(l) & static_cast<T>(r));
}

inline constexpr x11::Xkb::AXOption operator|(x11::Xkb::AXOption l,
                                              x11::Xkb::AXOption r) {
  using T = std::underlying_type_t<x11::Xkb::AXOption>;
  return static_cast<x11::Xkb::AXOption>(static_cast<T>(l) | static_cast<T>(r));
}

inline constexpr x11::Xkb::AXOption operator&(x11::Xkb::AXOption l,
                                              x11::Xkb::AXOption r) {
  using T = std::underlying_type_t<x11::Xkb::AXOption>;
  return static_cast<x11::Xkb::AXOption>(static_cast<T>(l) & static_cast<T>(r));
}

inline constexpr x11::Xkb::LedClassResult operator|(
    x11::Xkb::LedClassResult l,
    x11::Xkb::LedClassResult r) {
  using T = std::underlying_type_t<x11::Xkb::LedClassResult>;
  return static_cast<x11::Xkb::LedClassResult>(static_cast<T>(l) |
                                               static_cast<T>(r));
}

inline constexpr x11::Xkb::LedClassResult operator&(
    x11::Xkb::LedClassResult l,
    x11::Xkb::LedClassResult r) {
  using T = std::underlying_type_t<x11::Xkb::LedClassResult>;
  return static_cast<x11::Xkb::LedClassResult>(static_cast<T>(l) &
                                               static_cast<T>(r));
}

inline constexpr x11::Xkb::LedClass operator|(x11::Xkb::LedClass l,
                                              x11::Xkb::LedClass r) {
  using T = std::underlying_type_t<x11::Xkb::LedClass>;
  return static_cast<x11::Xkb::LedClass>(static_cast<T>(l) | static_cast<T>(r));
}

inline constexpr x11::Xkb::LedClass operator&(x11::Xkb::LedClass l,
                                              x11::Xkb::LedClass r) {
  using T = std::underlying_type_t<x11::Xkb::LedClass>;
  return static_cast<x11::Xkb::LedClass>(static_cast<T>(l) & static_cast<T>(r));
}

inline constexpr x11::Xkb::BellClassResult operator|(
    x11::Xkb::BellClassResult l,
    x11::Xkb::BellClassResult r) {
  using T = std::underlying_type_t<x11::Xkb::BellClassResult>;
  return static_cast<x11::Xkb::BellClassResult>(static_cast<T>(l) |
                                                static_cast<T>(r));
}

inline constexpr x11::Xkb::BellClassResult operator&(
    x11::Xkb::BellClassResult l,
    x11::Xkb::BellClassResult r) {
  using T = std::underlying_type_t<x11::Xkb::BellClassResult>;
  return static_cast<x11::Xkb::BellClassResult>(static_cast<T>(l) &
                                                static_cast<T>(r));
}

inline constexpr x11::Xkb::BellClass operator|(x11::Xkb::BellClass l,
                                               x11::Xkb::BellClass r) {
  using T = std::underlying_type_t<x11::Xkb::BellClass>;
  return static_cast<x11::Xkb::BellClass>(static_cast<T>(l) |
                                          static_cast<T>(r));
}

inline constexpr x11::Xkb::BellClass operator&(x11::Xkb::BellClass l,
                                               x11::Xkb::BellClass r) {
  using T = std::underlying_type_t<x11::Xkb::BellClass>;
  return static_cast<x11::Xkb::BellClass>(static_cast<T>(l) &
                                          static_cast<T>(r));
}

inline constexpr x11::Xkb::Id operator|(x11::Xkb::Id l, x11::Xkb::Id r) {
  using T = std::underlying_type_t<x11::Xkb::Id>;
  return static_cast<x11::Xkb::Id>(static_cast<T>(l) | static_cast<T>(r));
}

inline constexpr x11::Xkb::Id operator&(x11::Xkb::Id l, x11::Xkb::Id r) {
  using T = std::underlying_type_t<x11::Xkb::Id>;
  return static_cast<x11::Xkb::Id>(static_cast<T>(l) & static_cast<T>(r));
}

inline constexpr x11::Xkb::Group operator|(x11::Xkb::Group l,
                                           x11::Xkb::Group r) {
  using T = std::underlying_type_t<x11::Xkb::Group>;
  return static_cast<x11::Xkb::Group>(static_cast<T>(l) | static_cast<T>(r));
}

inline constexpr x11::Xkb::Group operator&(x11::Xkb::Group l,
                                           x11::Xkb::Group r) {
  using T = std::underlying_type_t<x11::Xkb::Group>;
  return static_cast<x11::Xkb::Group>(static_cast<T>(l) & static_cast<T>(r));
}

inline constexpr x11::Xkb::Groups operator|(x11::Xkb::Groups l,
                                            x11::Xkb::Groups r) {
  using T = std::underlying_type_t<x11::Xkb::Groups>;
  return static_cast<x11::Xkb::Groups>(static_cast<T>(l) | static_cast<T>(r));
}

inline constexpr x11::Xkb::Groups operator&(x11::Xkb::Groups l,
                                            x11::Xkb::Groups r) {
  using T = std::underlying_type_t<x11::Xkb::Groups>;
  return static_cast<x11::Xkb::Groups>(static_cast<T>(l) & static_cast<T>(r));
}

inline constexpr x11::Xkb::SetOfGroup operator|(x11::Xkb::SetOfGroup l,
                                                x11::Xkb::SetOfGroup r) {
  using T = std::underlying_type_t<x11::Xkb::SetOfGroup>;
  return static_cast<x11::Xkb::SetOfGroup>(static_cast<T>(l) |
                                           static_cast<T>(r));
}

inline constexpr x11::Xkb::SetOfGroup operator&(x11::Xkb::SetOfGroup l,
                                                x11::Xkb::SetOfGroup r) {
  using T = std::underlying_type_t<x11::Xkb::SetOfGroup>;
  return static_cast<x11::Xkb::SetOfGroup>(static_cast<T>(l) &
                                           static_cast<T>(r));
}

inline constexpr x11::Xkb::SetOfGroups operator|(x11::Xkb::SetOfGroups l,
                                                 x11::Xkb::SetOfGroups r) {
  using T = std::underlying_type_t<x11::Xkb::SetOfGroups>;
  return static_cast<x11::Xkb::SetOfGroups>(static_cast<T>(l) |
                                            static_cast<T>(r));
}

inline constexpr x11::Xkb::SetOfGroups operator&(x11::Xkb::SetOfGroups l,
                                                 x11::Xkb::SetOfGroups r) {
  using T = std::underlying_type_t<x11::Xkb::SetOfGroups>;
  return static_cast<x11::Xkb::SetOfGroups>(static_cast<T>(l) &
                                            static_cast<T>(r));
}

inline constexpr x11::Xkb::GroupsWrap operator|(x11::Xkb::GroupsWrap l,
                                                x11::Xkb::GroupsWrap r) {
  using T = std::underlying_type_t<x11::Xkb::GroupsWrap>;
  return static_cast<x11::Xkb::GroupsWrap>(static_cast<T>(l) |
                                           static_cast<T>(r));
}

inline constexpr x11::Xkb::GroupsWrap operator&(x11::Xkb::GroupsWrap l,
                                                x11::Xkb::GroupsWrap r) {
  using T = std::underlying_type_t<x11::Xkb::GroupsWrap>;
  return static_cast<x11::Xkb::GroupsWrap>(static_cast<T>(l) &
                                           static_cast<T>(r));
}

inline constexpr x11::Xkb::VModsHigh operator|(x11::Xkb::VModsHigh l,
                                               x11::Xkb::VModsHigh r) {
  using T = std::underlying_type_t<x11::Xkb::VModsHigh>;
  return static_cast<x11::Xkb::VModsHigh>(static_cast<T>(l) |
                                          static_cast<T>(r));
}

inline constexpr x11::Xkb::VModsHigh operator&(x11::Xkb::VModsHigh l,
                                               x11::Xkb::VModsHigh r) {
  using T = std::underlying_type_t<x11::Xkb::VModsHigh>;
  return static_cast<x11::Xkb::VModsHigh>(static_cast<T>(l) &
                                          static_cast<T>(r));
}

inline constexpr x11::Xkb::VModsLow operator|(x11::Xkb::VModsLow l,
                                              x11::Xkb::VModsLow r) {
  using T = std::underlying_type_t<x11::Xkb::VModsLow>;
  return static_cast<x11::Xkb::VModsLow>(static_cast<T>(l) | static_cast<T>(r));
}

inline constexpr x11::Xkb::VModsLow operator&(x11::Xkb::VModsLow l,
                                              x11::Xkb::VModsLow r) {
  using T = std::underlying_type_t<x11::Xkb::VModsLow>;
  return static_cast<x11::Xkb::VModsLow>(static_cast<T>(l) & static_cast<T>(r));
}

inline constexpr x11::Xkb::VMod operator|(x11::Xkb::VMod l, x11::Xkb::VMod r) {
  using T = std::underlying_type_t<x11::Xkb::VMod>;
  return static_cast<x11::Xkb::VMod>(static_cast<T>(l) | static_cast<T>(r));
}

inline constexpr x11::Xkb::VMod operator&(x11::Xkb::VMod l, x11::Xkb::VMod r) {
  using T = std::underlying_type_t<x11::Xkb::VMod>;
  return static_cast<x11::Xkb::VMod>(static_cast<T>(l) & static_cast<T>(r));
}

inline constexpr x11::Xkb::Explicit operator|(x11::Xkb::Explicit l,
                                              x11::Xkb::Explicit r) {
  using T = std::underlying_type_t<x11::Xkb::Explicit>;
  return static_cast<x11::Xkb::Explicit>(static_cast<T>(l) | static_cast<T>(r));
}

inline constexpr x11::Xkb::Explicit operator&(x11::Xkb::Explicit l,
                                              x11::Xkb::Explicit r) {
  using T = std::underlying_type_t<x11::Xkb::Explicit>;
  return static_cast<x11::Xkb::Explicit>(static_cast<T>(l) & static_cast<T>(r));
}

inline constexpr x11::Xkb::SymInterpretMatch operator|(
    x11::Xkb::SymInterpretMatch l,
    x11::Xkb::SymInterpretMatch r) {
  using T = std::underlying_type_t<x11::Xkb::SymInterpretMatch>;
  return static_cast<x11::Xkb::SymInterpretMatch>(static_cast<T>(l) |
                                                  static_cast<T>(r));
}

inline constexpr x11::Xkb::SymInterpretMatch operator&(
    x11::Xkb::SymInterpretMatch l,
    x11::Xkb::SymInterpretMatch r) {
  using T = std::underlying_type_t<x11::Xkb::SymInterpretMatch>;
  return static_cast<x11::Xkb::SymInterpretMatch>(static_cast<T>(l) &
                                                  static_cast<T>(r));
}

inline constexpr x11::Xkb::SymInterpMatch operator|(
    x11::Xkb::SymInterpMatch l,
    x11::Xkb::SymInterpMatch r) {
  using T = std::underlying_type_t<x11::Xkb::SymInterpMatch>;
  return static_cast<x11::Xkb::SymInterpMatch>(static_cast<T>(l) |
                                               static_cast<T>(r));
}

inline constexpr x11::Xkb::SymInterpMatch operator&(
    x11::Xkb::SymInterpMatch l,
    x11::Xkb::SymInterpMatch r) {
  using T = std::underlying_type_t<x11::Xkb::SymInterpMatch>;
  return static_cast<x11::Xkb::SymInterpMatch>(static_cast<T>(l) &
                                               static_cast<T>(r));
}

inline constexpr x11::Xkb::IMFlag operator|(x11::Xkb::IMFlag l,
                                            x11::Xkb::IMFlag r) {
  using T = std::underlying_type_t<x11::Xkb::IMFlag>;
  return static_cast<x11::Xkb::IMFlag>(static_cast<T>(l) | static_cast<T>(r));
}

inline constexpr x11::Xkb::IMFlag operator&(x11::Xkb::IMFlag l,
                                            x11::Xkb::IMFlag r) {
  using T = std::underlying_type_t<x11::Xkb::IMFlag>;
  return static_cast<x11::Xkb::IMFlag>(static_cast<T>(l) & static_cast<T>(r));
}

inline constexpr x11::Xkb::IMModsWhich operator|(x11::Xkb::IMModsWhich l,
                                                 x11::Xkb::IMModsWhich r) {
  using T = std::underlying_type_t<x11::Xkb::IMModsWhich>;
  return static_cast<x11::Xkb::IMModsWhich>(static_cast<T>(l) |
                                            static_cast<T>(r));
}

inline constexpr x11::Xkb::IMModsWhich operator&(x11::Xkb::IMModsWhich l,
                                                 x11::Xkb::IMModsWhich r) {
  using T = std::underlying_type_t<x11::Xkb::IMModsWhich>;
  return static_cast<x11::Xkb::IMModsWhich>(static_cast<T>(l) &
                                            static_cast<T>(r));
}

inline constexpr x11::Xkb::IMGroupsWhich operator|(x11::Xkb::IMGroupsWhich l,
                                                   x11::Xkb::IMGroupsWhich r) {
  using T = std::underlying_type_t<x11::Xkb::IMGroupsWhich>;
  return static_cast<x11::Xkb::IMGroupsWhich>(static_cast<T>(l) |
                                              static_cast<T>(r));
}

inline constexpr x11::Xkb::IMGroupsWhich operator&(x11::Xkb::IMGroupsWhich l,
                                                   x11::Xkb::IMGroupsWhich r) {
  using T = std::underlying_type_t<x11::Xkb::IMGroupsWhich>;
  return static_cast<x11::Xkb::IMGroupsWhich>(static_cast<T>(l) &
                                              static_cast<T>(r));
}

inline constexpr x11::Xkb::CMDetail operator|(x11::Xkb::CMDetail l,
                                              x11::Xkb::CMDetail r) {
  using T = std::underlying_type_t<x11::Xkb::CMDetail>;
  return static_cast<x11::Xkb::CMDetail>(static_cast<T>(l) | static_cast<T>(r));
}

inline constexpr x11::Xkb::CMDetail operator&(x11::Xkb::CMDetail l,
                                              x11::Xkb::CMDetail r) {
  using T = std::underlying_type_t<x11::Xkb::CMDetail>;
  return static_cast<x11::Xkb::CMDetail>(static_cast<T>(l) & static_cast<T>(r));
}

inline constexpr x11::Xkb::NameDetail operator|(x11::Xkb::NameDetail l,
                                                x11::Xkb::NameDetail r) {
  using T = std::underlying_type_t<x11::Xkb::NameDetail>;
  return static_cast<x11::Xkb::NameDetail>(static_cast<T>(l) |
                                           static_cast<T>(r));
}

inline constexpr x11::Xkb::NameDetail operator&(x11::Xkb::NameDetail l,
                                                x11::Xkb::NameDetail r) {
  using T = std::underlying_type_t<x11::Xkb::NameDetail>;
  return static_cast<x11::Xkb::NameDetail>(static_cast<T>(l) &
                                           static_cast<T>(r));
}

inline constexpr x11::Xkb::GBNDetail operator|(x11::Xkb::GBNDetail l,
                                               x11::Xkb::GBNDetail r) {
  using T = std::underlying_type_t<x11::Xkb::GBNDetail>;
  return static_cast<x11::Xkb::GBNDetail>(static_cast<T>(l) |
                                          static_cast<T>(r));
}

inline constexpr x11::Xkb::GBNDetail operator&(x11::Xkb::GBNDetail l,
                                               x11::Xkb::GBNDetail r) {
  using T = std::underlying_type_t<x11::Xkb::GBNDetail>;
  return static_cast<x11::Xkb::GBNDetail>(static_cast<T>(l) &
                                          static_cast<T>(r));
}

inline constexpr x11::Xkb::XIFeature operator|(x11::Xkb::XIFeature l,
                                               x11::Xkb::XIFeature r) {
  using T = std::underlying_type_t<x11::Xkb::XIFeature>;
  return static_cast<x11::Xkb::XIFeature>(static_cast<T>(l) |
                                          static_cast<T>(r));
}

inline constexpr x11::Xkb::XIFeature operator&(x11::Xkb::XIFeature l,
                                               x11::Xkb::XIFeature r) {
  using T = std::underlying_type_t<x11::Xkb::XIFeature>;
  return static_cast<x11::Xkb::XIFeature>(static_cast<T>(l) &
                                          static_cast<T>(r));
}

inline constexpr x11::Xkb::PerClientFlag operator|(x11::Xkb::PerClientFlag l,
                                                   x11::Xkb::PerClientFlag r) {
  using T = std::underlying_type_t<x11::Xkb::PerClientFlag>;
  return static_cast<x11::Xkb::PerClientFlag>(static_cast<T>(l) |
                                              static_cast<T>(r));
}

inline constexpr x11::Xkb::PerClientFlag operator&(x11::Xkb::PerClientFlag l,
                                                   x11::Xkb::PerClientFlag r) {
  using T = std::underlying_type_t<x11::Xkb::PerClientFlag>;
  return static_cast<x11::Xkb::PerClientFlag>(static_cast<T>(l) &
                                              static_cast<T>(r));
}

inline constexpr x11::Xkb::BehaviorType operator|(x11::Xkb::BehaviorType l,
                                                  x11::Xkb::BehaviorType r) {
  using T = std::underlying_type_t<x11::Xkb::BehaviorType>;
  return static_cast<x11::Xkb::BehaviorType>(static_cast<T>(l) |
                                             static_cast<T>(r));
}

inline constexpr x11::Xkb::BehaviorType operator&(x11::Xkb::BehaviorType l,
                                                  x11::Xkb::BehaviorType r) {
  using T = std::underlying_type_t<x11::Xkb::BehaviorType>;
  return static_cast<x11::Xkb::BehaviorType>(static_cast<T>(l) &
                                             static_cast<T>(r));
}

inline constexpr x11::Xkb::DoodadType operator|(x11::Xkb::DoodadType l,
                                                x11::Xkb::DoodadType r) {
  using T = std::underlying_type_t<x11::Xkb::DoodadType>;
  return static_cast<x11::Xkb::DoodadType>(static_cast<T>(l) |
                                           static_cast<T>(r));
}

inline constexpr x11::Xkb::DoodadType operator&(x11::Xkb::DoodadType l,
                                                x11::Xkb::DoodadType r) {
  using T = std::underlying_type_t<x11::Xkb::DoodadType>;
  return static_cast<x11::Xkb::DoodadType>(static_cast<T>(l) &
                                           static_cast<T>(r));
}

inline constexpr x11::Xkb::Error operator|(x11::Xkb::Error l,
                                           x11::Xkb::Error r) {
  using T = std::underlying_type_t<x11::Xkb::Error>;
  return static_cast<x11::Xkb::Error>(static_cast<T>(l) | static_cast<T>(r));
}

inline constexpr x11::Xkb::Error operator&(x11::Xkb::Error l,
                                           x11::Xkb::Error r) {
  using T = std::underlying_type_t<x11::Xkb::Error>;
  return static_cast<x11::Xkb::Error>(static_cast<T>(l) & static_cast<T>(r));
}

inline constexpr x11::Xkb::Sa operator|(x11::Xkb::Sa l, x11::Xkb::Sa r) {
  using T = std::underlying_type_t<x11::Xkb::Sa>;
  return static_cast<x11::Xkb::Sa>(static_cast<T>(l) | static_cast<T>(r));
}

inline constexpr x11::Xkb::Sa operator&(x11::Xkb::Sa l, x11::Xkb::Sa r) {
  using T = std::underlying_type_t<x11::Xkb::Sa>;
  return static_cast<x11::Xkb::Sa>(static_cast<T>(l) & static_cast<T>(r));
}

inline constexpr x11::Xkb::SAType operator|(x11::Xkb::SAType l,
                                            x11::Xkb::SAType r) {
  using T = std::underlying_type_t<x11::Xkb::SAType>;
  return static_cast<x11::Xkb::SAType>(static_cast<T>(l) | static_cast<T>(r));
}

inline constexpr x11::Xkb::SAType operator&(x11::Xkb::SAType l,
                                            x11::Xkb::SAType r) {
  using T = std::underlying_type_t<x11::Xkb::SAType>;
  return static_cast<x11::Xkb::SAType>(static_cast<T>(l) & static_cast<T>(r));
}

inline constexpr x11::Xkb::SAMovePtrFlag operator|(x11::Xkb::SAMovePtrFlag l,
                                                   x11::Xkb::SAMovePtrFlag r) {
  using T = std::underlying_type_t<x11::Xkb::SAMovePtrFlag>;
  return static_cast<x11::Xkb::SAMovePtrFlag>(static_cast<T>(l) |
                                              static_cast<T>(r));
}

inline constexpr x11::Xkb::SAMovePtrFlag operator&(x11::Xkb::SAMovePtrFlag l,
                                                   x11::Xkb::SAMovePtrFlag r) {
  using T = std::underlying_type_t<x11::Xkb::SAMovePtrFlag>;
  return static_cast<x11::Xkb::SAMovePtrFlag>(static_cast<T>(l) &
                                              static_cast<T>(r));
}

inline constexpr x11::Xkb::SASetPtrDfltFlag operator|(
    x11::Xkb::SASetPtrDfltFlag l,
    x11::Xkb::SASetPtrDfltFlag r) {
  using T = std::underlying_type_t<x11::Xkb::SASetPtrDfltFlag>;
  return static_cast<x11::Xkb::SASetPtrDfltFlag>(static_cast<T>(l) |
                                                 static_cast<T>(r));
}

inline constexpr x11::Xkb::SASetPtrDfltFlag operator&(
    x11::Xkb::SASetPtrDfltFlag l,
    x11::Xkb::SASetPtrDfltFlag r) {
  using T = std::underlying_type_t<x11::Xkb::SASetPtrDfltFlag>;
  return static_cast<x11::Xkb::SASetPtrDfltFlag>(static_cast<T>(l) &
                                                 static_cast<T>(r));
}

inline constexpr x11::Xkb::SAIsoLockFlag operator|(x11::Xkb::SAIsoLockFlag l,
                                                   x11::Xkb::SAIsoLockFlag r) {
  using T = std::underlying_type_t<x11::Xkb::SAIsoLockFlag>;
  return static_cast<x11::Xkb::SAIsoLockFlag>(static_cast<T>(l) |
                                              static_cast<T>(r));
}

inline constexpr x11::Xkb::SAIsoLockFlag operator&(x11::Xkb::SAIsoLockFlag l,
                                                   x11::Xkb::SAIsoLockFlag r) {
  using T = std::underlying_type_t<x11::Xkb::SAIsoLockFlag>;
  return static_cast<x11::Xkb::SAIsoLockFlag>(static_cast<T>(l) &
                                              static_cast<T>(r));
}

inline constexpr x11::Xkb::SAIsoLockNoAffect operator|(
    x11::Xkb::SAIsoLockNoAffect l,
    x11::Xkb::SAIsoLockNoAffect r) {
  using T = std::underlying_type_t<x11::Xkb::SAIsoLockNoAffect>;
  return static_cast<x11::Xkb::SAIsoLockNoAffect>(static_cast<T>(l) |
                                                  static_cast<T>(r));
}

inline constexpr x11::Xkb::SAIsoLockNoAffect operator&(
    x11::Xkb::SAIsoLockNoAffect l,
    x11::Xkb::SAIsoLockNoAffect r) {
  using T = std::underlying_type_t<x11::Xkb::SAIsoLockNoAffect>;
  return static_cast<x11::Xkb::SAIsoLockNoAffect>(static_cast<T>(l) &
                                                  static_cast<T>(r));
}

inline constexpr x11::Xkb::SwitchScreenFlag operator|(
    x11::Xkb::SwitchScreenFlag l,
    x11::Xkb::SwitchScreenFlag r) {
  using T = std::underlying_type_t<x11::Xkb::SwitchScreenFlag>;
  return static_cast<x11::Xkb::SwitchScreenFlag>(static_cast<T>(l) |
                                                 static_cast<T>(r));
}

inline constexpr x11::Xkb::SwitchScreenFlag operator&(
    x11::Xkb::SwitchScreenFlag l,
    x11::Xkb::SwitchScreenFlag r) {
  using T = std::underlying_type_t<x11::Xkb::SwitchScreenFlag>;
  return static_cast<x11::Xkb::SwitchScreenFlag>(static_cast<T>(l) &
                                                 static_cast<T>(r));
}

inline constexpr x11::Xkb::BoolCtrlsHigh operator|(x11::Xkb::BoolCtrlsHigh l,
                                                   x11::Xkb::BoolCtrlsHigh r) {
  using T = std::underlying_type_t<x11::Xkb::BoolCtrlsHigh>;
  return static_cast<x11::Xkb::BoolCtrlsHigh>(static_cast<T>(l) |
                                              static_cast<T>(r));
}

inline constexpr x11::Xkb::BoolCtrlsHigh operator&(x11::Xkb::BoolCtrlsHigh l,
                                                   x11::Xkb::BoolCtrlsHigh r) {
  using T = std::underlying_type_t<x11::Xkb::BoolCtrlsHigh>;
  return static_cast<x11::Xkb::BoolCtrlsHigh>(static_cast<T>(l) &
                                              static_cast<T>(r));
}

inline constexpr x11::Xkb::BoolCtrlsLow operator|(x11::Xkb::BoolCtrlsLow l,
                                                  x11::Xkb::BoolCtrlsLow r) {
  using T = std::underlying_type_t<x11::Xkb::BoolCtrlsLow>;
  return static_cast<x11::Xkb::BoolCtrlsLow>(static_cast<T>(l) |
                                             static_cast<T>(r));
}

inline constexpr x11::Xkb::BoolCtrlsLow operator&(x11::Xkb::BoolCtrlsLow l,
                                                  x11::Xkb::BoolCtrlsLow r) {
  using T = std::underlying_type_t<x11::Xkb::BoolCtrlsLow>;
  return static_cast<x11::Xkb::BoolCtrlsLow>(static_cast<T>(l) &
                                             static_cast<T>(r));
}

inline constexpr x11::Xkb::ActionMessageFlag operator|(
    x11::Xkb::ActionMessageFlag l,
    x11::Xkb::ActionMessageFlag r) {
  using T = std::underlying_type_t<x11::Xkb::ActionMessageFlag>;
  return static_cast<x11::Xkb::ActionMessageFlag>(static_cast<T>(l) |
                                                  static_cast<T>(r));
}

inline constexpr x11::Xkb::ActionMessageFlag operator&(
    x11::Xkb::ActionMessageFlag l,
    x11::Xkb::ActionMessageFlag r) {
  using T = std::underlying_type_t<x11::Xkb::ActionMessageFlag>;
  return static_cast<x11::Xkb::ActionMessageFlag>(static_cast<T>(l) &
                                                  static_cast<T>(r));
}

inline constexpr x11::Xkb::LockDeviceFlags operator|(
    x11::Xkb::LockDeviceFlags l,
    x11::Xkb::LockDeviceFlags r) {
  using T = std::underlying_type_t<x11::Xkb::LockDeviceFlags>;
  return static_cast<x11::Xkb::LockDeviceFlags>(static_cast<T>(l) |
                                                static_cast<T>(r));
}

inline constexpr x11::Xkb::LockDeviceFlags operator&(
    x11::Xkb::LockDeviceFlags l,
    x11::Xkb::LockDeviceFlags r) {
  using T = std::underlying_type_t<x11::Xkb::LockDeviceFlags>;
  return static_cast<x11::Xkb::LockDeviceFlags>(static_cast<T>(l) &
                                                static_cast<T>(r));
}

inline constexpr x11::Xkb::SAValWhat operator|(x11::Xkb::SAValWhat l,
                                               x11::Xkb::SAValWhat r) {
  using T = std::underlying_type_t<x11::Xkb::SAValWhat>;
  return static_cast<x11::Xkb::SAValWhat>(static_cast<T>(l) |
                                          static_cast<T>(r));
}

inline constexpr x11::Xkb::SAValWhat operator&(x11::Xkb::SAValWhat l,
                                               x11::Xkb::SAValWhat r) {
  using T = std::underlying_type_t<x11::Xkb::SAValWhat>;
  return static_cast<x11::Xkb::SAValWhat>(static_cast<T>(l) &
                                          static_cast<T>(r));
}

#endif  // UI_GFX_X_GENERATED_PROTOS_XKB_H_