forked from ziutek/mdtwm
-
Notifications
You must be signed in to change notification settings - Fork 0
/
xproto.go
4842 lines (4213 loc) · 105 KB
/
xproto.go
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
// This file was generated automatically from xproto.xml.
package xgb
import "errors"
type Char2b struct {
Byte1 byte
Byte2 byte
}
func getChar2b(b []byte, v *Char2b) int {
v.Byte1 = b[0]
v.Byte2 = b[1]
return 2
}
func (c *Conn) sendChar2bList(list []Char2b, count int) {
b0 := make([]byte, 2*count)
for k := 0; k < count; k++ {
b := b0[k*2:]
b[0] = list[k].Byte1
b[1] = list[k].Byte2
}
c.sendBytes(b0)
}
type Point struct {
X int16
Y int16
}
func getPoint(b []byte, v *Point) int {
v.X = int16(get16(b[0:]))
v.Y = int16(get16(b[2:]))
return 4
}
func (c *Conn) sendPointList(list []Point, count int) {
b0 := make([]byte, 4*count)
for k := 0; k < count; k++ {
b := b0[k*4:]
put16(b[0:], uint16(list[k].X))
put16(b[2:], uint16(list[k].Y))
}
c.sendBytes(b0)
}
type Rectangle struct {
X int16
Y int16
Width uint16
Height uint16
}
func getRectangle(b []byte, v *Rectangle) int {
v.X = int16(get16(b[0:]))
v.Y = int16(get16(b[2:]))
v.Width = get16(b[4:])
v.Height = get16(b[6:])
return 8
}
func (c *Conn) sendRectangleList(list []Rectangle, count int) {
b0 := make([]byte, 8*count)
for k := 0; k < count; k++ {
b := b0[k*8:]
put16(b[0:], uint16(list[k].X))
put16(b[2:], uint16(list[k].Y))
put16(b[4:], list[k].Width)
put16(b[6:], list[k].Height)
}
c.sendBytes(b0)
}
type Arc struct {
X int16
Y int16
Width uint16
Height uint16
Angle1 int16
Angle2 int16
}
func getArc(b []byte, v *Arc) int {
v.X = int16(get16(b[0:]))
v.Y = int16(get16(b[2:]))
v.Width = get16(b[4:])
v.Height = get16(b[6:])
v.Angle1 = int16(get16(b[8:]))
v.Angle2 = int16(get16(b[10:]))
return 12
}
func (c *Conn) sendArcList(list []Arc, count int) {
b0 := make([]byte, 12*count)
for k := 0; k < count; k++ {
b := b0[k*12:]
put16(b[0:], uint16(list[k].X))
put16(b[2:], uint16(list[k].Y))
put16(b[4:], list[k].Width)
put16(b[6:], list[k].Height)
put16(b[8:], uint16(list[k].Angle1))
put16(b[10:], uint16(list[k].Angle2))
}
c.sendBytes(b0)
}
type Format struct {
Depth byte
BitsPerPixel byte
ScanlinePad byte
}
func getFormat(b []byte, v *Format) int {
v.Depth = b[0]
v.BitsPerPixel = b[1]
v.ScanlinePad = b[2]
return 8
}
const (
VisualClassStaticGray = 0
VisualClassGrayScale = 1
VisualClassStaticColor = 2
VisualClassPseudoColor = 3
VisualClassTrueColor = 4
VisualClassDirectColor = 5
)
type VisualInfo struct {
VisualId Id
Class byte
BitsPerRgbValue byte
ColormapEntries uint16
RedMask uint32
GreenMask uint32
BlueMask uint32
}
func getVisualInfo(b []byte, v *VisualInfo) int {
v.VisualId = Id(get32(b[0:]))
v.Class = b[4]
v.BitsPerRgbValue = b[5]
v.ColormapEntries = get16(b[6:])
v.RedMask = get32(b[8:])
v.GreenMask = get32(b[12:])
v.BlueMask = get32(b[16:])
return 24
}
type DepthInfo struct {
Depth byte
VisualsLen uint16
Visuals []VisualInfo
}
func getDepthInfo(b []byte, v *DepthInfo) int {
v.Depth = b[0]
v.VisualsLen = get16(b[2:])
offset := 8
v.Visuals = make([]VisualInfo, int(v.VisualsLen))
for i := 0; i < int(v.VisualsLen); i++ {
offset += getVisualInfo(b[offset:], &v.Visuals[i])
}
return offset
}
const (
EventMaskNoEvent = 0
EventMaskKeyPress = 1
EventMaskKeyRelease = 2
EventMaskButtonPress = 4
EventMaskButtonRelease = 8
EventMaskEnterWindow = 16
EventMaskLeaveWindow = 32
EventMaskPointerMotion = 64
EventMaskPointerMotionHint = 128
EventMaskButton1Motion = 256
EventMaskButton2Motion = 512
EventMaskButton3Motion = 1024
EventMaskButton4Motion = 2048
EventMaskButton5Motion = 4096
EventMaskButtonMotion = 8192
EventMaskKeymapState = 16384
EventMaskExposure = 32768
EventMaskVisibilityChange = 65536
EventMaskStructureNotify = 131072
EventMaskResizeRedirect = 262144
EventMaskSubstructureNotify = 524288
EventMaskSubstructureRedirect = 1048576
EventMaskFocusChange = 2097152
EventMaskPropertyChange = 4194304
EventMaskColorMapChange = 8388608
EventMaskOwnerGrabButton = 16777216
)
const (
BackingStoreNotUseful = 0
BackingStoreWhenMapped = 1
BackingStoreAlways = 2
)
type ScreenInfo struct {
Root Id
DefaultColormap Id
WhitePixel uint32
BlackPixel uint32
CurrentInputMasks uint32
WidthInPixels uint16
HeightInPixels uint16
WidthInMillimeters uint16
HeightInMillimeters uint16
MinInstalledMaps uint16
MaxInstalledMaps uint16
RootVisual Id
BackingStores byte
SaveUnders bool
RootDepth byte
AllowedDepthsLen byte
AllowedDepths []DepthInfo
}
func getScreenInfo(b []byte, v *ScreenInfo) int {
v.Root = Id(get32(b[0:]))
v.DefaultColormap = Id(get32(b[4:]))
v.WhitePixel = get32(b[8:])
v.BlackPixel = get32(b[12:])
v.CurrentInputMasks = get32(b[16:])
v.WidthInPixels = get16(b[20:])
v.HeightInPixels = get16(b[22:])
v.WidthInMillimeters = get16(b[24:])
v.HeightInMillimeters = get16(b[26:])
v.MinInstalledMaps = get16(b[28:])
v.MaxInstalledMaps = get16(b[30:])
v.RootVisual = Id(get32(b[32:]))
v.BackingStores = b[36]
v.SaveUnders = b[37] != 0
v.RootDepth = b[38]
v.AllowedDepthsLen = b[39]
offset := 40
v.AllowedDepths = make([]DepthInfo, int(v.AllowedDepthsLen))
for i := 0; i < int(v.AllowedDepthsLen); i++ {
offset += getDepthInfo(b[offset:], &v.AllowedDepths[i])
}
return offset
}
const (
ImageOrderLSBFirst = 0
ImageOrderMSBFirst = 1
)
type SetupInfo struct {
Status byte
ProtocolMajorVersion uint16
ProtocolMinorVersion uint16
Length uint16
ReleaseNumber uint32
ResourceIdBase uint32
ResourceIdMask uint32
MotionBufferSize uint32
VendorLen uint16
MaximumRequestLength uint16
RootsLen byte
PixmapFormatsLen byte
ImageByteOrder byte
BitmapFormatBitOrder byte
BitmapFormatScanlineUnit byte
BitmapFormatScanlinePad byte
MinKeycode byte
MaxKeycode byte
Vendor []byte
PixmapFormats []Format
Roots []ScreenInfo
}
func getSetupInfo(b []byte, v *SetupInfo) int {
v.Status = b[0]
v.ProtocolMajorVersion = get16(b[2:])
v.ProtocolMinorVersion = get16(b[4:])
v.Length = get16(b[6:])
v.ReleaseNumber = get32(b[8:])
v.ResourceIdBase = get32(b[12:])
v.ResourceIdMask = get32(b[16:])
v.MotionBufferSize = get32(b[20:])
v.VendorLen = get16(b[24:])
v.MaximumRequestLength = get16(b[26:])
v.RootsLen = b[28]
v.PixmapFormatsLen = b[29]
v.ImageByteOrder = b[30]
v.BitmapFormatBitOrder = b[31]
v.BitmapFormatScanlineUnit = b[32]
v.BitmapFormatScanlinePad = b[33]
v.MinKeycode = b[34]
v.MaxKeycode = b[35]
offset := 40
v.Vendor = make([]byte, int(v.VendorLen))
copy(v.Vendor[0:len(v.Vendor)], b[offset:])
offset += len(v.Vendor) * 1
offset = pad(offset)
v.PixmapFormats = make([]Format, int(v.PixmapFormatsLen))
for i := 0; i < int(v.PixmapFormatsLen); i++ {
offset += getFormat(b[offset:], &v.PixmapFormats[i])
}
offset = pad(offset)
v.Roots = make([]ScreenInfo, int(v.RootsLen))
for i := 0; i < int(v.RootsLen); i++ {
offset += getScreenInfo(b[offset:], &v.Roots[i])
}
return offset
}
const (
ModMaskShift = 1
ModMaskLock = 2
ModMaskControl = 4
ModMask1 = 8
ModMask2 = 16
ModMask3 = 32
ModMask4 = 64
ModMask5 = 128
ModMaskAny = 32768
)
const (
KeyButMaskShift = 1
KeyButMaskLock = 2
KeyButMaskControl = 4
KeyButMaskMod1 = 8
KeyButMaskMod2 = 16
KeyButMaskMod3 = 32
KeyButMaskMod4 = 64
KeyButMaskMod5 = 128
KeyButMaskButton1 = 256
KeyButMaskButton2 = 512
KeyButMaskButton3 = 1024
KeyButMaskButton4 = 2048
KeyButMaskButton5 = 4096
)
const (
WindowNone = 0
)
const KeyPress = 2
type KeyPressEvent struct {
Detail byte
Time Timestamp
Root Id
Event Id
Child Id
RootX int16
RootY int16
EventX int16
EventY int16
State uint16
SameScreen bool
}
func getKeyPressEvent(b []byte) KeyPressEvent {
var v KeyPressEvent
v.Detail = b[1]
v.Time = Timestamp(get32(b[4:]))
v.Root = Id(get32(b[8:]))
v.Event = Id(get32(b[12:]))
v.Child = Id(get32(b[16:]))
v.RootX = int16(get16(b[20:]))
v.RootY = int16(get16(b[22:]))
v.EventX = int16(get16(b[24:]))
v.EventY = int16(get16(b[26:]))
v.State = get16(b[28:])
v.SameScreen = b[30] != 0
return v
}
func putKeyPressEvent(e KeyPressEvent, b []byte) {
b[1] = e.Detail
put32(b[4:], uint32(e.Time))
put32(b[8:], uint32(e.Root))
put32(b[12:], uint32(e.Event))
put32(b[16:], uint32(e.Child))
put16(b[20:], uint16(e.RootX))
put16(b[22:], uint16(e.RootY))
put16(b[24:], uint16(e.EventX))
put16(b[26:], uint16(e.EventY))
put16(b[28:], e.State)
if e.SameScreen {
b[30] = 1
} else {
b[30] = 0
}
}
const KeyRelease = 3
type KeyReleaseEvent KeyPressEvent
func getKeyReleaseEvent(b []byte) KeyReleaseEvent {
return (KeyReleaseEvent)(getKeyPressEvent(b))
}
func putKeyReleaseEvent(e KeyReleaseEvent, b []byte) {
putKeyPressEvent((KeyPressEvent)(e), b)
}
const (
ButtonMask1 = 256
ButtonMask2 = 512
ButtonMask3 = 1024
ButtonMask4 = 2048
ButtonMask5 = 4096
ButtonMaskAny = 32768
)
const ButtonPress = 4
type ButtonPressEvent struct {
Detail byte
Time Timestamp
Root Id
Event Id
Child Id
RootX int16
RootY int16
EventX int16
EventY int16
State uint16
SameScreen bool
}
func getButtonPressEvent(b []byte) ButtonPressEvent {
var v ButtonPressEvent
v.Detail = b[1]
v.Time = Timestamp(get32(b[4:]))
v.Root = Id(get32(b[8:]))
v.Event = Id(get32(b[12:]))
v.Child = Id(get32(b[16:]))
v.RootX = int16(get16(b[20:]))
v.RootY = int16(get16(b[22:]))
v.EventX = int16(get16(b[24:]))
v.EventY = int16(get16(b[26:]))
v.State = get16(b[28:])
v.SameScreen = b[30] != 0
return v
}
func putButtonPressEvent(e ButtonPressEvent, b []byte) {
b[1] = e.Detail
put32(b[4:], uint32(e.Time))
put32(b[8:], uint32(e.Root))
put32(b[12:], uint32(e.Event))
put32(b[16:], uint32(e.Child))
put16(b[20:], uint16(e.RootX))
put16(b[22:], uint16(e.RootY))
put16(b[24:], uint16(e.EventX))
put16(b[26:], uint16(e.EventY))
put16(b[28:], e.State)
if e.SameScreen {
b[30] = 1
} else {
b[30] = 0
}
}
const ButtonRelease = 5
type ButtonReleaseEvent ButtonPressEvent
func getButtonReleaseEvent(b []byte) ButtonReleaseEvent {
return (ButtonReleaseEvent)(getButtonPressEvent(b))
}
func putButtonReleaseEvent(e ButtonReleaseEvent, b []byte) {
putButtonPressEvent((ButtonPressEvent)(e), b)
}
const (
MotionNormal = 0
MotionHint = 1
)
const MotionNotify = 6
type MotionNotifyEvent struct {
Detail byte
Time Timestamp
Root Id
Event Id
Child Id
RootX int16
RootY int16
EventX int16
EventY int16
State uint16
SameScreen bool
}
func getMotionNotifyEvent(b []byte) MotionNotifyEvent {
var v MotionNotifyEvent
v.Detail = b[1]
v.Time = Timestamp(get32(b[4:]))
v.Root = Id(get32(b[8:]))
v.Event = Id(get32(b[12:]))
v.Child = Id(get32(b[16:]))
v.RootX = int16(get16(b[20:]))
v.RootY = int16(get16(b[22:]))
v.EventX = int16(get16(b[24:]))
v.EventY = int16(get16(b[26:]))
v.State = get16(b[28:])
v.SameScreen = b[30] != 0
return v
}
func putMotionNotifyEvent(e MotionNotifyEvent, b []byte) {
b[1] = e.Detail
put32(b[4:], uint32(e.Time))
put32(b[8:], uint32(e.Root))
put32(b[12:], uint32(e.Event))
put32(b[16:], uint32(e.Child))
put16(b[20:], uint16(e.RootX))
put16(b[22:], uint16(e.RootY))
put16(b[24:], uint16(e.EventX))
put16(b[26:], uint16(e.EventY))
put16(b[28:], e.State)
if e.SameScreen {
b[30] = 1
} else {
b[30] = 0
}
}
const (
NotifyDetailAncestor = 0
NotifyDetailVirtual = 1
NotifyDetailInferior = 2
NotifyDetailNonlinear = 3
NotifyDetailNonlinearVirtual = 4
NotifyDetailPointer = 5
NotifyDetailPointerRoot = 6
NotifyDetailNone = 7
)
const (
NotifyModeNormal = 0
NotifyModeGrab = 1
NotifyModeUngrab = 2
NotifyModeWhileGrabbed = 3
)
const EnterNotify = 7
type EnterNotifyEvent struct {
Detail byte
Time Timestamp
Root Id
Event Id
Child Id
RootX int16
RootY int16
EventX int16
EventY int16
State uint16
Mode byte
SameScreenFocus byte
}
func getEnterNotifyEvent(b []byte) EnterNotifyEvent {
var v EnterNotifyEvent
v.Detail = b[1]
v.Time = Timestamp(get32(b[4:]))
v.Root = Id(get32(b[8:]))
v.Event = Id(get32(b[12:]))
v.Child = Id(get32(b[16:]))
v.RootX = int16(get16(b[20:]))
v.RootY = int16(get16(b[22:]))
v.EventX = int16(get16(b[24:]))
v.EventY = int16(get16(b[26:]))
v.State = get16(b[28:])
v.Mode = b[30]
v.SameScreenFocus = b[31]
return v
}
func putEnterNotifyEvent(e EnterNotifyEvent, b []byte) {
b[1] = e.Detail
put32(b[4:], uint32(e.Time))
put32(b[8:], uint32(e.Root))
put32(b[12:], uint32(e.Event))
put32(b[16:], uint32(e.Child))
put16(b[20:], uint16(e.RootX))
put16(b[22:], uint16(e.RootY))
put16(b[24:], uint16(e.EventX))
put16(b[26:], uint16(e.EventY))
put16(b[28:], e.State)
b[30] = e.Mode
b[31] = e.SameScreenFocus
}
const LeaveNotify = 8
type LeaveNotifyEvent EnterNotifyEvent
func getLeaveNotifyEvent(b []byte) LeaveNotifyEvent {
return (LeaveNotifyEvent)(getEnterNotifyEvent(b))
}
func putLeaveNotifyEvent(e LeaveNotifyEvent, b []byte) {
putEnterNotifyEvent((EnterNotifyEvent)(e), b)
}
const FocusIn = 9
type FocusInEvent struct {
Detail byte
Event Id
Mode byte
}
func getFocusInEvent(b []byte) FocusInEvent {
var v FocusInEvent
v.Detail = b[1]
v.Event = Id(get32(b[4:]))
v.Mode = b[8]
return v
}
func putFocusInEvent(e FocusInEvent, b []byte) {
b[1] = e.Detail
put32(b[4:], uint32(e.Event))
b[8] = e.Mode
}
const FocusOut = 10
type FocusOutEvent FocusInEvent
func getFocusOutEvent(b []byte) FocusOutEvent {
return (FocusOutEvent)(getFocusInEvent(b))
}
func putFocusOutEvent(e FocusOutEvent, b []byte) {
putFocusInEvent((FocusInEvent)(e), b)
}
const KeymapNotify = 11
type KeymapNotifyEvent struct {
Keys [31]byte
}
func getKeymapNotifyEvent(b []byte) KeymapNotifyEvent {
var v KeymapNotifyEvent
copy(v.Keys[0:31], b[1:])
return v
}
func putKeymapNotifyEvent(e KeymapNotifyEvent, b []byte) {
copy(b[1:32], e.Keys[:])
}
const Expose = 12
type ExposeEvent struct {
Window Id
X uint16
Y uint16
Width uint16
Height uint16
Count uint16
}
func getExposeEvent(b []byte) ExposeEvent {
var v ExposeEvent
v.Window = Id(get32(b[4:]))
v.X = get16(b[8:])
v.Y = get16(b[10:])
v.Width = get16(b[12:])
v.Height = get16(b[14:])
v.Count = get16(b[16:])
return v
}
func putExposeEvent(e ExposeEvent, b []byte) {
put32(b[4:], uint32(e.Window))
put16(b[8:], e.X)
put16(b[10:], e.Y)
put16(b[12:], e.Width)
put16(b[14:], e.Height)
put16(b[16:], e.Count)
}
const GraphicsExposure = 13
type GraphicsExposureEvent struct {
Drawable Id
X uint16
Y uint16
Width uint16
Height uint16
MinorOpcode uint16
Count uint16
MajorOpcode byte
}
func getGraphicsExposureEvent(b []byte) GraphicsExposureEvent {
var v GraphicsExposureEvent
v.Drawable = Id(get32(b[4:]))
v.X = get16(b[8:])
v.Y = get16(b[10:])
v.Width = get16(b[12:])
v.Height = get16(b[14:])
v.MinorOpcode = get16(b[16:])
v.Count = get16(b[18:])
v.MajorOpcode = b[20]
return v
}
func putGraphicsExposureEvent(e GraphicsExposureEvent, b []byte) {
put32(b[4:], uint32(e.Drawable))
put16(b[8:], e.X)
put16(b[10:], e.Y)
put16(b[12:], e.Width)
put16(b[14:], e.Height)
put16(b[16:], e.MinorOpcode)
put16(b[18:], e.Count)
b[20] = e.MajorOpcode
}
const NoExposure = 14
type NoExposureEvent struct {
Drawable Id
MinorOpcode uint16
MajorOpcode byte
}
func getNoExposureEvent(b []byte) NoExposureEvent {
var v NoExposureEvent
v.Drawable = Id(get32(b[4:]))
v.MinorOpcode = get16(b[8:])
v.MajorOpcode = b[10]
return v
}
func putNoExposureEvent(e NoExposureEvent, b []byte) {
put32(b[4:], uint32(e.Drawable))
put16(b[8:], e.MinorOpcode)
b[10] = e.MajorOpcode
}
const (
VisibilityUnobscured = 0
VisibilityPartiallyObscured = 1
VisibilityFullyObscured = 2
)
const VisibilityNotify = 15
type VisibilityNotifyEvent struct {
Window Id
State byte
}
func getVisibilityNotifyEvent(b []byte) VisibilityNotifyEvent {
var v VisibilityNotifyEvent
v.Window = Id(get32(b[4:]))
v.State = b[8]
return v
}
func putVisibilityNotifyEvent(e VisibilityNotifyEvent, b []byte) {
put32(b[4:], uint32(e.Window))
b[8] = e.State
}
const CreateNotify = 16
type CreateNotifyEvent struct {
Parent Id
Window Id
X int16
Y int16
Width uint16
Height uint16
BorderWidth uint16
OverrideRedirect bool
}
func getCreateNotifyEvent(b []byte) CreateNotifyEvent {
var v CreateNotifyEvent
v.Parent = Id(get32(b[4:]))
v.Window = Id(get32(b[8:]))
v.X = int16(get16(b[12:]))
v.Y = int16(get16(b[14:]))
v.Width = get16(b[16:])
v.Height = get16(b[18:])
v.BorderWidth = get16(b[20:])
v.OverrideRedirect = b[22] != 0
return v
}
func putCreateNotifyEvent(e CreateNotifyEvent, b []byte) {
put32(b[4:], uint32(e.Parent))
put32(b[8:], uint32(e.Window))
put16(b[12:], uint16(e.X))
put16(b[14:], uint16(e.Y))
put16(b[16:], e.Width)
put16(b[18:], e.Height)
put16(b[20:], e.BorderWidth)
if e.OverrideRedirect {
b[22] = 1
} else {
b[22] = 0
}
}
const DestroyNotify = 17
type DestroyNotifyEvent struct {
Event Id
Window Id
}
func getDestroyNotifyEvent(b []byte) DestroyNotifyEvent {
var v DestroyNotifyEvent
v.Event = Id(get32(b[4:]))
v.Window = Id(get32(b[8:]))
return v
}
func putDestroyNotifyEvent(e DestroyNotifyEvent, b []byte) {
put32(b[4:], uint32(e.Event))
put32(b[8:], uint32(e.Window))
}
const UnmapNotify = 18
type UnmapNotifyEvent struct {
Event Id
Window Id
FromConfigure bool
}
func getUnmapNotifyEvent(b []byte) UnmapNotifyEvent {
var v UnmapNotifyEvent
v.Event = Id(get32(b[4:]))
v.Window = Id(get32(b[8:]))
v.FromConfigure = b[12] != 0
return v
}
func putUnmapNotifyEvent(e UnmapNotifyEvent, b []byte) {
put32(b[4:], uint32(e.Event))
put32(b[8:], uint32(e.Window))
if e.FromConfigure {
b[12] = 1
} else {
b[12] = 0
}
}
const MapNotify = 19
type MapNotifyEvent struct {
Event Id
Window Id
OverrideRedirect bool
}
func getMapNotifyEvent(b []byte) MapNotifyEvent {
var v MapNotifyEvent
v.Event = Id(get32(b[4:]))
v.Window = Id(get32(b[8:]))
v.OverrideRedirect = b[12] != 0
return v
}
func putMapNotifyEvent(e MapNotifyEvent, b []byte) {
put32(b[4:], uint32(e.Event))
put32(b[8:], uint32(e.Window))
if e.OverrideRedirect {
b[12] = 1
} else {
b[12] = 0
}
}
const MapRequest = 20
type MapRequestEvent struct {
Parent Id
Window Id
}
func getMapRequestEvent(b []byte) MapRequestEvent {
var v MapRequestEvent
v.Parent = Id(get32(b[4:]))
v.Window = Id(get32(b[8:]))
return v
}
func putMapRequestEvent(e MapRequestEvent, b []byte) {
put32(b[4:], uint32(e.Parent))
put32(b[8:], uint32(e.Window))
}
const ReparentNotify = 21
type ReparentNotifyEvent struct {
Event Id
Window Id
Parent Id
X int16
Y int16
OverrideRedirect bool
}
func getReparentNotifyEvent(b []byte) ReparentNotifyEvent {
var v ReparentNotifyEvent
v.Event = Id(get32(b[4:]))
v.Window = Id(get32(b[8:]))
v.Parent = Id(get32(b[12:]))
v.X = int16(get16(b[16:]))
v.Y = int16(get16(b[18:]))
v.OverrideRedirect = b[20] != 0
return v
}
func putReparentNotifyEvent(e ReparentNotifyEvent, b []byte) {
put32(b[4:], uint32(e.Event))
put32(b[8:], uint32(e.Window))
put32(b[12:], uint32(e.Parent))
put16(b[16:], uint16(e.X))
put16(b[18:], uint16(e.Y))
if e.OverrideRedirect {
b[20] = 1
} else {
b[20] = 0
}
}
const ConfigureNotify = 22
type ConfigureNotifyEvent struct {
Event Id
Window Id
AboveSibling Id
X int16
Y int16
Width uint16
Height uint16
BorderWidth uint16
OverrideRedirect bool
}
func getConfigureNotifyEvent(b []byte) ConfigureNotifyEvent {
var v ConfigureNotifyEvent
v.Event = Id(get32(b[4:]))
v.Window = Id(get32(b[8:]))
v.AboveSibling = Id(get32(b[12:]))
v.X = int16(get16(b[16:]))
v.Y = int16(get16(b[18:]))
v.Width = get16(b[20:])
v.Height = get16(b[22:])
v.BorderWidth = get16(b[24:])
v.OverrideRedirect = b[26] != 0
return v
}
func putConfigureNotifyEvent(e ConfigureNotifyEvent, b []byte) {
put32(b[4:], uint32(e.Event))
put32(b[8:], uint32(e.Window))
put32(b[12:], uint32(e.AboveSibling))
put16(b[16:], uint16(e.X))
put16(b[18:], uint16(e.Y))
put16(b[20:], e.Width)
put16(b[22:], e.Height)
put16(b[24:], e.BorderWidth)
if e.OverrideRedirect {
b[26] = 1
} else {
b[26] = 0
}
}
const ConfigureRequest = 23
type ConfigureRequestEvent struct {
StackMode byte
Parent Id
Window Id
Sibling Id
X int16
Y int16
Width uint16
Height uint16
BorderWidth uint16
ValueMask uint16