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
|
// Package xv is the X client API for the XVideo extension.
package xv
// This file is automatically generated from xv.xml. Edit at your peril!
import (
"github.com/BurntSushi/xgb"
"github.com/BurntSushi/xgb/shm"
"github.com/BurntSushi/xgb/xproto"
)
// Init must be called before using the XVideo extension.
func Init(c *xgb.Conn) error {
reply, err := xproto.QueryExtension(c, 6, "XVideo").Reply()
switch {
case err != nil:
return err
case !reply.Present:
return xgb.Errorf("No extension named XVideo could be found on on the server.")
}
c.ExtLock.Lock()
c.Extensions["XVideo"] = reply.MajorOpcode
c.ExtLock.Unlock()
for evNum, fun := range xgb.NewExtEventFuncs["XVideo"] {
xgb.NewEventFuncs[int(reply.FirstEvent)+evNum] = fun
}
for errNum, fun := range xgb.NewExtErrorFuncs["XVideo"] {
xgb.NewErrorFuncs[int(reply.FirstError)+errNum] = fun
}
return nil
}
func init() {
xgb.NewExtEventFuncs["XVideo"] = make(map[int]xgb.NewEventFun)
xgb.NewExtErrorFuncs["XVideo"] = make(map[int]xgb.NewErrorFun)
}
type AdaptorInfo struct {
BaseId Port
NameSize uint16
NumPorts uint16
NumFormats uint16
Type byte
// padding: 1 bytes
Name string // size: xgb.Pad((int(NameSize) * 1))
// alignment gap to multiple of 4
Formats []Format // size: xgb.Pad((int(NumFormats) * 8))
}
// AdaptorInfoRead reads a byte slice into a AdaptorInfo value.
func AdaptorInfoRead(buf []byte, v *AdaptorInfo) int {
b := 0
v.BaseId = Port(xgb.Get32(buf[b:]))
b += 4
v.NameSize = xgb.Get16(buf[b:])
b += 2
v.NumPorts = xgb.Get16(buf[b:])
b += 2
v.NumFormats = xgb.Get16(buf[b:])
b += 2
v.Type = buf[b]
b += 1
b += 1 // padding
{
byteString := make([]byte, v.NameSize)
copy(byteString[:v.NameSize], buf[b:])
v.Name = string(byteString)
b += int(v.NameSize)
}
b = (b + 3) & ^3 // alignment gap
v.Formats = make([]Format, v.NumFormats)
b += FormatReadList(buf[b:], v.Formats)
return b
}
// AdaptorInfoReadList reads a byte slice into a list of AdaptorInfo values.
func AdaptorInfoReadList(buf []byte, dest []AdaptorInfo) int {
b := 0
for i := 0; i < len(dest); i++ {
dest[i] = AdaptorInfo{}
b += AdaptorInfoRead(buf[b:], &dest[i])
}
return xgb.Pad(b)
}
// Bytes writes a AdaptorInfo value to a byte slice.
func (v AdaptorInfo) Bytes() []byte {
buf := make([]byte, (((12 + xgb.Pad((int(v.NameSize) * 1))) + 4) + xgb.Pad((int(v.NumFormats) * 8))))
b := 0
xgb.Put32(buf[b:], uint32(v.BaseId))
b += 4
xgb.Put16(buf[b:], v.NameSize)
b += 2
xgb.Put16(buf[b:], v.NumPorts)
b += 2
xgb.Put16(buf[b:], v.NumFormats)
b += 2
buf[b] = v.Type
b += 1
b += 1 // padding
copy(buf[b:], v.Name[:v.NameSize])
b += int(v.NameSize)
b = (b + 3) & ^3 // alignment gap
b += FormatListBytes(buf[b:], v.Formats)
return buf[:b]
}
// AdaptorInfoListBytes writes a list of AdaptorInfo values to a byte slice.
func AdaptorInfoListBytes(buf []byte, list []AdaptorInfo) int {
b := 0
var structBytes []byte
for _, item := range list {
structBytes = item.Bytes()
copy(buf[b:], structBytes)
b += len(structBytes)
}
return xgb.Pad(b)
}
// AdaptorInfoListSize computes the size (bytes) of a list of AdaptorInfo values.
func AdaptorInfoListSize(list []AdaptorInfo) int {
size := 0
for _, item := range list {
size += (((12 + xgb.Pad((int(item.NameSize) * 1))) + 4) + xgb.Pad((int(item.NumFormats) * 8)))
}
return size
}
const (
AttributeFlagGettable = 1
AttributeFlagSettable = 2
)
type AttributeInfo struct {
Flags uint32
Min int32
Max int32
Size uint32
Name string // size: xgb.Pad((int(Size) * 1))
// alignment gap to multiple of 4
}
// AttributeInfoRead reads a byte slice into a AttributeInfo value.
func AttributeInfoRead(buf []byte, v *AttributeInfo) int {
b := 0
v.Flags = xgb.Get32(buf[b:])
b += 4
v.Min = int32(xgb.Get32(buf[b:]))
b += 4
v.Max = int32(xgb.Get32(buf[b:]))
b += 4
v.Size = xgb.Get32(buf[b:])
b += 4
{
byteString := make([]byte, v.Size)
copy(byteString[:v.Size], buf[b:])
v.Name = string(byteString)
b += int(v.Size)
}
b = (b + 3) & ^3 // alignment gap
return b
}
// AttributeInfoReadList reads a byte slice into a list of AttributeInfo values.
func AttributeInfoReadList(buf []byte, dest []AttributeInfo) int {
b := 0
for i := 0; i < len(dest); i++ {
dest[i] = AttributeInfo{}
b += AttributeInfoRead(buf[b:], &dest[i])
}
return xgb.Pad(b)
}
// Bytes writes a AttributeInfo value to a byte slice.
func (v AttributeInfo) Bytes() []byte {
buf := make([]byte, ((16 + xgb.Pad((int(v.Size) * 1))) + 4))
b := 0
xgb.Put32(buf[b:], v.Flags)
b += 4
xgb.Put32(buf[b:], uint32(v.Min))
b += 4
xgb.Put32(buf[b:], uint32(v.Max))
b += 4
xgb.Put32(buf[b:], v.Size)
b += 4
copy(buf[b:], v.Name[:v.Size])
b += int(v.Size)
b = (b + 3) & ^3 // alignment gap
return buf[:b]
}
// AttributeInfoListBytes writes a list of AttributeInfo values to a byte slice.
func AttributeInfoListBytes(buf []byte, list []AttributeInfo) int {
b := 0
var structBytes []byte
for _, item := range list {
structBytes = item.Bytes()
copy(buf[b:], structBytes)
b += len(structBytes)
}
return xgb.Pad(b)
}
// AttributeInfoListSize computes the size (bytes) of a list of AttributeInfo values.
func AttributeInfoListSize(list []AttributeInfo) int {
size := 0
for _, item := range list {
size += ((16 + xgb.Pad((int(item.Size) * 1))) + 4)
}
return size
}
// BadBadControl is the error number for a BadBadControl.
const BadBadControl = 2
type BadControlError struct {
Sequence uint16
NiceName string
}
// BadControlErrorNew constructs a BadControlError value that implements xgb.Error from a byte slice.
func BadControlErrorNew(buf []byte) xgb.Error {
v := BadControlError{}
v.NiceName = "BadControl"
b := 1 // skip error determinant
b += 1 // don't read error number
v.Sequence = xgb.Get16(buf[b:])
b += 2
return v
}
// SequenceId returns the sequence id attached to the BadBadControl error.
// This is mostly used internally.
func (err BadControlError) SequenceId() uint16 {
return err.Sequence
}
// BadId returns the 'BadValue' number if one exists for the BadBadControl error. If no bad value exists, 0 is returned.
func (err BadControlError) BadId() uint32 {
return 0
}
// Error returns a rudimentary string representation of the BadBadControl error.
func (err BadControlError) Error() string {
fieldVals := make([]string, 0, 0)
fieldVals = append(fieldVals, "NiceName: "+err.NiceName)
fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", err.Sequence))
return "BadBadControl {" + xgb.StringsJoin(fieldVals, ", ") + "}"
}
func init() {
xgb.NewExtErrorFuncs["XVideo"][2] = BadControlErrorNew
}
// BadBadEncoding is the error number for a BadBadEncoding.
const BadBadEncoding = 1
type BadEncodingError struct {
Sequence uint16
NiceName string
}
// BadEncodingErrorNew constructs a BadEncodingError value that implements xgb.Error from a byte slice.
func BadEncodingErrorNew(buf []byte) xgb.Error {
v := BadEncodingError{}
v.NiceName = "BadEncoding"
b := 1 // skip error determinant
b += 1 // don't read error number
v.Sequence = xgb.Get16(buf[b:])
b += 2
return v
}
// SequenceId returns the sequence id attached to the BadBadEncoding error.
// This is mostly used internally.
func (err BadEncodingError) SequenceId() uint16 {
return err.Sequence
}
// BadId returns the 'BadValue' number if one exists for the BadBadEncoding error. If no bad value exists, 0 is returned.
func (err BadEncodingError) BadId() uint32 {
return 0
}
// Error returns a rudimentary string representation of the BadBadEncoding error.
func (err BadEncodingError) Error() string {
fieldVals := make([]string, 0, 0)
fieldVals = append(fieldVals, "NiceName: "+err.NiceName)
fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", err.Sequence))
return "BadBadEncoding {" + xgb.StringsJoin(fieldVals, ", ") + "}"
}
func init() {
xgb.NewExtErrorFuncs["XVideo"][1] = BadEncodingErrorNew
}
// BadBadPort is the error number for a BadBadPort.
const BadBadPort = 0
type BadPortError struct {
Sequence uint16
NiceName string
}
// BadPortErrorNew constructs a BadPortError value that implements xgb.Error from a byte slice.
func BadPortErrorNew(buf []byte) xgb.Error {
v := BadPortError{}
v.NiceName = "BadPort"
b := 1 // skip error determinant
b += 1 // don't read error number
v.Sequence = xgb.Get16(buf[b:])
b += 2
return v
}
// SequenceId returns the sequence id attached to the BadBadPort error.
// This is mostly used internally.
func (err BadPortError) SequenceId() uint16 {
return err.Sequence
}
// BadId returns the 'BadValue' number if one exists for the BadBadPort error. If no bad value exists, 0 is returned.
func (err BadPortError) BadId() uint32 {
return 0
}
// Error returns a rudimentary string representation of the BadBadPort error.
func (err BadPortError) Error() string {
fieldVals := make([]string, 0, 0)
fieldVals = append(fieldVals, "NiceName: "+err.NiceName)
fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", err.Sequence))
return "BadBadPort {" + xgb.StringsJoin(fieldVals, ", ") + "}"
}
func init() {
xgb.NewExtErrorFuncs["XVideo"][0] = BadPortErrorNew
}
type Encoding uint32
func NewEncodingId(c *xgb.Conn) (Encoding, error) {
id, err := c.NewId()
if err != nil {
return 0, err
}
return Encoding(id), nil
}
type EncodingInfo struct {
Encoding Encoding
NameSize uint16
Width uint16
Height uint16
// padding: 2 bytes
Rate Rational
Name string // size: xgb.Pad((int(NameSize) * 1))
// alignment gap to multiple of 4
}
// EncodingInfoRead reads a byte slice into a EncodingInfo value.
func EncodingInfoRead(buf []byte, v *EncodingInfo) int {
b := 0
v.Encoding = Encoding(xgb.Get32(buf[b:]))
b += 4
v.NameSize = xgb.Get16(buf[b:])
b += 2
v.Width = xgb.Get16(buf[b:])
b += 2
v.Height = xgb.Get16(buf[b:])
b += 2
b += 2 // padding
v.Rate = Rational{}
b += RationalRead(buf[b:], &v.Rate)
{
byteString := make([]byte, v.NameSize)
copy(byteString[:v.NameSize], buf[b:])
v.Name = string(byteString)
b += int(v.NameSize)
}
b = (b + 3) & ^3 // alignment gap
return b
}
// EncodingInfoReadList reads a byte slice into a list of EncodingInfo values.
func EncodingInfoReadList(buf []byte, dest []EncodingInfo) int {
b := 0
for i := 0; i < len(dest); i++ {
dest[i] = EncodingInfo{}
b += EncodingInfoRead(buf[b:], &dest[i])
}
return xgb.Pad(b)
}
// Bytes writes a EncodingInfo value to a byte slice.
func (v EncodingInfo) Bytes() []byte {
buf := make([]byte, ((20 + xgb.Pad((int(v.NameSize) * 1))) + 4))
b := 0
xgb.Put32(buf[b:], uint32(v.Encoding))
b += 4
xgb.Put16(buf[b:], v.NameSize)
b += 2
xgb.Put16(buf[b:], v.Width)
b += 2
xgb.Put16(buf[b:], v.Height)
b += 2
b += 2 // padding
{
structBytes := v.Rate.Bytes()
copy(buf[b:], structBytes)
b += len(structBytes)
}
copy(buf[b:], v.Name[:v.NameSize])
b += int(v.NameSize)
b = (b + 3) & ^3 // alignment gap
return buf[:b]
}
// EncodingInfoListBytes writes a list of EncodingInfo values to a byte slice.
func EncodingInfoListBytes(buf []byte, list []EncodingInfo) int {
b := 0
var structBytes []byte
for _, item := range list {
structBytes = item.Bytes()
copy(buf[b:], structBytes)
b += len(structBytes)
}
return xgb.Pad(b)
}
// EncodingInfoListSize computes the size (bytes) of a list of EncodingInfo values.
func EncodingInfoListSize(list []EncodingInfo) int {
size := 0
for _, item := range list {
size += ((20 + xgb.Pad((int(item.NameSize) * 1))) + 4)
}
return size
}
type Format struct {
Visual xproto.Visualid
Depth byte
// padding: 3 bytes
}
// FormatRead reads a byte slice into a Format value.
func FormatRead(buf []byte, v *Format) int {
b := 0
v.Visual = xproto.Visualid(xgb.Get32(buf[b:]))
b += 4
v.Depth = buf[b]
b += 1
b += 3 // padding
return b
}
// FormatReadList reads a byte slice into a list of Format values.
func FormatReadList(buf []byte, dest []Format) int {
b := 0
for i := 0; i < len(dest); i++ {
dest[i] = Format{}
b += FormatRead(buf[b:], &dest[i])
}
return xgb.Pad(b)
}
// Bytes writes a Format value to a byte slice.
func (v Format) Bytes() []byte {
buf := make([]byte, 8)
b := 0
xgb.Put32(buf[b:], uint32(v.Visual))
b += 4
buf[b] = v.Depth
b += 1
b += 3 // padding
return buf[:b]
}
// FormatListBytes writes a list of Format values to a byte slice.
func FormatListBytes(buf []byte, list []Format) int {
b := 0
var structBytes []byte
for _, item := range list {
structBytes = item.Bytes()
copy(buf[b:], structBytes)
b += len(structBytes)
}
return xgb.Pad(b)
}
const (
GrabPortStatusSuccess = 0
GrabPortStatusBadExtension = 1
GrabPortStatusAlreadyGrabbed = 2
GrabPortStatusInvalidTime = 3
GrabPortStatusBadReply = 4
GrabPortStatusBadAlloc = 5
)
type Image struct {
Id uint32
Width uint16
Height uint16
DataSize uint32
NumPlanes uint32
Pitches []uint32 // size: xgb.Pad((int(NumPlanes) * 4))
Offsets []uint32 // size: xgb.Pad((int(NumPlanes) * 4))
Data []byte // size: xgb.Pad((int(DataSize) * 1))
}
// ImageRead reads a byte slice into a Image value.
func ImageRead(buf []byte, v *Image) int {
b := 0
v.Id = xgb.Get32(buf[b:])
b += 4
v.Width = xgb.Get16(buf[b:])
b += 2
v.Height = xgb.Get16(buf[b:])
b += 2
v.DataSize = xgb.Get32(buf[b:])
b += 4
v.NumPlanes = xgb.Get32(buf[b:])
b += 4
v.Pitches = make([]uint32, v.NumPlanes)
for i := 0; i < int(v.NumPlanes); i++ {
v.Pitches[i] = xgb.Get32(buf[b:])
b += 4
}
v.Offsets = make([]uint32, v.NumPlanes)
for i := 0; i < int(v.NumPlanes); i++ {
v.Offsets[i] = xgb.Get32(buf[b:])
b += 4
}
v.Data = make([]byte, v.DataSize)
copy(v.Data[:v.DataSize], buf[b:])
b += int(v.DataSize)
return b
}
// ImageReadList reads a byte slice into a list of Image values.
func ImageReadList(buf []byte, dest []Image) int {
b := 0
for i := 0; i < len(dest); i++ {
dest[i] = Image{}
b += ImageRead(buf[b:], &dest[i])
}
return xgb.Pad(b)
}
// Bytes writes a Image value to a byte slice.
func (v Image) Bytes() []byte {
buf := make([]byte, (((16 + xgb.Pad((int(v.NumPlanes) * 4))) + xgb.Pad((int(v.NumPlanes) * 4))) + xgb.Pad((int(v.DataSize) * 1))))
b := 0
xgb.Put32(buf[b:], v.Id)
b += 4
xgb.Put16(buf[b:], v.Width)
b += 2
xgb.Put16(buf[b:], v.Height)
b += 2
xgb.Put32(buf[b:], v.DataSize)
b += 4
xgb.Put32(buf[b:], v.NumPlanes)
b += 4
for i := 0; i < int(v.NumPlanes); i++ {
xgb.Put32(buf[b:], v.Pitches[i])
b += 4
}
for i := 0; i < int(v.NumPlanes); i++ {
xgb.Put32(buf[b:], v.Offsets[i])
b += 4
}
copy(buf[b:], v.Data[:v.DataSize])
b += int(v.DataSize)
return buf[:b]
}
// ImageListBytes writes a list of Image values to a byte slice.
func ImageListBytes(buf []byte, list []Image) int {
b := 0
var structBytes []byte
for _, item := range list {
structBytes = item.Bytes()
copy(buf[b:], structBytes)
b += len(structBytes)
}
return xgb.Pad(b)
}
// ImageListSize computes the size (bytes) of a list of Image values.
func ImageListSize(list []Image) int {
size := 0
for _, item := range list {
size += (((16 + xgb.Pad((int(item.NumPlanes) * 4))) + xgb.Pad((int(item.NumPlanes) * 4))) + xgb.Pad((int(item.DataSize) * 1)))
}
return size
}
type ImageFormatInfo struct {
Id uint32
Type byte
ByteOrder byte
// padding: 2 bytes
Guid []byte // size: 16
Bpp byte
NumPlanes byte
// padding: 2 bytes
Depth byte
// padding: 3 bytes
RedMask uint32
GreenMask uint32
BlueMask uint32
Format byte
// padding: 3 bytes
YSampleBits uint32
USampleBits uint32
VSampleBits uint32
VhorzYPeriod uint32
VhorzUPeriod uint32
VhorzVPeriod uint32
VvertYPeriod uint32
VvertUPeriod uint32
VvertVPeriod uint32
VcompOrder []byte // size: 32
VscanlineOrder byte
// padding: 11 bytes
}
// ImageFormatInfoRead reads a byte slice into a ImageFormatInfo value.
func ImageFormatInfoRead(buf []byte, v *ImageFormatInfo) int {
b := 0
v.Id = xgb.Get32(buf[b:])
b += 4
v.Type = buf[b]
b += 1
v.ByteOrder = buf[b]
b += 1
b += 2 // padding
v.Guid = make([]byte, 16)
copy(v.Guid[:16], buf[b:])
b += int(16)
v.Bpp = buf[b]
b += 1
v.NumPlanes = buf[b]
b += 1
b += 2 // padding
v.Depth = buf[b]
b += 1
b += 3 // padding
v.RedMask = xgb.Get32(buf[b:])
b += 4
v.GreenMask = xgb.Get32(buf[b:])
b += 4
v.BlueMask = xgb.Get32(buf[b:])
b += 4
v.Format = buf[b]
b += 1
b += 3 // padding
v.YSampleBits = xgb.Get32(buf[b:])
b += 4
v.USampleBits = xgb.Get32(buf[b:])
b += 4
v.VSampleBits = xgb.Get32(buf[b:])
b += 4
v.VhorzYPeriod = xgb.Get32(buf[b:])
b += 4
v.VhorzUPeriod = xgb.Get32(buf[b:])
b += 4
v.VhorzVPeriod = xgb.Get32(buf[b:])
b += 4
v.VvertYPeriod = xgb.Get32(buf[b:])
b += 4
v.VvertUPeriod = xgb.Get32(buf[b:])
b += 4
v.VvertVPeriod = xgb.Get32(buf[b:])
b += 4
v.VcompOrder = make([]byte, 32)
copy(v.VcompOrder[:32], buf[b:])
b += int(32)
v.VscanlineOrder = buf[b]
b += 1
b += 11 // padding
return b
}
// ImageFormatInfoReadList reads a byte slice into a list of ImageFormatInfo values.
func ImageFormatInfoReadList(buf []byte, dest []ImageFormatInfo) int {
b := 0
for i := 0; i < len(dest); i++ {
dest[i] = ImageFormatInfo{}
b += ImageFormatInfoRead(buf[b:], &dest[i])
}
return xgb.Pad(b)
}
// Bytes writes a ImageFormatInfo value to a byte slice.
func (v ImageFormatInfo) Bytes() []byte {
buf := make([]byte, 128)
b := 0
xgb.Put32(buf[b:], v.Id)
b += 4
buf[b] = v.Type
b += 1
buf[b] = v.ByteOrder
b += 1
b += 2 // padding
copy(buf[b:], v.Guid[:16])
b += int(16)
buf[b] = v.Bpp
b += 1
buf[b] = v.NumPlanes
b += 1
b += 2 // padding
buf[b] = v.Depth
b += 1
b += 3 // padding
xgb.Put32(buf[b:], v.RedMask)
b += 4
xgb.Put32(buf[b:], v.GreenMask)
b += 4
xgb.Put32(buf[b:], v.BlueMask)
b += 4
buf[b] = v.Format
b += 1
b += 3 // padding
xgb.Put32(buf[b:], v.YSampleBits)
b += 4
xgb.Put32(buf[b:], v.USampleBits)
b += 4
xgb.Put32(buf[b:], v.VSampleBits)
b += 4
xgb.Put32(buf[b:], v.VhorzYPeriod)
b += 4
xgb.Put32(buf[b:], v.VhorzUPeriod)
b += 4
xgb.Put32(buf[b:], v.VhorzVPeriod)
b += 4
xgb.Put32(buf[b:], v.VvertYPeriod)
b += 4
xgb.Put32(buf[b:], v.VvertUPeriod)
b += 4
xgb.Put32(buf[b:], v.VvertVPeriod)
b += 4
copy(buf[b:], v.VcompOrder[:32])
b += int(32)
buf[b] = v.VscanlineOrder
b += 1
b += 11 // padding
return buf[:b]
}
// ImageFormatInfoListBytes writes a list of ImageFormatInfo values to a byte slice.
func ImageFormatInfoListBytes(buf []byte, list []ImageFormatInfo) int {
b := 0
var structBytes []byte
for _, item := range list {
structBytes = item.Bytes()
copy(buf[b:], structBytes)
b += len(structBytes)
}
return xgb.Pad(b)
}
// ImageFormatInfoListSize computes the size (bytes) of a list of ImageFormatInfo values.
func ImageFormatInfoListSize(list []ImageFormatInfo) int {
size := 0
for _ = range list {
size += 128
}
return size
}
const (
ImageFormatInfoFormatPacked = 0
ImageFormatInfoFormatPlanar = 1
)
const (
ImageFormatInfoTypeRgb = 0
ImageFormatInfoTypeYuv = 1
)
type Port uint32
func NewPortId(c *xgb.Conn) (Port, error) {
id, err := c.NewId()
if err != nil {
return 0, err
}
return Port(id), nil
}
// PortNotify is the event number for a PortNotifyEvent.
const PortNotify = 1
type PortNotifyEvent struct {
Sequence uint16
// padding: 1 bytes
Time xproto.Timestamp
Port Port
Attribute xproto.Atom
Value int32
}
// PortNotifyEventNew constructs a PortNotifyEvent value that implements xgb.Event from a byte slice.
func PortNotifyEventNew(buf []byte) xgb.Event {
v := PortNotifyEvent{}
b := 1 // don't read event number
b += 1 // padding
v.Sequence = xgb.Get16(buf[b:])
b += 2
v.Time = xproto.Timestamp(xgb.Get32(buf[b:]))
b += 4
v.Port = Port(xgb.Get32(buf[b:]))
b += 4
v.Attribute = xproto.Atom(xgb.Get32(buf[b:]))
b += 4
v.Value = int32(xgb.Get32(buf[b:]))
b += 4
return v
}
// Bytes writes a PortNotifyEvent value to a byte slice.
func (v PortNotifyEvent) Bytes() []byte {
buf := make([]byte, 32)
b := 0
// write event number
buf[b] = 1
b += 1
b += 1 // padding
b += 2 // skip sequence number
xgb.Put32(buf[b:], uint32(v.Time))
b += 4
xgb.Put32(buf[b:], uint32(v.Port))
b += 4
xgb.Put32(buf[b:], uint32(v.Attribute))
b += 4
xgb.Put32(buf[b:], uint32(v.Value))
b += 4
return buf
}
// SequenceId returns the sequence id attached to the PortNotify event.
// Events without a sequence number (KeymapNotify) return 0.
// This is mostly used internally.
func (v PortNotifyEvent) SequenceId() uint16 {
return v.Sequence
}
// String is a rudimentary string representation of PortNotifyEvent.
func (v PortNotifyEvent) String() string {
fieldVals := make([]string, 0, 5)
fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", v.Sequence))
fieldVals = append(fieldVals, xgb.Sprintf("Time: %d", v.Time))
fieldVals = append(fieldVals, xgb.Sprintf("Port: %d", v.Port))
fieldVals = append(fieldVals, xgb.Sprintf("Attribute: %d", v.Attribute))
fieldVals = append(fieldVals, xgb.Sprintf("Value: %d", v.Value))
return "PortNotify {" + xgb.StringsJoin(fieldVals, ", ") + "}"
}
func init() {
xgb.NewExtEventFuncs["XVideo"][1] = PortNotifyEventNew
}
type Rational struct {
Numerator int32
Denominator int32
}
// RationalRead reads a byte slice into a Rational value.
func RationalRead(buf []byte, v *Rational) int {
b := 0
v.Numerator = int32(xgb.Get32(buf[b:]))
b += 4
v.Denominator = int32(xgb.Get32(buf[b:]))
b += 4
return b
}
// RationalReadList reads a byte slice into a list of Rational values.
func RationalReadList(buf []byte, dest []Rational) int {
b := 0
for i := 0; i < len(dest); i++ {
dest[i] = Rational{}
b += RationalRead(buf[b:], &dest[i])
}
return xgb.Pad(b)
}
// Bytes writes a Rational value to a byte slice.
func (v Rational) Bytes() []byte {
buf := make([]byte, 8)
b := 0
xgb.Put32(buf[b:], uint32(v.Numerator))
b += 4
xgb.Put32(buf[b:], uint32(v.Denominator))
b += 4
return buf[:b]
}
// RationalListBytes writes a list of Rational values to a byte slice.
func RationalListBytes(buf []byte, list []Rational) int {
b := 0
var structBytes []byte
for _, item := range list {
structBytes = item.Bytes()
copy(buf[b:], structBytes)
b += len(structBytes)
}
return xgb.Pad(b)
}
const (
ScanlineOrderTopToBottom = 0
ScanlineOrderBottomToTop = 1
)
const (
TypeInputMask = 1
TypeOutputMask = 2
TypeVideoMask = 4
TypeStillMask = 8
TypeImageMask = 16
)
// VideoNotify is the event number for a VideoNotifyEvent.
const VideoNotify = 0
type VideoNotifyEvent struct {
Sequence uint16
Reason byte
Time xproto.Timestamp
Drawable xproto.Drawable
Port Port
}
// VideoNotifyEventNew constructs a VideoNotifyEvent value that implements xgb.Event from a byte slice.
func VideoNotifyEventNew(buf []byte) xgb.Event {
v := VideoNotifyEvent{}
b := 1 // don't read event number
v.Reason = buf[b]
b += 1
v.Sequence = xgb.Get16(buf[b:])
b += 2
v.Time = xproto.Timestamp(xgb.Get32(buf[b:]))
b += 4
v.Drawable = xproto.Drawable(xgb.Get32(buf[b:]))
b += 4
v.Port = Port(xgb.Get32(buf[b:]))
b += 4
return v
}
// Bytes writes a VideoNotifyEvent value to a byte slice.
func (v VideoNotifyEvent) Bytes() []byte {
buf := make([]byte, 32)
b := 0
// write event number
buf[b] = 0
b += 1
buf[b] = v.Reason
b += 1
b += 2 // skip sequence number
xgb.Put32(buf[b:], uint32(v.Time))
b += 4
xgb.Put32(buf[b:], uint32(v.Drawable))
b += 4
xgb.Put32(buf[b:], uint32(v.Port))
b += 4
return buf
}
// SequenceId returns the sequence id attached to the VideoNotify event.
// Events without a sequence number (KeymapNotify) return 0.
// This is mostly used internally.
func (v VideoNotifyEvent) SequenceId() uint16 {
return v.Sequence
}
// String is a rudimentary string representation of VideoNotifyEvent.
func (v VideoNotifyEvent) String() string {
fieldVals := make([]string, 0, 4)
fieldVals = append(fieldVals, xgb.Sprintf("Sequence: %d", v.Sequence))
fieldVals = append(fieldVals, xgb.Sprintf("Reason: %d", v.Reason))
fieldVals = append(fieldVals, xgb.Sprintf("Time: %d", v.Time))
fieldVals = append(fieldVals, xgb.Sprintf("Drawable: %d", v.Drawable))
fieldVals = append(fieldVals, xgb.Sprintf("Port: %d", v.Port))
return "VideoNotify {" + xgb.StringsJoin(fieldVals, ", ") + "}"
}
func init() {
xgb.NewExtEventFuncs["XVideo"][0] = VideoNotifyEventNew
}
const (
VideoNotifyReasonStarted = 0
VideoNotifyReasonStopped = 1
VideoNotifyReasonBusy = 2
VideoNotifyReasonPreempted = 3
VideoNotifyReasonHardError = 4
)
// Skipping definition for base type 'Bool'
// Skipping definition for base type 'Byte'
// Skipping definition for base type 'Card8'
// Skipping definition for base type 'Char'
// Skipping definition for base type 'Void'
// Skipping definition for base type 'Double'
// Skipping definition for base type 'Float'
// Skipping definition for base type 'Int16'
// Skipping definition for base type 'Int32'
// Skipping definition for base type 'Int8'
// Skipping definition for base type 'Card16'
// Skipping definition for base type 'Card32'
// GetPortAttributeCookie is a cookie used only for GetPortAttribute requests.
type GetPortAttributeCookie struct {
*xgb.Cookie
}
// GetPortAttribute sends a checked request.
// If an error occurs, it will be returned with the reply by calling GetPortAttributeCookie.Reply()
func GetPortAttribute(c *xgb.Conn, Port Port, Attribute xproto.Atom) GetPortAttributeCookie {
c.ExtLock.RLock()
defer c.ExtLock.RUnlock()
if _, ok := c.Extensions["XVideo"]; !ok {
panic("Cannot issue request 'GetPortAttribute' using the uninitialized extension 'XVideo'. xv.Init(connObj) must be called first.")
}
cookie := c.NewCookie(true, true)
c.NewRequest(getPortAttributeRequest(c, Port, Attribute), cookie)
return GetPortAttributeCookie{cookie}
}
// GetPortAttributeUnchecked sends an unchecked request.
// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent.
func GetPortAttributeUnchecked(c *xgb.Conn, Port Port, Attribute xproto.Atom) GetPortAttributeCookie {
c.ExtLock.RLock()
defer c.ExtLock.RUnlock()
if _, ok := c.Extensions["XVideo"]; !ok {
panic("Cannot issue request 'GetPortAttribute' using the uninitialized extension 'XVideo'. xv.Init(connObj) must be called first.")
}
cookie := c.NewCookie(false, true)
c.NewRequest(getPortAttributeRequest(c, Port, Attribute), cookie)
return GetPortAttributeCookie{cookie}
}
// GetPortAttributeReply represents the data returned from a GetPortAttribute request.
type GetPortAttributeReply struct {
Sequence uint16 // sequence number of the request for this reply
Length uint32 // number of bytes in this reply
// padding: 1 bytes
Value int32
}
// Reply blocks and returns the reply data for a GetPortAttribute request.
func (cook GetPortAttributeCookie) Reply() (*GetPortAttributeReply, error) {
buf, err := cook.Cookie.Reply()
if err != nil {
return nil, err
}
if buf == nil {
return nil, nil
}
return getPortAttributeReply(buf), nil
}
// getPortAttributeReply reads a byte slice into a GetPortAttributeReply value.
func getPortAttributeReply(buf []byte) *GetPortAttributeReply {
v := new(GetPortAttributeReply)
b := 1 // skip reply determinant
b += 1 // padding
v.Sequence = xgb.Get16(buf[b:])
b += 2
v.Length = xgb.Get32(buf[b:]) // 4-byte units
b += 4
v.Value = int32(xgb.Get32(buf[b:]))
b += 4
return v
}
// Write request to wire for GetPortAttribute
// getPortAttributeRequest writes a GetPortAttribute request to a byte slice.
func getPortAttributeRequest(c *xgb.Conn, Port Port, Attribute xproto.Atom) []byte {
size := 12
b := 0
buf := make([]byte, size)
c.ExtLock.RLock()
buf[b] = c.Extensions["XVideo"]
c.ExtLock.RUnlock()
b += 1
buf[b] = 14 // request opcode
b += 1
xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units
b += 2
xgb.Put32(buf[b:], uint32(Port))
b += 4
xgb.Put32(buf[b:], uint32(Attribute))
b += 4
return buf
}
// GetStillCookie is a cookie used only for GetStill requests.
type GetStillCookie struct {
*xgb.Cookie
}
// GetStill sends an unchecked request.
// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent.
func GetStill(c *xgb.Conn, Port Port, Drawable xproto.Drawable, Gc xproto.Gcontext, VidX int16, VidY int16, VidW uint16, VidH uint16, DrwX int16, DrwY int16, DrwW uint16, DrwH uint16) GetStillCookie {
c.ExtLock.RLock()
defer c.ExtLock.RUnlock()
if _, ok := c.Extensions["XVideo"]; !ok {
panic("Cannot issue request 'GetStill' using the uninitialized extension 'XVideo'. xv.Init(connObj) must be called first.")
}
cookie := c.NewCookie(false, false)
c.NewRequest(getStillRequest(c, Port, Drawable, Gc, VidX, VidY, VidW, VidH, DrwX, DrwY, DrwW, DrwH), cookie)
return GetStillCookie{cookie}
}
// GetStillChecked sends a checked request.
// If an error occurs, it can be retrieved using GetStillCookie.Check()
func GetStillChecked(c *xgb.Conn, Port Port, Drawable xproto.Drawable, Gc xproto.Gcontext, VidX int16, VidY int16, VidW uint16, VidH uint16, DrwX int16, DrwY int16, DrwW uint16, DrwH uint16) GetStillCookie {
c.ExtLock.RLock()
defer c.ExtLock.RUnlock()
if _, ok := c.Extensions["XVideo"]; !ok {
panic("Cannot issue request 'GetStill' using the uninitialized extension 'XVideo'. xv.Init(connObj) must be called first.")
}
cookie := c.NewCookie(true, false)
c.NewRequest(getStillRequest(c, Port, Drawable, Gc, VidX, VidY, VidW, VidH, DrwX, DrwY, DrwW, DrwH), cookie)
return GetStillCookie{cookie}
}
// Check returns an error if one occurred for checked requests that are not expecting a reply.
// This cannot be called for requests expecting a reply, nor for unchecked requests.
func (cook GetStillCookie) Check() error {
return cook.Cookie.Check()
}
// Write request to wire for GetStill
// getStillRequest writes a GetStill request to a byte slice.
func getStillRequest(c *xgb.Conn, Port Port, Drawable xproto.Drawable, Gc xproto.Gcontext, VidX int16, VidY int16, VidW uint16, VidH uint16, DrwX int16, DrwY int16, DrwW uint16, DrwH uint16) []byte {
size := 32
b := 0
buf := make([]byte, size)
c.ExtLock.RLock()
buf[b] = c.Extensions["XVideo"]
c.ExtLock.RUnlock()
b += 1
buf[b] = 8 // request opcode
b += 1
xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units
b += 2
xgb.Put32(buf[b:], uint32(Port))
b += 4
xgb.Put32(buf[b:], uint32(Drawable))
b += 4
xgb.Put32(buf[b:], uint32(Gc))
b += 4
xgb.Put16(buf[b:], uint16(VidX))
b += 2
xgb.Put16(buf[b:], uint16(VidY))
b += 2
xgb.Put16(buf[b:], VidW)
b += 2
xgb.Put16(buf[b:], VidH)
b += 2
xgb.Put16(buf[b:], uint16(DrwX))
b += 2
xgb.Put16(buf[b:], uint16(DrwY))
b += 2
xgb.Put16(buf[b:], DrwW)
b += 2
xgb.Put16(buf[b:], DrwH)
b += 2
return buf
}
// GetVideoCookie is a cookie used only for GetVideo requests.
type GetVideoCookie struct {
*xgb.Cookie
}
// GetVideo sends an unchecked request.
// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent.
func GetVideo(c *xgb.Conn, Port Port, Drawable xproto.Drawable, Gc xproto.Gcontext, VidX int16, VidY int16, VidW uint16, VidH uint16, DrwX int16, DrwY int16, DrwW uint16, DrwH uint16) GetVideoCookie {
c.ExtLock.RLock()
defer c.ExtLock.RUnlock()
if _, ok := c.Extensions["XVideo"]; !ok {
panic("Cannot issue request 'GetVideo' using the uninitialized extension 'XVideo'. xv.Init(connObj) must be called first.")
}
cookie := c.NewCookie(false, false)
c.NewRequest(getVideoRequest(c, Port, Drawable, Gc, VidX, VidY, VidW, VidH, DrwX, DrwY, DrwW, DrwH), cookie)
return GetVideoCookie{cookie}
}
// GetVideoChecked sends a checked request.
// If an error occurs, it can be retrieved using GetVideoCookie.Check()
func GetVideoChecked(c *xgb.Conn, Port Port, Drawable xproto.Drawable, Gc xproto.Gcontext, VidX int16, VidY int16, VidW uint16, VidH uint16, DrwX int16, DrwY int16, DrwW uint16, DrwH uint16) GetVideoCookie {
c.ExtLock.RLock()
defer c.ExtLock.RUnlock()
if _, ok := c.Extensions["XVideo"]; !ok {
panic("Cannot issue request 'GetVideo' using the uninitialized extension 'XVideo'. xv.Init(connObj) must be called first.")
}
cookie := c.NewCookie(true, false)
c.NewRequest(getVideoRequest(c, Port, Drawable, Gc, VidX, VidY, VidW, VidH, DrwX, DrwY, DrwW, DrwH), cookie)
return GetVideoCookie{cookie}
}
// Check returns an error if one occurred for checked requests that are not expecting a reply.
// This cannot be called for requests expecting a reply, nor for unchecked requests.
func (cook GetVideoCookie) Check() error {
return cook.Cookie.Check()
}
// Write request to wire for GetVideo
// getVideoRequest writes a GetVideo request to a byte slice.
func getVideoRequest(c *xgb.Conn, Port Port, Drawable xproto.Drawable, Gc xproto.Gcontext, VidX int16, VidY int16, VidW uint16, VidH uint16, DrwX int16, DrwY int16, DrwW uint16, DrwH uint16) []byte {
size := 32
b := 0
buf := make([]byte, size)
c.ExtLock.RLock()
buf[b] = c.Extensions["XVideo"]
c.ExtLock.RUnlock()
b += 1
buf[b] = 7 // request opcode
b += 1
xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units
b += 2
xgb.Put32(buf[b:], uint32(Port))
b += 4
xgb.Put32(buf[b:], uint32(Drawable))
b += 4
xgb.Put32(buf[b:], uint32(Gc))
b += 4
xgb.Put16(buf[b:], uint16(VidX))
b += 2
xgb.Put16(buf[b:], uint16(VidY))
b += 2
xgb.Put16(buf[b:], VidW)
b += 2
xgb.Put16(buf[b:], VidH)
b += 2
xgb.Put16(buf[b:], uint16(DrwX))
b += 2
xgb.Put16(buf[b:], uint16(DrwY))
b += 2
xgb.Put16(buf[b:], DrwW)
b += 2
xgb.Put16(buf[b:], DrwH)
b += 2
return buf
}
// GrabPortCookie is a cookie used only for GrabPort requests.
type GrabPortCookie struct {
*xgb.Cookie
}
// GrabPort sends a checked request.
// If an error occurs, it will be returned with the reply by calling GrabPortCookie.Reply()
func GrabPort(c *xgb.Conn, Port Port, Time xproto.Timestamp) GrabPortCookie {
c.ExtLock.RLock()
defer c.ExtLock.RUnlock()
if _, ok := c.Extensions["XVideo"]; !ok {
panic("Cannot issue request 'GrabPort' using the uninitialized extension 'XVideo'. xv.Init(connObj) must be called first.")
}
cookie := c.NewCookie(true, true)
c.NewRequest(grabPortRequest(c, Port, Time), cookie)
return GrabPortCookie{cookie}
}
// GrabPortUnchecked sends an unchecked request.
// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent.
func GrabPortUnchecked(c *xgb.Conn, Port Port, Time xproto.Timestamp) GrabPortCookie {
c.ExtLock.RLock()
defer c.ExtLock.RUnlock()
if _, ok := c.Extensions["XVideo"]; !ok {
panic("Cannot issue request 'GrabPort' using the uninitialized extension 'XVideo'. xv.Init(connObj) must be called first.")
}
cookie := c.NewCookie(false, true)
c.NewRequest(grabPortRequest(c, Port, Time), cookie)
return GrabPortCookie{cookie}
}
// GrabPortReply represents the data returned from a GrabPort request.
type GrabPortReply struct {
Sequence uint16 // sequence number of the request for this reply
Length uint32 // number of bytes in this reply
Result byte
}
// Reply blocks and returns the reply data for a GrabPort request.
func (cook GrabPortCookie) Reply() (*GrabPortReply, error) {
buf, err := cook.Cookie.Reply()
if err != nil {
return nil, err
}
if buf == nil {
return nil, nil
}
return grabPortReply(buf), nil
}
// grabPortReply reads a byte slice into a GrabPortReply value.
func grabPortReply(buf []byte) *GrabPortReply {
v := new(GrabPortReply)
b := 1 // skip reply determinant
v.Result = buf[b]
b += 1
v.Sequence = xgb.Get16(buf[b:])
b += 2
v.Length = xgb.Get32(buf[b:]) // 4-byte units
b += 4
return v
}
// Write request to wire for GrabPort
// grabPortRequest writes a GrabPort request to a byte slice.
func grabPortRequest(c *xgb.Conn, Port Port, Time xproto.Timestamp) []byte {
size := 12
b := 0
buf := make([]byte, size)
c.ExtLock.RLock()
buf[b] = c.Extensions["XVideo"]
c.ExtLock.RUnlock()
b += 1
buf[b] = 3 // request opcode
b += 1
xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units
b += 2
xgb.Put32(buf[b:], uint32(Port))
b += 4
xgb.Put32(buf[b:], uint32(Time))
b += 4
return buf
}
// ListImageFormatsCookie is a cookie used only for ListImageFormats requests.
type ListImageFormatsCookie struct {
*xgb.Cookie
}
// ListImageFormats sends a checked request.
// If an error occurs, it will be returned with the reply by calling ListImageFormatsCookie.Reply()
func ListImageFormats(c *xgb.Conn, Port Port) ListImageFormatsCookie {
c.ExtLock.RLock()
defer c.ExtLock.RUnlock()
if _, ok := c.Extensions["XVideo"]; !ok {
panic("Cannot issue request 'ListImageFormats' using the uninitialized extension 'XVideo'. xv.Init(connObj) must be called first.")
}
cookie := c.NewCookie(true, true)
c.NewRequest(listImageFormatsRequest(c, Port), cookie)
return ListImageFormatsCookie{cookie}
}
// ListImageFormatsUnchecked sends an unchecked request.
// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent.
func ListImageFormatsUnchecked(c *xgb.Conn, Port Port) ListImageFormatsCookie {
c.ExtLock.RLock()
defer c.ExtLock.RUnlock()
if _, ok := c.Extensions["XVideo"]; !ok {
panic("Cannot issue request 'ListImageFormats' using the uninitialized extension 'XVideo'. xv.Init(connObj) must be called first.")
}
cookie := c.NewCookie(false, true)
c.NewRequest(listImageFormatsRequest(c, Port), cookie)
return ListImageFormatsCookie{cookie}
}
// ListImageFormatsReply represents the data returned from a ListImageFormats request.
type ListImageFormatsReply struct {
Sequence uint16 // sequence number of the request for this reply
Length uint32 // number of bytes in this reply
// padding: 1 bytes
NumFormats uint32
// padding: 20 bytes
Format []ImageFormatInfo // size: ImageFormatInfoListSize(Format)
}
// Reply blocks and returns the reply data for a ListImageFormats request.
func (cook ListImageFormatsCookie) Reply() (*ListImageFormatsReply, error) {
buf, err := cook.Cookie.Reply()
if err != nil {
return nil, err
}
if buf == nil {
return nil, nil
}
return listImageFormatsReply(buf), nil
}
// listImageFormatsReply reads a byte slice into a ListImageFormatsReply value.
func listImageFormatsReply(buf []byte) *ListImageFormatsReply {
v := new(ListImageFormatsReply)
b := 1 // skip reply determinant
b += 1 // padding
v.Sequence = xgb.Get16(buf[b:])
b += 2
v.Length = xgb.Get32(buf[b:]) // 4-byte units
b += 4
v.NumFormats = xgb.Get32(buf[b:])
b += 4
b += 20 // padding
v.Format = make([]ImageFormatInfo, v.NumFormats)
b += ImageFormatInfoReadList(buf[b:], v.Format)
return v
}
// Write request to wire for ListImageFormats
// listImageFormatsRequest writes a ListImageFormats request to a byte slice.
func listImageFormatsRequest(c *xgb.Conn, Port Port) []byte {
size := 8
b := 0
buf := make([]byte, size)
c.ExtLock.RLock()
buf[b] = c.Extensions["XVideo"]
c.ExtLock.RUnlock()
b += 1
buf[b] = 16 // request opcode
b += 1
xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units
b += 2
xgb.Put32(buf[b:], uint32(Port))
b += 4
return buf
}
// PutImageCookie is a cookie used only for PutImage requests.
type PutImageCookie struct {
*xgb.Cookie
}
// PutImage sends an unchecked request.
// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent.
func PutImage(c *xgb.Conn, Port Port, Drawable xproto.Drawable, Gc xproto.Gcontext, Id uint32, SrcX int16, SrcY int16, SrcW uint16, SrcH uint16, DrwX int16, DrwY int16, DrwW uint16, DrwH uint16, Width uint16, Height uint16, Data []byte) PutImageCookie {
c.ExtLock.RLock()
defer c.ExtLock.RUnlock()
if _, ok := c.Extensions["XVideo"]; !ok {
panic("Cannot issue request 'PutImage' using the uninitialized extension 'XVideo'. xv.Init(connObj) must be called first.")
}
cookie := c.NewCookie(false, false)
c.NewRequest(putImageRequest(c, Port, Drawable, Gc, Id, SrcX, SrcY, SrcW, SrcH, DrwX, DrwY, DrwW, DrwH, Width, Height, Data), cookie)
return PutImageCookie{cookie}
}
// PutImageChecked sends a checked request.
// If an error occurs, it can be retrieved using PutImageCookie.Check()
func PutImageChecked(c *xgb.Conn, Port Port, Drawable xproto.Drawable, Gc xproto.Gcontext, Id uint32, SrcX int16, SrcY int16, SrcW uint16, SrcH uint16, DrwX int16, DrwY int16, DrwW uint16, DrwH uint16, Width uint16, Height uint16, Data []byte) PutImageCookie {
c.ExtLock.RLock()
defer c.ExtLock.RUnlock()
if _, ok := c.Extensions["XVideo"]; !ok {
panic("Cannot issue request 'PutImage' using the uninitialized extension 'XVideo'. xv.Init(connObj) must be called first.")
}
cookie := c.NewCookie(true, false)
c.NewRequest(putImageRequest(c, Port, Drawable, Gc, Id, SrcX, SrcY, SrcW, SrcH, DrwX, DrwY, DrwW, DrwH, Width, Height, Data), cookie)
return PutImageCookie{cookie}
}
// Check returns an error if one occurred for checked requests that are not expecting a reply.
// This cannot be called for requests expecting a reply, nor for unchecked requests.
func (cook PutImageCookie) Check() error {
return cook.Cookie.Check()
}
// Write request to wire for PutImage
// putImageRequest writes a PutImage request to a byte slice.
func putImageRequest(c *xgb.Conn, Port Port, Drawable xproto.Drawable, Gc xproto.Gcontext, Id uint32, SrcX int16, SrcY int16, SrcW uint16, SrcH uint16, DrwX int16, DrwY int16, DrwW uint16, DrwH uint16, Width uint16, Height uint16, Data []byte) []byte {
size := xgb.Pad((40 + xgb.Pad((len(Data) * 1))))
b := 0
buf := make([]byte, size)
c.ExtLock.RLock()
buf[b] = c.Extensions["XVideo"]
c.ExtLock.RUnlock()
b += 1
buf[b] = 18 // request opcode
b += 1
xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units
b += 2
xgb.Put32(buf[b:], uint32(Port))
b += 4
xgb.Put32(buf[b:], uint32(Drawable))
b += 4
xgb.Put32(buf[b:], uint32(Gc))
b += 4
xgb.Put32(buf[b:], Id)
b += 4
xgb.Put16(buf[b:], uint16(SrcX))
b += 2
xgb.Put16(buf[b:], uint16(SrcY))
b += 2
xgb.Put16(buf[b:], SrcW)
b += 2
xgb.Put16(buf[b:], SrcH)
b += 2
xgb.Put16(buf[b:], uint16(DrwX))
b += 2
xgb.Put16(buf[b:], uint16(DrwY))
b += 2
xgb.Put16(buf[b:], DrwW)
b += 2
xgb.Put16(buf[b:], DrwH)
b += 2
xgb.Put16(buf[b:], Width)
b += 2
xgb.Put16(buf[b:], Height)
b += 2
copy(buf[b:], Data[:len(Data)])
b += int(len(Data))
return buf
}
// PutStillCookie is a cookie used only for PutStill requests.
type PutStillCookie struct {
*xgb.Cookie
}
// PutStill sends an unchecked request.
// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent.
func PutStill(c *xgb.Conn, Port Port, Drawable xproto.Drawable, Gc xproto.Gcontext, VidX int16, VidY int16, VidW uint16, VidH uint16, DrwX int16, DrwY int16, DrwW uint16, DrwH uint16) PutStillCookie {
c.ExtLock.RLock()
defer c.ExtLock.RUnlock()
if _, ok := c.Extensions["XVideo"]; !ok {
panic("Cannot issue request 'PutStill' using the uninitialized extension 'XVideo'. xv.Init(connObj) must be called first.")
}
cookie := c.NewCookie(false, false)
c.NewRequest(putStillRequest(c, Port, Drawable, Gc, VidX, VidY, VidW, VidH, DrwX, DrwY, DrwW, DrwH), cookie)
return PutStillCookie{cookie}
}
// PutStillChecked sends a checked request.
// If an error occurs, it can be retrieved using PutStillCookie.Check()
func PutStillChecked(c *xgb.Conn, Port Port, Drawable xproto.Drawable, Gc xproto.Gcontext, VidX int16, VidY int16, VidW uint16, VidH uint16, DrwX int16, DrwY int16, DrwW uint16, DrwH uint16) PutStillCookie {
c.ExtLock.RLock()
defer c.ExtLock.RUnlock()
if _, ok := c.Extensions["XVideo"]; !ok {
panic("Cannot issue request 'PutStill' using the uninitialized extension 'XVideo'. xv.Init(connObj) must be called first.")
}
cookie := c.NewCookie(true, false)
c.NewRequest(putStillRequest(c, Port, Drawable, Gc, VidX, VidY, VidW, VidH, DrwX, DrwY, DrwW, DrwH), cookie)
return PutStillCookie{cookie}
}
// Check returns an error if one occurred for checked requests that are not expecting a reply.
// This cannot be called for requests expecting a reply, nor for unchecked requests.
func (cook PutStillCookie) Check() error {
return cook.Cookie.Check()
}
// Write request to wire for PutStill
// putStillRequest writes a PutStill request to a byte slice.
func putStillRequest(c *xgb.Conn, Port Port, Drawable xproto.Drawable, Gc xproto.Gcontext, VidX int16, VidY int16, VidW uint16, VidH uint16, DrwX int16, DrwY int16, DrwW uint16, DrwH uint16) []byte {
size := 32
b := 0
buf := make([]byte, size)
c.ExtLock.RLock()
buf[b] = c.Extensions["XVideo"]
c.ExtLock.RUnlock()
b += 1
buf[b] = 6 // request opcode
b += 1
xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units
b += 2
xgb.Put32(buf[b:], uint32(Port))
b += 4
xgb.Put32(buf[b:], uint32(Drawable))
b += 4
xgb.Put32(buf[b:], uint32(Gc))
b += 4
xgb.Put16(buf[b:], uint16(VidX))
b += 2
xgb.Put16(buf[b:], uint16(VidY))
b += 2
xgb.Put16(buf[b:], VidW)
b += 2
xgb.Put16(buf[b:], VidH)
b += 2
xgb.Put16(buf[b:], uint16(DrwX))
b += 2
xgb.Put16(buf[b:], uint16(DrwY))
b += 2
xgb.Put16(buf[b:], DrwW)
b += 2
xgb.Put16(buf[b:], DrwH)
b += 2
return buf
}
// PutVideoCookie is a cookie used only for PutVideo requests.
type PutVideoCookie struct {
*xgb.Cookie
}
// PutVideo sends an unchecked request.
// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent.
func PutVideo(c *xgb.Conn, Port Port, Drawable xproto.Drawable, Gc xproto.Gcontext, VidX int16, VidY int16, VidW uint16, VidH uint16, DrwX int16, DrwY int16, DrwW uint16, DrwH uint16) PutVideoCookie {
c.ExtLock.RLock()
defer c.ExtLock.RUnlock()
if _, ok := c.Extensions["XVideo"]; !ok {
panic("Cannot issue request 'PutVideo' using the uninitialized extension 'XVideo'. xv.Init(connObj) must be called first.")
}
cookie := c.NewCookie(false, false)
c.NewRequest(putVideoRequest(c, Port, Drawable, Gc, VidX, VidY, VidW, VidH, DrwX, DrwY, DrwW, DrwH), cookie)
return PutVideoCookie{cookie}
}
// PutVideoChecked sends a checked request.
// If an error occurs, it can be retrieved using PutVideoCookie.Check()
func PutVideoChecked(c *xgb.Conn, Port Port, Drawable xproto.Drawable, Gc xproto.Gcontext, VidX int16, VidY int16, VidW uint16, VidH uint16, DrwX int16, DrwY int16, DrwW uint16, DrwH uint16) PutVideoCookie {
c.ExtLock.RLock()
defer c.ExtLock.RUnlock()
if _, ok := c.Extensions["XVideo"]; !ok {
panic("Cannot issue request 'PutVideo' using the uninitialized extension 'XVideo'. xv.Init(connObj) must be called first.")
}
cookie := c.NewCookie(true, false)
c.NewRequest(putVideoRequest(c, Port, Drawable, Gc, VidX, VidY, VidW, VidH, DrwX, DrwY, DrwW, DrwH), cookie)
return PutVideoCookie{cookie}
}
// Check returns an error if one occurred for checked requests that are not expecting a reply.
// This cannot be called for requests expecting a reply, nor for unchecked requests.
func (cook PutVideoCookie) Check() error {
return cook.Cookie.Check()
}
// Write request to wire for PutVideo
// putVideoRequest writes a PutVideo request to a byte slice.
func putVideoRequest(c *xgb.Conn, Port Port, Drawable xproto.Drawable, Gc xproto.Gcontext, VidX int16, VidY int16, VidW uint16, VidH uint16, DrwX int16, DrwY int16, DrwW uint16, DrwH uint16) []byte {
size := 32
b := 0
buf := make([]byte, size)
c.ExtLock.RLock()
buf[b] = c.Extensions["XVideo"]
c.ExtLock.RUnlock()
b += 1
buf[b] = 5 // request opcode
b += 1
xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units
b += 2
xgb.Put32(buf[b:], uint32(Port))
b += 4
xgb.Put32(buf[b:], uint32(Drawable))
b += 4
xgb.Put32(buf[b:], uint32(Gc))
b += 4
xgb.Put16(buf[b:], uint16(VidX))
b += 2
xgb.Put16(buf[b:], uint16(VidY))
b += 2
xgb.Put16(buf[b:], VidW)
b += 2
xgb.Put16(buf[b:], VidH)
b += 2
xgb.Put16(buf[b:], uint16(DrwX))
b += 2
xgb.Put16(buf[b:], uint16(DrwY))
b += 2
xgb.Put16(buf[b:], DrwW)
b += 2
xgb.Put16(buf[b:], DrwH)
b += 2
return buf
}
// QueryAdaptorsCookie is a cookie used only for QueryAdaptors requests.
type QueryAdaptorsCookie struct {
*xgb.Cookie
}
// QueryAdaptors sends a checked request.
// If an error occurs, it will be returned with the reply by calling QueryAdaptorsCookie.Reply()
func QueryAdaptors(c *xgb.Conn, Window xproto.Window) QueryAdaptorsCookie {
c.ExtLock.RLock()
defer c.ExtLock.RUnlock()
if _, ok := c.Extensions["XVideo"]; !ok {
panic("Cannot issue request 'QueryAdaptors' using the uninitialized extension 'XVideo'. xv.Init(connObj) must be called first.")
}
cookie := c.NewCookie(true, true)
c.NewRequest(queryAdaptorsRequest(c, Window), cookie)
return QueryAdaptorsCookie{cookie}
}
// QueryAdaptorsUnchecked sends an unchecked request.
// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent.
func QueryAdaptorsUnchecked(c *xgb.Conn, Window xproto.Window) QueryAdaptorsCookie {
c.ExtLock.RLock()
defer c.ExtLock.RUnlock()
if _, ok := c.Extensions["XVideo"]; !ok {
panic("Cannot issue request 'QueryAdaptors' using the uninitialized extension 'XVideo'. xv.Init(connObj) must be called first.")
}
cookie := c.NewCookie(false, true)
c.NewRequest(queryAdaptorsRequest(c, Window), cookie)
return QueryAdaptorsCookie{cookie}
}
// QueryAdaptorsReply represents the data returned from a QueryAdaptors request.
type QueryAdaptorsReply struct {
Sequence uint16 // sequence number of the request for this reply
Length uint32 // number of bytes in this reply
// padding: 1 bytes
NumAdaptors uint16
// padding: 22 bytes
Info []AdaptorInfo // size: AdaptorInfoListSize(Info)
}
// Reply blocks and returns the reply data for a QueryAdaptors request.
func (cook QueryAdaptorsCookie) Reply() (*QueryAdaptorsReply, error) {
buf, err := cook.Cookie.Reply()
if err != nil {
return nil, err
}
if buf == nil {
return nil, nil
}
return queryAdaptorsReply(buf), nil
}
// queryAdaptorsReply reads a byte slice into a QueryAdaptorsReply value.
func queryAdaptorsReply(buf []byte) *QueryAdaptorsReply {
v := new(QueryAdaptorsReply)
b := 1 // skip reply determinant
b += 1 // padding
v.Sequence = xgb.Get16(buf[b:])
b += 2
v.Length = xgb.Get32(buf[b:]) // 4-byte units
b += 4
v.NumAdaptors = xgb.Get16(buf[b:])
b += 2
b += 22 // padding
v.Info = make([]AdaptorInfo, v.NumAdaptors)
b += AdaptorInfoReadList(buf[b:], v.Info)
return v
}
// Write request to wire for QueryAdaptors
// queryAdaptorsRequest writes a QueryAdaptors request to a byte slice.
func queryAdaptorsRequest(c *xgb.Conn, Window xproto.Window) []byte {
size := 8
b := 0
buf := make([]byte, size)
c.ExtLock.RLock()
buf[b] = c.Extensions["XVideo"]
c.ExtLock.RUnlock()
b += 1
buf[b] = 1 // request opcode
b += 1
xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units
b += 2
xgb.Put32(buf[b:], uint32(Window))
b += 4
return buf
}
// QueryBestSizeCookie is a cookie used only for QueryBestSize requests.
type QueryBestSizeCookie struct {
*xgb.Cookie
}
// QueryBestSize sends a checked request.
// If an error occurs, it will be returned with the reply by calling QueryBestSizeCookie.Reply()
func QueryBestSize(c *xgb.Conn, Port Port, VidW uint16, VidH uint16, DrwW uint16, DrwH uint16, Motion bool) QueryBestSizeCookie {
c.ExtLock.RLock()
defer c.ExtLock.RUnlock()
if _, ok := c.Extensions["XVideo"]; !ok {
panic("Cannot issue request 'QueryBestSize' using the uninitialized extension 'XVideo'. xv.Init(connObj) must be called first.")
}
cookie := c.NewCookie(true, true)
c.NewRequest(queryBestSizeRequest(c, Port, VidW, VidH, DrwW, DrwH, Motion), cookie)
return QueryBestSizeCookie{cookie}
}
// QueryBestSizeUnchecked sends an unchecked request.
// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent.
func QueryBestSizeUnchecked(c *xgb.Conn, Port Port, VidW uint16, VidH uint16, DrwW uint16, DrwH uint16, Motion bool) QueryBestSizeCookie {
c.ExtLock.RLock()
defer c.ExtLock.RUnlock()
if _, ok := c.Extensions["XVideo"]; !ok {
panic("Cannot issue request 'QueryBestSize' using the uninitialized extension 'XVideo'. xv.Init(connObj) must be called first.")
}
cookie := c.NewCookie(false, true)
c.NewRequest(queryBestSizeRequest(c, Port, VidW, VidH, DrwW, DrwH, Motion), cookie)
return QueryBestSizeCookie{cookie}
}
// QueryBestSizeReply represents the data returned from a QueryBestSize request.
type QueryBestSizeReply struct {
Sequence uint16 // sequence number of the request for this reply
Length uint32 // number of bytes in this reply
// padding: 1 bytes
ActualWidth uint16
ActualHeight uint16
}
// Reply blocks and returns the reply data for a QueryBestSize request.
func (cook QueryBestSizeCookie) Reply() (*QueryBestSizeReply, error) {
buf, err := cook.Cookie.Reply()
if err != nil {
return nil, err
}
if buf == nil {
return nil, nil
}
return queryBestSizeReply(buf), nil
}
// queryBestSizeReply reads a byte slice into a QueryBestSizeReply value.
func queryBestSizeReply(buf []byte) *QueryBestSizeReply {
v := new(QueryBestSizeReply)
b := 1 // skip reply determinant
b += 1 // padding
v.Sequence = xgb.Get16(buf[b:])
b += 2
v.Length = xgb.Get32(buf[b:]) // 4-byte units
b += 4
v.ActualWidth = xgb.Get16(buf[b:])
b += 2
v.ActualHeight = xgb.Get16(buf[b:])
b += 2
return v
}
// Write request to wire for QueryBestSize
// queryBestSizeRequest writes a QueryBestSize request to a byte slice.
func queryBestSizeRequest(c *xgb.Conn, Port Port, VidW uint16, VidH uint16, DrwW uint16, DrwH uint16, Motion bool) []byte {
size := 20
b := 0
buf := make([]byte, size)
c.ExtLock.RLock()
buf[b] = c.Extensions["XVideo"]
c.ExtLock.RUnlock()
b += 1
buf[b] = 12 // request opcode
b += 1
xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units
b += 2
xgb.Put32(buf[b:], uint32(Port))
b += 4
xgb.Put16(buf[b:], VidW)
b += 2
xgb.Put16(buf[b:], VidH)
b += 2
xgb.Put16(buf[b:], DrwW)
b += 2
xgb.Put16(buf[b:], DrwH)
b += 2
if Motion {
buf[b] = 1
} else {
buf[b] = 0
}
b += 1
b += 3 // padding
return buf
}
// QueryEncodingsCookie is a cookie used only for QueryEncodings requests.
type QueryEncodingsCookie struct {
*xgb.Cookie
}
// QueryEncodings sends a checked request.
// If an error occurs, it will be returned with the reply by calling QueryEncodingsCookie.Reply()
func QueryEncodings(c *xgb.Conn, Port Port) QueryEncodingsCookie {
c.ExtLock.RLock()
defer c.ExtLock.RUnlock()
if _, ok := c.Extensions["XVideo"]; !ok {
panic("Cannot issue request 'QueryEncodings' using the uninitialized extension 'XVideo'. xv.Init(connObj) must be called first.")
}
cookie := c.NewCookie(true, true)
c.NewRequest(queryEncodingsRequest(c, Port), cookie)
return QueryEncodingsCookie{cookie}
}
// QueryEncodingsUnchecked sends an unchecked request.
// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent.
func QueryEncodingsUnchecked(c *xgb.Conn, Port Port) QueryEncodingsCookie {
c.ExtLock.RLock()
defer c.ExtLock.RUnlock()
if _, ok := c.Extensions["XVideo"]; !ok {
panic("Cannot issue request 'QueryEncodings' using the uninitialized extension 'XVideo'. xv.Init(connObj) must be called first.")
}
cookie := c.NewCookie(false, true)
c.NewRequest(queryEncodingsRequest(c, Port), cookie)
return QueryEncodingsCookie{cookie}
}
// QueryEncodingsReply represents the data returned from a QueryEncodings request.
type QueryEncodingsReply struct {
Sequence uint16 // sequence number of the request for this reply
Length uint32 // number of bytes in this reply
// padding: 1 bytes
NumEncodings uint16
// padding: 22 bytes
Info []EncodingInfo // size: EncodingInfoListSize(Info)
}
// Reply blocks and returns the reply data for a QueryEncodings request.
func (cook QueryEncodingsCookie) Reply() (*QueryEncodingsReply, error) {
buf, err := cook.Cookie.Reply()
if err != nil {
return nil, err
}
if buf == nil {
return nil, nil
}
return queryEncodingsReply(buf), nil
}
// queryEncodingsReply reads a byte slice into a QueryEncodingsReply value.
func queryEncodingsReply(buf []byte) *QueryEncodingsReply {
v := new(QueryEncodingsReply)
b := 1 // skip reply determinant
b += 1 // padding
v.Sequence = xgb.Get16(buf[b:])
b += 2
v.Length = xgb.Get32(buf[b:]) // 4-byte units
b += 4
v.NumEncodings = xgb.Get16(buf[b:])
b += 2
b += 22 // padding
v.Info = make([]EncodingInfo, v.NumEncodings)
b += EncodingInfoReadList(buf[b:], v.Info)
return v
}
// Write request to wire for QueryEncodings
// queryEncodingsRequest writes a QueryEncodings request to a byte slice.
func queryEncodingsRequest(c *xgb.Conn, Port Port) []byte {
size := 8
b := 0
buf := make([]byte, size)
c.ExtLock.RLock()
buf[b] = c.Extensions["XVideo"]
c.ExtLock.RUnlock()
b += 1
buf[b] = 2 // request opcode
b += 1
xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units
b += 2
xgb.Put32(buf[b:], uint32(Port))
b += 4
return buf
}
// QueryExtensionCookie is a cookie used only for QueryExtension requests.
type QueryExtensionCookie struct {
*xgb.Cookie
}
// QueryExtension sends a checked request.
// If an error occurs, it will be returned with the reply by calling QueryExtensionCookie.Reply()
func QueryExtension(c *xgb.Conn) QueryExtensionCookie {
c.ExtLock.RLock()
defer c.ExtLock.RUnlock()
if _, ok := c.Extensions["XVideo"]; !ok {
panic("Cannot issue request 'QueryExtension' using the uninitialized extension 'XVideo'. xv.Init(connObj) must be called first.")
}
cookie := c.NewCookie(true, true)
c.NewRequest(queryExtensionRequest(c), cookie)
return QueryExtensionCookie{cookie}
}
// QueryExtensionUnchecked sends an unchecked request.
// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent.
func QueryExtensionUnchecked(c *xgb.Conn) QueryExtensionCookie {
c.ExtLock.RLock()
defer c.ExtLock.RUnlock()
if _, ok := c.Extensions["XVideo"]; !ok {
panic("Cannot issue request 'QueryExtension' using the uninitialized extension 'XVideo'. xv.Init(connObj) must be called first.")
}
cookie := c.NewCookie(false, true)
c.NewRequest(queryExtensionRequest(c), cookie)
return QueryExtensionCookie{cookie}
}
// QueryExtensionReply represents the data returned from a QueryExtension request.
type QueryExtensionReply struct {
Sequence uint16 // sequence number of the request for this reply
Length uint32 // number of bytes in this reply
// padding: 1 bytes
Major uint16
Minor uint16
}
// Reply blocks and returns the reply data for a QueryExtension request.
func (cook QueryExtensionCookie) Reply() (*QueryExtensionReply, error) {
buf, err := cook.Cookie.Reply()
if err != nil {
return nil, err
}
if buf == nil {
return nil, nil
}
return queryExtensionReply(buf), nil
}
// queryExtensionReply reads a byte slice into a QueryExtensionReply value.
func queryExtensionReply(buf []byte) *QueryExtensionReply {
v := new(QueryExtensionReply)
b := 1 // skip reply determinant
b += 1 // padding
v.Sequence = xgb.Get16(buf[b:])
b += 2
v.Length = xgb.Get32(buf[b:]) // 4-byte units
b += 4
v.Major = xgb.Get16(buf[b:])
b += 2
v.Minor = xgb.Get16(buf[b:])
b += 2
return v
}
// Write request to wire for QueryExtension
// queryExtensionRequest writes a QueryExtension request to a byte slice.
func queryExtensionRequest(c *xgb.Conn) []byte {
size := 4
b := 0
buf := make([]byte, size)
c.ExtLock.RLock()
buf[b] = c.Extensions["XVideo"]
c.ExtLock.RUnlock()
b += 1
buf[b] = 0 // request opcode
b += 1
xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units
b += 2
return buf
}
// QueryImageAttributesCookie is a cookie used only for QueryImageAttributes requests.
type QueryImageAttributesCookie struct {
*xgb.Cookie
}
// QueryImageAttributes sends a checked request.
// If an error occurs, it will be returned with the reply by calling QueryImageAttributesCookie.Reply()
func QueryImageAttributes(c *xgb.Conn, Port Port, Id uint32, Width uint16, Height uint16) QueryImageAttributesCookie {
c.ExtLock.RLock()
defer c.ExtLock.RUnlock()
if _, ok := c.Extensions["XVideo"]; !ok {
panic("Cannot issue request 'QueryImageAttributes' using the uninitialized extension 'XVideo'. xv.Init(connObj) must be called first.")
}
cookie := c.NewCookie(true, true)
c.NewRequest(queryImageAttributesRequest(c, Port, Id, Width, Height), cookie)
return QueryImageAttributesCookie{cookie}
}
// QueryImageAttributesUnchecked sends an unchecked request.
// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent.
func QueryImageAttributesUnchecked(c *xgb.Conn, Port Port, Id uint32, Width uint16, Height uint16) QueryImageAttributesCookie {
c.ExtLock.RLock()
defer c.ExtLock.RUnlock()
if _, ok := c.Extensions["XVideo"]; !ok {
panic("Cannot issue request 'QueryImageAttributes' using the uninitialized extension 'XVideo'. xv.Init(connObj) must be called first.")
}
cookie := c.NewCookie(false, true)
c.NewRequest(queryImageAttributesRequest(c, Port, Id, Width, Height), cookie)
return QueryImageAttributesCookie{cookie}
}
// QueryImageAttributesReply represents the data returned from a QueryImageAttributes request.
type QueryImageAttributesReply struct {
Sequence uint16 // sequence number of the request for this reply
Length uint32 // number of bytes in this reply
// padding: 1 bytes
NumPlanes uint32
DataSize uint32
Width uint16
Height uint16
// padding: 12 bytes
Pitches []uint32 // size: xgb.Pad((int(NumPlanes) * 4))
Offsets []uint32 // size: xgb.Pad((int(NumPlanes) * 4))
}
// Reply blocks and returns the reply data for a QueryImageAttributes request.
func (cook QueryImageAttributesCookie) Reply() (*QueryImageAttributesReply, error) {
buf, err := cook.Cookie.Reply()
if err != nil {
return nil, err
}
if buf == nil {
return nil, nil
}
return queryImageAttributesReply(buf), nil
}
// queryImageAttributesReply reads a byte slice into a QueryImageAttributesReply value.
func queryImageAttributesReply(buf []byte) *QueryImageAttributesReply {
v := new(QueryImageAttributesReply)
b := 1 // skip reply determinant
b += 1 // padding
v.Sequence = xgb.Get16(buf[b:])
b += 2
v.Length = xgb.Get32(buf[b:]) // 4-byte units
b += 4
v.NumPlanes = xgb.Get32(buf[b:])
b += 4
v.DataSize = xgb.Get32(buf[b:])
b += 4
v.Width = xgb.Get16(buf[b:])
b += 2
v.Height = xgb.Get16(buf[b:])
b += 2
b += 12 // padding
v.Pitches = make([]uint32, v.NumPlanes)
for i := 0; i < int(v.NumPlanes); i++ {
v.Pitches[i] = xgb.Get32(buf[b:])
b += 4
}
v.Offsets = make([]uint32, v.NumPlanes)
for i := 0; i < int(v.NumPlanes); i++ {
v.Offsets[i] = xgb.Get32(buf[b:])
b += 4
}
return v
}
// Write request to wire for QueryImageAttributes
// queryImageAttributesRequest writes a QueryImageAttributes request to a byte slice.
func queryImageAttributesRequest(c *xgb.Conn, Port Port, Id uint32, Width uint16, Height uint16) []byte {
size := 16
b := 0
buf := make([]byte, size)
c.ExtLock.RLock()
buf[b] = c.Extensions["XVideo"]
c.ExtLock.RUnlock()
b += 1
buf[b] = 17 // request opcode
b += 1
xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units
b += 2
xgb.Put32(buf[b:], uint32(Port))
b += 4
xgb.Put32(buf[b:], Id)
b += 4
xgb.Put16(buf[b:], Width)
b += 2
xgb.Put16(buf[b:], Height)
b += 2
return buf
}
// QueryPortAttributesCookie is a cookie used only for QueryPortAttributes requests.
type QueryPortAttributesCookie struct {
*xgb.Cookie
}
// QueryPortAttributes sends a checked request.
// If an error occurs, it will be returned with the reply by calling QueryPortAttributesCookie.Reply()
func QueryPortAttributes(c *xgb.Conn, Port Port) QueryPortAttributesCookie {
c.ExtLock.RLock()
defer c.ExtLock.RUnlock()
if _, ok := c.Extensions["XVideo"]; !ok {
panic("Cannot issue request 'QueryPortAttributes' using the uninitialized extension 'XVideo'. xv.Init(connObj) must be called first.")
}
cookie := c.NewCookie(true, true)
c.NewRequest(queryPortAttributesRequest(c, Port), cookie)
return QueryPortAttributesCookie{cookie}
}
// QueryPortAttributesUnchecked sends an unchecked request.
// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent.
func QueryPortAttributesUnchecked(c *xgb.Conn, Port Port) QueryPortAttributesCookie {
c.ExtLock.RLock()
defer c.ExtLock.RUnlock()
if _, ok := c.Extensions["XVideo"]; !ok {
panic("Cannot issue request 'QueryPortAttributes' using the uninitialized extension 'XVideo'. xv.Init(connObj) must be called first.")
}
cookie := c.NewCookie(false, true)
c.NewRequest(queryPortAttributesRequest(c, Port), cookie)
return QueryPortAttributesCookie{cookie}
}
// QueryPortAttributesReply represents the data returned from a QueryPortAttributes request.
type QueryPortAttributesReply struct {
Sequence uint16 // sequence number of the request for this reply
Length uint32 // number of bytes in this reply
// padding: 1 bytes
NumAttributes uint32
TextSize uint32
// padding: 16 bytes
Attributes []AttributeInfo // size: AttributeInfoListSize(Attributes)
}
// Reply blocks and returns the reply data for a QueryPortAttributes request.
func (cook QueryPortAttributesCookie) Reply() (*QueryPortAttributesReply, error) {
buf, err := cook.Cookie.Reply()
if err != nil {
return nil, err
}
if buf == nil {
return nil, nil
}
return queryPortAttributesReply(buf), nil
}
// queryPortAttributesReply reads a byte slice into a QueryPortAttributesReply value.
func queryPortAttributesReply(buf []byte) *QueryPortAttributesReply {
v := new(QueryPortAttributesReply)
b := 1 // skip reply determinant
b += 1 // padding
v.Sequence = xgb.Get16(buf[b:])
b += 2
v.Length = xgb.Get32(buf[b:]) // 4-byte units
b += 4
v.NumAttributes = xgb.Get32(buf[b:])
b += 4
v.TextSize = xgb.Get32(buf[b:])
b += 4
b += 16 // padding
v.Attributes = make([]AttributeInfo, v.NumAttributes)
b += AttributeInfoReadList(buf[b:], v.Attributes)
return v
}
// Write request to wire for QueryPortAttributes
// queryPortAttributesRequest writes a QueryPortAttributes request to a byte slice.
func queryPortAttributesRequest(c *xgb.Conn, Port Port) []byte {
size := 8
b := 0
buf := make([]byte, size)
c.ExtLock.RLock()
buf[b] = c.Extensions["XVideo"]
c.ExtLock.RUnlock()
b += 1
buf[b] = 15 // request opcode
b += 1
xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units
b += 2
xgb.Put32(buf[b:], uint32(Port))
b += 4
return buf
}
// SelectPortNotifyCookie is a cookie used only for SelectPortNotify requests.
type SelectPortNotifyCookie struct {
*xgb.Cookie
}
// SelectPortNotify sends an unchecked request.
// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent.
func SelectPortNotify(c *xgb.Conn, Port Port, Onoff bool) SelectPortNotifyCookie {
c.ExtLock.RLock()
defer c.ExtLock.RUnlock()
if _, ok := c.Extensions["XVideo"]; !ok {
panic("Cannot issue request 'SelectPortNotify' using the uninitialized extension 'XVideo'. xv.Init(connObj) must be called first.")
}
cookie := c.NewCookie(false, false)
c.NewRequest(selectPortNotifyRequest(c, Port, Onoff), cookie)
return SelectPortNotifyCookie{cookie}
}
// SelectPortNotifyChecked sends a checked request.
// If an error occurs, it can be retrieved using SelectPortNotifyCookie.Check()
func SelectPortNotifyChecked(c *xgb.Conn, Port Port, Onoff bool) SelectPortNotifyCookie {
c.ExtLock.RLock()
defer c.ExtLock.RUnlock()
if _, ok := c.Extensions["XVideo"]; !ok {
panic("Cannot issue request 'SelectPortNotify' using the uninitialized extension 'XVideo'. xv.Init(connObj) must be called first.")
}
cookie := c.NewCookie(true, false)
c.NewRequest(selectPortNotifyRequest(c, Port, Onoff), cookie)
return SelectPortNotifyCookie{cookie}
}
// Check returns an error if one occurred for checked requests that are not expecting a reply.
// This cannot be called for requests expecting a reply, nor for unchecked requests.
func (cook SelectPortNotifyCookie) Check() error {
return cook.Cookie.Check()
}
// Write request to wire for SelectPortNotify
// selectPortNotifyRequest writes a SelectPortNotify request to a byte slice.
func selectPortNotifyRequest(c *xgb.Conn, Port Port, Onoff bool) []byte {
size := 12
b := 0
buf := make([]byte, size)
c.ExtLock.RLock()
buf[b] = c.Extensions["XVideo"]
c.ExtLock.RUnlock()
b += 1
buf[b] = 11 // request opcode
b += 1
xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units
b += 2
xgb.Put32(buf[b:], uint32(Port))
b += 4
if Onoff {
buf[b] = 1
} else {
buf[b] = 0
}
b += 1
b += 3 // padding
return buf
}
// SelectVideoNotifyCookie is a cookie used only for SelectVideoNotify requests.
type SelectVideoNotifyCookie struct {
*xgb.Cookie
}
// SelectVideoNotify sends an unchecked request.
// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent.
func SelectVideoNotify(c *xgb.Conn, Drawable xproto.Drawable, Onoff bool) SelectVideoNotifyCookie {
c.ExtLock.RLock()
defer c.ExtLock.RUnlock()
if _, ok := c.Extensions["XVideo"]; !ok {
panic("Cannot issue request 'SelectVideoNotify' using the uninitialized extension 'XVideo'. xv.Init(connObj) must be called first.")
}
cookie := c.NewCookie(false, false)
c.NewRequest(selectVideoNotifyRequest(c, Drawable, Onoff), cookie)
return SelectVideoNotifyCookie{cookie}
}
// SelectVideoNotifyChecked sends a checked request.
// If an error occurs, it can be retrieved using SelectVideoNotifyCookie.Check()
func SelectVideoNotifyChecked(c *xgb.Conn, Drawable xproto.Drawable, Onoff bool) SelectVideoNotifyCookie {
c.ExtLock.RLock()
defer c.ExtLock.RUnlock()
if _, ok := c.Extensions["XVideo"]; !ok {
panic("Cannot issue request 'SelectVideoNotify' using the uninitialized extension 'XVideo'. xv.Init(connObj) must be called first.")
}
cookie := c.NewCookie(true, false)
c.NewRequest(selectVideoNotifyRequest(c, Drawable, Onoff), cookie)
return SelectVideoNotifyCookie{cookie}
}
// Check returns an error if one occurred for checked requests that are not expecting a reply.
// This cannot be called for requests expecting a reply, nor for unchecked requests.
func (cook SelectVideoNotifyCookie) Check() error {
return cook.Cookie.Check()
}
// Write request to wire for SelectVideoNotify
// selectVideoNotifyRequest writes a SelectVideoNotify request to a byte slice.
func selectVideoNotifyRequest(c *xgb.Conn, Drawable xproto.Drawable, Onoff bool) []byte {
size := 12
b := 0
buf := make([]byte, size)
c.ExtLock.RLock()
buf[b] = c.Extensions["XVideo"]
c.ExtLock.RUnlock()
b += 1
buf[b] = 10 // request opcode
b += 1
xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units
b += 2
xgb.Put32(buf[b:], uint32(Drawable))
b += 4
if Onoff {
buf[b] = 1
} else {
buf[b] = 0
}
b += 1
b += 3 // padding
return buf
}
// SetPortAttributeCookie is a cookie used only for SetPortAttribute requests.
type SetPortAttributeCookie struct {
*xgb.Cookie
}
// SetPortAttribute sends an unchecked request.
// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent.
func SetPortAttribute(c *xgb.Conn, Port Port, Attribute xproto.Atom, Value int32) SetPortAttributeCookie {
c.ExtLock.RLock()
defer c.ExtLock.RUnlock()
if _, ok := c.Extensions["XVideo"]; !ok {
panic("Cannot issue request 'SetPortAttribute' using the uninitialized extension 'XVideo'. xv.Init(connObj) must be called first.")
}
cookie := c.NewCookie(false, false)
c.NewRequest(setPortAttributeRequest(c, Port, Attribute, Value), cookie)
return SetPortAttributeCookie{cookie}
}
// SetPortAttributeChecked sends a checked request.
// If an error occurs, it can be retrieved using SetPortAttributeCookie.Check()
func SetPortAttributeChecked(c *xgb.Conn, Port Port, Attribute xproto.Atom, Value int32) SetPortAttributeCookie {
c.ExtLock.RLock()
defer c.ExtLock.RUnlock()
if _, ok := c.Extensions["XVideo"]; !ok {
panic("Cannot issue request 'SetPortAttribute' using the uninitialized extension 'XVideo'. xv.Init(connObj) must be called first.")
}
cookie := c.NewCookie(true, false)
c.NewRequest(setPortAttributeRequest(c, Port, Attribute, Value), cookie)
return SetPortAttributeCookie{cookie}
}
// Check returns an error if one occurred for checked requests that are not expecting a reply.
// This cannot be called for requests expecting a reply, nor for unchecked requests.
func (cook SetPortAttributeCookie) Check() error {
return cook.Cookie.Check()
}
// Write request to wire for SetPortAttribute
// setPortAttributeRequest writes a SetPortAttribute request to a byte slice.
func setPortAttributeRequest(c *xgb.Conn, Port Port, Attribute xproto.Atom, Value int32) []byte {
size := 16
b := 0
buf := make([]byte, size)
c.ExtLock.RLock()
buf[b] = c.Extensions["XVideo"]
c.ExtLock.RUnlock()
b += 1
buf[b] = 13 // request opcode
b += 1
xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units
b += 2
xgb.Put32(buf[b:], uint32(Port))
b += 4
xgb.Put32(buf[b:], uint32(Attribute))
b += 4
xgb.Put32(buf[b:], uint32(Value))
b += 4
return buf
}
// ShmPutImageCookie is a cookie used only for ShmPutImage requests.
type ShmPutImageCookie struct {
*xgb.Cookie
}
// ShmPutImage sends an unchecked request.
// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent.
func ShmPutImage(c *xgb.Conn, Port Port, Drawable xproto.Drawable, Gc xproto.Gcontext, Shmseg shm.Seg, Id uint32, Offset uint32, SrcX int16, SrcY int16, SrcW uint16, SrcH uint16, DrwX int16, DrwY int16, DrwW uint16, DrwH uint16, Width uint16, Height uint16, SendEvent byte) ShmPutImageCookie {
c.ExtLock.RLock()
defer c.ExtLock.RUnlock()
if _, ok := c.Extensions["XVideo"]; !ok {
panic("Cannot issue request 'ShmPutImage' using the uninitialized extension 'XVideo'. xv.Init(connObj) must be called first.")
}
cookie := c.NewCookie(false, false)
c.NewRequest(shmPutImageRequest(c, Port, Drawable, Gc, Shmseg, Id, Offset, SrcX, SrcY, SrcW, SrcH, DrwX, DrwY, DrwW, DrwH, Width, Height, SendEvent), cookie)
return ShmPutImageCookie{cookie}
}
// ShmPutImageChecked sends a checked request.
// If an error occurs, it can be retrieved using ShmPutImageCookie.Check()
func ShmPutImageChecked(c *xgb.Conn, Port Port, Drawable xproto.Drawable, Gc xproto.Gcontext, Shmseg shm.Seg, Id uint32, Offset uint32, SrcX int16, SrcY int16, SrcW uint16, SrcH uint16, DrwX int16, DrwY int16, DrwW uint16, DrwH uint16, Width uint16, Height uint16, SendEvent byte) ShmPutImageCookie {
c.ExtLock.RLock()
defer c.ExtLock.RUnlock()
if _, ok := c.Extensions["XVideo"]; !ok {
panic("Cannot issue request 'ShmPutImage' using the uninitialized extension 'XVideo'. xv.Init(connObj) must be called first.")
}
cookie := c.NewCookie(true, false)
c.NewRequest(shmPutImageRequest(c, Port, Drawable, Gc, Shmseg, Id, Offset, SrcX, SrcY, SrcW, SrcH, DrwX, DrwY, DrwW, DrwH, Width, Height, SendEvent), cookie)
return ShmPutImageCookie{cookie}
}
// Check returns an error if one occurred for checked requests that are not expecting a reply.
// This cannot be called for requests expecting a reply, nor for unchecked requests.
func (cook ShmPutImageCookie) Check() error {
return cook.Cookie.Check()
}
// Write request to wire for ShmPutImage
// shmPutImageRequest writes a ShmPutImage request to a byte slice.
func shmPutImageRequest(c *xgb.Conn, Port Port, Drawable xproto.Drawable, Gc xproto.Gcontext, Shmseg shm.Seg, Id uint32, Offset uint32, SrcX int16, SrcY int16, SrcW uint16, SrcH uint16, DrwX int16, DrwY int16, DrwW uint16, DrwH uint16, Width uint16, Height uint16, SendEvent byte) []byte {
size := 52
b := 0
buf := make([]byte, size)
c.ExtLock.RLock()
buf[b] = c.Extensions["XVideo"]
c.ExtLock.RUnlock()
b += 1
buf[b] = 19 // request opcode
b += 1
xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units
b += 2
xgb.Put32(buf[b:], uint32(Port))
b += 4
xgb.Put32(buf[b:], uint32(Drawable))
b += 4
xgb.Put32(buf[b:], uint32(Gc))
b += 4
xgb.Put32(buf[b:], uint32(Shmseg))
b += 4
xgb.Put32(buf[b:], Id)
b += 4
xgb.Put32(buf[b:], Offset)
b += 4
xgb.Put16(buf[b:], uint16(SrcX))
b += 2
xgb.Put16(buf[b:], uint16(SrcY))
b += 2
xgb.Put16(buf[b:], SrcW)
b += 2
xgb.Put16(buf[b:], SrcH)
b += 2
xgb.Put16(buf[b:], uint16(DrwX))
b += 2
xgb.Put16(buf[b:], uint16(DrwY))
b += 2
xgb.Put16(buf[b:], DrwW)
b += 2
xgb.Put16(buf[b:], DrwH)
b += 2
xgb.Put16(buf[b:], Width)
b += 2
xgb.Put16(buf[b:], Height)
b += 2
buf[b] = SendEvent
b += 1
b += 3 // padding
return buf
}
// StopVideoCookie is a cookie used only for StopVideo requests.
type StopVideoCookie struct {
*xgb.Cookie
}
// StopVideo sends an unchecked request.
// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent.
func StopVideo(c *xgb.Conn, Port Port, Drawable xproto.Drawable) StopVideoCookie {
c.ExtLock.RLock()
defer c.ExtLock.RUnlock()
if _, ok := c.Extensions["XVideo"]; !ok {
panic("Cannot issue request 'StopVideo' using the uninitialized extension 'XVideo'. xv.Init(connObj) must be called first.")
}
cookie := c.NewCookie(false, false)
c.NewRequest(stopVideoRequest(c, Port, Drawable), cookie)
return StopVideoCookie{cookie}
}
// StopVideoChecked sends a checked request.
// If an error occurs, it can be retrieved using StopVideoCookie.Check()
func StopVideoChecked(c *xgb.Conn, Port Port, Drawable xproto.Drawable) StopVideoCookie {
c.ExtLock.RLock()
defer c.ExtLock.RUnlock()
if _, ok := c.Extensions["XVideo"]; !ok {
panic("Cannot issue request 'StopVideo' using the uninitialized extension 'XVideo'. xv.Init(connObj) must be called first.")
}
cookie := c.NewCookie(true, false)
c.NewRequest(stopVideoRequest(c, Port, Drawable), cookie)
return StopVideoCookie{cookie}
}
// Check returns an error if one occurred for checked requests that are not expecting a reply.
// This cannot be called for requests expecting a reply, nor for unchecked requests.
func (cook StopVideoCookie) Check() error {
return cook.Cookie.Check()
}
// Write request to wire for StopVideo
// stopVideoRequest writes a StopVideo request to a byte slice.
func stopVideoRequest(c *xgb.Conn, Port Port, Drawable xproto.Drawable) []byte {
size := 12
b := 0
buf := make([]byte, size)
c.ExtLock.RLock()
buf[b] = c.Extensions["XVideo"]
c.ExtLock.RUnlock()
b += 1
buf[b] = 9 // request opcode
b += 1
xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units
b += 2
xgb.Put32(buf[b:], uint32(Port))
b += 4
xgb.Put32(buf[b:], uint32(Drawable))
b += 4
return buf
}
// UngrabPortCookie is a cookie used only for UngrabPort requests.
type UngrabPortCookie struct {
*xgb.Cookie
}
// UngrabPort sends an unchecked request.
// If an error occurs, it can only be retrieved using xgb.WaitForEvent or xgb.PollForEvent.
func UngrabPort(c *xgb.Conn, Port Port, Time xproto.Timestamp) UngrabPortCookie {
c.ExtLock.RLock()
defer c.ExtLock.RUnlock()
if _, ok := c.Extensions["XVideo"]; !ok {
panic("Cannot issue request 'UngrabPort' using the uninitialized extension 'XVideo'. xv.Init(connObj) must be called first.")
}
cookie := c.NewCookie(false, false)
c.NewRequest(ungrabPortRequest(c, Port, Time), cookie)
return UngrabPortCookie{cookie}
}
// UngrabPortChecked sends a checked request.
// If an error occurs, it can be retrieved using UngrabPortCookie.Check()
func UngrabPortChecked(c *xgb.Conn, Port Port, Time xproto.Timestamp) UngrabPortCookie {
c.ExtLock.RLock()
defer c.ExtLock.RUnlock()
if _, ok := c.Extensions["XVideo"]; !ok {
panic("Cannot issue request 'UngrabPort' using the uninitialized extension 'XVideo'. xv.Init(connObj) must be called first.")
}
cookie := c.NewCookie(true, false)
c.NewRequest(ungrabPortRequest(c, Port, Time), cookie)
return UngrabPortCookie{cookie}
}
// Check returns an error if one occurred for checked requests that are not expecting a reply.
// This cannot be called for requests expecting a reply, nor for unchecked requests.
func (cook UngrabPortCookie) Check() error {
return cook.Cookie.Check()
}
// Write request to wire for UngrabPort
// ungrabPortRequest writes a UngrabPort request to a byte slice.
func ungrabPortRequest(c *xgb.Conn, Port Port, Time xproto.Timestamp) []byte {
size := 12
b := 0
buf := make([]byte, size)
c.ExtLock.RLock()
buf[b] = c.Extensions["XVideo"]
c.ExtLock.RUnlock()
b += 1
buf[b] = 4 // request opcode
b += 1
xgb.Put16(buf[b:], uint16(size/4)) // write request size in 4-byte units
b += 2
xgb.Put32(buf[b:], uint32(Port))
b += 4
xgb.Put32(buf[b:], uint32(Time))
b += 4
return buf
}
|