#1 feat(xtgen): generator for xcb-proto bindings
A bigreq/replies_fuzz_test.go +21 -0
A bigreq/replies_generated.go +21 -0
A bigreq/requests_generated.go +21 -0
A bigreq/sizes_test.go +11 -0
A bigreq/types_generated.go +2 -0
A buf.go +92 -0
A buf_test.go +69 -0
A cmd/xtgen/emit.go +252 -0
A cmd/xtgen/expr.go +43 -0
A cmd/xtgen/ir.go +39 -0
A cmd/xtgen/layout.go +103 -0
M cmd/xtgen/main.go +47 -1
A cmd/xtgen/naming.go +43 -0
A cmd/xtgen/parse.go +292 -0
A cmd/xtgen/parse_test.go +74 -0
A cmd/xtgen/replies.go +554 -0
A cmd/xtgen/replies_test.go +70 -0
A cmd/xtgen/requests.go +359 -0
A cmd/xtgen/resolve.go +356 -0
A cmd/xtgen/resolve_test.go +165 -0
A cmd/xtgen/templates/ext.tmpl +10 -0
A cmd/xtgen/templates/replies.tmpl +5 -0
A cmd/xtgen/templates/requests.tmpl +5 -0
A cmd/xtgen/templates/sizes.tmpl +7 -0
A cmd/xtgen/templates/types.tmpl +5 -0
A cmd/xtgen/values.go +136 -0
A cmd/xtgen/values_test.go +93 -0
A composite/replies_fuzz_test.go +39 -0
A composite/replies_generated.go +42 -0
A composite/requests_generated.go +176 -0
A composite/sizes_test.go +14 -0
A composite/types_generated.go +7 -0
A ext.go +27 -0
A ext_generated.go +19 -0
A ge/replies_fuzz_test.go +22 -0
A ge/replies_generated.go +24 -0
A ge/requests_generated.go +24 -0
A ge/sizes_test.go +11 -0
A ge/types_generated.go +2 -0
A generate.go +3 -0
A internal/xtest/README.md +40 -0
A internal/xtest/capture_test.go +405 -0
A internal/xtest/golden.go +22 -0
A lists_test.go +87 -0
A render/replies_fuzz_test.go +135 -0
A render/replies_generated.go +380 -0
A render/requests_generated.go +1276 -0
A render/sizes_test.go +68 -0
A render/types_generated.go +522 -0
A replies_test.go +304 -0
A requests_test.go +62 -0
A res/replies_fuzz_test.go +146 -0
A res/replies_generated.go +348 -0
A res/requests_generated.go +144 -0
A res/sizes_test.go +47 -0
A res/types_generated.go +159 -0
A shape/replies_fuzz_test.go +86 -0
A shape/replies_generated.go +123 -0
A shape/requests_generated.go +214 -0
A shape/sizes_test.go +23 -0
A shape/types_generated.go +20 -0
A testdata/golden/render/CreatePicture.req.hex +3 -0
A testdata/golden/render/QueryPictFormats.reply.hex +3 -0
A testdata/golden/res/QueryClientIds.reply.hex +3 -0
A testdata/golden/res/QueryClientIds.req.hex +3 -0
A testdata/golden/xfixes/QueryVersion.reply.hex +3 -0
A testdata/golden/xfixes/QueryVersion.req.hex +3 -0
A testdata/golden/xproto/ChangeProperty.req.hex +3 -0
A testdata/golden/xproto/ChangeWindowAttributes.req.hex +3 -0
A testdata/golden/xproto/ConfigureWindow.req.hex +3 -0
A testdata/golden/xproto/ConfigureWindowAll.req.hex +3 -0
A testdata/golden/xproto/ConfigureWindowSparse.req.hex +3 -0
A testdata/golden/xproto/CreateWindow.req.hex +3 -0
A testdata/golden/xproto/GetGeometry.reply.hex +3 -0
A testdata/golden/xproto/GetGeometry.req.hex +3 -0
A testdata/golden/xproto/GetProperty.reply.hex +3 -0
| @@ -0,0 +1,3 @@ | |||
| 1 | + | # source: Xvfb reply via raw socketpair tee to an independent reference request | |
| 2 | + | # xtrace fallback: local xtrace is glibc's execution tracer, not X11 xtrace | |
| 3 | + | 01080700010000001f000000000000000300000000000000000000000000000061626300 | |
A testdata/golden/xproto/GetPropertyEmpty.reply.hex +3 -0
| @@ -0,0 +1,3 @@ | |||
| 1 | + | # source: Xvfb reply via raw socketpair tee to an independent reference request | |
| 2 | + | # xtrace fallback: local xtrace is glibc's execution tracer, not X11 xtrace | |
| 3 | + | 0100170000000000000000000000000000000000000000000000000000000000 | |
A testdata/golden/xproto/GetWindowAttributes.reply.hex +3 -0
| @@ -0,0 +1,3 @@ | |||
| 1 | + | # source: Xvfb reply via raw socketpair tee to an independent reference request | |
| 2 | + | # xtrace fallback: local xtrace is glibc's execution tracer, not X11 xtrace | |
| 3 | + | 01001500030000002100000001000001ffffffff000000000101000020000000000000000000000000000000 | |
A testdata/golden/xproto/InternAtom.reply.hex +3 -0
| @@ -0,0 +1,3 @@ | |||
| 1 | + | # source: Xvfb reply via raw socketpair tee to an independent reference request | |
| 2 | + | # xtrace fallback: local xtrace is glibc's execution tracer, not X11 xtrace | |
| 3 | + | 0100050000000000e70000000000000000000000000000000000000000000000 | |
A testdata/golden/xproto/InternAtom.req.hex +3 -0
| @@ -0,0 +1,3 @@ | |||
| 1 | + | # source: Xvfb via raw socketpair tee; independent reference encoder; server accepted | |
| 2 | + | # xtrace fallback: local xtrace is glibc's execution tracer, not X11 xtrace | |
| 3 | + | 100004000700000058545552424f5f00 | |
A testdata/golden/xproto/ListExtensions.reply.hex +3 -0
| @@ -0,0 +1,3 @@ | |||
| 1 | + | # source: Xvfb reply via raw socketpair tee to an independent reference request | |
| 2 | + | # xtrace fallback: local xtrace is glibc's execution tracer, not X11 xtrace | |
| 3 | + | 01171800370000000000000000000000000000000000000000000000000000001747656e65726963204576656e7420457874656e73696f6e055348415045074d49542d53484d0f58496e707574457874656e73696f6e0558544553540c4249472d52455155455354530453594e4309584b4559424f4152440758432d4d495343085345435552495459065846495845530652454e4445520552414e44520858494e4552414d4109436f6d706f736974650644414d414745104d49542d53435245454e2d53415645520d444f55424c452d425546464552065245434f52440750726573656e740a582d5265736f757263650658566964656f03474c5800 | |
A testdata/golden/xproto/MapWindow.req.hex +3 -0
| @@ -0,0 +1,3 @@ | |||
| 1 | + | # source: Xvfb via raw socketpair tee; independent reference encoder; server accepted | |
| 2 | + | # xtrace fallback: local xtrace is glibc's execution tracer, not X11 xtrace | |
| 3 | + | 080002009f030000 | |
A testdata/golden/xproto/QueryExtension.reply.hex +3 -0
| @@ -0,0 +1,3 @@ | |||
| 1 | + | # source: Xvfb reply via raw socketpair tee to an independent reference request | |
| 2 | + | # xtrace fallback: local xtrace is glibc's execution tracer, not X11 xtrace | |
| 3 | + | 0100010000000000018a578c0000000000000000000000000000000000000000 | |
A testdata/golden/xproto/QueryTree.reply.hex +3 -0
| @@ -0,0 +1,3 @@ | |||
| 1 | + | # source: Xvfb reply via raw socketpair tee to an independent reference request | |
| 2 | + | # xtrace fallback: local xtrace is glibc's execution tracer, not X11 xtrace | |
| 3 | + | 01001600020000009f03000000000000020000000000000000000000000000000200200001002000 | |
A values_test.go +103 -0
| @@ -0,0 +1,103 @@ | |||
| 1 | + | package xturbo_test | |
| 2 | + | ||
| 3 | + | import ( | |
| 4 | + | "bytes" | |
| 5 | + | "encoding/binary" | |
| 6 | + | "testing" | |
| 7 | + | ||
| 8 | + | "bnema.dev/xturbo" | |
| 9 | + | "bnema.dev/xturbo/internal/xtest" | |
| 10 | + | "bnema.dev/xturbo/render" | |
| 11 | + | "bnema.dev/xturbo/xproto" | |
| 12 | + | ) | |
| 13 | + | ||
| 14 | + | func TestValueRequestGoldens(t *testing.T) { | |
| 15 | + | for _, name := range []string{"xproto/ConfigureWindow", "xproto/ConfigureWindowSparse", "xproto/ConfigureWindowAll", "xproto/CreateWindow", "xproto/ChangeWindowAttributes", "render/CreatePicture"} { | |
| 16 | + | t.Run(name, func(t *testing.T) { | |
| 17 | + | want, err := xtest.LoadHex("testdata/golden/" + name + ".req.hex") | |
| 18 | + | if err != nil { | |
| 19 | + | t.Fatal(err) | |
| 20 | + | } | |
| 21 | + | u32 := func(off int) uint32 { return binary.LittleEndian.Uint32(want[off:]) } | |
| 22 | + | b := xturbo.NewBuf(0) | |
| 23 | + | var seq xturbo.Seq | |
| 24 | + | switch name { | |
| 25 | + | case "xproto/ConfigureWindow": | |
| 26 | + | seq = xproto.ConfigureWindow(b, xproto.Window(u32(4)), &xproto.ConfigureWindowValues{}) | |
| 27 | + | case "xproto/ConfigureWindowSparse": | |
| 28 | + | var v xproto.ConfigureWindowValues | |
| 29 | + | if v.SetStackMode(xproto.StackModeAbove).SetWidth(80).SetX(-7) != &v { | |
| 30 | + | t.Fatal("setter chaining") | |
| 31 | + | } | |
| 32 | + | seq = xproto.ConfigureWindow(b, xproto.Window(u32(4)), &v) | |
| 33 | + | case "xproto/ConfigureWindowAll": | |
| 34 | + | var v xproto.ConfigureWindowValues | |
| 35 | + | v.SetStackMode(xproto.StackModeAbove).SetSibling(xproto.Window(u32(32))).SetBorderWidth(2).SetHeight(72).SetWidth(96).SetY(9).SetX(-3) | |
| 36 | + | seq = xproto.ConfigureWindow(b, xproto.Window(u32(4)), &v) | |
| 37 | + | case "xproto/CreateWindow": | |
| 38 | + | var v xproto.CreateWindowValues | |
| 39 | + | v.SetSaveUnder(false).SetOverrideRedirect(true).SetBackgroundPixel(0x123456) | |
| 40 | + | seq = xproto.CreateWindow(b, 0, xproto.Window(u32(4)), xproto.Window(u32(8)), 0, 0, 64, 48, 0, xproto.WindowClassInputOutput, 0, &v) | |
| 41 | + | case "xproto/ChangeWindowAttributes": | |
| 42 | + | var v xproto.ChangeWindowAttributesValues | |
| 43 | + | v.SetSaveUnder(true).SetOverrideRedirect(false) | |
| 44 | + | seq = xproto.ChangeWindowAttributes(b, xproto.Window(u32(4)), &v) | |
| 45 | + | case "render/CreatePicture": | |
| 46 | + | var ext xturbo.ExtTable | |
| 47 | + | ext.Set(xturbo.ExtRender, want[0], 0, 0) | |
| 48 | + | b.Ext = &ext | |
| 49 | + | var v render.CreatePictureValues | |
| 50 | + | v.SetClipyorigin(7).SetClipxorigin(-5).SetRepeat(render.RepeatNormal) | |
| 51 | + | seq = render.CreatePicture(b, render.Picture(u32(4)), xproto.Drawable(u32(8)), render.Pictformat(u32(12)), &v) | |
| 52 | + | } | |
| 53 | + | if seq != 1 || b.Err() != nil { | |
| 54 | + | t.Fatalf("seq=%d err=%v", seq, b.Err()) | |
| 55 | + | } | |
| 56 | + | if !bytes.Equal(b.Bytes(), want) { | |
| 57 | + | t.Fatalf("got %x want %x", b.Bytes(), want) | |
| 58 | + | } | |
| 59 | + | }) | |
| 60 | + | } | |
| 61 | + | } | |
| 62 | + | ||
| 63 | + | func TestAllocValueRequests(t *testing.T) { | |
| 64 | + | b := xturbo.NewBuf(0) | |
| 65 | + | var ext xturbo.ExtTable | |
| 66 | + | ext.Set(xturbo.ExtRender, 139, 0, 0) | |
| 67 | + | b.Ext = &ext | |
| 68 | + | var v xproto.ConfigureWindowValues | |
| 69 | + | v.SetX(-1).SetY(-2).SetWidth(800).SetHeight(600).SetBorderWidth(1).SetSibling(2).SetStackMode(xproto.StackModeAbove) | |
| 70 | + | var create xproto.CreateWindowValues | |
| 71 | + | create.SetOverrideRedirect(true).SetSaveUnder(false) | |
| 72 | + | var change xproto.ChangeWindowAttributesValues | |
| 73 | + | change.SetOverrideRedirect(false).SetSaveUnder(true) | |
| 74 | + | var pic render.CreatePictureValues | |
| 75 | + | pic.SetRepeat(render.RepeatNormal).SetClipxorigin(-1) | |
| 76 | + | if n := testing.AllocsPerRun(1000, func() { | |
| 77 | + | b.Reset() | |
| 78 | + | xproto.ConfigureWindow(b, 1, &v) | |
| 79 | + | xproto.CreateWindow(b, 0, 1, 2, 0, 0, 80, 60, 0, xproto.WindowClassInputOutput, 0, &create) | |
| 80 | + | xproto.ChangeWindowAttributes(b, 1, &change) | |
| 81 | + | render.CreatePicture(b, 1, 1, 1, &pic) | |
| 82 | + | }); n != 0 { | |
| 83 | + | t.Fatal(n) | |
| 84 | + | } | |
| 85 | + | if b.Err() != nil { | |
| 86 | + | t.Fatal(b.Err()) | |
| 87 | + | } | |
| 88 | + | } | |
| 89 | + | ||
| 90 | + | func TestValueRequestFailures(t *testing.T) { | |
| 91 | + | b := xturbo.NewBuf(0) | |
| 92 | + | b.Fail(xturbo.ErrBadLength) | |
| 93 | + | if xproto.ConfigureWindow(b, 1, &xproto.ConfigureWindowValues{}) != 0 || b.Len() != 0 || b.Err() != xturbo.ErrBadLength { | |
| 94 | + | t.Fatal("sticky error") | |
| 95 | + | } | |
| 96 | + | for _, ext := range []*xturbo.ExtTable{nil, {}} { | |
| 97 | + | b := xturbo.NewBuf(0) | |
| 98 | + | b.Ext = ext | |
| 99 | + | if render.CreatePicture(b, 1, 1, 1, &render.CreatePictureValues{}) != 0 || b.Err() != xturbo.ErrExtMissing || b.Len() != 0 { | |
| 100 | + | t.Fatal("missing extension") | |
| 101 | + | } | |
| 102 | + | } | |
| 103 | + | } | |
A xcmisc/replies_fuzz_test.go +60 -0
| @@ -0,0 +1,60 @@ | |||
| 1 | + | // Code generated by xtgen; DO NOT EDIT. | |
| 2 | + | package xcmisc | |
| 3 | + | ||
| 4 | + | import "testing" | |
| 5 | + | ||
| 6 | + | func FuzzParseGetVersionReply(f *testing.F) { | |
| 7 | + | f.Add(make([]byte, 32)) | |
| 8 | + | f.Fuzz(func(t *testing.T, raw []byte) { | |
| 9 | + | r, ok := ParseGetVersionReply(raw) | |
| 10 | + | if !ok { | |
| 11 | + | if len(raw) >= 32 { | |
| 12 | + | t.Fatal("rejected a complete fixed-size reply") | |
| 13 | + | } | |
| 14 | + | return | |
| 15 | + | } | |
| 16 | + | if len(r.Raw()) != len(raw) { | |
| 17 | + | t.Fatal("Raw must return the parsed bytes") | |
| 18 | + | } | |
| 19 | + | _ = r.ServerMajorVersion() | |
| 20 | + | _ = r.ServerMinorVersion() | |
| 21 | + | }) | |
| 22 | + | } | |
| 23 | + | ||
| 24 | + | func FuzzParseGetXIDRangeReply(f *testing.F) { | |
| 25 | + | f.Add(make([]byte, 32)) | |
| 26 | + | f.Fuzz(func(t *testing.T, raw []byte) { | |
| 27 | + | r, ok := ParseGetXIDRangeReply(raw) | |
| 28 | + | if !ok { | |
| 29 | + | if len(raw) >= 32 { | |
| 30 | + | t.Fatal("rejected a complete fixed-size reply") | |
| 31 | + | } | |
| 32 | + | return | |
| 33 | + | } | |
| 34 | + | if len(r.Raw()) != len(raw) { | |
| 35 | + | t.Fatal("Raw must return the parsed bytes") | |
| 36 | + | } | |
| 37 | + | _ = r.StartId() | |
| 38 | + | _ = r.Count() | |
| 39 | + | }) | |
| 40 | + | } | |
| 41 | + | ||
| 42 | + | func FuzzParseGetXIDListReply(f *testing.F) { | |
| 43 | + | f.Add(make([]byte, 32)) | |
| 44 | + | f.Fuzz(func(t *testing.T, raw []byte) { | |
| 45 | + | r, ok := ParseGetXIDListReply(raw) | |
| 46 | + | if !ok { | |
| 47 | + | return | |
| 48 | + | } | |
| 49 | + | if len(r.Raw()) != len(raw) { | |
| 50 | + | t.Fatal("Raw must return the parsed bytes") | |
| 51 | + | } | |
| 52 | + | _ = r.IdsLen() | |
| 53 | + | { | |
| 54 | + | l0 := r.Ids() | |
| 55 | + | for i := 0; i < l0.Len(); i++ { | |
| 56 | + | _ = l0.At(i) | |
| 57 | + | } | |
| 58 | + | } | |
| 59 | + | }) | |
| 60 | + | } | |
A xcmisc/replies_generated.go +80 -0
| @@ -0,0 +1,80 @@ | |||
| 1 | + | // Code generated by xtgen; DO NOT EDIT. | |
| 2 | + | package xcmisc | |
| 3 | + | ||
| 4 | + | import "encoding/binary" | |
| 5 | + | ||
| 6 | + | // GetVersionReply is a zero-copy view over a GetVersion reply; offsets count from reply byte 0. | |
| 7 | + | // It borrows the reply bytes: valid only until the Handler callback returns, because the read ring is reused. Copy what you keep. | |
| 8 | + | type GetVersionReply struct{ raw []byte } | |
| 9 | + | ||
| 10 | + | // ParseGetVersionReply validates raw (the whole reply, 32+4*length bytes) once; getters do not re-check. | |
| 11 | + | func ParseGetVersionReply(raw []byte) (GetVersionReply, bool) { | |
| 12 | + | if len(raw) < 32 { | |
| 13 | + | return GetVersionReply{}, false | |
| 14 | + | } | |
| 15 | + | r := GetVersionReply{raw: raw} | |
| 16 | + | return r, true | |
| 17 | + | } | |
| 18 | + | func (r GetVersionReply) Raw() []byte { return r.raw } | |
| 19 | + | func (r GetVersionReply) ServerMajorVersion() uint16 { | |
| 20 | + | return uint16(binary.LittleEndian.Uint16(r.raw[8:])) | |
| 21 | + | } | |
| 22 | + | func (r GetVersionReply) ServerMinorVersion() uint16 { | |
| 23 | + | return uint16(binary.LittleEndian.Uint16(r.raw[10:])) | |
| 24 | + | } | |
| 25 | + | ||
| 26 | + | // GetXIDRangeReply is a zero-copy view over a GetXIDRange reply; offsets count from reply byte 0. | |
| 27 | + | // It borrows the reply bytes: valid only until the Handler callback returns, because the read ring is reused. Copy what you keep. | |
| 28 | + | type GetXIDRangeReply struct{ raw []byte } | |
| 29 | + | ||
| 30 | + | // ParseGetXIDRangeReply validates raw (the whole reply, 32+4*length bytes) once; getters do not re-check. | |
| 31 | + | func ParseGetXIDRangeReply(raw []byte) (GetXIDRangeReply, bool) { | |
| 32 | + | if len(raw) < 32 { | |
| 33 | + | return GetXIDRangeReply{}, false | |
| 34 | + | } | |
| 35 | + | r := GetXIDRangeReply{raw: raw} | |
| 36 | + | return r, true | |
| 37 | + | } | |
| 38 | + | func (r GetXIDRangeReply) Raw() []byte { return r.raw } | |
| 39 | + | func (r GetXIDRangeReply) StartId() uint32 { return uint32(binary.LittleEndian.Uint32(r.raw[8:])) } | |
| 40 | + | func (r GetXIDRangeReply) Count() uint32 { return uint32(binary.LittleEndian.Uint32(r.raw[12:])) } | |
| 41 | + | ||
| 42 | + | // GetXIDListReply is a zero-copy view over a GetXIDList reply; offsets count from reply byte 0. | |
| 43 | + | // It borrows the reply bytes: valid only until the Handler callback returns, because the read ring is reused. Copy what you keep. | |
| 44 | + | type GetXIDListReply struct{ raw []byte } | |
| 45 | + | ||
| 46 | + | // ParseGetXIDListReply validates raw (the whole reply, 32+4*length bytes) once; getters do not re-check. | |
| 47 | + | func ParseGetXIDListReply(raw []byte) (GetXIDListReply, bool) { | |
| 48 | + | if len(raw) < 32 { | |
| 49 | + | return GetXIDListReply{}, false | |
| 50 | + | } | |
| 51 | + | r := GetXIDListReply{raw: raw} | |
| 52 | + | off := 32 | |
| 53 | + | { | |
| 54 | + | n := int(r.IdsLen()) | |
| 55 | + | if n < 0 || n > len(r.raw) { | |
| 56 | + | return GetXIDListReply{}, false | |
| 57 | + | } | |
| 58 | + | off += n * 4 | |
| 59 | + | } | |
| 60 | + | if off > len(r.raw) { | |
| 61 | + | return GetXIDListReply{}, false | |
| 62 | + | } | |
| 63 | + | if off > len(r.raw) { | |
| 64 | + | return GetXIDListReply{}, false | |
| 65 | + | } | |
| 66 | + | return r, true | |
| 67 | + | } | |
| 68 | + | func (r GetXIDListReply) Raw() []byte { return r.raw } | |
| 69 | + | func (r GetXIDListReply) IdsLen() uint32 { return uint32(binary.LittleEndian.Uint32(r.raw[8:])) } | |
| 70 | + | func (r GetXIDListReply) Ids() Uint32List { | |
| 71 | + | off := 32 | |
| 72 | + | end := off + (int(r.IdsLen()))*4 | |
| 73 | + | return Uint32List{b: r.raw[off:end:end]} | |
| 74 | + | } | |
| 75 | + | ||
| 76 | + | // Uint32List is a borrowed view over a wire list of uint32. It shares the lifetime of the bytes it was taken from; copy what you keep. | |
| 77 | + | type Uint32List struct{ b []byte } | |
| 78 | + | ||
| 79 | + | func (l Uint32List) Len() int { return len(l.b) / 4 } | |
| 80 | + | func (l Uint32List) At(i int) uint32 { return uint32(binary.LittleEndian.Uint32(l.b[i*4:])) } | |
A xcmisc/requests_generated.go +59 -0
| @@ -0,0 +1,59 @@ | |||
| 1 | + | // Code generated by xtgen; DO NOT EDIT. | |
| 2 | + | package xcmisc | |
| 3 | + | ||
| 4 | + | import "encoding/binary" | |
| 5 | + | import "bnema.dev/xturbo" | |
| 6 | + | ||
| 7 | + | func GetVersion(b *xturbo.Buf, clientMajorVersion uint16, clientMinorVersion uint16) xturbo.Seq { | |
| 8 | + | if b.Ext == nil { | |
| 9 | + | b.Fail(xturbo.ErrExtMissing) | |
| 10 | + | return 0 | |
| 11 | + | } | |
| 12 | + | major := b.Ext.Major(xturbo.ExtXCMisc) | |
| 13 | + | if major == 0 { | |
| 14 | + | b.Fail(xturbo.ErrExtMissing) | |
| 15 | + | return 0 | |
| 16 | + | } | |
| 17 | + | p, seq := b.Request(major, 0, 4) | |
| 18 | + | if p == nil { | |
| 19 | + | return 0 | |
| 20 | + | } | |
| 21 | + | binary.LittleEndian.PutUint16(p[0:], uint16(clientMajorVersion)) | |
| 22 | + | binary.LittleEndian.PutUint16(p[2:], uint16(clientMinorVersion)) | |
| 23 | + | return seq | |
| 24 | + | } | |
| 25 | + | ||
| 26 | + | func GetXIDRange(b *xturbo.Buf) xturbo.Seq { | |
| 27 | + | if b.Ext == nil { | |
| 28 | + | b.Fail(xturbo.ErrExtMissing) | |
| 29 | + | return 0 | |
| 30 | + | } | |
| 31 | + | major := b.Ext.Major(xturbo.ExtXCMisc) | |
| 32 | + | if major == 0 { | |
| 33 | + | b.Fail(xturbo.ErrExtMissing) | |
| 34 | + | return 0 | |
| 35 | + | } | |
| 36 | + | p, seq := b.Request(major, 1, 0) | |
| 37 | + | if p == nil { | |
| 38 | + | return 0 | |
| 39 | + | } | |
| 40 | + | return seq | |
| 41 | + | } | |
| 42 | + | ||
| 43 | + | func GetXIDList(b *xturbo.Buf, count uint32) xturbo.Seq { | |
| 44 | + | if b.Ext == nil { | |
| 45 | + | b.Fail(xturbo.ErrExtMissing) | |
| 46 | + | return 0 | |
| 47 | + | } | |
| 48 | + | major := b.Ext.Major(xturbo.ExtXCMisc) | |
| 49 | + | if major == 0 { | |
| 50 | + | b.Fail(xturbo.ErrExtMissing) | |
| 51 | + | return 0 | |
| 52 | + | } | |
| 53 | + | p, seq := b.Request(major, 2, 4) | |
| 54 | + | if p == nil { | |
| 55 | + | return 0 | |
| 56 | + | } | |
| 57 | + | binary.LittleEndian.PutUint32(p[0:], uint32(count)) | |
| 58 | + | return seq | |
| 59 | + | } | |
A xcmisc/sizes_test.go +17 -0
| @@ -0,0 +1,17 @@ | |||
| 1 | + | // Code generated by xtgen; DO NOT EDIT. | |
| 2 | + | package xcmisc | |
| 3 | + | ||
| 4 | + | import "testing" | |
| 5 | + | ||
| 6 | + | func TestWireSizes(t *testing.T) { | |
| 7 | + | if got := 32; got != 32 { | |
| 8 | + | t.Errorf("reply GetVersion fixed size = %d", got) | |
| 9 | + | } | |
| 10 | + | if got := 32; got != 32 { | |
| 11 | + | t.Errorf("reply GetXIDRange fixed size = %d", got) | |
| 12 | + | } | |
| 13 | + | if got := 32; got != 32 { | |
| 14 | + | t.Errorf("reply GetXIDList fixed size = %d", got) | |
| 15 | + | } | |
| 16 | + | ||
| 17 | + | } | |
A xcmisc/types_generated.go +2 -0
| @@ -0,0 +1,2 @@ | |||
| 1 | + | // Code generated by xtgen; DO NOT EDIT. | |
| 2 | + | package xcmisc | |
A xfixes/replies_fuzz_test.go +136 -0
| @@ -0,0 +1,136 @@ | |||
| 1 | + | // Code generated by xtgen; DO NOT EDIT. | |
| 2 | + | package xfixes | |
| 3 | + | ||
| 4 | + | import "testing" | |
| 5 | + | import "bnema.dev/xturbo/internal/xtest" | |
| 6 | + | ||
| 7 | + | func FuzzParseQueryVersionReply(f *testing.F) { | |
| 8 | + | f.Add(make([]byte, 32)) | |
| 9 | + | if raw, err := xtest.LoadHex("../testdata/golden/xfixes/QueryVersion.reply.hex"); err != nil { | |
| 10 | + | f.Fatal(err) | |
| 11 | + | } else { | |
| 12 | + | f.Add(raw) | |
| 13 | + | } | |
| 14 | + | f.Fuzz(func(t *testing.T, raw []byte) { | |
| 15 | + | r, ok := ParseQueryVersionReply(raw) | |
| 16 | + | if !ok { | |
| 17 | + | if len(raw) >= 32 { | |
| 18 | + | t.Fatal("rejected a complete fixed-size reply") | |
| 19 | + | } | |
| 20 | + | return | |
| 21 | + | } | |
| 22 | + | if len(r.Raw()) != len(raw) { | |
| 23 | + | t.Fatal("Raw must return the parsed bytes") | |
| 24 | + | } | |
| 25 | + | _ = r.MajorVersion() | |
| 26 | + | _ = r.MinorVersion() | |
| 27 | + | }) | |
| 28 | + | } | |
| 29 | + | ||
| 30 | + | func FuzzParseGetCursorImageReply(f *testing.F) { | |
| 31 | + | f.Add(make([]byte, 32)) | |
| 32 | + | f.Fuzz(func(t *testing.T, raw []byte) { | |
| 33 | + | r, ok := ParseGetCursorImageReply(raw) | |
| 34 | + | if !ok { | |
| 35 | + | return | |
| 36 | + | } | |
| 37 | + | if len(r.Raw()) != len(raw) { | |
| 38 | + | t.Fatal("Raw must return the parsed bytes") | |
| 39 | + | } | |
| 40 | + | _ = r.X() | |
| 41 | + | _ = r.Y() | |
| 42 | + | _ = r.Width() | |
| 43 | + | _ = r.Height() | |
| 44 | + | _ = r.Xhot() | |
| 45 | + | _ = r.Yhot() | |
| 46 | + | _ = r.CursorSerial() | |
| 47 | + | { | |
| 48 | + | l0 := r.CursorImage() | |
| 49 | + | for i := 0; i < l0.Len(); i++ { | |
| 50 | + | _ = l0.At(i) | |
| 51 | + | } | |
| 52 | + | } | |
| 53 | + | }) | |
| 54 | + | } | |
| 55 | + | ||
| 56 | + | func FuzzParseFetchRegionReply(f *testing.F) { | |
| 57 | + | f.Add(make([]byte, 32)) | |
| 58 | + | f.Fuzz(func(t *testing.T, raw []byte) { | |
| 59 | + | r, ok := ParseFetchRegionReply(raw) | |
| 60 | + | if !ok { | |
| 61 | + | return | |
| 62 | + | } | |
| 63 | + | if len(r.Raw()) != len(raw) { | |
| 64 | + | t.Fatal("Raw must return the parsed bytes") | |
| 65 | + | } | |
| 66 | + | _ = r.Extents() | |
| 67 | + | { | |
| 68 | + | l0 := r.Rectangles() | |
| 69 | + | for i := 0; i < l0.Len(); i++ { | |
| 70 | + | _ = l0.At(i) | |
| 71 | + | } | |
| 72 | + | } | |
| 73 | + | }) | |
| 74 | + | } | |
| 75 | + | ||
| 76 | + | func FuzzParseGetCursorNameReply(f *testing.F) { | |
| 77 | + | f.Add(make([]byte, 32)) | |
| 78 | + | f.Fuzz(func(t *testing.T, raw []byte) { | |
| 79 | + | r, ok := ParseGetCursorNameReply(raw) | |
| 80 | + | if !ok { | |
| 81 | + | return | |
| 82 | + | } | |
| 83 | + | if len(r.Raw()) != len(raw) { | |
| 84 | + | t.Fatal("Raw must return the parsed bytes") | |
| 85 | + | } | |
| 86 | + | _ = r.Atom() | |
| 87 | + | _ = r.Nbytes() | |
| 88 | + | _ = len(r.Name()) | |
| 89 | + | }) | |
| 90 | + | } | |
| 91 | + | ||
| 92 | + | func FuzzParseGetCursorImageAndNameReply(f *testing.F) { | |
| 93 | + | f.Add(make([]byte, 32)) | |
| 94 | + | f.Fuzz(func(t *testing.T, raw []byte) { | |
| 95 | + | r, ok := ParseGetCursorImageAndNameReply(raw) | |
| 96 | + | if !ok { | |
| 97 | + | return | |
| 98 | + | } | |
| 99 | + | if len(r.Raw()) != len(raw) { | |
| 100 | + | t.Fatal("Raw must return the parsed bytes") | |
| 101 | + | } | |
| 102 | + | _ = r.X() | |
| 103 | + | _ = r.Y() | |
| 104 | + | _ = r.Width() | |
| 105 | + | _ = r.Height() | |
| 106 | + | _ = r.Xhot() | |
| 107 | + | _ = r.Yhot() | |
| 108 | + | _ = r.CursorSerial() | |
| 109 | + | _ = r.CursorAtom() | |
| 110 | + | _ = r.Nbytes() | |
| 111 | + | { | |
| 112 | + | l0 := r.CursorImage() | |
| 113 | + | for i := 0; i < l0.Len(); i++ { | |
| 114 | + | _ = l0.At(i) | |
| 115 | + | } | |
| 116 | + | } | |
| 117 | + | _ = len(r.Name()) | |
| 118 | + | }) | |
| 119 | + | } | |
| 120 | + | ||
| 121 | + | func FuzzParseGetClientDisconnectModeReply(f *testing.F) { | |
| 122 | + | f.Add(make([]byte, 32)) | |
| 123 | + | f.Fuzz(func(t *testing.T, raw []byte) { | |
| 124 | + | r, ok := ParseGetClientDisconnectModeReply(raw) | |
| 125 | + | if !ok { | |
| 126 | + | if len(raw) >= 32 { | |
| 127 | + | t.Fatal("rejected a complete fixed-size reply") | |
| 128 | + | } | |
| 129 | + | return | |
| 130 | + | } | |
| 131 | + | if len(r.Raw()) != len(raw) { | |
| 132 | + | t.Fatal("Raw must return the parsed bytes") | |
| 133 | + | } | |
| 134 | + | _ = r.DisconnectMode() | |
| 135 | + | }) | |
| 136 | + | } | |
A xfixes/replies_generated.go +242 -0
| @@ -0,0 +1,242 @@ | |||
| 1 | + | // Code generated by xtgen; DO NOT EDIT. | |
| 2 | + | package xfixes | |
| 3 | + | ||
| 4 | + | import "bnema.dev/xturbo/xproto" | |
| 5 | + | import "encoding/binary" | |
| 6 | + | ||
| 7 | + | // QueryVersionReply is a zero-copy view over a QueryVersion reply; offsets count from reply byte 0. | |
| 8 | + | // It borrows the reply bytes: valid only until the Handler callback returns, because the read ring is reused. Copy what you keep. | |
| 9 | + | type QueryVersionReply struct{ raw []byte } | |
| 10 | + | ||
| 11 | + | // ParseQueryVersionReply validates raw (the whole reply, 32+4*length bytes) once; getters do not re-check. | |
| 12 | + | func ParseQueryVersionReply(raw []byte) (QueryVersionReply, bool) { | |
| 13 | + | if len(raw) < 32 { | |
| 14 | + | return QueryVersionReply{}, false | |
| 15 | + | } | |
| 16 | + | r := QueryVersionReply{raw: raw} | |
| 17 | + | return r, true | |
| 18 | + | } | |
| 19 | + | func (r QueryVersionReply) Raw() []byte { return r.raw } | |
| 20 | + | func (r QueryVersionReply) MajorVersion() uint32 { | |
| 21 | + | return uint32(binary.LittleEndian.Uint32(r.raw[8:])) | |
| 22 | + | } | |
| 23 | + | func (r QueryVersionReply) MinorVersion() uint32 { | |
| 24 | + | return uint32(binary.LittleEndian.Uint32(r.raw[12:])) | |
| 25 | + | } | |
| 26 | + | ||
| 27 | + | // GetCursorImageReply is a zero-copy view over a GetCursorImage reply; offsets count from reply byte 0. | |
| 28 | + | // It borrows the reply bytes: valid only until the Handler callback returns, because the read ring is reused. Copy what you keep. | |
| 29 | + | type GetCursorImageReply struct{ raw []byte } | |
| 30 | + | ||
| 31 | + | // ParseGetCursorImageReply validates raw (the whole reply, 32+4*length bytes) once; getters do not re-check. | |
| 32 | + | func ParseGetCursorImageReply(raw []byte) (GetCursorImageReply, bool) { | |
| 33 | + | if len(raw) < 32 { | |
| 34 | + | return GetCursorImageReply{}, false | |
| 35 | + | } | |
| 36 | + | r := GetCursorImageReply{raw: raw} | |
| 37 | + | off := 32 | |
| 38 | + | { | |
| 39 | + | n := (int(r.Width()) * int(r.Height())) | |
| 40 | + | if n < 0 || n > len(r.raw) { | |
| 41 | + | return GetCursorImageReply{}, false | |
| 42 | + | } | |
| 43 | + | off += n * 4 | |
| 44 | + | } | |
| 45 | + | if off > len(r.raw) { | |
| 46 | + | return GetCursorImageReply{}, false | |
| 47 | + | } | |
| 48 | + | if off > len(r.raw) { | |
| 49 | + | return GetCursorImageReply{}, false | |
| 50 | + | } | |
| 51 | + | return r, true | |
| 52 | + | } | |
| 53 | + | func (r GetCursorImageReply) Raw() []byte { return r.raw } | |
| 54 | + | func (r GetCursorImageReply) X() int16 { return int16(binary.LittleEndian.Uint16(r.raw[8:])) } | |
| 55 | + | func (r GetCursorImageReply) Y() int16 { return int16(binary.LittleEndian.Uint16(r.raw[10:])) } | |
| 56 | + | func (r GetCursorImageReply) Width() uint16 { return uint16(binary.LittleEndian.Uint16(r.raw[12:])) } | |
| 57 | + | func (r GetCursorImageReply) Height() uint16 { return uint16(binary.LittleEndian.Uint16(r.raw[14:])) } | |
| 58 | + | func (r GetCursorImageReply) Xhot() uint16 { return uint16(binary.LittleEndian.Uint16(r.raw[16:])) } | |
| 59 | + | func (r GetCursorImageReply) Yhot() uint16 { return uint16(binary.LittleEndian.Uint16(r.raw[18:])) } | |
| 60 | + | func (r GetCursorImageReply) CursorSerial() uint32 { | |
| 61 | + | return uint32(binary.LittleEndian.Uint32(r.raw[20:])) | |
| 62 | + | } | |
| 63 | + | func (r GetCursorImageReply) CursorImage() Uint32List { | |
| 64 | + | off := 32 | |
| 65 | + | end := off + (int(r.Width())*int(r.Height()))*4 | |
| 66 | + | return Uint32List{b: r.raw[off:end:end]} | |
| 67 | + | } | |
| 68 | + | ||
| 69 | + | // FetchRegionReply is a zero-copy view over a FetchRegion reply; offsets count from reply byte 0. | |
| 70 | + | // It borrows the reply bytes: valid only until the Handler callback returns, because the read ring is reused. Copy what you keep. | |
| 71 | + | type FetchRegionReply struct{ raw []byte } | |
| 72 | + | ||
| 73 | + | // ParseFetchRegionReply validates raw (the whole reply, 32+4*length bytes) once; getters do not re-check. | |
| 74 | + | func ParseFetchRegionReply(raw []byte) (FetchRegionReply, bool) { | |
| 75 | + | if len(raw) < 32 { | |
| 76 | + | return FetchRegionReply{}, false | |
| 77 | + | } | |
| 78 | + | r := FetchRegionReply{raw: raw} | |
| 79 | + | off := 32 | |
| 80 | + | { | |
| 81 | + | n := (int(binary.LittleEndian.Uint32(r.raw[4:])) / 2) | |
| 82 | + | if n < 0 || n > len(r.raw) { | |
| 83 | + | return FetchRegionReply{}, false | |
| 84 | + | } | |
| 85 | + | off += n * 8 | |
| 86 | + | } | |
| 87 | + | if off > len(r.raw) { | |
| 88 | + | return FetchRegionReply{}, false | |
| 89 | + | } | |
| 90 | + | if off > len(r.raw) { | |
| 91 | + | return FetchRegionReply{}, false | |
| 92 | + | } | |
| 93 | + | return r, true | |
| 94 | + | } | |
| 95 | + | func (r FetchRegionReply) Raw() []byte { return r.raw } | |
| 96 | + | func (r FetchRegionReply) Extents() xproto.Rectangle { return xproto.GetRectangle(r.raw[8:]) } | |
| 97 | + | func (r FetchRegionReply) Rectangles() RectangleList { | |
| 98 | + | off := 32 | |
| 99 | + | end := off + (int(binary.LittleEndian.Uint32(r.raw[4:]))/2)*8 | |
| 100 | + | return RectangleList{b: r.raw[off:end:end]} | |
| 101 | + | } | |
| 102 | + | ||
| 103 | + | // GetCursorNameReply is a zero-copy view over a GetCursorName reply; offsets count from reply byte 0. | |
| 104 | + | // It borrows the reply bytes: valid only until the Handler callback returns, because the read ring is reused. Copy what you keep. | |
| 105 | + | type GetCursorNameReply struct{ raw []byte } | |
| 106 | + | ||
| 107 | + | // ParseGetCursorNameReply validates raw (the whole reply, 32+4*length bytes) once; getters do not re-check. | |
| 108 | + | func ParseGetCursorNameReply(raw []byte) (GetCursorNameReply, bool) { | |
| 109 | + | if len(raw) < 32 { | |
| 110 | + | return GetCursorNameReply{}, false | |
| 111 | + | } | |
| 112 | + | r := GetCursorNameReply{raw: raw} | |
| 113 | + | off := 32 | |
| 114 | + | { | |
| 115 | + | n := int(r.Nbytes()) | |
| 116 | + | if n < 0 || n > len(r.raw) { | |
| 117 | + | return GetCursorNameReply{}, false | |
| 118 | + | } | |
| 119 | + | off += n * 1 | |
| 120 | + | } | |
| 121 | + | if off > len(r.raw) { | |
| 122 | + | return GetCursorNameReply{}, false | |
| 123 | + | } | |
| 124 | + | if off > len(r.raw) { | |
| 125 | + | return GetCursorNameReply{}, false | |
| 126 | + | } | |
| 127 | + | return r, true | |
| 128 | + | } | |
| 129 | + | func (r GetCursorNameReply) Raw() []byte { return r.raw } | |
| 130 | + | func (r GetCursorNameReply) Atom() xproto.Atom { | |
| 131 | + | return xproto.Atom(binary.LittleEndian.Uint32(r.raw[8:])) | |
| 132 | + | } | |
| 133 | + | func (r GetCursorNameReply) Nbytes() uint16 { return uint16(binary.LittleEndian.Uint16(r.raw[12:])) } | |
| 134 | + | func (r GetCursorNameReply) Name() []byte { | |
| 135 | + | off := 32 | |
| 136 | + | end := off + int(r.Nbytes()) | |
| 137 | + | return r.raw[off:end:end] | |
| 138 | + | } | |
| 139 | + | ||
| 140 | + | // GetCursorImageAndNameReply is a zero-copy view over a GetCursorImageAndName reply; offsets count from reply byte 0. | |
| 141 | + | // It borrows the reply bytes: valid only until the Handler callback returns, because the read ring is reused. Copy what you keep. | |
| 142 | + | type GetCursorImageAndNameReply struct{ raw []byte } | |
| 143 | + | ||
| 144 | + | // ParseGetCursorImageAndNameReply validates raw (the whole reply, 32+4*length bytes) once; getters do not re-check. | |
| 145 | + | func ParseGetCursorImageAndNameReply(raw []byte) (GetCursorImageAndNameReply, bool) { | |
| 146 | + | if len(raw) < 32 { | |
| 147 | + | return GetCursorImageAndNameReply{}, false | |
| 148 | + | } | |
| 149 | + | r := GetCursorImageAndNameReply{raw: raw} | |
| 150 | + | off := 32 | |
| 151 | + | { | |
| 152 | + | n := (int(r.Width()) * int(r.Height())) | |
| 153 | + | if n < 0 || n > len(r.raw) { | |
| 154 | + | return GetCursorImageAndNameReply{}, false | |
| 155 | + | } | |
| 156 | + | off += n * 4 | |
| 157 | + | } | |
| 158 | + | if off > len(r.raw) { | |
| 159 | + | return GetCursorImageAndNameReply{}, false | |
| 160 | + | } | |
| 161 | + | { | |
| 162 | + | n := int(r.Nbytes()) | |
| 163 | + | if n < 0 || n > len(r.raw) { | |
| 164 | + | return GetCursorImageAndNameReply{}, false | |
| 165 | + | } | |
| 166 | + | off += n * 1 | |
| 167 | + | } | |
| 168 | + | if off > len(r.raw) { | |
| 169 | + | return GetCursorImageAndNameReply{}, false | |
| 170 | + | } | |
| 171 | + | if off > len(r.raw) { | |
| 172 | + | return GetCursorImageAndNameReply{}, false | |
| 173 | + | } | |
| 174 | + | return r, true | |
| 175 | + | } | |
| 176 | + | func (r GetCursorImageAndNameReply) Raw() []byte { return r.raw } | |
| 177 | + | func (r GetCursorImageAndNameReply) X() int16 { return int16(binary.LittleEndian.Uint16(r.raw[8:])) } | |
| 178 | + | func (r GetCursorImageAndNameReply) Y() int16 { return int16(binary.LittleEndian.Uint16(r.raw[10:])) } | |
| 179 | + | func (r GetCursorImageAndNameReply) Width() uint16 { | |
| 180 | + | return uint16(binary.LittleEndian.Uint16(r.raw[12:])) | |
| 181 | + | } | |
| 182 | + | func (r GetCursorImageAndNameReply) Height() uint16 { | |
| 183 | + | return uint16(binary.LittleEndian.Uint16(r.raw[14:])) | |
| 184 | + | } | |
| 185 | + | func (r GetCursorImageAndNameReply) Xhot() uint16 { | |
| 186 | + | return uint16(binary.LittleEndian.Uint16(r.raw[16:])) | |
| 187 | + | } | |
| 188 | + | func (r GetCursorImageAndNameReply) Yhot() uint16 { | |
| 189 | + | return uint16(binary.LittleEndian.Uint16(r.raw[18:])) | |
| 190 | + | } | |
| 191 | + | func (r GetCursorImageAndNameReply) CursorSerial() uint32 { | |
| 192 | + | return uint32(binary.LittleEndian.Uint32(r.raw[20:])) | |
| 193 | + | } | |
| 194 | + | func (r GetCursorImageAndNameReply) CursorAtom() xproto.Atom { | |
| 195 | + | return xproto.Atom(binary.LittleEndian.Uint32(r.raw[24:])) | |
| 196 | + | } | |
| 197 | + | func (r GetCursorImageAndNameReply) Nbytes() uint16 { | |
| 198 | + | return uint16(binary.LittleEndian.Uint16(r.raw[28:])) | |
| 199 | + | } | |
| 200 | + | func (r GetCursorImageAndNameReply) CursorImage() Uint32List { | |
| 201 | + | off := 32 | |
| 202 | + | end := off + (int(r.Width())*int(r.Height()))*4 | |
| 203 | + | return Uint32List{b: r.raw[off:end:end]} | |
| 204 | + | } | |
| 205 | + | func (r GetCursorImageAndNameReply) Name() []byte { | |
| 206 | + | off := 32 | |
| 207 | + | { | |
| 208 | + | n := (int(r.Width()) * int(r.Height())) | |
| 209 | + | off += n * 4 | |
| 210 | + | } | |
| 211 | + | end := off + int(r.Nbytes()) | |
| 212 | + | return r.raw[off:end:end] | |
| 213 | + | } | |
| 214 | + | ||
| 215 | + | // GetClientDisconnectModeReply is a zero-copy view over a GetClientDisconnectMode reply; offsets count from reply byte 0. | |
| 216 | + | // It borrows the reply bytes: valid only until the Handler callback returns, because the read ring is reused. Copy what you keep. | |
| 217 | + | type GetClientDisconnectModeReply struct{ raw []byte } | |
| 218 | + | ||
| 219 | + | // ParseGetClientDisconnectModeReply validates raw (the whole reply, 32+4*length bytes) once; getters do not re-check. | |
| 220 | + | func ParseGetClientDisconnectModeReply(raw []byte) (GetClientDisconnectModeReply, bool) { | |
| 221 | + | if len(raw) < 32 { | |
| 222 | + | return GetClientDisconnectModeReply{}, false | |
| 223 | + | } | |
| 224 | + | r := GetClientDisconnectModeReply{raw: raw} | |
| 225 | + | return r, true | |
| 226 | + | } | |
| 227 | + | func (r GetClientDisconnectModeReply) Raw() []byte { return r.raw } | |
| 228 | + | func (r GetClientDisconnectModeReply) DisconnectMode() ClientDisconnectFlags { | |
| 229 | + | return ClientDisconnectFlags(binary.LittleEndian.Uint32(r.raw[8:])) | |
| 230 | + | } | |
| 231 | + | ||
| 232 | + | // RectangleList is a borrowed view over a wire list of xproto.Rectangle. It shares the lifetime of the bytes it was taken from; copy what you keep. | |
| 233 | + | type RectangleList struct{ b []byte } | |
| 234 | + | ||
| 235 | + | func (l RectangleList) Len() int { return len(l.b) / 8 } | |
| 236 | + | func (l RectangleList) At(i int) xproto.Rectangle { return xproto.GetRectangle(l.b[i*8:]) } | |
| 237 | + | ||
| 238 | + | // Uint32List is a borrowed view over a wire list of uint32. It shares the lifetime of the bytes it was taken from; copy what you keep. | |
| 239 | + | type Uint32List struct{ b []byte } | |
| 240 | + | ||
| 241 | + | func (l Uint32List) Len() int { return len(l.b) / 4 } | |
| 242 | + | func (l Uint32List) At(i int) uint32 { return uint32(binary.LittleEndian.Uint32(l.b[i*4:])) } | |
A xfixes/requests_generated.go +766 -0
| @@ -0,0 +1,766 @@ | |||
| 1 | + | // Code generated by xtgen; DO NOT EDIT. | |
| 2 | + | package xfixes | |
| 3 | + | ||
| 4 | + | import "bnema.dev/xturbo/render" | |
| 5 | + | import "bnema.dev/xturbo/shape" | |
| 6 | + | import "bnema.dev/xturbo/xproto" | |
| 7 | + | import "encoding/binary" | |
| 8 | + | import "bnema.dev/xturbo" | |
| 9 | + | ||
| 10 | + | func QueryVersion(b *xturbo.Buf, clientMajorVersion uint32, clientMinorVersion uint32) xturbo.Seq { | |
| 11 | + | if b.Ext == nil { | |
| 12 | + | b.Fail(xturbo.ErrExtMissing) | |
| 13 | + | return 0 | |
| 14 | + | } | |
| 15 | + | major := b.Ext.Major(xturbo.ExtXFixes) | |
| 16 | + | if major == 0 { | |
| 17 | + | b.Fail(xturbo.ErrExtMissing) | |
| 18 | + | return 0 | |
| 19 | + | } | |
| 20 | + | p, seq := b.Request(major, 0, 8) | |
| 21 | + | if p == nil { | |
| 22 | + | return 0 | |
| 23 | + | } | |
| 24 | + | binary.LittleEndian.PutUint32(p[0:], uint32(clientMajorVersion)) | |
| 25 | + | binary.LittleEndian.PutUint32(p[4:], uint32(clientMinorVersion)) | |
| 26 | + | return seq | |
| 27 | + | } | |
| 28 | + | ||
| 29 | + | func ChangeSaveSet(b *xturbo.Buf, mode SaveSetMode, target SaveSetTarget, map_ SaveSetMapping, window xproto.Window) xturbo.Seq { | |
| 30 | + | if b.Ext == nil { | |
| 31 | + | b.Fail(xturbo.ErrExtMissing) | |
| 32 | + | return 0 | |
| 33 | + | } | |
| 34 | + | major := b.Ext.Major(xturbo.ExtXFixes) | |
| 35 | + | if major == 0 { | |
| 36 | + | b.Fail(xturbo.ErrExtMissing) | |
| 37 | + | return 0 | |
| 38 | + | } | |
| 39 | + | p, seq := b.Request(major, 1, 8) | |
| 40 | + | if p == nil { | |
| 41 | + | return 0 | |
| 42 | + | } | |
| 43 | + | p[0:][0] = byte(mode) | |
| 44 | + | p[1:][0] = byte(target) | |
| 45 | + | p[2:][0] = byte(map_) | |
| 46 | + | binary.LittleEndian.PutUint32(p[4:], uint32(window)) | |
| 47 | + | return seq | |
| 48 | + | } | |
| 49 | + | ||
| 50 | + | func SelectSelectionInput(b *xturbo.Buf, window xproto.Window, selection xproto.Atom, eventMask SelectionEventMask) xturbo.Seq { | |
| 51 | + | if b.Ext == nil { | |
| 52 | + | b.Fail(xturbo.ErrExtMissing) | |
| 53 | + | return 0 | |
| 54 | + | } | |
| 55 | + | major := b.Ext.Major(xturbo.ExtXFixes) | |
| 56 | + | if major == 0 { | |
| 57 | + | b.Fail(xturbo.ErrExtMissing) | |
| 58 | + | return 0 | |
| 59 | + | } | |
| 60 | + | p, seq := b.Request(major, 2, 12) | |
| 61 | + | if p == nil { | |
| 62 | + | return 0 | |
| 63 | + | } | |
| 64 | + | binary.LittleEndian.PutUint32(p[0:], uint32(window)) | |
| 65 | + | binary.LittleEndian.PutUint32(p[4:], uint32(selection)) | |
| 66 | + | binary.LittleEndian.PutUint32(p[8:], uint32(eventMask)) | |
| 67 | + | return seq | |
| 68 | + | } | |
| 69 | + | ||
| 70 | + | func SelectCursorInput(b *xturbo.Buf, window xproto.Window, eventMask CursorNotifyMask) xturbo.Seq { | |
| 71 | + | if b.Ext == nil { | |
| 72 | + | b.Fail(xturbo.ErrExtMissing) | |
| 73 | + | return 0 | |
| 74 | + | } | |
| 75 | + | major := b.Ext.Major(xturbo.ExtXFixes) | |
| 76 | + | if major == 0 { | |
| 77 | + | b.Fail(xturbo.ErrExtMissing) | |
| 78 | + | return 0 | |
| 79 | + | } | |
| 80 | + | p, seq := b.Request(major, 3, 8) | |
| 81 | + | if p == nil { | |
| 82 | + | return 0 | |
| 83 | + | } | |
| 84 | + | binary.LittleEndian.PutUint32(p[0:], uint32(window)) | |
| 85 | + | binary.LittleEndian.PutUint32(p[4:], uint32(eventMask)) | |
| 86 | + | return seq | |
| 87 | + | } | |
| 88 | + | ||
| 89 | + | func GetCursorImage(b *xturbo.Buf) xturbo.Seq { | |
| 90 | + | if b.Ext == nil { | |
| 91 | + | b.Fail(xturbo.ErrExtMissing) | |
| 92 | + | return 0 | |
| 93 | + | } | |
| 94 | + | major := b.Ext.Major(xturbo.ExtXFixes) | |
| 95 | + | if major == 0 { | |
| 96 | + | b.Fail(xturbo.ErrExtMissing) | |
| 97 | + | return 0 | |
| 98 | + | } | |
| 99 | + | p, seq := b.Request(major, 4, 0) | |
| 100 | + | if p == nil { | |
| 101 | + | return 0 | |
| 102 | + | } | |
| 103 | + | return seq | |
| 104 | + | } | |
| 105 | + | ||
| 106 | + | func CreateRegion(b *xturbo.Buf, region Region, rectangles []xproto.Rectangle) xturbo.Seq { | |
| 107 | + | size := 0 | |
| 108 | + | size += 4 | |
| 109 | + | size += len(rectangles) * 8 | |
| 110 | + | size = (size + 3) &^ 3 | |
| 111 | + | if b.Ext == nil { | |
| 112 | + | b.Fail(xturbo.ErrExtMissing) | |
| 113 | + | return 0 | |
| 114 | + | } | |
| 115 | + | major := b.Ext.Major(xturbo.ExtXFixes) | |
| 116 | + | if major == 0 { | |
| 117 | + | b.Fail(xturbo.ErrExtMissing) | |
| 118 | + | return 0 | |
| 119 | + | } | |
| 120 | + | p, seq := b.Request(major, 5, size) | |
| 121 | + | if p == nil { | |
| 122 | + | return 0 | |
| 123 | + | } | |
| 124 | + | off := 0 | |
| 125 | + | binary.LittleEndian.PutUint32(p[off:], uint32(region)) | |
| 126 | + | off += 4 | |
| 127 | + | for i := range rectangles { | |
| 128 | + | rectangles[i].Put(p[off:]) | |
| 129 | + | off += 8 | |
| 130 | + | } | |
| 131 | + | return seq | |
| 132 | + | } | |
| 133 | + | ||
| 134 | + | func CreateRegionFromBitmap(b *xturbo.Buf, region Region, bitmap xproto.Pixmap) xturbo.Seq { | |
| 135 | + | if b.Ext == nil { | |
| 136 | + | b.Fail(xturbo.ErrExtMissing) | |
| 137 | + | return 0 | |
| 138 | + | } | |
| 139 | + | major := b.Ext.Major(xturbo.ExtXFixes) | |
| 140 | + | if major == 0 { | |
| 141 | + | b.Fail(xturbo.ErrExtMissing) | |
| 142 | + | return 0 | |
| 143 | + | } | |
| 144 | + | p, seq := b.Request(major, 6, 8) | |
| 145 | + | if p == nil { | |
| 146 | + | return 0 | |
| 147 | + | } | |
| 148 | + | binary.LittleEndian.PutUint32(p[0:], uint32(region)) | |
| 149 | + | binary.LittleEndian.PutUint32(p[4:], uint32(bitmap)) | |
| 150 | + | return seq | |
| 151 | + | } | |
| 152 | + | ||
| 153 | + | func CreateRegionFromWindow(b *xturbo.Buf, region Region, window xproto.Window, kind shape.Sk) xturbo.Seq { | |
| 154 | + | if b.Ext == nil { | |
| 155 | + | b.Fail(xturbo.ErrExtMissing) | |
| 156 | + | return 0 | |
| 157 | + | } | |
| 158 | + | major := b.Ext.Major(xturbo.ExtXFixes) | |
| 159 | + | if major == 0 { | |
| 160 | + | b.Fail(xturbo.ErrExtMissing) | |
| 161 | + | return 0 | |
| 162 | + | } | |
| 163 | + | p, seq := b.Request(major, 7, 12) | |
| 164 | + | if p == nil { | |
| 165 | + | return 0 | |
| 166 | + | } | |
| 167 | + | binary.LittleEndian.PutUint32(p[0:], uint32(region)) | |
| 168 | + | binary.LittleEndian.PutUint32(p[4:], uint32(window)) | |
| 169 | + | p[8:][0] = byte(kind) | |
| 170 | + | return seq | |
| 171 | + | } | |
| 172 | + | ||
| 173 | + | func CreateRegionFromGC(b *xturbo.Buf, region Region, gc xproto.Gcontext) xturbo.Seq { | |
| 174 | + | if b.Ext == nil { | |
| 175 | + | b.Fail(xturbo.ErrExtMissing) | |
| 176 | + | return 0 | |
| 177 | + | } | |
| 178 | + | major := b.Ext.Major(xturbo.ExtXFixes) | |
| 179 | + | if major == 0 { | |
| 180 | + | b.Fail(xturbo.ErrExtMissing) | |
| 181 | + | return 0 | |
| 182 | + | } | |
| 183 | + | p, seq := b.Request(major, 8, 8) | |
| 184 | + | if p == nil { | |
| 185 | + | return 0 | |
| 186 | + | } | |
| 187 | + | binary.LittleEndian.PutUint32(p[0:], uint32(region)) | |
| 188 | + | binary.LittleEndian.PutUint32(p[4:], uint32(gc)) | |
| 189 | + | return seq | |
| 190 | + | } | |
| 191 | + | ||
| 192 | + | func CreateRegionFromPicture(b *xturbo.Buf, region Region, picture render.Picture) xturbo.Seq { | |
| 193 | + | if b.Ext == nil { | |
| 194 | + | b.Fail(xturbo.ErrExtMissing) | |
| 195 | + | return 0 | |
| 196 | + | } | |
| 197 | + | major := b.Ext.Major(xturbo.ExtXFixes) | |
| 198 | + | if major == 0 { | |
| 199 | + | b.Fail(xturbo.ErrExtMissing) | |
| 200 | + | return 0 | |
| 201 | + | } | |
| 202 | + | p, seq := b.Request(major, 9, 8) | |
| 203 | + | if p == nil { | |
| 204 | + | return 0 | |
| 205 | + | } | |
| 206 | + | binary.LittleEndian.PutUint32(p[0:], uint32(region)) | |
| 207 | + | binary.LittleEndian.PutUint32(p[4:], uint32(picture)) | |
| 208 | + | return seq | |
| 209 | + | } | |
| 210 | + | ||
| 211 | + | func DestroyRegion(b *xturbo.Buf, region Region) xturbo.Seq { | |
| 212 | + | if b.Ext == nil { | |
| 213 | + | b.Fail(xturbo.ErrExtMissing) | |
| 214 | + | return 0 | |
| 215 | + | } | |
| 216 | + | major := b.Ext.Major(xturbo.ExtXFixes) | |
| 217 | + | if major == 0 { | |
| 218 | + | b.Fail(xturbo.ErrExtMissing) | |
| 219 | + | return 0 | |
| 220 | + | } | |
| 221 | + | p, seq := b.Request(major, 10, 4) | |
| 222 | + | if p == nil { | |
| 223 | + | return 0 | |
| 224 | + | } | |
| 225 | + | binary.LittleEndian.PutUint32(p[0:], uint32(region)) | |
| 226 | + | return seq | |
| 227 | + | } | |
| 228 | + | ||
| 229 | + | func SetRegion(b *xturbo.Buf, region Region, rectangles []xproto.Rectangle) xturbo.Seq { | |
| 230 | + | size := 0 | |
| 231 | + | size += 4 | |
| 232 | + | size += len(rectangles) * 8 | |
| 233 | + | size = (size + 3) &^ 3 | |
| 234 | + | if b.Ext == nil { | |
| 235 | + | b.Fail(xturbo.ErrExtMissing) | |
| 236 | + | return 0 | |
| 237 | + | } | |
| 238 | + | major := b.Ext.Major(xturbo.ExtXFixes) | |
| 239 | + | if major == 0 { | |
| 240 | + | b.Fail(xturbo.ErrExtMissing) | |
| 241 | + | return 0 | |
| 242 | + | } | |
| 243 | + | p, seq := b.Request(major, 11, size) | |
| 244 | + | if p == nil { | |
| 245 | + | return 0 | |
| 246 | + | } | |
| 247 | + | off := 0 | |
| 248 | + | binary.LittleEndian.PutUint32(p[off:], uint32(region)) | |
| 249 | + | off += 4 | |
| 250 | + | for i := range rectangles { | |
| 251 | + | rectangles[i].Put(p[off:]) | |
| 252 | + | off += 8 | |
| 253 | + | } | |
| 254 | + | return seq | |
| 255 | + | } | |
| 256 | + | ||
| 257 | + | func CopyRegion(b *xturbo.Buf, source Region, destination Region) xturbo.Seq { | |
| 258 | + | if b.Ext == nil { | |
| 259 | + | b.Fail(xturbo.ErrExtMissing) | |
| 260 | + | return 0 | |
| 261 | + | } | |
| 262 | + | major := b.Ext.Major(xturbo.ExtXFixes) | |
| 263 | + | if major == 0 { | |
| 264 | + | b.Fail(xturbo.ErrExtMissing) | |
| 265 | + | return 0 | |
| 266 | + | } | |
| 267 | + | p, seq := b.Request(major, 12, 8) | |
| 268 | + | if p == nil { | |
| 269 | + | return 0 | |
| 270 | + | } | |
| 271 | + | binary.LittleEndian.PutUint32(p[0:], uint32(source)) | |
| 272 | + | binary.LittleEndian.PutUint32(p[4:], uint32(destination)) | |
| 273 | + | return seq | |
| 274 | + | } | |
| 275 | + | ||
| 276 | + | func UnionRegion(b *xturbo.Buf, source1 Region, source2 Region, destination Region) xturbo.Seq { | |
| 277 | + | if b.Ext == nil { | |
| 278 | + | b.Fail(xturbo.ErrExtMissing) | |
| 279 | + | return 0 | |
| 280 | + | } | |
| 281 | + | major := b.Ext.Major(xturbo.ExtXFixes) | |
| 282 | + | if major == 0 { | |
| 283 | + | b.Fail(xturbo.ErrExtMissing) | |
| 284 | + | return 0 | |
| 285 | + | } | |
| 286 | + | p, seq := b.Request(major, 13, 12) | |
| 287 | + | if p == nil { | |
| 288 | + | return 0 | |
| 289 | + | } | |
| 290 | + | binary.LittleEndian.PutUint32(p[0:], uint32(source1)) | |
| 291 | + | binary.LittleEndian.PutUint32(p[4:], uint32(source2)) | |
| 292 | + | binary.LittleEndian.PutUint32(p[8:], uint32(destination)) | |
| 293 | + | return seq | |
| 294 | + | } | |
| 295 | + | ||
| 296 | + | func IntersectRegion(b *xturbo.Buf, source1 Region, source2 Region, destination Region) xturbo.Seq { | |
| 297 | + | if b.Ext == nil { | |
| 298 | + | b.Fail(xturbo.ErrExtMissing) | |
| 299 | + | return 0 | |
| 300 | + | } | |
| 301 | + | major := b.Ext.Major(xturbo.ExtXFixes) | |
| 302 | + | if major == 0 { | |
| 303 | + | b.Fail(xturbo.ErrExtMissing) | |
| 304 | + | return 0 | |
| 305 | + | } | |
| 306 | + | p, seq := b.Request(major, 14, 12) | |
| 307 | + | if p == nil { | |
| 308 | + | return 0 | |
| 309 | + | } | |
| 310 | + | binary.LittleEndian.PutUint32(p[0:], uint32(source1)) | |
| 311 | + | binary.LittleEndian.PutUint32(p[4:], uint32(source2)) | |
| 312 | + | binary.LittleEndian.PutUint32(p[8:], uint32(destination)) | |
| 313 | + | return seq | |
| 314 | + | } | |
| 315 | + | ||
| 316 | + | func SubtractRegion(b *xturbo.Buf, source1 Region, source2 Region, destination Region) xturbo.Seq { | |
| 317 | + | if b.Ext == nil { | |
| 318 | + | b.Fail(xturbo.ErrExtMissing) | |
| 319 | + | return 0 | |
| 320 | + | } | |
| 321 | + | major := b.Ext.Major(xturbo.ExtXFixes) | |
| 322 | + | if major == 0 { | |
| 323 | + | b.Fail(xturbo.ErrExtMissing) | |
| 324 | + | return 0 | |
| 325 | + | } | |
| 326 | + | p, seq := b.Request(major, 15, 12) | |
| 327 | + | if p == nil { | |
| 328 | + | return 0 | |
| 329 | + | } | |
| 330 | + | binary.LittleEndian.PutUint32(p[0:], uint32(source1)) | |
| 331 | + | binary.LittleEndian.PutUint32(p[4:], uint32(source2)) | |
| 332 | + | binary.LittleEndian.PutUint32(p[8:], uint32(destination)) | |
| 333 | + | return seq | |
| 334 | + | } | |
| 335 | + | ||
| 336 | + | func InvertRegion(b *xturbo.Buf, source Region, bounds xproto.Rectangle, destination Region) xturbo.Seq { | |
| 337 | + | if b.Ext == nil { | |
| 338 | + | b.Fail(xturbo.ErrExtMissing) | |
| 339 | + | return 0 | |
| 340 | + | } | |
| 341 | + | major := b.Ext.Major(xturbo.ExtXFixes) | |
| 342 | + | if major == 0 { | |
| 343 | + | b.Fail(xturbo.ErrExtMissing) | |
| 344 | + | return 0 | |
| 345 | + | } | |
| 346 | + | p, seq := b.Request(major, 16, 16) | |
| 347 | + | if p == nil { | |
| 348 | + | return 0 | |
| 349 | + | } | |
| 350 | + | binary.LittleEndian.PutUint32(p[0:], uint32(source)) | |
| 351 | + | bounds.Put(p[4:]) | |
| 352 | + | binary.LittleEndian.PutUint32(p[12:], uint32(destination)) | |
| 353 | + | return seq | |
| 354 | + | } | |
| 355 | + | ||
| 356 | + | func TranslateRegion(b *xturbo.Buf, region Region, dx int16, dy int16) xturbo.Seq { | |
| 357 | + | if b.Ext == nil { | |
| 358 | + | b.Fail(xturbo.ErrExtMissing) | |
| 359 | + | return 0 | |
| 360 | + | } | |
| 361 | + | major := b.Ext.Major(xturbo.ExtXFixes) | |
| 362 | + | if major == 0 { | |
| 363 | + | b.Fail(xturbo.ErrExtMissing) | |
| 364 | + | return 0 | |
| 365 | + | } | |
| 366 | + | p, seq := b.Request(major, 17, 8) | |
| 367 | + | if p == nil { | |
| 368 | + | return 0 | |
| 369 | + | } | |
| 370 | + | binary.LittleEndian.PutUint32(p[0:], uint32(region)) | |
| 371 | + | binary.LittleEndian.PutUint16(p[4:], uint16(dx)) | |
| 372 | + | binary.LittleEndian.PutUint16(p[6:], uint16(dy)) | |
| 373 | + | return seq | |
| 374 | + | } | |
| 375 | + | ||
| 376 | + | func RegionExtents(b *xturbo.Buf, source Region, destination Region) xturbo.Seq { | |
| 377 | + | if b.Ext == nil { | |
| 378 | + | b.Fail(xturbo.ErrExtMissing) | |
| 379 | + | return 0 | |
| 380 | + | } | |
| 381 | + | major := b.Ext.Major(xturbo.ExtXFixes) | |
| 382 | + | if major == 0 { | |
| 383 | + | b.Fail(xturbo.ErrExtMissing) | |
| 384 | + | return 0 | |
| 385 | + | } | |
| 386 | + | p, seq := b.Request(major, 18, 8) | |
| 387 | + | if p == nil { | |
| 388 | + | return 0 | |
| 389 | + | } | |
| 390 | + | binary.LittleEndian.PutUint32(p[0:], uint32(source)) | |
| 391 | + | binary.LittleEndian.PutUint32(p[4:], uint32(destination)) | |
| 392 | + | return seq | |
| 393 | + | } | |
| 394 | + | ||
| 395 | + | func FetchRegion(b *xturbo.Buf, region Region) xturbo.Seq { | |
| 396 | + | if b.Ext == nil { | |
| 397 | + | b.Fail(xturbo.ErrExtMissing) | |
| 398 | + | return 0 | |
| 399 | + | } | |
| 400 | + | major := b.Ext.Major(xturbo.ExtXFixes) | |
| 401 | + | if major == 0 { | |
| 402 | + | b.Fail(xturbo.ErrExtMissing) | |
| 403 | + | return 0 | |
| 404 | + | } | |
| 405 | + | p, seq := b.Request(major, 19, 4) | |
| 406 | + | if p == nil { | |
| 407 | + | return 0 | |
| 408 | + | } | |
| 409 | + | binary.LittleEndian.PutUint32(p[0:], uint32(region)) | |
| 410 | + | return seq | |
| 411 | + | } | |
| 412 | + | ||
| 413 | + | func SetGCClipRegion(b *xturbo.Buf, gc xproto.Gcontext, region Region, xOrigin int16, yOrigin int16) xturbo.Seq { | |
| 414 | + | if b.Ext == nil { | |
| 415 | + | b.Fail(xturbo.ErrExtMissing) | |
| 416 | + | return 0 | |
| 417 | + | } | |
| 418 | + | major := b.Ext.Major(xturbo.ExtXFixes) | |
| 419 | + | if major == 0 { | |
| 420 | + | b.Fail(xturbo.ErrExtMissing) | |
| 421 | + | return 0 | |
| 422 | + | } | |
| 423 | + | p, seq := b.Request(major, 20, 12) | |
| 424 | + | if p == nil { | |
| 425 | + | return 0 | |
| 426 | + | } | |
| 427 | + | binary.LittleEndian.PutUint32(p[0:], uint32(gc)) | |
| 428 | + | binary.LittleEndian.PutUint32(p[4:], uint32(region)) | |
| 429 | + | binary.LittleEndian.PutUint16(p[8:], uint16(xOrigin)) | |
| 430 | + | binary.LittleEndian.PutUint16(p[10:], uint16(yOrigin)) | |
| 431 | + | return seq | |
| 432 | + | } | |
| 433 | + | ||
| 434 | + | func SetWindowShapeRegion(b *xturbo.Buf, dest xproto.Window, destKind shape.Sk, xOffset int16, yOffset int16, region Region) xturbo.Seq { | |
| 435 | + | if b.Ext == nil { | |
| 436 | + | b.Fail(xturbo.ErrExtMissing) | |
| 437 | + | return 0 | |
| 438 | + | } | |
| 439 | + | major := b.Ext.Major(xturbo.ExtXFixes) | |
| 440 | + | if major == 0 { | |
| 441 | + | b.Fail(xturbo.ErrExtMissing) | |
| 442 | + | return 0 | |
| 443 | + | } | |
| 444 | + | p, seq := b.Request(major, 21, 16) | |
| 445 | + | if p == nil { | |
| 446 | + | return 0 | |
| 447 | + | } | |
| 448 | + | binary.LittleEndian.PutUint32(p[0:], uint32(dest)) | |
| 449 | + | p[4:][0] = byte(destKind) | |
| 450 | + | binary.LittleEndian.PutUint16(p[8:], uint16(xOffset)) | |
| 451 | + | binary.LittleEndian.PutUint16(p[10:], uint16(yOffset)) | |
| 452 | + | binary.LittleEndian.PutUint32(p[12:], uint32(region)) | |
| 453 | + | return seq | |
| 454 | + | } | |
| 455 | + | ||
| 456 | + | func SetPictureClipRegion(b *xturbo.Buf, picture render.Picture, region Region, xOrigin int16, yOrigin int16) xturbo.Seq { | |
| 457 | + | if b.Ext == nil { | |
| 458 | + | b.Fail(xturbo.ErrExtMissing) | |
| 459 | + | return 0 | |
| 460 | + | } | |
| 461 | + | major := b.Ext.Major(xturbo.ExtXFixes) | |
| 462 | + | if major == 0 { | |
| 463 | + | b.Fail(xturbo.ErrExtMissing) | |
| 464 | + | return 0 | |
| 465 | + | } | |
| 466 | + | p, seq := b.Request(major, 22, 12) | |
| 467 | + | if p == nil { | |
| 468 | + | return 0 | |
| 469 | + | } | |
| 470 | + | binary.LittleEndian.PutUint32(p[0:], uint32(picture)) | |
| 471 | + | binary.LittleEndian.PutUint32(p[4:], uint32(region)) | |
| 472 | + | binary.LittleEndian.PutUint16(p[8:], uint16(xOrigin)) | |
| 473 | + | binary.LittleEndian.PutUint16(p[10:], uint16(yOrigin)) | |
| 474 | + | return seq | |
| 475 | + | } | |
| 476 | + | ||
| 477 | + | func SetCursorName(b *xturbo.Buf, cursor xproto.Cursor, name string) xturbo.Seq { | |
| 478 | + | if uint64(len(name)) > 65535 { | |
| 479 | + | b.Fail(xturbo.ErrBadLength) | |
| 480 | + | return 0 | |
| 481 | + | } | |
| 482 | + | size := 0 | |
| 483 | + | size += 4 | |
| 484 | + | size += 2 | |
| 485 | + | size += 2 | |
| 486 | + | size += len(name) * 1 | |
| 487 | + | size = (size + 3) &^ 3 | |
| 488 | + | if b.Ext == nil { | |
| 489 | + | b.Fail(xturbo.ErrExtMissing) | |
| 490 | + | return 0 | |
| 491 | + | } | |
| 492 | + | major := b.Ext.Major(xturbo.ExtXFixes) | |
| 493 | + | if major == 0 { | |
| 494 | + | b.Fail(xturbo.ErrExtMissing) | |
| 495 | + | return 0 | |
| 496 | + | } | |
| 497 | + | p, seq := b.Request(major, 23, size) | |
| 498 | + | if p == nil { | |
| 499 | + | return 0 | |
| 500 | + | } | |
| 501 | + | off := 0 | |
| 502 | + | binary.LittleEndian.PutUint32(p[off:], uint32(cursor)) | |
| 503 | + | off += 4 | |
| 504 | + | binary.LittleEndian.PutUint16(p[off:], uint16(len(name))) | |
| 505 | + | off += 2 | |
| 506 | + | off += 2 | |
| 507 | + | copy(p[off:], name) | |
| 508 | + | off += len(name) | |
| 509 | + | return seq | |
| 510 | + | } | |
| 511 | + | ||
| 512 | + | func GetCursorName(b *xturbo.Buf, cursor xproto.Cursor) xturbo.Seq { | |
| 513 | + | if b.Ext == nil { | |
| 514 | + | b.Fail(xturbo.ErrExtMissing) | |
| 515 | + | return 0 | |
| 516 | + | } | |
| 517 | + | major := b.Ext.Major(xturbo.ExtXFixes) | |
| 518 | + | if major == 0 { | |
| 519 | + | b.Fail(xturbo.ErrExtMissing) | |
| 520 | + | return 0 | |
| 521 | + | } | |
| 522 | + | p, seq := b.Request(major, 24, 4) | |
| 523 | + | if p == nil { | |
| 524 | + | return 0 | |
| 525 | + | } | |
| 526 | + | binary.LittleEndian.PutUint32(p[0:], uint32(cursor)) | |
| 527 | + | return seq | |
| 528 | + | } | |
| 529 | + | ||
| 530 | + | func GetCursorImageAndName(b *xturbo.Buf) xturbo.Seq { | |
| 531 | + | if b.Ext == nil { | |
| 532 | + | b.Fail(xturbo.ErrExtMissing) | |
| 533 | + | return 0 | |
| 534 | + | } | |
| 535 | + | major := b.Ext.Major(xturbo.ExtXFixes) | |
| 536 | + | if major == 0 { | |
| 537 | + | b.Fail(xturbo.ErrExtMissing) | |
| 538 | + | return 0 | |
| 539 | + | } | |
| 540 | + | p, seq := b.Request(major, 25, 0) | |
| 541 | + | if p == nil { | |
| 542 | + | return 0 | |
| 543 | + | } | |
| 544 | + | return seq | |
| 545 | + | } | |
| 546 | + | ||
| 547 | + | func ChangeCursor(b *xturbo.Buf, source xproto.Cursor, destination xproto.Cursor) xturbo.Seq { | |
| 548 | + | if b.Ext == nil { | |
| 549 | + | b.Fail(xturbo.ErrExtMissing) | |
| 550 | + | return 0 | |
| 551 | + | } | |
| 552 | + | major := b.Ext.Major(xturbo.ExtXFixes) | |
| 553 | + | if major == 0 { | |
| 554 | + | b.Fail(xturbo.ErrExtMissing) | |
| 555 | + | return 0 | |
| 556 | + | } | |
| 557 | + | p, seq := b.Request(major, 26, 8) | |
| 558 | + | if p == nil { | |
| 559 | + | return 0 | |
| 560 | + | } | |
| 561 | + | binary.LittleEndian.PutUint32(p[0:], uint32(source)) | |
| 562 | + | binary.LittleEndian.PutUint32(p[4:], uint32(destination)) | |
| 563 | + | return seq | |
| 564 | + | } | |
| 565 | + | ||
| 566 | + | func ChangeCursorByName(b *xturbo.Buf, src xproto.Cursor, name string) xturbo.Seq { | |
| 567 | + | if uint64(len(name)) > 65535 { | |
| 568 | + | b.Fail(xturbo.ErrBadLength) | |
| 569 | + | return 0 | |
| 570 | + | } | |
| 571 | + | size := 0 | |
| 572 | + | size += 4 | |
| 573 | + | size += 2 | |
| 574 | + | size += 2 | |
| 575 | + | size += len(name) * 1 | |
| 576 | + | size = (size + 3) &^ 3 | |
| 577 | + | if b.Ext == nil { | |
| 578 | + | b.Fail(xturbo.ErrExtMissing) | |
| 579 | + | return 0 | |
| 580 | + | } | |
| 581 | + | major := b.Ext.Major(xturbo.ExtXFixes) | |
| 582 | + | if major == 0 { | |
| 583 | + | b.Fail(xturbo.ErrExtMissing) | |
| 584 | + | return 0 | |
| 585 | + | } | |
| 586 | + | p, seq := b.Request(major, 27, size) | |
| 587 | + | if p == nil { | |
| 588 | + | return 0 | |
| 589 | + | } | |
| 590 | + | off := 0 | |
| 591 | + | binary.LittleEndian.PutUint32(p[off:], uint32(src)) | |
| 592 | + | off += 4 | |
| 593 | + | binary.LittleEndian.PutUint16(p[off:], uint16(len(name))) | |
| 594 | + | off += 2 | |
| 595 | + | off += 2 | |
| 596 | + | copy(p[off:], name) | |
| 597 | + | off += len(name) | |
| 598 | + | return seq | |
| 599 | + | } | |
| 600 | + | ||
| 601 | + | func ExpandRegion(b *xturbo.Buf, source Region, destination Region, left uint16, right uint16, top uint16, bottom uint16) xturbo.Seq { | |
| 602 | + | if b.Ext == nil { | |
| 603 | + | b.Fail(xturbo.ErrExtMissing) | |
| 604 | + | return 0 | |
| 605 | + | } | |
| 606 | + | major := b.Ext.Major(xturbo.ExtXFixes) | |
| 607 | + | if major == 0 { | |
| 608 | + | b.Fail(xturbo.ErrExtMissing) | |
| 609 | + | return 0 | |
| 610 | + | } | |
| 611 | + | p, seq := b.Request(major, 28, 16) | |
| 612 | + | if p == nil { | |
| 613 | + | return 0 | |
| 614 | + | } | |
| 615 | + | binary.LittleEndian.PutUint32(p[0:], uint32(source)) | |
| 616 | + | binary.LittleEndian.PutUint32(p[4:], uint32(destination)) | |
| 617 | + | binary.LittleEndian.PutUint16(p[8:], uint16(left)) | |
| 618 | + | binary.LittleEndian.PutUint16(p[10:], uint16(right)) | |
| 619 | + | binary.LittleEndian.PutUint16(p[12:], uint16(top)) | |
| 620 | + | binary.LittleEndian.PutUint16(p[14:], uint16(bottom)) | |
| 621 | + | return seq | |
| 622 | + | } | |
| 623 | + | ||
| 624 | + | func HideCursor(b *xturbo.Buf, window xproto.Window) xturbo.Seq { | |
| 625 | + | if b.Ext == nil { | |
| 626 | + | b.Fail(xturbo.ErrExtMissing) | |
| 627 | + | return 0 | |
| 628 | + | } | |
| 629 | + | major := b.Ext.Major(xturbo.ExtXFixes) | |
| 630 | + | if major == 0 { | |
| 631 | + | b.Fail(xturbo.ErrExtMissing) | |
| 632 | + | return 0 | |
| 633 | + | } | |
| 634 | + | p, seq := b.Request(major, 29, 4) | |
| 635 | + | if p == nil { | |
| 636 | + | return 0 | |
| 637 | + | } | |
| 638 | + | binary.LittleEndian.PutUint32(p[0:], uint32(window)) | |
| 639 | + | return seq | |
| 640 | + | } | |
| 641 | + | ||
| 642 | + | func ShowCursor(b *xturbo.Buf, window xproto.Window) xturbo.Seq { | |
| 643 | + | if b.Ext == nil { | |
| 644 | + | b.Fail(xturbo.ErrExtMissing) | |
| 645 | + | return 0 | |
| 646 | + | } | |
| 647 | + | major := b.Ext.Major(xturbo.ExtXFixes) | |
| 648 | + | if major == 0 { | |
| 649 | + | b.Fail(xturbo.ErrExtMissing) | |
| 650 | + | return 0 | |
| 651 | + | } | |
| 652 | + | p, seq := b.Request(major, 30, 4) | |
| 653 | + | if p == nil { | |
| 654 | + | return 0 | |
| 655 | + | } | |
| 656 | + | binary.LittleEndian.PutUint32(p[0:], uint32(window)) | |
| 657 | + | return seq | |
| 658 | + | } | |
| 659 | + | ||
| 660 | + | func CreatePointerBarrier(b *xturbo.Buf, barrier Barrier, window xproto.Window, x1 uint16, y1 uint16, x2 uint16, y2 uint16, directions BarrierDirections, devices []uint16) xturbo.Seq { | |
| 661 | + | if uint64(len(devices)) > 65535 { | |
| 662 | + | b.Fail(xturbo.ErrBadLength) | |
| 663 | + | return 0 | |
| 664 | + | } | |
| 665 | + | size := 0 | |
| 666 | + | size += 4 | |
| 667 | + | size += 4 | |
| 668 | + | size += 2 | |
| 669 | + | size += 2 | |
| 670 | + | size += 2 | |
| 671 | + | size += 2 | |
| 672 | + | size += 4 | |
| 673 | + | size += 2 | |
| 674 | + | size += 2 | |
| 675 | + | size += len(devices) * 2 | |
| 676 | + | size = (size + 3) &^ 3 | |
| 677 | + | if b.Ext == nil { | |
| 678 | + | b.Fail(xturbo.ErrExtMissing) | |
| 679 | + | return 0 | |
| 680 | + | } | |
| 681 | + | major := b.Ext.Major(xturbo.ExtXFixes) | |
| 682 | + | if major == 0 { | |
| 683 | + | b.Fail(xturbo.ErrExtMissing) | |
| 684 | + | return 0 | |
| 685 | + | } | |
| 686 | + | p, seq := b.Request(major, 31, size) | |
| 687 | + | if p == nil { | |
| 688 | + | return 0 | |
| 689 | + | } | |
| 690 | + | off := 0 | |
| 691 | + | binary.LittleEndian.PutUint32(p[off:], uint32(barrier)) | |
| 692 | + | off += 4 | |
| 693 | + | binary.LittleEndian.PutUint32(p[off:], uint32(window)) | |
| 694 | + | off += 4 | |
| 695 | + | binary.LittleEndian.PutUint16(p[off:], uint16(x1)) | |
| 696 | + | off += 2 | |
| 697 | + | binary.LittleEndian.PutUint16(p[off:], uint16(y1)) | |
| 698 | + | off += 2 | |
| 699 | + | binary.LittleEndian.PutUint16(p[off:], uint16(x2)) | |
| 700 | + | off += 2 | |
| 701 | + | binary.LittleEndian.PutUint16(p[off:], uint16(y2)) | |
| 702 | + | off += 2 | |
| 703 | + | binary.LittleEndian.PutUint32(p[off:], uint32(directions)) | |
| 704 | + | off += 4 | |
| 705 | + | off += 2 | |
| 706 | + | binary.LittleEndian.PutUint16(p[off:], uint16(len(devices))) | |
| 707 | + | off += 2 | |
| 708 | + | for i := range devices { | |
| 709 | + | binary.LittleEndian.PutUint16(p[off:], uint16(devices[i])) | |
| 710 | + | off += 2 | |
| 711 | + | } | |
| 712 | + | return seq | |
| 713 | + | } | |
| 714 | + | ||
| 715 | + | func DeletePointerBarrier(b *xturbo.Buf, barrier Barrier) xturbo.Seq { | |
| 716 | + | if b.Ext == nil { | |
| 717 | + | b.Fail(xturbo.ErrExtMissing) | |
| 718 | + | return 0 | |
| 719 | + | } | |
| 720 | + | major := b.Ext.Major(xturbo.ExtXFixes) | |
| 721 | + | if major == 0 { | |
| 722 | + | b.Fail(xturbo.ErrExtMissing) | |
| 723 | + | return 0 | |
| 724 | + | } | |
| 725 | + | p, seq := b.Request(major, 32, 4) | |
| 726 | + | if p == nil { | |
| 727 | + | return 0 | |
| 728 | + | } | |
| 729 | + | binary.LittleEndian.PutUint32(p[0:], uint32(barrier)) | |
| 730 | + | return seq | |
| 731 | + | } | |
| 732 | + | ||
| 733 | + | func SetClientDisconnectMode(b *xturbo.Buf, disconnectMode ClientDisconnectFlags) xturbo.Seq { | |
| 734 | + | if b.Ext == nil { | |
| 735 | + | b.Fail(xturbo.ErrExtMissing) | |
| 736 | + | return 0 | |
| 737 | + | } | |
| 738 | + | major := b.Ext.Major(xturbo.ExtXFixes) | |
| 739 | + | if major == 0 { | |
| 740 | + | b.Fail(xturbo.ErrExtMissing) | |
| 741 | + | return 0 | |
| 742 | + | } | |
| 743 | + | p, seq := b.Request(major, 33, 4) | |
| 744 | + | if p == nil { | |
| 745 | + | return 0 | |
| 746 | + | } | |
| 747 | + | binary.LittleEndian.PutUint32(p[0:], uint32(disconnectMode)) | |
| 748 | + | return seq | |
| 749 | + | } | |
| 750 | + | ||
| 751 | + | func GetClientDisconnectMode(b *xturbo.Buf) xturbo.Seq { | |
| 752 | + | if b.Ext == nil { | |
| 753 | + | b.Fail(xturbo.ErrExtMissing) | |
| 754 | + | return 0 | |
| 755 | + | } | |
| 756 | + | major := b.Ext.Major(xturbo.ExtXFixes) | |
| 757 | + | if major == 0 { | |
| 758 | + | b.Fail(xturbo.ErrExtMissing) | |
| 759 | + | return 0 | |
| 760 | + | } | |
| 761 | + | p, seq := b.Request(major, 34, 0) | |
| 762 | + | if p == nil { | |
| 763 | + | return 0 | |
| 764 | + | } | |
| 765 | + | return seq | |
| 766 | + | } | |
A xfixes/sizes_test.go +32 -0
| @@ -0,0 +1,32 @@ | |||
| 1 | + | // Code generated by xtgen; DO NOT EDIT. | |
| 2 | + | package xfixes | |
| 3 | + | ||
| 4 | + | import "testing" | |
| 5 | + | ||
| 6 | + | func TestWireSizes(t *testing.T) { | |
| 7 | + | if got := 32; got != 32 { | |
| 8 | + | t.Errorf("reply QueryVersion fixed size = %d", got) | |
| 9 | + | } | |
| 10 | + | if got := 32; got != 32 { | |
| 11 | + | t.Errorf("event SelectionNotify fixed size = %d", got) | |
| 12 | + | } | |
| 13 | + | if got := 32; got != 32 { | |
| 14 | + | t.Errorf("event CursorNotify fixed size = %d", got) | |
| 15 | + | } | |
| 16 | + | if got := 32; got != 32 { | |
| 17 | + | t.Errorf("reply GetCursorImage fixed size = %d", got) | |
| 18 | + | } | |
| 19 | + | if got := 32; got != 32 { | |
| 20 | + | t.Errorf("reply FetchRegion fixed size = %d", got) | |
| 21 | + | } | |
| 22 | + | if got := 32; got != 32 { | |
| 23 | + | t.Errorf("reply GetCursorName fixed size = %d", got) | |
| 24 | + | } | |
| 25 | + | if got := 32; got != 32 { | |
| 26 | + | t.Errorf("reply GetCursorImageAndName fixed size = %d", got) | |
| 27 | + | } | |
| 28 | + | if got := 32; got != 32 { | |
| 29 | + | t.Errorf("reply GetClientDisconnectMode fixed size = %d", got) | |
| 30 | + | } | |
| 31 | + | ||
| 32 | + | } | |
A xfixes/types_generated.go +55 -0
| @@ -0,0 +1,55 @@ | |||
| 1 | + | // Code generated by xtgen; DO NOT EDIT. | |
| 2 | + | package xfixes | |
| 3 | + | ||
| 4 | + | type Region uint32 | |
| 5 | + | ||
| 6 | + | type Barrier uint32 | |
| 7 | + | ||
| 8 | + | type SaveSetMode uint8 | |
| 9 | + | ||
| 10 | + | const SaveSetModeInsert SaveSetMode = 0 | |
| 11 | + | const SaveSetModeDelete SaveSetMode = 1 | |
| 12 | + | ||
| 13 | + | type SaveSetTarget uint8 | |
| 14 | + | ||
| 15 | + | const SaveSetTargetNearest SaveSetTarget = 0 | |
| 16 | + | const SaveSetTargetRoot SaveSetTarget = 1 | |
| 17 | + | ||
| 18 | + | type SaveSetMapping uint8 | |
| 19 | + | ||
| 20 | + | const SaveSetMappingMap SaveSetMapping = 0 | |
| 21 | + | const SaveSetMappingUnmap SaveSetMapping = 1 | |
| 22 | + | ||
| 23 | + | type SelectionEvent uint8 | |
| 24 | + | ||
| 25 | + | const SelectionEventSetSelectionOwner SelectionEvent = 0 | |
| 26 | + | const SelectionEventSelectionWindowDestroy SelectionEvent = 1 | |
| 27 | + | const SelectionEventSelectionClientClose SelectionEvent = 2 | |
| 28 | + | ||
| 29 | + | type SelectionEventMask uint32 | |
| 30 | + | ||
| 31 | + | const SelectionEventMaskSetSelectionOwner SelectionEventMask = 1 | |
| 32 | + | const SelectionEventMaskSelectionWindowDestroy SelectionEventMask = 2 | |
| 33 | + | const SelectionEventMaskSelectionClientClose SelectionEventMask = 4 | |
| 34 | + | ||
| 35 | + | type CursorNotify uint8 | |
| 36 | + | ||
| 37 | + | const CursorNotifyDisplayCursor CursorNotify = 0 | |
| 38 | + | ||
| 39 | + | type CursorNotifyMask uint32 | |
| 40 | + | ||
| 41 | + | const CursorNotifyMaskDisplayCursor CursorNotifyMask = 1 | |
| 42 | + | ||
| 43 | + | const RegionNone Region = 0 | |
| 44 | + | ||
| 45 | + | type BarrierDirections uint32 | |
| 46 | + | ||
| 47 | + | const BarrierDirectionsPositiveX BarrierDirections = 1 | |
| 48 | + | const BarrierDirectionsPositiveY BarrierDirections = 2 | |
| 49 | + | const BarrierDirectionsNegativeX BarrierDirections = 4 | |
| 50 | + | const BarrierDirectionsNegativeY BarrierDirections = 8 | |
| 51 | + | ||
| 52 | + | type ClientDisconnectFlags uint32 | |
| 53 | + | ||
| 54 | + | const ClientDisconnectFlagsDefault ClientDisconnectFlags = 0 | |
| 55 | + | const ClientDisconnectFlagsTerminate ClientDisconnectFlags = 1 | |
A xproto/replies_fuzz_test.go +895 -0
| @@ -0,0 +1,895 @@ | |||
| 1 | + | // Code generated by xtgen; DO NOT EDIT. | |
| 2 | + | package xproto | |
| 3 | + | ||
| 4 | + | import "testing" | |
| 5 | + | import "bnema.dev/xturbo/internal/xtest" | |
| 6 | + | ||
| 7 | + | func FuzzParseGetWindowAttributesReply(f *testing.F) { | |
| 8 | + | f.Add(make([]byte, 44)) | |
| 9 | + | if raw, err := xtest.LoadHex("../testdata/golden/xproto/GetWindowAttributes.reply.hex"); err != nil { | |
| 10 | + | f.Fatal(err) | |
| 11 | + | } else { | |
| 12 | + | f.Add(raw) | |
| 13 | + | } | |
| 14 | + | f.Fuzz(func(t *testing.T, raw []byte) { | |
| 15 | + | r, ok := ParseGetWindowAttributesReply(raw) | |
| 16 | + | if !ok { | |
| 17 | + | if len(raw) >= 44 { | |
| 18 | + | t.Fatal("rejected a complete fixed-size reply") | |
| 19 | + | } | |
| 20 | + | return | |
| 21 | + | } | |
| 22 | + | if len(r.Raw()) != len(raw) { | |
| 23 | + | t.Fatal("Raw must return the parsed bytes") | |
| 24 | + | } | |
| 25 | + | _ = r.BackingStore() | |
| 26 | + | _ = r.Visual() | |
| 27 | + | _ = r.Class() | |
| 28 | + | _ = r.BitGravity() | |
| 29 | + | _ = r.WinGravity() | |
| 30 | + | _ = r.BackingPlanes() | |
| 31 | + | _ = r.BackingPixel() | |
| 32 | + | _ = r.SaveUnder() | |
| 33 | + | _ = r.MapIsInstalled() | |
| 34 | + | _ = r.MapState() | |
| 35 | + | _ = r.OverrideRedirect() | |
| 36 | + | _ = r.Colormap() | |
| 37 | + | _ = r.AllEventMasks() | |
| 38 | + | _ = r.YourEventMask() | |
| 39 | + | _ = r.DoNotPropagateMask() | |
| 40 | + | }) | |
| 41 | + | } | |
| 42 | + | ||
| 43 | + | func FuzzParseGetGeometryReply(f *testing.F) { | |
| 44 | + | f.Add(make([]byte, 32)) | |
| 45 | + | if raw, err := xtest.LoadHex("../testdata/golden/xproto/GetGeometry.reply.hex"); err != nil { | |
| 46 | + | f.Fatal(err) | |
| 47 | + | } else { | |
| 48 | + | f.Add(raw) | |
| 49 | + | } | |
| 50 | + | f.Fuzz(func(t *testing.T, raw []byte) { | |
| 51 | + | r, ok := ParseGetGeometryReply(raw) | |
| 52 | + | if !ok { | |
| 53 | + | if len(raw) >= 32 { | |
| 54 | + | t.Fatal("rejected a complete fixed-size reply") | |
| 55 | + | } | |
| 56 | + | return | |
| 57 | + | } | |
| 58 | + | if len(r.Raw()) != len(raw) { | |
| 59 | + | t.Fatal("Raw must return the parsed bytes") | |
| 60 | + | } | |
| 61 | + | _ = r.Depth() | |
| 62 | + | _ = r.Root() | |
| 63 | + | _ = r.X() | |
| 64 | + | _ = r.Y() | |
| 65 | + | _ = r.Width() | |
| 66 | + | _ = r.Height() | |
| 67 | + | _ = r.BorderWidth() | |
| 68 | + | }) | |
| 69 | + | } | |
| 70 | + | ||
| 71 | + | func FuzzParseQueryTreeReply(f *testing.F) { | |
| 72 | + | f.Add(make([]byte, 32)) | |
| 73 | + | if raw, err := xtest.LoadHex("../testdata/golden/xproto/QueryTree.reply.hex"); err != nil { | |
| 74 | + | f.Fatal(err) | |
| 75 | + | } else { | |
| 76 | + | f.Add(raw) | |
| 77 | + | } | |
| 78 | + | f.Fuzz(func(t *testing.T, raw []byte) { | |
| 79 | + | r, ok := ParseQueryTreeReply(raw) | |
| 80 | + | if !ok { | |
| 81 | + | return | |
| 82 | + | } | |
| 83 | + | if len(r.Raw()) != len(raw) { | |
| 84 | + | t.Fatal("Raw must return the parsed bytes") | |
| 85 | + | } | |
| 86 | + | _ = r.Root() | |
| 87 | + | _ = r.Parent() | |
| 88 | + | _ = r.ChildrenLen() | |
| 89 | + | { | |
| 90 | + | l0 := r.Children() | |
| 91 | + | for i := 0; i < l0.Len(); i++ { | |
| 92 | + | _ = l0.At(i) | |
| 93 | + | } | |
| 94 | + | } | |
| 95 | + | }) | |
| 96 | + | } | |
| 97 | + | ||
| 98 | + | func FuzzParseInternAtomReply(f *testing.F) { | |
| 99 | + | f.Add(make([]byte, 32)) | |
| 100 | + | if raw, err := xtest.LoadHex("../testdata/golden/xproto/InternAtom.reply.hex"); err != nil { | |
| 101 | + | f.Fatal(err) | |
| 102 | + | } else { | |
| 103 | + | f.Add(raw) | |
| 104 | + | } | |
| 105 | + | f.Fuzz(func(t *testing.T, raw []byte) { | |
| 106 | + | r, ok := ParseInternAtomReply(raw) | |
| 107 | + | if !ok { | |
| 108 | + | if len(raw) >= 32 { | |
| 109 | + | t.Fatal("rejected a complete fixed-size reply") | |
| 110 | + | } | |
| 111 | + | return | |
| 112 | + | } | |
| 113 | + | if len(r.Raw()) != len(raw) { | |
| 114 | + | t.Fatal("Raw must return the parsed bytes") | |
| 115 | + | } | |
| 116 | + | _ = r.Atom() | |
| 117 | + | }) | |
| 118 | + | } | |
| 119 | + | ||
| 120 | + | func FuzzParseGetAtomNameReply(f *testing.F) { | |
| 121 | + | f.Add(make([]byte, 32)) | |
| 122 | + | f.Fuzz(func(t *testing.T, raw []byte) { | |
| 123 | + | r, ok := ParseGetAtomNameReply(raw) | |
| 124 | + | if !ok { | |
| 125 | + | return | |
| 126 | + | } | |
| 127 | + | if len(r.Raw()) != len(raw) { | |
| 128 | + | t.Fatal("Raw must return the parsed bytes") | |
| 129 | + | } | |
| 130 | + | _ = r.NameLen() | |
| 131 | + | _ = len(r.Name()) | |
| 132 | + | }) | |
| 133 | + | } | |
| 134 | + | ||
| 135 | + | func FuzzParseGetPropertyReply(f *testing.F) { | |
| 136 | + | f.Add(make([]byte, 32)) | |
| 137 | + | if raw, err := xtest.LoadHex("../testdata/golden/xproto/GetProperty.reply.hex"); err != nil { | |
| 138 | + | f.Fatal(err) | |
| 139 | + | } else { | |
| 140 | + | f.Add(raw) | |
| 141 | + | } | |
| 142 | + | if raw, err := xtest.LoadHex("../testdata/golden/xproto/GetPropertyEmpty.reply.hex"); err != nil { | |
| 143 | + | f.Fatal(err) | |
| 144 | + | } else { | |
| 145 | + | f.Add(raw) | |
| 146 | + | } | |
| 147 | + | f.Fuzz(func(t *testing.T, raw []byte) { | |
| 148 | + | r, ok := ParseGetPropertyReply(raw) | |
| 149 | + | if !ok { | |
| 150 | + | return | |
| 151 | + | } | |
| 152 | + | if len(r.Raw()) != len(raw) { | |
| 153 | + | t.Fatal("Raw must return the parsed bytes") | |
| 154 | + | } | |
| 155 | + | _ = r.Format() | |
| 156 | + | _ = r.Type() | |
| 157 | + | _ = r.BytesAfter() | |
| 158 | + | _ = r.ValueLen() | |
| 159 | + | _ = len(r.Value()) | |
| 160 | + | }) | |
| 161 | + | } | |
| 162 | + | ||
| 163 | + | func FuzzParseListPropertiesReply(f *testing.F) { | |
| 164 | + | f.Add(make([]byte, 32)) | |
| 165 | + | f.Fuzz(func(t *testing.T, raw []byte) { | |
| 166 | + | r, ok := ParseListPropertiesReply(raw) | |
| 167 | + | if !ok { | |
| 168 | + | return | |
| 169 | + | } | |
| 170 | + | if len(r.Raw()) != len(raw) { | |
| 171 | + | t.Fatal("Raw must return the parsed bytes") | |
| 172 | + | } | |
| 173 | + | _ = r.AtomsLen() | |
| 174 | + | { | |
| 175 | + | l0 := r.Atoms() | |
| 176 | + | for i := 0; i < l0.Len(); i++ { | |
| 177 | + | _ = l0.At(i) | |
| 178 | + | } | |
| 179 | + | } | |
| 180 | + | }) | |
| 181 | + | } | |
| 182 | + | ||
| 183 | + | func FuzzParseGetSelectionOwnerReply(f *testing.F) { | |
| 184 | + | f.Add(make([]byte, 32)) | |
| 185 | + | f.Fuzz(func(t *testing.T, raw []byte) { | |
| 186 | + | r, ok := ParseGetSelectionOwnerReply(raw) | |
| 187 | + | if !ok { | |
| 188 | + | if len(raw) >= 32 { | |
| 189 | + | t.Fatal("rejected a complete fixed-size reply") | |
| 190 | + | } | |
| 191 | + | return | |
| 192 | + | } | |
| 193 | + | if len(r.Raw()) != len(raw) { | |
| 194 | + | t.Fatal("Raw must return the parsed bytes") | |
| 195 | + | } | |
| 196 | + | _ = r.Owner() | |
| 197 | + | }) | |
| 198 | + | } | |
| 199 | + | ||
| 200 | + | func FuzzParseGrabPointerReply(f *testing.F) { | |
| 201 | + | f.Add(make([]byte, 32)) | |
| 202 | + | f.Fuzz(func(t *testing.T, raw []byte) { | |
| 203 | + | r, ok := ParseGrabPointerReply(raw) | |
| 204 | + | if !ok { | |
| 205 | + | if len(raw) >= 32 { | |
| 206 | + | t.Fatal("rejected a complete fixed-size reply") | |
| 207 | + | } | |
| 208 | + | return | |
| 209 | + | } | |
| 210 | + | if len(r.Raw()) != len(raw) { | |
| 211 | + | t.Fatal("Raw must return the parsed bytes") | |
| 212 | + | } | |
| 213 | + | _ = r.Status() | |
| 214 | + | }) | |
| 215 | + | } | |
| 216 | + | ||
| 217 | + | func FuzzParseGrabKeyboardReply(f *testing.F) { | |
| 218 | + | f.Add(make([]byte, 32)) | |
| 219 | + | f.Fuzz(func(t *testing.T, raw []byte) { | |
| 220 | + | r, ok := ParseGrabKeyboardReply(raw) | |
| 221 | + | if !ok { | |
| 222 | + | if len(raw) >= 32 { | |
| 223 | + | t.Fatal("rejected a complete fixed-size reply") | |
| 224 | + | } | |
| 225 | + | return | |
| 226 | + | } | |
| 227 | + | if len(r.Raw()) != len(raw) { | |
| 228 | + | t.Fatal("Raw must return the parsed bytes") | |
| 229 | + | } | |
| 230 | + | _ = r.Status() | |
| 231 | + | }) | |
| 232 | + | } | |
| 233 | + | ||
| 234 | + | func FuzzParseQueryPointerReply(f *testing.F) { | |
| 235 | + | f.Add(make([]byte, 32)) | |
| 236 | + | f.Fuzz(func(t *testing.T, raw []byte) { | |
| 237 | + | r, ok := ParseQueryPointerReply(raw) | |
| 238 | + | if !ok { | |
| 239 | + | if len(raw) >= 32 { | |
| 240 | + | t.Fatal("rejected a complete fixed-size reply") | |
| 241 | + | } | |
| 242 | + | return | |
| 243 | + | } | |
| 244 | + | if len(r.Raw()) != len(raw) { | |
| 245 | + | t.Fatal("Raw must return the parsed bytes") | |
| 246 | + | } | |
| 247 | + | _ = r.SameScreen() | |
| 248 | + | _ = r.Root() | |
| 249 | + | _ = r.Child() | |
| 250 | + | _ = r.RootX() | |
| 251 | + | _ = r.RootY() | |
| 252 | + | _ = r.WinX() | |
| 253 | + | _ = r.WinY() | |
| 254 | + | _ = r.Mask() | |
| 255 | + | }) | |
| 256 | + | } | |
| 257 | + | ||
| 258 | + | func FuzzParseGetMotionEventsReply(f *testing.F) { | |
| 259 | + | f.Add(make([]byte, 32)) | |
| 260 | + | f.Fuzz(func(t *testing.T, raw []byte) { | |
| 261 | + | r, ok := ParseGetMotionEventsReply(raw) | |
| 262 | + | if !ok { | |
| 263 | + | return | |
| 264 | + | } | |
| 265 | + | if len(r.Raw()) != len(raw) { | |
| 266 | + | t.Fatal("Raw must return the parsed bytes") | |
| 267 | + | } | |
| 268 | + | _ = r.EventsLen() | |
| 269 | + | { | |
| 270 | + | l0 := r.Events() | |
| 271 | + | for i := 0; i < l0.Len(); i++ { | |
| 272 | + | _ = l0.At(i) | |
| 273 | + | } | |
| 274 | + | } | |
| 275 | + | }) | |
| 276 | + | } | |
| 277 | + | ||
| 278 | + | func FuzzParseTranslateCoordinatesReply(f *testing.F) { | |
| 279 | + | f.Add(make([]byte, 32)) | |
| 280 | + | f.Fuzz(func(t *testing.T, raw []byte) { | |
| 281 | + | r, ok := ParseTranslateCoordinatesReply(raw) | |
| 282 | + | if !ok { | |
| 283 | + | if len(raw) >= 32 { | |
| 284 | + | t.Fatal("rejected a complete fixed-size reply") | |
| 285 | + | } | |
| 286 | + | return | |
| 287 | + | } | |
| 288 | + | if len(r.Raw()) != len(raw) { | |
| 289 | + | t.Fatal("Raw must return the parsed bytes") | |
| 290 | + | } | |
| 291 | + | _ = r.SameScreen() | |
| 292 | + | _ = r.Child() | |
| 293 | + | _ = r.DstX() | |
| 294 | + | _ = r.DstY() | |
| 295 | + | }) | |
| 296 | + | } | |
| 297 | + | ||
| 298 | + | func FuzzParseGetInputFocusReply(f *testing.F) { | |
| 299 | + | f.Add(make([]byte, 32)) | |
| 300 | + | f.Fuzz(func(t *testing.T, raw []byte) { | |
| 301 | + | r, ok := ParseGetInputFocusReply(raw) | |
| 302 | + | if !ok { | |
| 303 | + | if len(raw) >= 32 { | |
| 304 | + | t.Fatal("rejected a complete fixed-size reply") | |
| 305 | + | } | |
| 306 | + | return | |
| 307 | + | } | |
| 308 | + | if len(r.Raw()) != len(raw) { | |
| 309 | + | t.Fatal("Raw must return the parsed bytes") | |
| 310 | + | } | |
| 311 | + | _ = r.RevertTo() | |
| 312 | + | _ = r.Focus() | |
| 313 | + | }) | |
| 314 | + | } | |
| 315 | + | ||
| 316 | + | func FuzzParseQueryKeymapReply(f *testing.F) { | |
| 317 | + | f.Add(make([]byte, 40)) | |
| 318 | + | f.Fuzz(func(t *testing.T, raw []byte) { | |
| 319 | + | r, ok := ParseQueryKeymapReply(raw) | |
| 320 | + | if !ok { | |
| 321 | + | if len(raw) >= 40 { | |
| 322 | + | t.Fatal("rejected a complete fixed-size reply") | |
| 323 | + | } | |
| 324 | + | return | |
| 325 | + | } | |
| 326 | + | if len(r.Raw()) != len(raw) { | |
| 327 | + | t.Fatal("Raw must return the parsed bytes") | |
| 328 | + | } | |
| 329 | + | _ = len(r.Keys()) | |
| 330 | + | }) | |
| 331 | + | } | |
| 332 | + | ||
| 333 | + | func FuzzParseQueryFontReply(f *testing.F) { | |
| 334 | + | f.Add(make([]byte, 60)) | |
| 335 | + | f.Fuzz(func(t *testing.T, raw []byte) { | |
| 336 | + | r, ok := ParseQueryFontReply(raw) | |
| 337 | + | if !ok { | |
| 338 | + | return | |
| 339 | + | } | |
| 340 | + | if len(r.Raw()) != len(raw) { | |
| 341 | + | t.Fatal("Raw must return the parsed bytes") | |
| 342 | + | } | |
| 343 | + | _ = r.MinBounds() | |
| 344 | + | _ = r.MaxBounds() | |
| 345 | + | _ = r.MinCharOrByte2() | |
| 346 | + | _ = r.MaxCharOrByte2() | |
| 347 | + | _ = r.DefaultChar() | |
| 348 | + | _ = r.PropertiesLen() | |
| 349 | + | _ = r.DrawDirection() | |
| 350 | + | _ = r.MinByte1() | |
| 351 | + | _ = r.MaxByte1() | |
| 352 | + | _ = r.AllCharsExist() | |
| 353 | + | _ = r.FontAscent() | |
| 354 | + | _ = r.FontDescent() | |
| 355 | + | _ = r.CharInfosLen() | |
| 356 | + | { | |
| 357 | + | l0 := r.Properties() | |
| 358 | + | for i := 0; i < l0.Len(); i++ { | |
| 359 | + | _ = l0.At(i) | |
| 360 | + | } | |
| 361 | + | } | |
| 362 | + | { | |
| 363 | + | l0 := r.CharInfos() | |
| 364 | + | for i := 0; i < l0.Len(); i++ { | |
| 365 | + | _ = l0.At(i) | |
| 366 | + | } | |
| 367 | + | } | |
| 368 | + | }) | |
| 369 | + | } | |
| 370 | + | ||
| 371 | + | func FuzzParseQueryTextExtentsReply(f *testing.F) { | |
| 372 | + | f.Add(make([]byte, 32)) | |
| 373 | + | f.Fuzz(func(t *testing.T, raw []byte) { | |
| 374 | + | r, ok := ParseQueryTextExtentsReply(raw) | |
| 375 | + | if !ok { | |
| 376 | + | if len(raw) >= 32 { | |
| 377 | + | t.Fatal("rejected a complete fixed-size reply") | |
| 378 | + | } | |
| 379 | + | return | |
| 380 | + | } | |
| 381 | + | if len(r.Raw()) != len(raw) { | |
| 382 | + | t.Fatal("Raw must return the parsed bytes") | |
| 383 | + | } | |
| 384 | + | _ = r.DrawDirection() | |
| 385 | + | _ = r.FontAscent() | |
| 386 | + | _ = r.FontDescent() | |
| 387 | + | _ = r.OverallAscent() | |
| 388 | + | _ = r.OverallDescent() | |
| 389 | + | _ = r.OverallWidth() | |
| 390 | + | _ = r.OverallLeft() | |
| 391 | + | _ = r.OverallRight() | |
| 392 | + | }) | |
| 393 | + | } | |
| 394 | + | ||
| 395 | + | func FuzzParseListFontsReply(f *testing.F) { | |
| 396 | + | f.Add(make([]byte, 32)) | |
| 397 | + | f.Fuzz(func(t *testing.T, raw []byte) { | |
| 398 | + | r, ok := ParseListFontsReply(raw) | |
| 399 | + | if !ok { | |
| 400 | + | return | |
| 401 | + | } | |
| 402 | + | if len(r.Raw()) != len(raw) { | |
| 403 | + | t.Fatal("Raw must return the parsed bytes") | |
| 404 | + | } | |
| 405 | + | _ = r.NamesLen() | |
| 406 | + | { | |
| 407 | + | it0 := r.Names() | |
| 408 | + | for it0.Next() { | |
| 409 | + | _ = it0.Value().NameLen() | |
| 410 | + | _ = len(it0.Value().Name()) | |
| 411 | + | } | |
| 412 | + | if it0.Err() { | |
| 413 | + | t.Fatal("iterator error after successful Parse") | |
| 414 | + | } | |
| 415 | + | } | |
| 416 | + | }) | |
| 417 | + | } | |
| 418 | + | ||
| 419 | + | func FuzzParseListFontsWithInfoReply(f *testing.F) { | |
| 420 | + | f.Add(make([]byte, 60)) | |
| 421 | + | f.Fuzz(func(t *testing.T, raw []byte) { | |
| 422 | + | r, ok := ParseListFontsWithInfoReply(raw) | |
| 423 | + | if !ok { | |
| 424 | + | return | |
| 425 | + | } | |
| 426 | + | if len(r.Raw()) != len(raw) { | |
| 427 | + | t.Fatal("Raw must return the parsed bytes") | |
| 428 | + | } | |
| 429 | + | _ = r.NameLen() | |
| 430 | + | _ = r.MinBounds() | |
| 431 | + | _ = r.MaxBounds() | |
| 432 | + | _ = r.MinCharOrByte2() | |
| 433 | + | _ = r.MaxCharOrByte2() | |
| 434 | + | _ = r.DefaultChar() | |
| 435 | + | _ = r.PropertiesLen() | |
| 436 | + | _ = r.DrawDirection() | |
| 437 | + | _ = r.MinByte1() | |
| 438 | + | _ = r.MaxByte1() | |
| 439 | + | _ = r.AllCharsExist() | |
| 440 | + | _ = r.FontAscent() | |
| 441 | + | _ = r.FontDescent() | |
| 442 | + | _ = r.RepliesHint() | |
| 443 | + | { | |
| 444 | + | l0 := r.Properties() | |
| 445 | + | for i := 0; i < l0.Len(); i++ { | |
| 446 | + | _ = l0.At(i) | |
| 447 | + | } | |
| 448 | + | } | |
| 449 | + | _ = len(r.Name()) | |
| 450 | + | }) | |
| 451 | + | } | |
| 452 | + | ||
| 453 | + | func FuzzParseGetFontPathReply(f *testing.F) { | |
| 454 | + | f.Add(make([]byte, 32)) | |
| 455 | + | f.Fuzz(func(t *testing.T, raw []byte) { | |
| 456 | + | r, ok := ParseGetFontPathReply(raw) | |
| 457 | + | if !ok { | |
| 458 | + | return | |
| 459 | + | } | |
| 460 | + | if len(r.Raw()) != len(raw) { | |
| 461 | + | t.Fatal("Raw must return the parsed bytes") | |
| 462 | + | } | |
| 463 | + | _ = r.PathLen() | |
| 464 | + | { | |
| 465 | + | it0 := r.Path() | |
| 466 | + | for it0.Next() { | |
| 467 | + | _ = it0.Value().NameLen() | |
| 468 | + | _ = len(it0.Value().Name()) | |
| 469 | + | } | |
| 470 | + | if it0.Err() { | |
| 471 | + | t.Fatal("iterator error after successful Parse") | |
| 472 | + | } | |
| 473 | + | } | |
| 474 | + | }) | |
| 475 | + | } | |
| 476 | + | ||
| 477 | + | func FuzzParseGetImageReply(f *testing.F) { | |
| 478 | + | f.Add(make([]byte, 32)) | |
| 479 | + | f.Fuzz(func(t *testing.T, raw []byte) { | |
| 480 | + | r, ok := ParseGetImageReply(raw) | |
| 481 | + | if !ok { | |
| 482 | + | return | |
| 483 | + | } | |
| 484 | + | if len(r.Raw()) != len(raw) { | |
| 485 | + | t.Fatal("Raw must return the parsed bytes") | |
| 486 | + | } | |
| 487 | + | _ = r.Depth() | |
| 488 | + | _ = r.Visual() | |
| 489 | + | _ = len(r.Data()) | |
| 490 | + | }) | |
| 491 | + | } | |
| 492 | + | ||
| 493 | + | func FuzzParseListInstalledColormapsReply(f *testing.F) { | |
| 494 | + | f.Add(make([]byte, 32)) | |
| 495 | + | f.Fuzz(func(t *testing.T, raw []byte) { | |
| 496 | + | r, ok := ParseListInstalledColormapsReply(raw) | |
| 497 | + | if !ok { | |
| 498 | + | return | |
| 499 | + | } | |
| 500 | + | if len(r.Raw()) != len(raw) { | |
| 501 | + | t.Fatal("Raw must return the parsed bytes") | |
| 502 | + | } | |
| 503 | + | _ = r.CmapsLen() | |
| 504 | + | { | |
| 505 | + | l0 := r.Cmaps() | |
| 506 | + | for i := 0; i < l0.Len(); i++ { | |
| 507 | + | _ = l0.At(i) | |
| 508 | + | } | |
| 509 | + | } | |
| 510 | + | }) | |
| 511 | + | } | |
| 512 | + | ||
| 513 | + | func FuzzParseAllocColorReply(f *testing.F) { | |
| 514 | + | f.Add(make([]byte, 32)) | |
| 515 | + | f.Fuzz(func(t *testing.T, raw []byte) { | |
| 516 | + | r, ok := ParseAllocColorReply(raw) | |
| 517 | + | if !ok { | |
| 518 | + | if len(raw) >= 32 { | |
| 519 | + | t.Fatal("rejected a complete fixed-size reply") | |
| 520 | + | } | |
| 521 | + | return | |
| 522 | + | } | |
| 523 | + | if len(r.Raw()) != len(raw) { | |
| 524 | + | t.Fatal("Raw must return the parsed bytes") | |
| 525 | + | } | |
| 526 | + | _ = r.Red() | |
| 527 | + | _ = r.Green() | |
| 528 | + | _ = r.Blue() | |
| 529 | + | _ = r.Pixel() | |
| 530 | + | }) | |
| 531 | + | } | |
| 532 | + | ||
| 533 | + | func FuzzParseAllocNamedColorReply(f *testing.F) { | |
| 534 | + | f.Add(make([]byte, 32)) | |
| 535 | + | f.Fuzz(func(t *testing.T, raw []byte) { | |
| 536 | + | r, ok := ParseAllocNamedColorReply(raw) | |
| 537 | + | if !ok { | |
| 538 | + | if len(raw) >= 32 { | |
| 539 | + | t.Fatal("rejected a complete fixed-size reply") | |
| 540 | + | } | |
| 541 | + | return | |
| 542 | + | } | |
| 543 | + | if len(r.Raw()) != len(raw) { | |
| 544 | + | t.Fatal("Raw must return the parsed bytes") | |
| 545 | + | } | |
| 546 | + | _ = r.Pixel() | |
| 547 | + | _ = r.ExactRed() | |
| 548 | + | _ = r.ExactGreen() | |
| 549 | + | _ = r.ExactBlue() | |
| 550 | + | _ = r.VisualRed() | |
| 551 | + | _ = r.VisualGreen() | |
| 552 | + | _ = r.VisualBlue() | |
| 553 | + | }) | |
| 554 | + | } | |
| 555 | + | ||
| 556 | + | func FuzzParseAllocColorCellsReply(f *testing.F) { | |
| 557 | + | f.Add(make([]byte, 32)) | |
| 558 | + | f.Fuzz(func(t *testing.T, raw []byte) { | |
| 559 | + | r, ok := ParseAllocColorCellsReply(raw) | |
| 560 | + | if !ok { | |
| 561 | + | return | |
| 562 | + | } | |
| 563 | + | if len(r.Raw()) != len(raw) { | |
| 564 | + | t.Fatal("Raw must return the parsed bytes") | |
| 565 | + | } | |
| 566 | + | _ = r.PixelsLen() | |
| 567 | + | _ = r.MasksLen() | |
| 568 | + | { | |
| 569 | + | l0 := r.Pixels() | |
| 570 | + | for i := 0; i < l0.Len(); i++ { | |
| 571 | + | _ = l0.At(i) | |
| 572 | + | } | |
| 573 | + | } | |
| 574 | + | { | |
| 575 | + | l0 := r.Masks() | |
| 576 | + | for i := 0; i < l0.Len(); i++ { | |
| 577 | + | _ = l0.At(i) | |
| 578 | + | } | |
| 579 | + | } | |
| 580 | + | }) | |
| 581 | + | } | |
| 582 | + | ||
| 583 | + | func FuzzParseAllocColorPlanesReply(f *testing.F) { | |
| 584 | + | f.Add(make([]byte, 32)) | |
| 585 | + | f.Fuzz(func(t *testing.T, raw []byte) { | |
| 586 | + | r, ok := ParseAllocColorPlanesReply(raw) | |
| 587 | + | if !ok { | |
| 588 | + | return | |
| 589 | + | } | |
| 590 | + | if len(r.Raw()) != len(raw) { | |
| 591 | + | t.Fatal("Raw must return the parsed bytes") | |
| 592 | + | } | |
| 593 | + | _ = r.PixelsLen() | |
| 594 | + | _ = r.RedMask() | |
| 595 | + | _ = r.GreenMask() | |
| 596 | + | _ = r.BlueMask() | |
| 597 | + | { | |
| 598 | + | l0 := r.Pixels() | |
| 599 | + | for i := 0; i < l0.Len(); i++ { | |
| 600 | + | _ = l0.At(i) | |
| 601 | + | } | |
| 602 | + | } | |
| 603 | + | }) | |
| 604 | + | } | |
| 605 | + | ||
| 606 | + | func FuzzParseQueryColorsReply(f *testing.F) { | |
| 607 | + | f.Add(make([]byte, 32)) | |
| 608 | + | f.Fuzz(func(t *testing.T, raw []byte) { | |
| 609 | + | r, ok := ParseQueryColorsReply(raw) | |
| 610 | + | if !ok { | |
| 611 | + | return | |
| 612 | + | } | |
| 613 | + | if len(r.Raw()) != len(raw) { | |
| 614 | + | t.Fatal("Raw must return the parsed bytes") | |
| 615 | + | } | |
| 616 | + | _ = r.ColorsLen() | |
| 617 | + | { | |
| 618 | + | l0 := r.Colors() | |
| 619 | + | for i := 0; i < l0.Len(); i++ { | |
| 620 | + | _ = l0.At(i) | |
| 621 | + | } | |
| 622 | + | } | |
| 623 | + | }) | |
| 624 | + | } | |
| 625 | + | ||
| 626 | + | func FuzzParseLookupColorReply(f *testing.F) { | |
| 627 | + | f.Add(make([]byte, 32)) | |
| 628 | + | f.Fuzz(func(t *testing.T, raw []byte) { | |
| 629 | + | r, ok := ParseLookupColorReply(raw) | |
| 630 | + | if !ok { | |
| 631 | + | if len(raw) >= 32 { | |
| 632 | + | t.Fatal("rejected a complete fixed-size reply") | |
| 633 | + | } | |
| 634 | + | return | |
| 635 | + | } | |
| 636 | + | if len(r.Raw()) != len(raw) { | |
| 637 | + | t.Fatal("Raw must return the parsed bytes") | |
| 638 | + | } | |
| 639 | + | _ = r.ExactRed() | |
| 640 | + | _ = r.ExactGreen() | |
| 641 | + | _ = r.ExactBlue() | |
| 642 | + | _ = r.VisualRed() | |
| 643 | + | _ = r.VisualGreen() | |
| 644 | + | _ = r.VisualBlue() | |
| 645 | + | }) | |
| 646 | + | } | |
| 647 | + | ||
| 648 | + | func FuzzParseQueryBestSizeReply(f *testing.F) { | |
| 649 | + | f.Add(make([]byte, 32)) | |
| 650 | + | f.Fuzz(func(t *testing.T, raw []byte) { | |
| 651 | + | r, ok := ParseQueryBestSizeReply(raw) | |
| 652 | + | if !ok { | |
| 653 | + | if len(raw) >= 32 { | |
| 654 | + | t.Fatal("rejected a complete fixed-size reply") | |
| 655 | + | } | |
| 656 | + | return | |
| 657 | + | } | |
| 658 | + | if len(r.Raw()) != len(raw) { | |
| 659 | + | t.Fatal("Raw must return the parsed bytes") | |
| 660 | + | } | |
| 661 | + | _ = r.Width() | |
| 662 | + | _ = r.Height() | |
| 663 | + | }) | |
| 664 | + | } | |
| 665 | + | ||
| 666 | + | func FuzzParseQueryExtensionReply(f *testing.F) { | |
| 667 | + | f.Add(make([]byte, 32)) | |
| 668 | + | if raw, err := xtest.LoadHex("../testdata/golden/xproto/QueryExtension.reply.hex"); err != nil { | |
| 669 | + | f.Fatal(err) | |
| 670 | + | } else { | |
| 671 | + | f.Add(raw) | |
| 672 | + | } | |
| 673 | + | f.Fuzz(func(t *testing.T, raw []byte) { | |
| 674 | + | r, ok := ParseQueryExtensionReply(raw) | |
| 675 | + | if !ok { | |
| 676 | + | if len(raw) >= 32 { | |
| 677 | + | t.Fatal("rejected a complete fixed-size reply") | |
| 678 | + | } | |
| 679 | + | return | |
| 680 | + | } | |
| 681 | + | if len(r.Raw()) != len(raw) { | |
| 682 | + | t.Fatal("Raw must return the parsed bytes") | |
| 683 | + | } | |
| 684 | + | _ = r.Present() | |
| 685 | + | _ = r.MajorOpcode() | |
| 686 | + | _ = r.FirstEvent() | |
| 687 | + | _ = r.FirstError() | |
| 688 | + | }) | |
| 689 | + | } | |
| 690 | + | ||
| 691 | + | func FuzzParseListExtensionsReply(f *testing.F) { | |
| 692 | + | f.Add(make([]byte, 32)) | |
| 693 | + | if raw, err := xtest.LoadHex("../testdata/golden/xproto/ListExtensions.reply.hex"); err != nil { | |
| 694 | + | f.Fatal(err) | |
| 695 | + | } else { | |
| 696 | + | f.Add(raw) | |
| 697 | + | } | |
| 698 | + | f.Fuzz(func(t *testing.T, raw []byte) { | |
| 699 | + | r, ok := ParseListExtensionsReply(raw) | |
| 700 | + | if !ok { | |
| 701 | + | return | |
| 702 | + | } | |
| 703 | + | if len(r.Raw()) != len(raw) { | |
| 704 | + | t.Fatal("Raw must return the parsed bytes") | |
| 705 | + | } | |
| 706 | + | _ = r.NamesLen() | |
| 707 | + | { | |
| 708 | + | it0 := r.Names() | |
| 709 | + | for it0.Next() { | |
| 710 | + | _ = it0.Value().NameLen() | |
| 711 | + | _ = len(it0.Value().Name()) | |
| 712 | + | } | |
| 713 | + | if it0.Err() { | |
| 714 | + | t.Fatal("iterator error after successful Parse") | |
| 715 | + | } | |
| 716 | + | } | |
| 717 | + | }) | |
| 718 | + | } | |
| 719 | + | ||
| 720 | + | func FuzzParseGetKeyboardMappingReply(f *testing.F) { | |
| 721 | + | f.Add(make([]byte, 32)) | |
| 722 | + | f.Fuzz(func(t *testing.T, raw []byte) { | |
| 723 | + | r, ok := ParseGetKeyboardMappingReply(raw) | |
| 724 | + | if !ok { | |
| 725 | + | return | |
| 726 | + | } | |
| 727 | + | if len(r.Raw()) != len(raw) { | |
| 728 | + | t.Fatal("Raw must return the parsed bytes") | |
| 729 | + | } | |
| 730 | + | _ = r.KeysymsPerKeycode() | |
| 731 | + | { | |
| 732 | + | l0 := r.Keysyms() | |
| 733 | + | for i := 0; i < l0.Len(); i++ { | |
| 734 | + | _ = l0.At(i) | |
| 735 | + | } | |
| 736 | + | } | |
| 737 | + | }) | |
| 738 | + | } | |
| 739 | + | ||
| 740 | + | func FuzzParseGetKeyboardControlReply(f *testing.F) { | |
| 741 | + | f.Add(make([]byte, 52)) | |
| 742 | + | f.Fuzz(func(t *testing.T, raw []byte) { | |
| 743 | + | r, ok := ParseGetKeyboardControlReply(raw) | |
| 744 | + | if !ok { | |
| 745 | + | if len(raw) >= 52 { | |
| 746 | + | t.Fatal("rejected a complete fixed-size reply") | |
| 747 | + | } | |
| 748 | + | return | |
| 749 | + | } | |
| 750 | + | if len(r.Raw()) != len(raw) { | |
| 751 | + | t.Fatal("Raw must return the parsed bytes") | |
| 752 | + | } | |
| 753 | + | _ = r.GlobalAutoRepeat() | |
| 754 | + | _ = r.LedMask() | |
| 755 | + | _ = r.KeyClickPercent() | |
| 756 | + | _ = r.BellPercent() | |
| 757 | + | _ = r.BellPitch() | |
| 758 | + | _ = r.BellDuration() | |
| 759 | + | _ = len(r.AutoRepeats()) | |
| 760 | + | }) | |
| 761 | + | } | |
| 762 | + | ||
| 763 | + | func FuzzParseGetPointerControlReply(f *testing.F) { | |
| 764 | + | f.Add(make([]byte, 32)) | |
| 765 | + | f.Fuzz(func(t *testing.T, raw []byte) { | |
| 766 | + | r, ok := ParseGetPointerControlReply(raw) | |
| 767 | + | if !ok { | |
| 768 | + | if len(raw) >= 32 { | |
| 769 | + | t.Fatal("rejected a complete fixed-size reply") | |
| 770 | + | } | |
| 771 | + | return | |
| 772 | + | } | |
| 773 | + | if len(r.Raw()) != len(raw) { | |
| 774 | + | t.Fatal("Raw must return the parsed bytes") | |
| 775 | + | } | |
| 776 | + | _ = r.AccelerationNumerator() | |
| 777 | + | _ = r.AccelerationDenominator() | |
| 778 | + | _ = r.Threshold() | |
| 779 | + | }) | |
| 780 | + | } | |
| 781 | + | ||
| 782 | + | func FuzzParseGetScreenSaverReply(f *testing.F) { | |
| 783 | + | f.Add(make([]byte, 32)) | |
| 784 | + | f.Fuzz(func(t *testing.T, raw []byte) { | |
| 785 | + | r, ok := ParseGetScreenSaverReply(raw) | |
| 786 | + | if !ok { | |
| 787 | + | if len(raw) >= 32 { | |
| 788 | + | t.Fatal("rejected a complete fixed-size reply") | |
| 789 | + | } | |
| 790 | + | return | |
| 791 | + | } | |
| 792 | + | if len(r.Raw()) != len(raw) { | |
| 793 | + | t.Fatal("Raw must return the parsed bytes") | |
| 794 | + | } | |
| 795 | + | _ = r.Timeout() | |
| 796 | + | _ = r.Interval() | |
| 797 | + | _ = r.PreferBlanking() | |
| 798 | + | _ = r.AllowExposures() | |
| 799 | + | }) | |
| 800 | + | } | |
| 801 | + | ||
| 802 | + | func FuzzParseListHostsReply(f *testing.F) { | |
| 803 | + | f.Add(make([]byte, 32)) | |
| 804 | + | f.Fuzz(func(t *testing.T, raw []byte) { | |
| 805 | + | r, ok := ParseListHostsReply(raw) | |
| 806 | + | if !ok { | |
| 807 | + | return | |
| 808 | + | } | |
| 809 | + | if len(r.Raw()) != len(raw) { | |
| 810 | + | t.Fatal("Raw must return the parsed bytes") | |
| 811 | + | } | |
| 812 | + | _ = r.Mode() | |
| 813 | + | _ = r.HostsLen() | |
| 814 | + | { | |
| 815 | + | it0 := r.Hosts() | |
| 816 | + | for it0.Next() { | |
| 817 | + | _ = it0.Value().Family() | |
| 818 | + | _ = it0.Value().AddressLen() | |
| 819 | + | _ = len(it0.Value().Address()) | |
| 820 | + | } | |
| 821 | + | if it0.Err() { | |
| 822 | + | t.Fatal("iterator error after successful Parse") | |
| 823 | + | } | |
| 824 | + | } | |
| 825 | + | }) | |
| 826 | + | } | |
| 827 | + | ||
| 828 | + | func FuzzParseSetPointerMappingReply(f *testing.F) { | |
| 829 | + | f.Add(make([]byte, 32)) | |
| 830 | + | f.Fuzz(func(t *testing.T, raw []byte) { | |
| 831 | + | r, ok := ParseSetPointerMappingReply(raw) | |
| 832 | + | if !ok { | |
| 833 | + | if len(raw) >= 32 { | |
| 834 | + | t.Fatal("rejected a complete fixed-size reply") | |
| 835 | + | } | |
| 836 | + | return | |
| 837 | + | } | |
| 838 | + | if len(r.Raw()) != len(raw) { | |
| 839 | + | t.Fatal("Raw must return the parsed bytes") | |
| 840 | + | } | |
| 841 | + | _ = r.Status() | |
| 842 | + | }) | |
| 843 | + | } | |
| 844 | + | ||
| 845 | + | func FuzzParseGetPointerMappingReply(f *testing.F) { | |
| 846 | + | f.Add(make([]byte, 32)) | |
| 847 | + | f.Fuzz(func(t *testing.T, raw []byte) { | |
| 848 | + | r, ok := ParseGetPointerMappingReply(raw) | |
| 849 | + | if !ok { | |
| 850 | + | return | |
| 851 | + | } | |
| 852 | + | if len(r.Raw()) != len(raw) { | |
| 853 | + | t.Fatal("Raw must return the parsed bytes") | |
| 854 | + | } | |
| 855 | + | _ = r.MapLen() | |
| 856 | + | _ = len(r.Map()) | |
| 857 | + | }) | |
| 858 | + | } | |
| 859 | + | ||
| 860 | + | func FuzzParseSetModifierMappingReply(f *testing.F) { | |
| 861 | + | f.Add(make([]byte, 32)) | |
| 862 | + | f.Fuzz(func(t *testing.T, raw []byte) { | |
| 863 | + | r, ok := ParseSetModifierMappingReply(raw) | |
| 864 | + | if !ok { | |
| 865 | + | if len(raw) >= 32 { | |
| 866 | + | t.Fatal("rejected a complete fixed-size reply") | |
| 867 | + | } | |
| 868 | + | return | |
| 869 | + | } | |
| 870 | + | if len(r.Raw()) != len(raw) { | |
| 871 | + | t.Fatal("Raw must return the parsed bytes") | |
| 872 | + | } | |
| 873 | + | _ = r.Status() | |
| 874 | + | }) | |
| 875 | + | } | |
| 876 | + | ||
| 877 | + | func FuzzParseGetModifierMappingReply(f *testing.F) { | |
| 878 | + | f.Add(make([]byte, 32)) | |
| 879 | + | f.Fuzz(func(t *testing.T, raw []byte) { | |
| 880 | + | r, ok := ParseGetModifierMappingReply(raw) | |
| 881 | + | if !ok { | |
| 882 | + | return | |
| 883 | + | } | |
| 884 | + | if len(r.Raw()) != len(raw) { | |
| 885 | + | t.Fatal("Raw must return the parsed bytes") | |
| 886 | + | } | |
| 887 | + | _ = r.KeycodesPerModifier() | |
| 888 | + | { | |
| 889 | + | l0 := r.Keycodes() | |
| 890 | + | for i := 0; i < l0.Len(); i++ { | |
| 891 | + | _ = l0.At(i) | |
| 892 | + | } | |
| 893 | + | } | |
| 894 | + | }) | |
| 895 | + | } | |
A xproto/replies_generated.go +1964 -0
| @@ -0,0 +1,1964 @@ | |||
| 1 | + | // Code generated by xtgen; DO NOT EDIT. | |
| 2 | + | package xproto | |
| 3 | + | ||
| 4 | + | import "encoding/binary" | |
| 5 | + | ||
| 6 | + | // GetWindowAttributesReply is a zero-copy view over a GetWindowAttributes reply; offsets count from reply byte 0. | |
| 7 | + | // It borrows the reply bytes: valid only until the Handler callback returns, because the read ring is reused. Copy what you keep. | |
| 8 | + | type GetWindowAttributesReply struct{ raw []byte } | |
| 9 | + | ||
| 10 | + | // ParseGetWindowAttributesReply validates raw (the whole reply, 32+4*length bytes) once; getters do not re-check. | |
| 11 | + | func ParseGetWindowAttributesReply(raw []byte) (GetWindowAttributesReply, bool) { | |
| 12 | + | if len(raw) < 44 { | |
| 13 | + | return GetWindowAttributesReply{}, false | |
| 14 | + | } | |
| 15 | + | r := GetWindowAttributesReply{raw: raw} | |
| 16 | + | return r, true | |
| 17 | + | } | |
| 18 | + | func (r GetWindowAttributesReply) Raw() []byte { return r.raw } | |
| 19 | + | func (r GetWindowAttributesReply) BackingStore() BackingStore { return BackingStore(r.raw[1:][0]) } | |
| 20 | + | func (r GetWindowAttributesReply) Visual() Visualid { | |
| 21 | + | return Visualid(binary.LittleEndian.Uint32(r.raw[8:])) | |
| 22 | + | } | |
| 23 | + | func (r GetWindowAttributesReply) Class() WindowClass { | |
| 24 | + | return WindowClass(binary.LittleEndian.Uint16(r.raw[12:])) | |
| 25 | + | } | |
| 26 | + | func (r GetWindowAttributesReply) BitGravity() Gravity { return Gravity(r.raw[14:][0]) } | |
| 27 | + | func (r GetWindowAttributesReply) WinGravity() Gravity { return Gravity(r.raw[15:][0]) } | |
| 28 | + | func (r GetWindowAttributesReply) BackingPlanes() uint32 { | |
| 29 | + | return uint32(binary.LittleEndian.Uint32(r.raw[16:])) | |
| 30 | + | } | |
| 31 | + | func (r GetWindowAttributesReply) BackingPixel() uint32 { | |
| 32 | + | return uint32(binary.LittleEndian.Uint32(r.raw[20:])) | |
| 33 | + | } | |
| 34 | + | func (r GetWindowAttributesReply) SaveUnder() bool { return (r.raw[24:][0] != 0) } | |
| 35 | + | func (r GetWindowAttributesReply) MapIsInstalled() bool { return (r.raw[25:][0] != 0) } | |
| 36 | + | func (r GetWindowAttributesReply) MapState() MapState { return MapState(r.raw[26:][0]) } | |
| 37 | + | func (r GetWindowAttributesReply) OverrideRedirect() bool { return (r.raw[27:][0] != 0) } | |
| 38 | + | func (r GetWindowAttributesReply) Colormap() Colormap { | |
| 39 | + | return Colormap(binary.LittleEndian.Uint32(r.raw[28:])) | |
| 40 | + | } | |
| 41 | + | func (r GetWindowAttributesReply) AllEventMasks() EventMask { | |
| 42 | + | return EventMask(binary.LittleEndian.Uint32(r.raw[32:])) | |
| 43 | + | } | |
| 44 | + | func (r GetWindowAttributesReply) YourEventMask() EventMask { | |
| 45 | + | return EventMask(binary.LittleEndian.Uint32(r.raw[36:])) | |
| 46 | + | } | |
| 47 | + | func (r GetWindowAttributesReply) DoNotPropagateMask() EventMask { | |
| 48 | + | return EventMask(binary.LittleEndian.Uint16(r.raw[40:])) | |
| 49 | + | } | |
| 50 | + | ||
| 51 | + | // GetGeometryReply is a zero-copy view over a GetGeometry reply; offsets count from reply byte 0. | |
| 52 | + | // It borrows the reply bytes: valid only until the Handler callback returns, because the read ring is reused. Copy what you keep. | |
| 53 | + | type GetGeometryReply struct{ raw []byte } | |
| 54 | + | ||
| 55 | + | // ParseGetGeometryReply validates raw (the whole reply, 32+4*length bytes) once; getters do not re-check. | |
| 56 | + | func ParseGetGeometryReply(raw []byte) (GetGeometryReply, bool) { | |
| 57 | + | if len(raw) < 32 { | |
| 58 | + | return GetGeometryReply{}, false | |
| 59 | + | } | |
| 60 | + | r := GetGeometryReply{raw: raw} | |
| 61 | + | return r, true | |
| 62 | + | } | |
| 63 | + | func (r GetGeometryReply) Raw() []byte { return r.raw } | |
| 64 | + | func (r GetGeometryReply) Depth() uint8 { return uint8(r.raw[1:][0]) } | |
| 65 | + | func (r GetGeometryReply) Root() Window { return Window(binary.LittleEndian.Uint32(r.raw[8:])) } | |
| 66 | + | func (r GetGeometryReply) X() int16 { return int16(binary.LittleEndian.Uint16(r.raw[12:])) } | |
| 67 | + | func (r GetGeometryReply) Y() int16 { return int16(binary.LittleEndian.Uint16(r.raw[14:])) } | |
| 68 | + | func (r GetGeometryReply) Width() uint16 { return uint16(binary.LittleEndian.Uint16(r.raw[16:])) } | |
| 69 | + | func (r GetGeometryReply) Height() uint16 { return uint16(binary.LittleEndian.Uint16(r.raw[18:])) } | |
| 70 | + | func (r GetGeometryReply) BorderWidth() uint16 { return uint16(binary.LittleEndian.Uint16(r.raw[20:])) } | |
| 71 | + | ||
| 72 | + | // QueryTreeReply is a zero-copy view over a QueryTree reply; offsets count from reply byte 0. | |
| 73 | + | // It borrows the reply bytes: valid only until the Handler callback returns, because the read ring is reused. Copy what you keep. | |
| 74 | + | type QueryTreeReply struct{ raw []byte } | |
| 75 | + | ||
| 76 | + | // ParseQueryTreeReply validates raw (the whole reply, 32+4*length bytes) once; getters do not re-check. | |
| 77 | + | func ParseQueryTreeReply(raw []byte) (QueryTreeReply, bool) { | |
| 78 | + | if len(raw) < 32 { | |
| 79 | + | return QueryTreeReply{}, false | |
| 80 | + | } | |
| 81 | + | r := QueryTreeReply{raw: raw} | |
| 82 | + | off := 32 | |
| 83 | + | { | |
| 84 | + | n := int(r.ChildrenLen()) | |
| 85 | + | if n < 0 || n > len(r.raw) { | |
| 86 | + | return QueryTreeReply{}, false | |
| 87 | + | } | |
| 88 | + | off += n * 4 | |
| 89 | + | } | |
| 90 | + | if off > len(r.raw) { | |
| 91 | + | return QueryTreeReply{}, false | |
| 92 | + | } | |
| 93 | + | if off > len(r.raw) { | |
| 94 | + | return QueryTreeReply{}, false | |
| 95 | + | } | |
| 96 | + | return r, true | |
| 97 | + | } | |
| 98 | + | func (r QueryTreeReply) Raw() []byte { return r.raw } | |
| 99 | + | func (r QueryTreeReply) Root() Window { return Window(binary.LittleEndian.Uint32(r.raw[8:])) } | |
| 100 | + | func (r QueryTreeReply) Parent() Window { return Window(binary.LittleEndian.Uint32(r.raw[12:])) } | |
| 101 | + | func (r QueryTreeReply) ChildrenLen() uint16 { return uint16(binary.LittleEndian.Uint16(r.raw[16:])) } | |
| 102 | + | func (r QueryTreeReply) Children() WindowList { | |
| 103 | + | off := 32 | |
| 104 | + | end := off + (int(r.ChildrenLen()))*4 | |
| 105 | + | return WindowList{b: r.raw[off:end:end]} | |
| 106 | + | } | |
| 107 | + | ||
| 108 | + | // InternAtomReply is a zero-copy view over a InternAtom reply; offsets count from reply byte 0. | |
| 109 | + | // It borrows the reply bytes: valid only until the Handler callback returns, because the read ring is reused. Copy what you keep. | |
| 110 | + | type InternAtomReply struct{ raw []byte } | |
| 111 | + | ||
| 112 | + | // ParseInternAtomReply validates raw (the whole reply, 32+4*length bytes) once; getters do not re-check. | |
| 113 | + | func ParseInternAtomReply(raw []byte) (InternAtomReply, bool) { | |
| 114 | + | if len(raw) < 32 { | |
| 115 | + | return InternAtomReply{}, false | |
| 116 | + | } | |
| 117 | + | r := InternAtomReply{raw: raw} | |
| 118 | + | return r, true | |
| 119 | + | } | |
| 120 | + | func (r InternAtomReply) Raw() []byte { return r.raw } | |
| 121 | + | func (r InternAtomReply) Atom() Atom { return Atom(binary.LittleEndian.Uint32(r.raw[8:])) } | |
| 122 | + | ||
| 123 | + | // GetAtomNameReply is a zero-copy view over a GetAtomName reply; offsets count from reply byte 0. | |
| 124 | + | // It borrows the reply bytes: valid only until the Handler callback returns, because the read ring is reused. Copy what you keep. | |
| 125 | + | type GetAtomNameReply struct{ raw []byte } | |
| 126 | + | ||
| 127 | + | // ParseGetAtomNameReply validates raw (the whole reply, 32+4*length bytes) once; getters do not re-check. | |
| 128 | + | func ParseGetAtomNameReply(raw []byte) (GetAtomNameReply, bool) { | |
| 129 | + | if len(raw) < 32 { | |
| 130 | + | return GetAtomNameReply{}, false | |
| 131 | + | } | |
| 132 | + | r := GetAtomNameReply{raw: raw} | |
| 133 | + | off := 32 | |
| 134 | + | { | |
| 135 | + | n := int(r.NameLen()) | |
| 136 | + | if n < 0 || n > len(r.raw) { | |
| 137 | + | return GetAtomNameReply{}, false | |
| 138 | + | } | |
| 139 | + | off += n * 1 | |
| 140 | + | } | |
| 141 | + | if off > len(r.raw) { | |
| 142 | + | return GetAtomNameReply{}, false | |
| 143 | + | } | |
| 144 | + | if off > len(r.raw) { | |
| 145 | + | return GetAtomNameReply{}, false | |
| 146 | + | } | |
| 147 | + | return r, true | |
| 148 | + | } | |
| 149 | + | func (r GetAtomNameReply) Raw() []byte { return r.raw } | |
| 150 | + | func (r GetAtomNameReply) NameLen() uint16 { return uint16(binary.LittleEndian.Uint16(r.raw[8:])) } | |
| 151 | + | func (r GetAtomNameReply) Name() []byte { | |
| 152 | + | off := 32 | |
| 153 | + | end := off + int(r.NameLen()) | |
| 154 | + | return r.raw[off:end:end] | |
| 155 | + | } | |
| 156 | + | ||
| 157 | + | // GetPropertyReply is a zero-copy view over a GetProperty reply; offsets count from reply byte 0. | |
| 158 | + | // It borrows the reply bytes: valid only until the Handler callback returns, because the read ring is reused. Copy what you keep. | |
| 159 | + | type GetPropertyReply struct{ raw []byte } | |
| 160 | + | ||
| 161 | + | // ParseGetPropertyReply validates raw (the whole reply, 32+4*length bytes) once; getters do not re-check. | |
| 162 | + | func ParseGetPropertyReply(raw []byte) (GetPropertyReply, bool) { | |
| 163 | + | if len(raw) < 32 { | |
| 164 | + | return GetPropertyReply{}, false | |
| 165 | + | } | |
| 166 | + | r := GetPropertyReply{raw: raw} | |
| 167 | + | off := 32 | |
| 168 | + | { | |
| 169 | + | n := (int(r.ValueLen()) * (int(r.Format()) / 8)) | |
| 170 | + | if n < 0 || n > len(r.raw) { | |
| 171 | + | return GetPropertyReply{}, false | |
| 172 | + | } | |
| 173 | + | off += n * 1 | |
| 174 | + | } | |
| 175 | + | if off > len(r.raw) { | |
| 176 | + | return GetPropertyReply{}, false | |
| 177 | + | } | |
| 178 | + | if off > len(r.raw) { | |
| 179 | + | return GetPropertyReply{}, false | |
| 180 | + | } | |
| 181 | + | return r, true | |
| 182 | + | } | |
| 183 | + | func (r GetPropertyReply) Raw() []byte { return r.raw } | |
| 184 | + | func (r GetPropertyReply) Format() uint8 { return uint8(r.raw[1:][0]) } | |
| 185 | + | func (r GetPropertyReply) Type() Atom { return Atom(binary.LittleEndian.Uint32(r.raw[8:])) } | |
| 186 | + | func (r GetPropertyReply) BytesAfter() uint32 { return uint32(binary.LittleEndian.Uint32(r.raw[12:])) } | |
| 187 | + | func (r GetPropertyReply) ValueLen() uint32 { return uint32(binary.LittleEndian.Uint32(r.raw[16:])) } | |
| 188 | + | func (r GetPropertyReply) Value() []byte { | |
| 189 | + | off := 32 | |
| 190 | + | end := off + (int(r.ValueLen()) * (int(r.Format()) / 8)) | |
| 191 | + | return r.raw[off:end:end] | |
| 192 | + | } | |
| 193 | + | ||
| 194 | + | // ListPropertiesReply is a zero-copy view over a ListProperties reply; offsets count from reply byte 0. | |
| 195 | + | // It borrows the reply bytes: valid only until the Handler callback returns, because the read ring is reused. Copy what you keep. | |
| 196 | + | type ListPropertiesReply struct{ raw []byte } | |
| 197 | + | ||
| 198 | + | // ParseListPropertiesReply validates raw (the whole reply, 32+4*length bytes) once; getters do not re-check. | |
| 199 | + | func ParseListPropertiesReply(raw []byte) (ListPropertiesReply, bool) { | |
| 200 | + | if len(raw) < 32 { | |
| 201 | + | return ListPropertiesReply{}, false | |
| 202 | + | } | |
| 203 | + | r := ListPropertiesReply{raw: raw} | |
| 204 | + | off := 32 | |
| 205 | + | { | |
| 206 | + | n := int(r.AtomsLen()) | |
| 207 | + | if n < 0 || n > len(r.raw) { | |
| 208 | + | return ListPropertiesReply{}, false | |
| 209 | + | } | |
| 210 | + | off += n * 4 | |
| 211 | + | } | |
| 212 | + | if off > len(r.raw) { | |
| 213 | + | return ListPropertiesReply{}, false | |
| 214 | + | } | |
| 215 | + | if off > len(r.raw) { | |
| 216 | + | return ListPropertiesReply{}, false | |
| 217 | + | } | |
| 218 | + | return r, true | |
| 219 | + | } | |
| 220 | + | func (r ListPropertiesReply) Raw() []byte { return r.raw } | |
| 221 | + | func (r ListPropertiesReply) AtomsLen() uint16 { return uint16(binary.LittleEndian.Uint16(r.raw[8:])) } | |
| 222 | + | func (r ListPropertiesReply) Atoms() AtomList { | |
| 223 | + | off := 32 | |
| 224 | + | end := off + (int(r.AtomsLen()))*4 | |
| 225 | + | return AtomList{b: r.raw[off:end:end]} | |
| 226 | + | } | |
| 227 | + | ||
| 228 | + | // GetSelectionOwnerReply is a zero-copy view over a GetSelectionOwner reply; offsets count from reply byte 0. | |
| 229 | + | // It borrows the reply bytes: valid only until the Handler callback returns, because the read ring is reused. Copy what you keep. | |
| 230 | + | type GetSelectionOwnerReply struct{ raw []byte } | |
| 231 | + | ||
| 232 | + | // ParseGetSelectionOwnerReply validates raw (the whole reply, 32+4*length bytes) once; getters do not re-check. | |
| 233 | + | func ParseGetSelectionOwnerReply(raw []byte) (GetSelectionOwnerReply, bool) { | |
| 234 | + | if len(raw) < 32 { | |
| 235 | + | return GetSelectionOwnerReply{}, false | |
| 236 | + | } | |
| 237 | + | r := GetSelectionOwnerReply{raw: raw} | |
| 238 | + | return r, true | |
| 239 | + | } | |
| 240 | + | func (r GetSelectionOwnerReply) Raw() []byte { return r.raw } | |
| 241 | + | func (r GetSelectionOwnerReply) Owner() Window { return Window(binary.LittleEndian.Uint32(r.raw[8:])) } | |
| 242 | + | ||
| 243 | + | // GrabPointerReply is a zero-copy view over a GrabPointer reply; offsets count from reply byte 0. | |
| 244 | + | // It borrows the reply bytes: valid only until the Handler callback returns, because the read ring is reused. Copy what you keep. | |
| 245 | + | type GrabPointerReply struct{ raw []byte } | |
| 246 | + | ||
| 247 | + | // ParseGrabPointerReply validates raw (the whole reply, 32+4*length bytes) once; getters do not re-check. | |
| 248 | + | func ParseGrabPointerReply(raw []byte) (GrabPointerReply, bool) { | |
| 249 | + | if len(raw) < 32 { | |
| 250 | + | return GrabPointerReply{}, false | |
| 251 | + | } | |
| 252 | + | r := GrabPointerReply{raw: raw} | |
| 253 | + | return r, true | |
| 254 | + | } | |
| 255 | + | func (r GrabPointerReply) Raw() []byte { return r.raw } | |
| 256 | + | func (r GrabPointerReply) Status() GrabStatus { return GrabStatus(r.raw[1:][0]) } | |
| 257 | + | ||
| 258 | + | // GrabKeyboardReply is a zero-copy view over a GrabKeyboard reply; offsets count from reply byte 0. | |
| 259 | + | // It borrows the reply bytes: valid only until the Handler callback returns, because the read ring is reused. Copy what you keep. | |
| 260 | + | type GrabKeyboardReply struct{ raw []byte } | |
| 261 | + | ||
| 262 | + | // ParseGrabKeyboardReply validates raw (the whole reply, 32+4*length bytes) once; getters do not re-check. | |
| 263 | + | func ParseGrabKeyboardReply(raw []byte) (GrabKeyboardReply, bool) { | |
| 264 | + | if len(raw) < 32 { | |
| 265 | + | return GrabKeyboardReply{}, false | |
| 266 | + | } | |
| 267 | + | r := GrabKeyboardReply{raw: raw} | |
| 268 | + | return r, true | |
| 269 | + | } | |
| 270 | + | func (r GrabKeyboardReply) Raw() []byte { return r.raw } | |
| 271 | + | func (r GrabKeyboardReply) Status() GrabStatus { return GrabStatus(r.raw[1:][0]) } | |
| 272 | + | ||
| 273 | + | // QueryPointerReply is a zero-copy view over a QueryPointer reply; offsets count from reply byte 0. | |
| 274 | + | // It borrows the reply bytes: valid only until the Handler callback returns, because the read ring is reused. Copy what you keep. | |
| 275 | + | type QueryPointerReply struct{ raw []byte } | |
| 276 | + | ||
| 277 | + | // ParseQueryPointerReply validates raw (the whole reply, 32+4*length bytes) once; getters do not re-check. | |
| 278 | + | func ParseQueryPointerReply(raw []byte) (QueryPointerReply, bool) { | |
| 279 | + | if len(raw) < 32 { | |
| 280 | + | return QueryPointerReply{}, false | |
| 281 | + | } | |
| 282 | + | r := QueryPointerReply{raw: raw} | |
| 283 | + | return r, true | |
| 284 | + | } | |
| 285 | + | func (r QueryPointerReply) Raw() []byte { return r.raw } | |
| 286 | + | func (r QueryPointerReply) SameScreen() bool { return (r.raw[1:][0] != 0) } | |
| 287 | + | func (r QueryPointerReply) Root() Window { return Window(binary.LittleEndian.Uint32(r.raw[8:])) } | |
| 288 | + | func (r QueryPointerReply) Child() Window { return Window(binary.LittleEndian.Uint32(r.raw[12:])) } | |
| 289 | + | func (r QueryPointerReply) RootX() int16 { return int16(binary.LittleEndian.Uint16(r.raw[16:])) } | |
| 290 | + | func (r QueryPointerReply) RootY() int16 { return int16(binary.LittleEndian.Uint16(r.raw[18:])) } | |
| 291 | + | func (r QueryPointerReply) WinX() int16 { return int16(binary.LittleEndian.Uint16(r.raw[20:])) } | |
| 292 | + | func (r QueryPointerReply) WinY() int16 { return int16(binary.LittleEndian.Uint16(r.raw[22:])) } | |
| 293 | + | func (r QueryPointerReply) Mask() KeyButMask { | |
| 294 | + | return KeyButMask(binary.LittleEndian.Uint16(r.raw[24:])) | |
| 295 | + | } | |
| 296 | + | ||
| 297 | + | // GetMotionEventsReply is a zero-copy view over a GetMotionEvents reply; offsets count from reply byte 0. | |
| 298 | + | // It borrows the reply bytes: valid only until the Handler callback returns, because the read ring is reused. Copy what you keep. | |
| 299 | + | type GetMotionEventsReply struct{ raw []byte } | |
| 300 | + | ||
| 301 | + | // ParseGetMotionEventsReply validates raw (the whole reply, 32+4*length bytes) once; getters do not re-check. | |
| 302 | + | func ParseGetMotionEventsReply(raw []byte) (GetMotionEventsReply, bool) { | |
| 303 | + | if len(raw) < 32 { | |
| 304 | + | return GetMotionEventsReply{}, false | |
| 305 | + | } | |
| 306 | + | r := GetMotionEventsReply{raw: raw} | |
| 307 | + | off := 32 | |
| 308 | + | { | |
| 309 | + | n := int(r.EventsLen()) | |
| 310 | + | if n < 0 || n > len(r.raw) { | |
| 311 | + | return GetMotionEventsReply{}, false | |
| 312 | + | } | |
| 313 | + | off += n * 8 | |
| 314 | + | } | |
| 315 | + | if off > len(r.raw) { | |
| 316 | + | return GetMotionEventsReply{}, false | |
| 317 | + | } | |
| 318 | + | if off > len(r.raw) { | |
| 319 | + | return GetMotionEventsReply{}, false | |
| 320 | + | } | |
| 321 | + | return r, true | |
| 322 | + | } | |
| 323 | + | func (r GetMotionEventsReply) Raw() []byte { return r.raw } | |
| 324 | + | func (r GetMotionEventsReply) EventsLen() uint32 { | |
| 325 | + | return uint32(binary.LittleEndian.Uint32(r.raw[8:])) | |
| 326 | + | } | |
| 327 | + | func (r GetMotionEventsReply) Events() TimecoordList { | |
| 328 | + | off := 32 | |
| 329 | + | end := off + (int(r.EventsLen()))*8 | |
| 330 | + | return TimecoordList{b: r.raw[off:end:end]} | |
| 331 | + | } | |
| 332 | + | ||
| 333 | + | // TranslateCoordinatesReply is a zero-copy view over a TranslateCoordinates reply; offsets count from reply byte 0. | |
| 334 | + | // It borrows the reply bytes: valid only until the Handler callback returns, because the read ring is reused. Copy what you keep. | |
| 335 | + | type TranslateCoordinatesReply struct{ raw []byte } | |
| 336 | + | ||
| 337 | + | // ParseTranslateCoordinatesReply validates raw (the whole reply, 32+4*length bytes) once; getters do not re-check. | |
| 338 | + | func ParseTranslateCoordinatesReply(raw []byte) (TranslateCoordinatesReply, bool) { | |
| 339 | + | if len(raw) < 32 { | |
| 340 | + | return TranslateCoordinatesReply{}, false | |
| 341 | + | } | |
| 342 | + | r := TranslateCoordinatesReply{raw: raw} | |
| 343 | + | return r, true | |
| 344 | + | } | |
| 345 | + | func (r TranslateCoordinatesReply) Raw() []byte { return r.raw } | |
| 346 | + | func (r TranslateCoordinatesReply) SameScreen() bool { return (r.raw[1:][0] != 0) } | |
| 347 | + | func (r TranslateCoordinatesReply) Child() Window { | |
| 348 | + | return Window(binary.LittleEndian.Uint32(r.raw[8:])) | |
| 349 | + | } | |
| 350 | + | func (r TranslateCoordinatesReply) DstX() int16 { return int16(binary.LittleEndian.Uint16(r.raw[12:])) } | |
| 351 | + | func (r TranslateCoordinatesReply) DstY() int16 { return int16(binary.LittleEndian.Uint16(r.raw[14:])) } | |
| 352 | + | ||
| 353 | + | // GetInputFocusReply is a zero-copy view over a GetInputFocus reply; offsets count from reply byte 0. | |
| 354 | + | // It borrows the reply bytes: valid only until the Handler callback returns, because the read ring is reused. Copy what you keep. | |
| 355 | + | type GetInputFocusReply struct{ raw []byte } | |
| 356 | + | ||
| 357 | + | // ParseGetInputFocusReply validates raw (the whole reply, 32+4*length bytes) once; getters do not re-check. | |
| 358 | + | func ParseGetInputFocusReply(raw []byte) (GetInputFocusReply, bool) { | |
| 359 | + | if len(raw) < 32 { | |
| 360 | + | return GetInputFocusReply{}, false | |
| 361 | + | } | |
| 362 | + | r := GetInputFocusReply{raw: raw} | |
| 363 | + | return r, true | |
| 364 | + | } | |
| 365 | + | func (r GetInputFocusReply) Raw() []byte { return r.raw } | |
| 366 | + | func (r GetInputFocusReply) RevertTo() InputFocus { return InputFocus(r.raw[1:][0]) } | |
| 367 | + | func (r GetInputFocusReply) Focus() Window { return Window(binary.LittleEndian.Uint32(r.raw[8:])) } | |
| 368 | + | ||
| 369 | + | // QueryKeymapReply is a zero-copy view over a QueryKeymap reply; offsets count from reply byte 0. | |
| 370 | + | // It borrows the reply bytes: valid only until the Handler callback returns, because the read ring is reused. Copy what you keep. | |
| 371 | + | type QueryKeymapReply struct{ raw []byte } | |
| 372 | + | ||
| 373 | + | // ParseQueryKeymapReply validates raw (the whole reply, 32+4*length bytes) once; getters do not re-check. | |
| 374 | + | func ParseQueryKeymapReply(raw []byte) (QueryKeymapReply, bool) { | |
| 375 | + | if len(raw) < 40 { | |
| 376 | + | return QueryKeymapReply{}, false | |
| 377 | + | } | |
| 378 | + | r := QueryKeymapReply{raw: raw} | |
| 379 | + | return r, true | |
| 380 | + | } | |
| 381 | + | func (r QueryKeymapReply) Raw() []byte { return r.raw } | |
| 382 | + | func (r QueryKeymapReply) Keys() []byte { off := 8; end := off + 32; return r.raw[off:end:end] } | |
| 383 | + | ||
| 384 | + | // QueryFontReply is a zero-copy view over a QueryFont reply; offsets count from reply byte 0. | |
| 385 | + | // It borrows the reply bytes: valid only until the Handler callback returns, because the read ring is reused. Copy what you keep. | |
| 386 | + | type QueryFontReply struct{ raw []byte } | |
| 387 | + | ||
| 388 | + | // ParseQueryFontReply validates raw (the whole reply, 32+4*length bytes) once; getters do not re-check. | |
| 389 | + | func ParseQueryFontReply(raw []byte) (QueryFontReply, bool) { | |
| 390 | + | if len(raw) < 60 { | |
| 391 | + | return QueryFontReply{}, false | |
| 392 | + | } | |
| 393 | + | r := QueryFontReply{raw: raw} | |
| 394 | + | off := 60 | |
| 395 | + | { | |
| 396 | + | n := int(r.PropertiesLen()) | |
| 397 | + | if n < 0 || n > len(r.raw) { | |
| 398 | + | return QueryFontReply{}, false | |
| 399 | + | } | |
| 400 | + | off += n * 8 | |
| 401 | + | } | |
| 402 | + | if off > len(r.raw) { | |
| 403 | + | return QueryFontReply{}, false | |
| 404 | + | } | |
| 405 | + | { | |
| 406 | + | n := int(r.CharInfosLen()) | |
| 407 | + | if n < 0 || n > len(r.raw) { | |
| 408 | + | return QueryFontReply{}, false | |
| 409 | + | } | |
| 410 | + | off += n * 12 | |
| 411 | + | } | |
| 412 | + | if off > len(r.raw) { | |
| 413 | + | return QueryFontReply{}, false | |
| 414 | + | } | |
| 415 | + | if off > len(r.raw) { | |
| 416 | + | return QueryFontReply{}, false | |
| 417 | + | } | |
| 418 | + | return r, true | |
| 419 | + | } | |
| 420 | + | func (r QueryFontReply) Raw() []byte { return r.raw } | |
| 421 | + | func (r QueryFontReply) MinBounds() Charinfo { return GetCharinfo(r.raw[8:]) } | |
| 422 | + | func (r QueryFontReply) MaxBounds() Charinfo { return GetCharinfo(r.raw[24:]) } | |
| 423 | + | func (r QueryFontReply) MinCharOrByte2() uint16 { | |
| 424 | + | return uint16(binary.LittleEndian.Uint16(r.raw[40:])) | |
| 425 | + | } | |
| 426 | + | func (r QueryFontReply) MaxCharOrByte2() uint16 { | |
| 427 | + | return uint16(binary.LittleEndian.Uint16(r.raw[42:])) | |
| 428 | + | } | |
| 429 | + | func (r QueryFontReply) DefaultChar() uint16 { return uint16(binary.LittleEndian.Uint16(r.raw[44:])) } | |
| 430 | + | func (r QueryFontReply) PropertiesLen() uint16 { return uint16(binary.LittleEndian.Uint16(r.raw[46:])) } | |
| 431 | + | func (r QueryFontReply) DrawDirection() FontDraw { return FontDraw(r.raw[48:][0]) } | |
| 432 | + | func (r QueryFontReply) MinByte1() uint8 { return uint8(r.raw[49:][0]) } | |
| 433 | + | func (r QueryFontReply) MaxByte1() uint8 { return uint8(r.raw[50:][0]) } | |
| 434 | + | func (r QueryFontReply) AllCharsExist() bool { return (r.raw[51:][0] != 0) } | |
| 435 | + | func (r QueryFontReply) FontAscent() int16 { return int16(binary.LittleEndian.Uint16(r.raw[52:])) } | |
| 436 | + | func (r QueryFontReply) FontDescent() int16 { return int16(binary.LittleEndian.Uint16(r.raw[54:])) } | |
| 437 | + | func (r QueryFontReply) CharInfosLen() uint32 { return uint32(binary.LittleEndian.Uint32(r.raw[56:])) } | |
| 438 | + | func (r QueryFontReply) Properties() FontpropList { | |
| 439 | + | off := 60 | |
| 440 | + | end := off + (int(r.PropertiesLen()))*8 | |
| 441 | + | return FontpropList{b: r.raw[off:end:end]} | |
| 442 | + | } | |
| 443 | + | func (r QueryFontReply) CharInfos() CharinfoList { | |
| 444 | + | off := 60 | |
| 445 | + | { | |
| 446 | + | n := int(r.PropertiesLen()) | |
| 447 | + | off += n * 8 | |
| 448 | + | } | |
| 449 | + | end := off + (int(r.CharInfosLen()))*12 | |
| 450 | + | return CharinfoList{b: r.raw[off:end:end]} | |
| 451 | + | } | |
| 452 | + | ||
| 453 | + | // QueryTextExtentsReply is a zero-copy view over a QueryTextExtents reply; offsets count from reply byte 0. | |
| 454 | + | // It borrows the reply bytes: valid only until the Handler callback returns, because the read ring is reused. Copy what you keep. | |
| 455 | + | type QueryTextExtentsReply struct{ raw []byte } | |
| 456 | + | ||
| 457 | + | // ParseQueryTextExtentsReply validates raw (the whole reply, 32+4*length bytes) once; getters do not re-check. | |
| 458 | + | func ParseQueryTextExtentsReply(raw []byte) (QueryTextExtentsReply, bool) { | |
| 459 | + | if len(raw) < 32 { | |
| 460 | + | return QueryTextExtentsReply{}, false | |
| 461 | + | } | |
| 462 | + | r := QueryTextExtentsReply{raw: raw} | |
| 463 | + | return r, true | |
| 464 | + | } | |
| 465 | + | func (r QueryTextExtentsReply) Raw() []byte { return r.raw } | |
| 466 | + | func (r QueryTextExtentsReply) DrawDirection() FontDraw { return FontDraw(r.raw[1:][0]) } | |
| 467 | + | func (r QueryTextExtentsReply) FontAscent() int16 { | |
| 468 | + | return int16(binary.LittleEndian.Uint16(r.raw[8:])) | |
| 469 | + | } | |
| 470 | + | func (r QueryTextExtentsReply) FontDescent() int16 { | |
| 471 | + | return int16(binary.LittleEndian.Uint16(r.raw[10:])) | |
| 472 | + | } | |
| 473 | + | func (r QueryTextExtentsReply) OverallAscent() int16 { | |
| 474 | + | return int16(binary.LittleEndian.Uint16(r.raw[12:])) | |
| 475 | + | } | |
| 476 | + | func (r QueryTextExtentsReply) OverallDescent() int16 { | |
| 477 | + | return int16(binary.LittleEndian.Uint16(r.raw[14:])) | |
| 478 | + | } | |
| 479 | + | func (r QueryTextExtentsReply) OverallWidth() int32 { | |
| 480 | + | return int32(binary.LittleEndian.Uint32(r.raw[16:])) | |
| 481 | + | } | |
| 482 | + | func (r QueryTextExtentsReply) OverallLeft() int32 { | |
| 483 | + | return int32(binary.LittleEndian.Uint32(r.raw[20:])) | |
| 484 | + | } | |
| 485 | + | func (r QueryTextExtentsReply) OverallRight() int32 { | |
| 486 | + | return int32(binary.LittleEndian.Uint32(r.raw[24:])) | |
| 487 | + | } | |
| 488 | + | ||
| 489 | + | // ListFontsReply is a zero-copy view over a ListFonts reply; offsets count from reply byte 0. | |
| 490 | + | // It borrows the reply bytes: valid only until the Handler callback returns, because the read ring is reused. Copy what you keep. | |
| 491 | + | type ListFontsReply struct{ raw []byte } | |
| 492 | + | ||
| 493 | + | // ParseListFontsReply validates raw (the whole reply, 32+4*length bytes) once; getters do not re-check. | |
| 494 | + | func ParseListFontsReply(raw []byte) (ListFontsReply, bool) { | |
| 495 | + | if len(raw) < 32 { | |
| 496 | + | return ListFontsReply{}, false | |
| 497 | + | } | |
| 498 | + | r := ListFontsReply{raw: raw} | |
| 499 | + | off := 32 | |
| 500 | + | { | |
| 501 | + | n := int(r.NamesLen()) | |
| 502 | + | if off > len(r.raw) || n < 0 || n > len(r.raw) { | |
| 503 | + | return ListFontsReply{}, false | |
| 504 | + | } | |
| 505 | + | it := NewStrIter(r.raw[off:], n) | |
| 506 | + | for it.Next() { | |
| 507 | + | off += it.Value().Size() | |
| 508 | + | } | |
| 509 | + | if it.Err() { | |
| 510 | + | return ListFontsReply{}, false | |
| 511 | + | } | |
| 512 | + | } | |
| 513 | + | if off > len(r.raw) { | |
| 514 | + | return ListFontsReply{}, false | |
| 515 | + | } | |
| 516 | + | return r, true | |
| 517 | + | } | |
| 518 | + | func (r ListFontsReply) Raw() []byte { return r.raw } | |
| 519 | + | func (r ListFontsReply) NamesLen() uint16 { return uint16(binary.LittleEndian.Uint16(r.raw[8:])) } | |
| 520 | + | func (r ListFontsReply) Names() StrIter { off := 32; return NewStrIter(r.raw[off:], int(r.NamesLen())) } | |
| 521 | + | ||
| 522 | + | // ListFontsWithInfoReply is a zero-copy view over a ListFontsWithInfo reply; offsets count from reply byte 0. | |
| 523 | + | // It borrows the reply bytes: valid only until the Handler callback returns, because the read ring is reused. Copy what you keep. | |
| 524 | + | type ListFontsWithInfoReply struct{ raw []byte } | |
| 525 | + | ||
| 526 | + | // ParseListFontsWithInfoReply validates raw (the whole reply, 32+4*length bytes) once; getters do not re-check. | |
| 527 | + | func ParseListFontsWithInfoReply(raw []byte) (ListFontsWithInfoReply, bool) { | |
| 528 | + | if len(raw) < 60 { | |
| 529 | + | return ListFontsWithInfoReply{}, false | |
| 530 | + | } | |
| 531 | + | r := ListFontsWithInfoReply{raw: raw} | |
| 532 | + | off := 60 | |
| 533 | + | { | |
| 534 | + | n := int(r.PropertiesLen()) | |
| 535 | + | if n < 0 || n > len(r.raw) { | |
| 536 | + | return ListFontsWithInfoReply{}, false | |
| 537 | + | } | |
| 538 | + | off += n * 8 | |
| 539 | + | } | |
| 540 | + | if off > len(r.raw) { | |
| 541 | + | return ListFontsWithInfoReply{}, false | |
| 542 | + | } | |
| 543 | + | { | |
| 544 | + | n := int(r.NameLen()) | |
| 545 | + | if n < 0 || n > len(r.raw) { | |
| 546 | + | return ListFontsWithInfoReply{}, false | |
| 547 | + | } | |
| 548 | + | off += n * 1 | |
| 549 | + | } | |
| 550 | + | if off > len(r.raw) { | |
| 551 | + | return ListFontsWithInfoReply{}, false | |
| 552 | + | } | |
| 553 | + | if off > len(r.raw) { | |
| 554 | + | return ListFontsWithInfoReply{}, false | |
| 555 | + | } | |
| 556 | + | return r, true | |
| 557 | + | } | |
| 558 | + | func (r ListFontsWithInfoReply) Raw() []byte { return r.raw } | |
| 559 | + | func (r ListFontsWithInfoReply) NameLen() uint8 { return uint8(r.raw[1:][0]) } | |
| 560 | + | func (r ListFontsWithInfoReply) MinBounds() Charinfo { return GetCharinfo(r.raw[8:]) } | |
| 561 | + | func (r ListFontsWithInfoReply) MaxBounds() Charinfo { return GetCharinfo(r.raw[24:]) } | |
| 562 | + | func (r ListFontsWithInfoReply) MinCharOrByte2() uint16 { | |
| 563 | + | return uint16(binary.LittleEndian.Uint16(r.raw[40:])) | |
| 564 | + | } | |
| 565 | + | func (r ListFontsWithInfoReply) MaxCharOrByte2() uint16 { | |
| 566 | + | return uint16(binary.LittleEndian.Uint16(r.raw[42:])) | |
| 567 | + | } | |
| 568 | + | func (r ListFontsWithInfoReply) DefaultChar() uint16 { | |
| 569 | + | return uint16(binary.LittleEndian.Uint16(r.raw[44:])) | |
| 570 | + | } | |
| 571 | + | func (r ListFontsWithInfoReply) PropertiesLen() uint16 { | |
| 572 | + | return uint16(binary.LittleEndian.Uint16(r.raw[46:])) | |
| 573 | + | } | |
| 574 | + | func (r ListFontsWithInfoReply) DrawDirection() FontDraw { return FontDraw(r.raw[48:][0]) } | |
| 575 | + | func (r ListFontsWithInfoReply) MinByte1() uint8 { return uint8(r.raw[49:][0]) } | |
| 576 | + | func (r ListFontsWithInfoReply) MaxByte1() uint8 { return uint8(r.raw[50:][0]) } | |
| 577 | + | func (r ListFontsWithInfoReply) AllCharsExist() bool { return (r.raw[51:][0] != 0) } | |
| 578 | + | func (r ListFontsWithInfoReply) FontAscent() int16 { | |
| 579 | + | return int16(binary.LittleEndian.Uint16(r.raw[52:])) | |
| 580 | + | } | |
| 581 | + | func (r ListFontsWithInfoReply) FontDescent() int16 { | |
| 582 | + | return int16(binary.LittleEndian.Uint16(r.raw[54:])) | |
| 583 | + | } | |
| 584 | + | func (r ListFontsWithInfoReply) RepliesHint() uint32 { | |
| 585 | + | return uint32(binary.LittleEndian.Uint32(r.raw[56:])) | |
| 586 | + | } | |
| 587 | + | func (r ListFontsWithInfoReply) Properties() FontpropList { | |
| 588 | + | off := 60 | |
| 589 | + | end := off + (int(r.PropertiesLen()))*8 | |
| 590 | + | return FontpropList{b: r.raw[off:end:end]} | |
| 591 | + | } | |
| 592 | + | func (r ListFontsWithInfoReply) Name() []byte { | |
| 593 | + | off := 60 | |
| 594 | + | { | |
| 595 | + | n := int(r.PropertiesLen()) | |
| 596 | + | off += n * 8 | |
| 597 | + | } | |
| 598 | + | end := off + int(r.NameLen()) | |
| 599 | + | return r.raw[off:end:end] | |
| 600 | + | } | |
| 601 | + | ||
| 602 | + | // GetFontPathReply is a zero-copy view over a GetFontPath reply; offsets count from reply byte 0. | |
| 603 | + | // It borrows the reply bytes: valid only until the Handler callback returns, because the read ring is reused. Copy what you keep. | |
| 604 | + | type GetFontPathReply struct{ raw []byte } | |
| 605 | + | ||
| 606 | + | // ParseGetFontPathReply validates raw (the whole reply, 32+4*length bytes) once; getters do not re-check. | |
| 607 | + | func ParseGetFontPathReply(raw []byte) (GetFontPathReply, bool) { | |
| 608 | + | if len(raw) < 32 { | |
| 609 | + | return GetFontPathReply{}, false | |
| 610 | + | } | |
| 611 | + | r := GetFontPathReply{raw: raw} | |
| 612 | + | off := 32 | |
| 613 | + | { | |
| 614 | + | n := int(r.PathLen()) | |
| 615 | + | if off > len(r.raw) || n < 0 || n > len(r.raw) { | |
| 616 | + | return GetFontPathReply{}, false | |
| 617 | + | } | |
| 618 | + | it := NewStrIter(r.raw[off:], n) | |
| 619 | + | for it.Next() { | |
| 620 | + | off += it.Value().Size() | |
| 621 | + | } | |
| 622 | + | if it.Err() { | |
| 623 | + | return GetFontPathReply{}, false | |
| 624 | + | } | |
| 625 | + | } | |
| 626 | + | if off > len(r.raw) { | |
| 627 | + | return GetFontPathReply{}, false | |
| 628 | + | } | |
| 629 | + | return r, true | |
| 630 | + | } | |
| 631 | + | func (r GetFontPathReply) Raw() []byte { return r.raw } | |
| 632 | + | func (r GetFontPathReply) PathLen() uint16 { return uint16(binary.LittleEndian.Uint16(r.raw[8:])) } | |
| 633 | + | func (r GetFontPathReply) Path() StrIter { off := 32; return NewStrIter(r.raw[off:], int(r.PathLen())) } | |
| 634 | + | ||
| 635 | + | // GetImageReply is a zero-copy view over a GetImage reply; offsets count from reply byte 0. | |
| 636 | + | // It borrows the reply bytes: valid only until the Handler callback returns, because the read ring is reused. Copy what you keep. | |
| 637 | + | type GetImageReply struct{ raw []byte } | |
| 638 | + | ||
| 639 | + | // ParseGetImageReply validates raw (the whole reply, 32+4*length bytes) once; getters do not re-check. | |
| 640 | + | func ParseGetImageReply(raw []byte) (GetImageReply, bool) { | |
| 641 | + | if len(raw) < 32 { | |
| 642 | + | return GetImageReply{}, false | |
| 643 | + | } | |
| 644 | + | r := GetImageReply{raw: raw} | |
| 645 | + | off := 32 | |
| 646 | + | { | |
| 647 | + | n := (int(binary.LittleEndian.Uint32(r.raw[4:])) * 4) | |
| 648 | + | if n < 0 || n > len(r.raw) { | |
| 649 | + | return GetImageReply{}, false | |
| 650 | + | } | |
| 651 | + | off += n * 1 | |
| 652 | + | } | |
| 653 | + | if off > len(r.raw) { | |
| 654 | + | return GetImageReply{}, false | |
| 655 | + | } | |
| 656 | + | if off > len(r.raw) { | |
| 657 | + | return GetImageReply{}, false | |
| 658 | + | } | |
| 659 | + | return r, true | |
| 660 | + | } | |
| 661 | + | func (r GetImageReply) Raw() []byte { return r.raw } | |
| 662 | + | func (r GetImageReply) Depth() uint8 { return uint8(r.raw[1:][0]) } | |
| 663 | + | func (r GetImageReply) Visual() Visualid { return Visualid(binary.LittleEndian.Uint32(r.raw[8:])) } | |
| 664 | + | func (r GetImageReply) Data() []byte { | |
| 665 | + | off := 32 | |
| 666 | + | end := off + (int(binary.LittleEndian.Uint32(r.raw[4:])) * 4) | |
| 667 | + | return r.raw[off:end:end] | |
| 668 | + | } | |
| 669 | + | ||
| 670 | + | // ListInstalledColormapsReply is a zero-copy view over a ListInstalledColormaps reply; offsets count from reply byte 0. | |
| 671 | + | // It borrows the reply bytes: valid only until the Handler callback returns, because the read ring is reused. Copy what you keep. | |
| 672 | + | type ListInstalledColormapsReply struct{ raw []byte } | |
| 673 | + | ||
| 674 | + | // ParseListInstalledColormapsReply validates raw (the whole reply, 32+4*length bytes) once; getters do not re-check. | |
| 675 | + | func ParseListInstalledColormapsReply(raw []byte) (ListInstalledColormapsReply, bool) { | |
| 676 | + | if len(raw) < 32 { | |
| 677 | + | return ListInstalledColormapsReply{}, false | |
| 678 | + | } | |
| 679 | + | r := ListInstalledColormapsReply{raw: raw} | |
| 680 | + | off := 32 | |
| 681 | + | { | |
| 682 | + | n := int(r.CmapsLen()) | |
| 683 | + | if n < 0 || n > len(r.raw) { | |
| 684 | + | return ListInstalledColormapsReply{}, false | |
| 685 | + | } | |
| 686 | + | off += n * 4 | |
| 687 | + | } | |
| 688 | + | if off > len(r.raw) { | |
| 689 | + | return ListInstalledColormapsReply{}, false | |
| 690 | + | } | |
| 691 | + | if off > len(r.raw) { | |
| 692 | + | return ListInstalledColormapsReply{}, false | |
| 693 | + | } | |
| 694 | + | return r, true | |
| 695 | + | } | |
| 696 | + | func (r ListInstalledColormapsReply) Raw() []byte { return r.raw } | |
| 697 | + | func (r ListInstalledColormapsReply) CmapsLen() uint16 { | |
| 698 | + | return uint16(binary.LittleEndian.Uint16(r.raw[8:])) | |
| 699 | + | } | |
| 700 | + | func (r ListInstalledColormapsReply) Cmaps() ColormapList { | |
| 701 | + | off := 32 | |
| 702 | + | end := off + (int(r.CmapsLen()))*4 | |
| 703 | + | return ColormapList{b: r.raw[off:end:end]} | |
| 704 | + | } | |
| 705 | + | ||
| 706 | + | // AllocColorReply is a zero-copy view over a AllocColor reply; offsets count from reply byte 0. | |
| 707 | + | // It borrows the reply bytes: valid only until the Handler callback returns, because the read ring is reused. Copy what you keep. | |
| 708 | + | type AllocColorReply struct{ raw []byte } | |
| 709 | + | ||
| 710 | + | // ParseAllocColorReply validates raw (the whole reply, 32+4*length bytes) once; getters do not re-check. | |
| 711 | + | func ParseAllocColorReply(raw []byte) (AllocColorReply, bool) { | |
| 712 | + | if len(raw) < 32 { | |
| 713 | + | return AllocColorReply{}, false | |
| 714 | + | } | |
| 715 | + | r := AllocColorReply{raw: raw} | |
| 716 | + | return r, true | |
| 717 | + | } | |
| 718 | + | func (r AllocColorReply) Raw() []byte { return r.raw } | |
| 719 | + | func (r AllocColorReply) Red() uint16 { return uint16(binary.LittleEndian.Uint16(r.raw[8:])) } | |
| 720 | + | func (r AllocColorReply) Green() uint16 { return uint16(binary.LittleEndian.Uint16(r.raw[10:])) } | |
| 721 | + | func (r AllocColorReply) Blue() uint16 { return uint16(binary.LittleEndian.Uint16(r.raw[12:])) } | |
| 722 | + | func (r AllocColorReply) Pixel() uint32 { return uint32(binary.LittleEndian.Uint32(r.raw[16:])) } | |
| 723 | + | ||
| 724 | + | // AllocNamedColorReply is a zero-copy view over a AllocNamedColor reply; offsets count from reply byte 0. | |
| 725 | + | // It borrows the reply bytes: valid only until the Handler callback returns, because the read ring is reused. Copy what you keep. | |
| 726 | + | type AllocNamedColorReply struct{ raw []byte } | |
| 727 | + | ||
| 728 | + | // ParseAllocNamedColorReply validates raw (the whole reply, 32+4*length bytes) once; getters do not re-check. | |
| 729 | + | func ParseAllocNamedColorReply(raw []byte) (AllocNamedColorReply, bool) { | |
| 730 | + | if len(raw) < 32 { | |
| 731 | + | return AllocNamedColorReply{}, false | |
| 732 | + | } | |
| 733 | + | r := AllocNamedColorReply{raw: raw} | |
| 734 | + | return r, true | |
| 735 | + | } | |
| 736 | + | func (r AllocNamedColorReply) Raw() []byte { return r.raw } | |
| 737 | + | func (r AllocNamedColorReply) Pixel() uint32 { return uint32(binary.LittleEndian.Uint32(r.raw[8:])) } | |
| 738 | + | func (r AllocNamedColorReply) ExactRed() uint16 { | |
| 739 | + | return uint16(binary.LittleEndian.Uint16(r.raw[12:])) | |
| 740 | + | } | |
| 741 | + | func (r AllocNamedColorReply) ExactGreen() uint16 { | |
| 742 | + | return uint16(binary.LittleEndian.Uint16(r.raw[14:])) | |
| 743 | + | } | |
| 744 | + | func (r AllocNamedColorReply) ExactBlue() uint16 { | |
| 745 | + | return uint16(binary.LittleEndian.Uint16(r.raw[16:])) | |
| 746 | + | } | |
| 747 | + | func (r AllocNamedColorReply) VisualRed() uint16 { | |
| 748 | + | return uint16(binary.LittleEndian.Uint16(r.raw[18:])) | |
| 749 | + | } | |
| 750 | + | func (r AllocNamedColorReply) VisualGreen() uint16 { | |
| 751 | + | return uint16(binary.LittleEndian.Uint16(r.raw[20:])) | |
| 752 | + | } | |
| 753 | + | func (r AllocNamedColorReply) VisualBlue() uint16 { | |
| 754 | + | return uint16(binary.LittleEndian.Uint16(r.raw[22:])) | |
| 755 | + | } | |
| 756 | + | ||
| 757 | + | // AllocColorCellsReply is a zero-copy view over a AllocColorCells reply; offsets count from reply byte 0. | |
| 758 | + | // It borrows the reply bytes: valid only until the Handler callback returns, because the read ring is reused. Copy what you keep. | |
| 759 | + | type AllocColorCellsReply struct{ raw []byte } | |
| 760 | + | ||
| 761 | + | // ParseAllocColorCellsReply validates raw (the whole reply, 32+4*length bytes) once; getters do not re-check. | |
| 762 | + | func ParseAllocColorCellsReply(raw []byte) (AllocColorCellsReply, bool) { | |
| 763 | + | if len(raw) < 32 { | |
| 764 | + | return AllocColorCellsReply{}, false | |
| 765 | + | } | |
| 766 | + | r := AllocColorCellsReply{raw: raw} | |
| 767 | + | off := 32 | |
| 768 | + | { | |
| 769 | + | n := int(r.PixelsLen()) | |
| 770 | + | if n < 0 || n > len(r.raw) { | |
| 771 | + | return AllocColorCellsReply{}, false | |
| 772 | + | } | |
| 773 | + | off += n * 4 | |
| 774 | + | } | |
| 775 | + | if off > len(r.raw) { | |
| 776 | + | return AllocColorCellsReply{}, false | |
| 777 | + | } | |
| 778 | + | { | |
| 779 | + | n := int(r.MasksLen()) | |
| 780 | + | if n < 0 || n > len(r.raw) { | |
| 781 | + | return AllocColorCellsReply{}, false | |
| 782 | + | } | |
| 783 | + | off += n * 4 | |
| 784 | + | } | |
| 785 | + | if off > len(r.raw) { | |
| 786 | + | return AllocColorCellsReply{}, false | |
| 787 | + | } | |
| 788 | + | if off > len(r.raw) { | |
| 789 | + | return AllocColorCellsReply{}, false | |
| 790 | + | } | |
| 791 | + | return r, true | |
| 792 | + | } | |
| 793 | + | func (r AllocColorCellsReply) Raw() []byte { return r.raw } | |
| 794 | + | func (r AllocColorCellsReply) PixelsLen() uint16 { | |
| 795 | + | return uint16(binary.LittleEndian.Uint16(r.raw[8:])) | |
| 796 | + | } | |
| 797 | + | func (r AllocColorCellsReply) MasksLen() uint16 { | |
| 798 | + | return uint16(binary.LittleEndian.Uint16(r.raw[10:])) | |
| 799 | + | } | |
| 800 | + | func (r AllocColorCellsReply) Pixels() Uint32List { | |
| 801 | + | off := 32 | |
| 802 | + | end := off + (int(r.PixelsLen()))*4 | |
| 803 | + | return Uint32List{b: r.raw[off:end:end]} | |
| 804 | + | } | |
| 805 | + | func (r AllocColorCellsReply) Masks() Uint32List { | |
| 806 | + | off := 32 | |
| 807 | + | { | |
| 808 | + | n := int(r.PixelsLen()) | |
| 809 | + | off += n * 4 | |
| 810 | + | } | |
| 811 | + | end := off + (int(r.MasksLen()))*4 | |
| 812 | + | return Uint32List{b: r.raw[off:end:end]} | |
| 813 | + | } | |
| 814 | + | ||
| 815 | + | // AllocColorPlanesReply is a zero-copy view over a AllocColorPlanes reply; offsets count from reply byte 0. | |
| 816 | + | // It borrows the reply bytes: valid only until the Handler callback returns, because the read ring is reused. Copy what you keep. | |
| 817 | + | type AllocColorPlanesReply struct{ raw []byte } | |
| 818 | + | ||
| 819 | + | // ParseAllocColorPlanesReply validates raw (the whole reply, 32+4*length bytes) once; getters do not re-check. | |
| 820 | + | func ParseAllocColorPlanesReply(raw []byte) (AllocColorPlanesReply, bool) { | |
| 821 | + | if len(raw) < 32 { | |
| 822 | + | return AllocColorPlanesReply{}, false | |
| 823 | + | } | |
| 824 | + | r := AllocColorPlanesReply{raw: raw} | |
| 825 | + | off := 32 | |
| 826 | + | { | |
| 827 | + | n := int(r.PixelsLen()) | |
| 828 | + | if n < 0 || n > len(r.raw) { | |
| 829 | + | return AllocColorPlanesReply{}, false | |
| 830 | + | } | |
| 831 | + | off += n * 4 | |
| 832 | + | } | |
| 833 | + | if off > len(r.raw) { | |
| 834 | + | return AllocColorPlanesReply{}, false | |
| 835 | + | } | |
| 836 | + | if off > len(r.raw) { | |
| 837 | + | return AllocColorPlanesReply{}, false | |
| 838 | + | } | |
| 839 | + | return r, true | |
| 840 | + | } | |
| 841 | + | func (r AllocColorPlanesReply) Raw() []byte { return r.raw } | |
| 842 | + | func (r AllocColorPlanesReply) PixelsLen() uint16 { | |
| 843 | + | return uint16(binary.LittleEndian.Uint16(r.raw[8:])) | |
| 844 | + | } | |
| 845 | + | func (r AllocColorPlanesReply) RedMask() uint32 { | |
| 846 | + | return uint32(binary.LittleEndian.Uint32(r.raw[12:])) | |
| 847 | + | } | |
| 848 | + | func (r AllocColorPlanesReply) GreenMask() uint32 { | |
| 849 | + | return uint32(binary.LittleEndian.Uint32(r.raw[16:])) | |
| 850 | + | } | |
| 851 | + | func (r AllocColorPlanesReply) BlueMask() uint32 { | |
| 852 | + | return uint32(binary.LittleEndian.Uint32(r.raw[20:])) | |
| 853 | + | } | |
| 854 | + | func (r AllocColorPlanesReply) Pixels() Uint32List { | |
| 855 | + | off := 32 | |
| 856 | + | end := off + (int(r.PixelsLen()))*4 | |
| 857 | + | return Uint32List{b: r.raw[off:end:end]} | |
| 858 | + | } | |
| 859 | + | ||
| 860 | + | // QueryColorsReply is a zero-copy view over a QueryColors reply; offsets count from reply byte 0. | |
| 861 | + | // It borrows the reply bytes: valid only until the Handler callback returns, because the read ring is reused. Copy what you keep. | |
| 862 | + | type QueryColorsReply struct{ raw []byte } | |
| 863 | + | ||
| 864 | + | // ParseQueryColorsReply validates raw (the whole reply, 32+4*length bytes) once; getters do not re-check. | |
| 865 | + | func ParseQueryColorsReply(raw []byte) (QueryColorsReply, bool) { | |
| 866 | + | if len(raw) < 32 { | |
| 867 | + | return QueryColorsReply{}, false | |
| 868 | + | } | |
| 869 | + | r := QueryColorsReply{raw: raw} | |
| 870 | + | off := 32 | |
| 871 | + | { | |
| 872 | + | n := int(r.ColorsLen()) | |
| 873 | + | if n < 0 || n > len(r.raw) { | |
| 874 | + | return QueryColorsReply{}, false | |
| 875 | + | } | |
| 876 | + | off += n * 8 | |
| 877 | + | } | |
| 878 | + | if off > len(r.raw) { | |
| 879 | + | return QueryColorsReply{}, false | |
| 880 | + | } | |
| 881 | + | if off > len(r.raw) { | |
| 882 | + | return QueryColorsReply{}, false | |
| 883 | + | } | |
| 884 | + | return r, true | |
| 885 | + | } | |
| 886 | + | func (r QueryColorsReply) Raw() []byte { return r.raw } | |
| 887 | + | func (r QueryColorsReply) ColorsLen() uint16 { return uint16(binary.LittleEndian.Uint16(r.raw[8:])) } | |
| 888 | + | func (r QueryColorsReply) Colors() RgbList { | |
| 889 | + | off := 32 | |
| 890 | + | end := off + (int(r.ColorsLen()))*8 | |
| 891 | + | return RgbList{b: r.raw[off:end:end]} | |
| 892 | + | } | |
| 893 | + | ||
| 894 | + | // LookupColorReply is a zero-copy view over a LookupColor reply; offsets count from reply byte 0. | |
| 895 | + | // It borrows the reply bytes: valid only until the Handler callback returns, because the read ring is reused. Copy what you keep. | |
| 896 | + | type LookupColorReply struct{ raw []byte } | |
| 897 | + | ||
| 898 | + | // ParseLookupColorReply validates raw (the whole reply, 32+4*length bytes) once; getters do not re-check. | |
| 899 | + | func ParseLookupColorReply(raw []byte) (LookupColorReply, bool) { | |
| 900 | + | if len(raw) < 32 { | |
| 901 | + | return LookupColorReply{}, false | |
| 902 | + | } | |
| 903 | + | r := LookupColorReply{raw: raw} | |
| 904 | + | return r, true | |
| 905 | + | } | |
| 906 | + | func (r LookupColorReply) Raw() []byte { return r.raw } | |
| 907 | + | func (r LookupColorReply) ExactRed() uint16 { return uint16(binary.LittleEndian.Uint16(r.raw[8:])) } | |
| 908 | + | func (r LookupColorReply) ExactGreen() uint16 { return uint16(binary.LittleEndian.Uint16(r.raw[10:])) } | |
| 909 | + | func (r LookupColorReply) ExactBlue() uint16 { return uint16(binary.LittleEndian.Uint16(r.raw[12:])) } | |
| 910 | + | func (r LookupColorReply) VisualRed() uint16 { return uint16(binary.LittleEndian.Uint16(r.raw[14:])) } | |
| 911 | + | func (r LookupColorReply) VisualGreen() uint16 { return uint16(binary.LittleEndian.Uint16(r.raw[16:])) } | |
| 912 | + | func (r LookupColorReply) VisualBlue() uint16 { return uint16(binary.LittleEndian.Uint16(r.raw[18:])) } | |
| 913 | + | ||
| 914 | + | // QueryBestSizeReply is a zero-copy view over a QueryBestSize reply; offsets count from reply byte 0. | |
| 915 | + | // It borrows the reply bytes: valid only until the Handler callback returns, because the read ring is reused. Copy what you keep. | |
| 916 | + | type QueryBestSizeReply struct{ raw []byte } | |
| 917 | + | ||
| 918 | + | // ParseQueryBestSizeReply validates raw (the whole reply, 32+4*length bytes) once; getters do not re-check. | |
| 919 | + | func ParseQueryBestSizeReply(raw []byte) (QueryBestSizeReply, bool) { | |
| 920 | + | if len(raw) < 32 { | |
| 921 | + | return QueryBestSizeReply{}, false | |
| 922 | + | } | |
| 923 | + | r := QueryBestSizeReply{raw: raw} | |
| 924 | + | return r, true | |
| 925 | + | } | |
| 926 | + | func (r QueryBestSizeReply) Raw() []byte { return r.raw } | |
| 927 | + | func (r QueryBestSizeReply) Width() uint16 { return uint16(binary.LittleEndian.Uint16(r.raw[8:])) } | |
| 928 | + | func (r QueryBestSizeReply) Height() uint16 { return uint16(binary.LittleEndian.Uint16(r.raw[10:])) } | |
| 929 | + | ||
| 930 | + | // QueryExtensionReply is a zero-copy view over a QueryExtension reply; offsets count from reply byte 0. | |
| 931 | + | // It borrows the reply bytes: valid only until the Handler callback returns, because the read ring is reused. Copy what you keep. | |
| 932 | + | type QueryExtensionReply struct{ raw []byte } | |
| 933 | + | ||
| 934 | + | // ParseQueryExtensionReply validates raw (the whole reply, 32+4*length bytes) once; getters do not re-check. | |
| 935 | + | func ParseQueryExtensionReply(raw []byte) (QueryExtensionReply, bool) { | |
| 936 | + | if len(raw) < 32 { | |
| 937 | + | return QueryExtensionReply{}, false | |
| 938 | + | } | |
| 939 | + | r := QueryExtensionReply{raw: raw} | |
| 940 | + | return r, true | |
| 941 | + | } | |
| 942 | + | func (r QueryExtensionReply) Raw() []byte { return r.raw } | |
| 943 | + | func (r QueryExtensionReply) Present() bool { return (r.raw[8:][0] != 0) } | |
| 944 | + | func (r QueryExtensionReply) MajorOpcode() uint8 { return uint8(r.raw[9:][0]) } | |
| 945 | + | func (r QueryExtensionReply) FirstEvent() uint8 { return uint8(r.raw[10:][0]) } | |
| 946 | + | func (r QueryExtensionReply) FirstError() uint8 { return uint8(r.raw[11:][0]) } | |
| 947 | + | ||
| 948 | + | // ListExtensionsReply is a zero-copy view over a ListExtensions reply; offsets count from reply byte 0. | |
| 949 | + | // It borrows the reply bytes: valid only until the Handler callback returns, because the read ring is reused. Copy what you keep. | |
| 950 | + | type ListExtensionsReply struct{ raw []byte } | |
| 951 | + | ||
| 952 | + | // ParseListExtensionsReply validates raw (the whole reply, 32+4*length bytes) once; getters do not re-check. | |
| 953 | + | func ParseListExtensionsReply(raw []byte) (ListExtensionsReply, bool) { | |
| 954 | + | if len(raw) < 32 { | |
| 955 | + | return ListExtensionsReply{}, false | |
| 956 | + | } | |
| 957 | + | r := ListExtensionsReply{raw: raw} | |
| 958 | + | off := 32 | |
| 959 | + | { | |
| 960 | + | n := int(r.NamesLen()) | |
| 961 | + | if off > len(r.raw) || n < 0 || n > len(r.raw) { | |
| 962 | + | return ListExtensionsReply{}, false | |
| 963 | + | } | |
| 964 | + | it := NewStrIter(r.raw[off:], n) | |
| 965 | + | for it.Next() { | |
| 966 | + | off += it.Value().Size() | |
| 967 | + | } | |
| 968 | + | if it.Err() { | |
| 969 | + | return ListExtensionsReply{}, false | |
| 970 | + | } | |
| 971 | + | } | |
| 972 | + | if off > len(r.raw) { | |
| 973 | + | return ListExtensionsReply{}, false | |
| 974 | + | } | |
| 975 | + | return r, true | |
| 976 | + | } | |
| 977 | + | func (r ListExtensionsReply) Raw() []byte { return r.raw } | |
| 978 | + | func (r ListExtensionsReply) NamesLen() uint8 { return uint8(r.raw[1:][0]) } | |
| 979 | + | func (r ListExtensionsReply) Names() StrIter { | |
| 980 | + | off := 32 | |
| 981 | + | return NewStrIter(r.raw[off:], int(r.NamesLen())) | |
| 982 | + | } | |
| 983 | + | ||
| 984 | + | // GetKeyboardMappingReply is a zero-copy view over a GetKeyboardMapping reply; offsets count from reply byte 0. | |
| 985 | + | // It borrows the reply bytes: valid only until the Handler callback returns, because the read ring is reused. Copy what you keep. | |
| 986 | + | type GetKeyboardMappingReply struct{ raw []byte } | |
| 987 | + | ||
| 988 | + | // ParseGetKeyboardMappingReply validates raw (the whole reply, 32+4*length bytes) once; getters do not re-check. | |
| 989 | + | func ParseGetKeyboardMappingReply(raw []byte) (GetKeyboardMappingReply, bool) { | |
| 990 | + | if len(raw) < 32 { | |
| 991 | + | return GetKeyboardMappingReply{}, false | |
| 992 | + | } | |
| 993 | + | r := GetKeyboardMappingReply{raw: raw} | |
| 994 | + | off := 32 | |
| 995 | + | { | |
| 996 | + | n := int(binary.LittleEndian.Uint32(r.raw[4:])) | |
| 997 | + | if n < 0 || n > len(r.raw) { | |
| 998 | + | return GetKeyboardMappingReply{}, false | |
| 999 | + | } | |
| 1000 | + | off += n * 4 | |
| 1001 | + | } | |
| 1002 | + | if off > len(r.raw) { | |
| 1003 | + | return GetKeyboardMappingReply{}, false | |
| 1004 | + | } | |
| 1005 | + | if off > len(r.raw) { | |
| 1006 | + | return GetKeyboardMappingReply{}, false | |
| 1007 | + | } | |
| 1008 | + | return r, true | |
| 1009 | + | } | |
| 1010 | + | func (r GetKeyboardMappingReply) Raw() []byte { return r.raw } | |
| 1011 | + | func (r GetKeyboardMappingReply) KeysymsPerKeycode() byte { return byte(r.raw[1:][0]) } | |
| 1012 | + | func (r GetKeyboardMappingReply) Keysyms() KeysymList { | |
| 1013 | + | off := 32 | |
| 1014 | + | end := off + (int(binary.LittleEndian.Uint32(r.raw[4:])))*4 | |
| 1015 | + | return KeysymList{b: r.raw[off:end:end]} | |
| 1016 | + | } | |
| 1017 | + | ||
| 1018 | + | // GetKeyboardControlReply is a zero-copy view over a GetKeyboardControl reply; offsets count from reply byte 0. | |
| 1019 | + | // It borrows the reply bytes: valid only until the Handler callback returns, because the read ring is reused. Copy what you keep. | |
| 1020 | + | type GetKeyboardControlReply struct{ raw []byte } | |
| 1021 | + | ||
| 1022 | + | // ParseGetKeyboardControlReply validates raw (the whole reply, 32+4*length bytes) once; getters do not re-check. | |
| 1023 | + | func ParseGetKeyboardControlReply(raw []byte) (GetKeyboardControlReply, bool) { | |
| 1024 | + | if len(raw) < 52 { | |
| 1025 | + | return GetKeyboardControlReply{}, false | |
| 1026 | + | } | |
| 1027 | + | r := GetKeyboardControlReply{raw: raw} | |
| 1028 | + | return r, true | |
| 1029 | + | } | |
| 1030 | + | func (r GetKeyboardControlReply) Raw() []byte { return r.raw } | |
| 1031 | + | func (r GetKeyboardControlReply) GlobalAutoRepeat() AutoRepeatMode { | |
| 1032 | + | return AutoRepeatMode(r.raw[1:][0]) | |
| 1033 | + | } | |
| 1034 | + | func (r GetKeyboardControlReply) LedMask() uint32 { | |
| 1035 | + | return uint32(binary.LittleEndian.Uint32(r.raw[8:])) | |
| 1036 | + | } | |
| 1037 | + | func (r GetKeyboardControlReply) KeyClickPercent() uint8 { return uint8(r.raw[12:][0]) } | |
| 1038 | + | func (r GetKeyboardControlReply) BellPercent() uint8 { return uint8(r.raw[13:][0]) } | |
| 1039 | + | func (r GetKeyboardControlReply) BellPitch() uint16 { | |
| 1040 | + | return uint16(binary.LittleEndian.Uint16(r.raw[14:])) | |
| 1041 | + | } | |
| 1042 | + | func (r GetKeyboardControlReply) BellDuration() uint16 { | |
| 1043 | + | return uint16(binary.LittleEndian.Uint16(r.raw[16:])) | |
| 1044 | + | } | |
| 1045 | + | func (r GetKeyboardControlReply) AutoRepeats() []byte { | |
| 1046 | + | off := 20 | |
| 1047 | + | end := off + 32 | |
| 1048 | + | return r.raw[off:end:end] | |
| 1049 | + | } | |
| 1050 | + | ||
| 1051 | + | // GetPointerControlReply is a zero-copy view over a GetPointerControl reply; offsets count from reply byte 0. | |
| 1052 | + | // It borrows the reply bytes: valid only until the Handler callback returns, because the read ring is reused. Copy what you keep. | |
| 1053 | + | type GetPointerControlReply struct{ raw []byte } | |
| 1054 | + | ||
| 1055 | + | // ParseGetPointerControlReply validates raw (the whole reply, 32+4*length bytes) once; getters do not re-check. | |
| 1056 | + | func ParseGetPointerControlReply(raw []byte) (GetPointerControlReply, bool) { | |
| 1057 | + | if len(raw) < 32 { | |
| 1058 | + | return GetPointerControlReply{}, false | |
| 1059 | + | } | |
| 1060 | + | r := GetPointerControlReply{raw: raw} | |
| 1061 | + | return r, true | |
| 1062 | + | } | |
| 1063 | + | func (r GetPointerControlReply) Raw() []byte { return r.raw } | |
| 1064 | + | func (r GetPointerControlReply) AccelerationNumerator() uint16 { | |
| 1065 | + | return uint16(binary.LittleEndian.Uint16(r.raw[8:])) | |
| 1066 | + | } | |
| 1067 | + | func (r GetPointerControlReply) AccelerationDenominator() uint16 { | |
| 1068 | + | return uint16(binary.LittleEndian.Uint16(r.raw[10:])) | |
| 1069 | + | } | |
| 1070 | + | func (r GetPointerControlReply) Threshold() uint16 { | |
| 1071 | + | return uint16(binary.LittleEndian.Uint16(r.raw[12:])) | |
| 1072 | + | } | |
| 1073 | + | ||
| 1074 | + | // GetScreenSaverReply is a zero-copy view over a GetScreenSaver reply; offsets count from reply byte 0. | |
| 1075 | + | // It borrows the reply bytes: valid only until the Handler callback returns, because the read ring is reused. Copy what you keep. | |
| 1076 | + | type GetScreenSaverReply struct{ raw []byte } | |
| 1077 | + | ||
| 1078 | + | // ParseGetScreenSaverReply validates raw (the whole reply, 32+4*length bytes) once; getters do not re-check. | |
| 1079 | + | func ParseGetScreenSaverReply(raw []byte) (GetScreenSaverReply, bool) { | |
| 1080 | + | if len(raw) < 32 { | |
| 1081 | + | return GetScreenSaverReply{}, false | |
| 1082 | + | } | |
| 1083 | + | r := GetScreenSaverReply{raw: raw} | |
| 1084 | + | return r, true | |
| 1085 | + | } | |
| 1086 | + | func (r GetScreenSaverReply) Raw() []byte { return r.raw } | |
| 1087 | + | func (r GetScreenSaverReply) Timeout() uint16 { return uint16(binary.LittleEndian.Uint16(r.raw[8:])) } | |
| 1088 | + | func (r GetScreenSaverReply) Interval() uint16 { return uint16(binary.LittleEndian.Uint16(r.raw[10:])) } | |
| 1089 | + | func (r GetScreenSaverReply) PreferBlanking() Blanking { return Blanking(r.raw[12:][0]) } | |
| 1090 | + | func (r GetScreenSaverReply) AllowExposures() Exposures { return Exposures(r.raw[13:][0]) } | |
| 1091 | + | ||
| 1092 | + | // ListHostsReply is a zero-copy view over a ListHosts reply; offsets count from reply byte 0. | |
| 1093 | + | // It borrows the reply bytes: valid only until the Handler callback returns, because the read ring is reused. Copy what you keep. | |
| 1094 | + | type ListHostsReply struct{ raw []byte } | |
| 1095 | + | ||
| 1096 | + | // ParseListHostsReply validates raw (the whole reply, 32+4*length bytes) once; getters do not re-check. | |
| 1097 | + | func ParseListHostsReply(raw []byte) (ListHostsReply, bool) { | |
| 1098 | + | if len(raw) < 32 { | |
| 1099 | + | return ListHostsReply{}, false | |
| 1100 | + | } | |
| 1101 | + | r := ListHostsReply{raw: raw} | |
| 1102 | + | off := 32 | |
| 1103 | + | { | |
| 1104 | + | n := int(r.HostsLen()) | |
| 1105 | + | if off > len(r.raw) || n < 0 || n > len(r.raw) { | |
| 1106 | + | return ListHostsReply{}, false | |
| 1107 | + | } | |
| 1108 | + | it := NewHostIter(r.raw[off:], n) | |
| 1109 | + | for it.Next() { | |
| 1110 | + | off += it.Value().Size() | |
| 1111 | + | } | |
| 1112 | + | if it.Err() { | |
| 1113 | + | return ListHostsReply{}, false | |
| 1114 | + | } | |
| 1115 | + | } | |
| 1116 | + | if off > len(r.raw) { | |
| 1117 | + | return ListHostsReply{}, false | |
| 1118 | + | } | |
| 1119 | + | return r, true | |
| 1120 | + | } | |
| 1121 | + | func (r ListHostsReply) Raw() []byte { return r.raw } | |
| 1122 | + | func (r ListHostsReply) Mode() AccessControl { return AccessControl(r.raw[1:][0]) } | |
| 1123 | + | func (r ListHostsReply) HostsLen() uint16 { return uint16(binary.LittleEndian.Uint16(r.raw[8:])) } | |
| 1124 | + | func (r ListHostsReply) Hosts() HostIter { | |
| 1125 | + | off := 32 | |
| 1126 | + | return NewHostIter(r.raw[off:], int(r.HostsLen())) | |
| 1127 | + | } | |
| 1128 | + | ||
| 1129 | + | // SetPointerMappingReply is a zero-copy view over a SetPointerMapping reply; offsets count from reply byte 0. | |
| 1130 | + | // It borrows the reply bytes: valid only until the Handler callback returns, because the read ring is reused. Copy what you keep. | |
| 1131 | + | type SetPointerMappingReply struct{ raw []byte } | |
| 1132 | + | ||
| 1133 | + | // ParseSetPointerMappingReply validates raw (the whole reply, 32+4*length bytes) once; getters do not re-check. | |
| 1134 | + | func ParseSetPointerMappingReply(raw []byte) (SetPointerMappingReply, bool) { | |
| 1135 | + | if len(raw) < 32 { | |
| 1136 | + | return SetPointerMappingReply{}, false | |
| 1137 | + | } | |
| 1138 | + | r := SetPointerMappingReply{raw: raw} | |
| 1139 | + | return r, true | |
| 1140 | + | } | |
| 1141 | + | func (r SetPointerMappingReply) Raw() []byte { return r.raw } | |
| 1142 | + | func (r SetPointerMappingReply) Status() MappingStatus { return MappingStatus(r.raw[1:][0]) } | |
| 1143 | + | ||
| 1144 | + | // GetPointerMappingReply is a zero-copy view over a GetPointerMapping reply; offsets count from reply byte 0. | |
| 1145 | + | // It borrows the reply bytes: valid only until the Handler callback returns, because the read ring is reused. Copy what you keep. | |
| 1146 | + | type GetPointerMappingReply struct{ raw []byte } | |
| 1147 | + | ||
| 1148 | + | // ParseGetPointerMappingReply validates raw (the whole reply, 32+4*length bytes) once; getters do not re-check. | |
| 1149 | + | func ParseGetPointerMappingReply(raw []byte) (GetPointerMappingReply, bool) { | |
| 1150 | + | if len(raw) < 32 { | |
| 1151 | + | return GetPointerMappingReply{}, false | |
| 1152 | + | } | |
| 1153 | + | r := GetPointerMappingReply{raw: raw} | |
| 1154 | + | off := 32 | |
| 1155 | + | { | |
| 1156 | + | n := int(r.MapLen()) | |
| 1157 | + | if n < 0 || n > len(r.raw) { | |
| 1158 | + | return GetPointerMappingReply{}, false | |
| 1159 | + | } | |
| 1160 | + | off += n * 1 | |
| 1161 | + | } | |
| 1162 | + | if off > len(r.raw) { | |
| 1163 | + | return GetPointerMappingReply{}, false | |
| 1164 | + | } | |
| 1165 | + | if off > len(r.raw) { | |
| 1166 | + | return GetPointerMappingReply{}, false | |
| 1167 | + | } | |
| 1168 | + | return r, true | |
| 1169 | + | } | |
| 1170 | + | func (r GetPointerMappingReply) Raw() []byte { return r.raw } | |
| 1171 | + | func (r GetPointerMappingReply) MapLen() uint8 { return uint8(r.raw[1:][0]) } | |
| 1172 | + | func (r GetPointerMappingReply) Map() []byte { | |
| 1173 | + | off := 32 | |
| 1174 | + | end := off + int(r.MapLen()) | |
| 1175 | + | return r.raw[off:end:end] | |
| 1176 | + | } | |
| 1177 | + | ||
| 1178 | + | // SetModifierMappingReply is a zero-copy view over a SetModifierMapping reply; offsets count from reply byte 0. | |
| 1179 | + | // It borrows the reply bytes: valid only until the Handler callback returns, because the read ring is reused. Copy what you keep. | |
| 1180 | + | type SetModifierMappingReply struct{ raw []byte } | |
| 1181 | + | ||
| 1182 | + | // ParseSetModifierMappingReply validates raw (the whole reply, 32+4*length bytes) once; getters do not re-check. | |
| 1183 | + | func ParseSetModifierMappingReply(raw []byte) (SetModifierMappingReply, bool) { | |
| 1184 | + | if len(raw) < 32 { | |
| 1185 | + | return SetModifierMappingReply{}, false | |
| 1186 | + | } | |
| 1187 | + | r := SetModifierMappingReply{raw: raw} | |
| 1188 | + | return r, true | |
| 1189 | + | } | |
| 1190 | + | func (r SetModifierMappingReply) Raw() []byte { return r.raw } | |
| 1191 | + | func (r SetModifierMappingReply) Status() MappingStatus { return MappingStatus(r.raw[1:][0]) } | |
| 1192 | + | ||
| 1193 | + | // GetModifierMappingReply is a zero-copy view over a GetModifierMapping reply; offsets count from reply byte 0. | |
| 1194 | + | // It borrows the reply bytes: valid only until the Handler callback returns, because the read ring is reused. Copy what you keep. | |
| 1195 | + | type GetModifierMappingReply struct{ raw []byte } | |
| 1196 | + | ||
| 1197 | + | // ParseGetModifierMappingReply validates raw (the whole reply, 32+4*length bytes) once; getters do not re-check. | |
| 1198 | + | func ParseGetModifierMappingReply(raw []byte) (GetModifierMappingReply, bool) { | |
| 1199 | + | if len(raw) < 32 { | |
| 1200 | + | return GetModifierMappingReply{}, false | |
| 1201 | + | } | |
| 1202 | + | r := GetModifierMappingReply{raw: raw} | |
| 1203 | + | off := 32 | |
| 1204 | + | { | |
| 1205 | + | n := (int(r.KeycodesPerModifier()) * 8) | |
| 1206 | + | if n < 0 || n > len(r.raw) { | |
| 1207 | + | return GetModifierMappingReply{}, false | |
| 1208 | + | } | |
| 1209 | + | off += n * 1 | |
| 1210 | + | } | |
| 1211 | + | if off > len(r.raw) { | |
| 1212 | + | return GetModifierMappingReply{}, false | |
| 1213 | + | } | |
| 1214 | + | if off > len(r.raw) { | |
| 1215 | + | return GetModifierMappingReply{}, false | |
| 1216 | + | } | |
| 1217 | + | return r, true | |
| 1218 | + | } | |
| 1219 | + | func (r GetModifierMappingReply) Raw() []byte { return r.raw } | |
| 1220 | + | func (r GetModifierMappingReply) KeycodesPerModifier() uint8 { return uint8(r.raw[1:][0]) } | |
| 1221 | + | func (r GetModifierMappingReply) Keycodes() KeycodeList { | |
| 1222 | + | off := 32 | |
| 1223 | + | end := off + (int(r.KeycodesPerModifier())*8)*1 | |
| 1224 | + | return KeycodeList{b: r.raw[off:end:end]} | |
| 1225 | + | } | |
| 1226 | + | ||
| 1227 | + | // DepthView is a zero-copy view over one wire-encoded Depth, yielded by DepthIter. | |
| 1228 | + | // It shares the lifetime of the bytes it was taken from (for replies: until the Handler callback returns). Copy what you keep. | |
| 1229 | + | type DepthView struct{ raw []byte } | |
| 1230 | + | ||
| 1231 | + | func (v DepthView) Raw() []byte { return v.raw } | |
| 1232 | + | ||
| 1233 | + | // Size is the element's wire size, including trailing alignment. | |
| 1234 | + | func (v DepthView) Size() int { return len(v.raw) } | |
| 1235 | + | func sizeDepth(p []byte) int { | |
| 1236 | + | if len(p) < 8 { | |
| 1237 | + | return -1 | |
| 1238 | + | } | |
| 1239 | + | v := DepthView{raw: p} | |
| 1240 | + | _ = v | |
| 1241 | + | off := 8 | |
| 1242 | + | { | |
| 1243 | + | n := int(v.VisualsLen()) | |
| 1244 | + | if n < 0 || n > len(v.raw) { | |
| 1245 | + | return -1 | |
| 1246 | + | } | |
| 1247 | + | off += n * 24 | |
| 1248 | + | } | |
| 1249 | + | if off > len(v.raw) { | |
| 1250 | + | return -1 | |
| 1251 | + | } | |
| 1252 | + | if off > len(v.raw) { | |
| 1253 | + | return -1 | |
| 1254 | + | } | |
| 1255 | + | return off | |
| 1256 | + | } | |
| 1257 | + | func (v DepthView) Depth() uint8 { return uint8(v.raw[0:][0]) } | |
| 1258 | + | func (v DepthView) VisualsLen() uint16 { return uint16(binary.LittleEndian.Uint16(v.raw[2:])) } | |
| 1259 | + | func (v DepthView) Visuals() VisualtypeList { | |
| 1260 | + | off := 8 | |
| 1261 | + | end := off + (int(v.VisualsLen()))*24 | |
| 1262 | + | return VisualtypeList{b: v.raw[off:end:end]} | |
| 1263 | + | } | |
| 1264 | + | ||
| 1265 | + | // DepthIter walks n consecutive Depth elements; Err reports a malformed length. | |
| 1266 | + | // It shares the lifetime of the bytes it walks. | |
| 1267 | + | type DepthIter struct { | |
| 1268 | + | b []byte | |
| 1269 | + | n int | |
| 1270 | + | v DepthView | |
| 1271 | + | err bool | |
| 1272 | + | } | |
| 1273 | + | ||
| 1274 | + | // NewDepthIter iterates n elements encoded at the start of b. | |
| 1275 | + | func NewDepthIter(b []byte, n int) DepthIter { return DepthIter{b: b, n: n} } | |
| 1276 | + | func (it *DepthIter) Next() bool { | |
| 1277 | + | if it.n <= 0 || it.err { | |
| 1278 | + | return false | |
| 1279 | + | } | |
| 1280 | + | s := sizeDepth(it.b) | |
| 1281 | + | if s < 0 { | |
| 1282 | + | it.err = true | |
| 1283 | + | it.n = 0 | |
| 1284 | + | return false | |
| 1285 | + | } | |
| 1286 | + | it.v = DepthView{raw: it.b[:s:s]} | |
| 1287 | + | it.b = it.b[s:] | |
| 1288 | + | it.n-- | |
| 1289 | + | return true | |
| 1290 | + | } | |
| 1291 | + | func (it *DepthIter) Value() DepthView { return it.v } | |
| 1292 | + | func (it *DepthIter) Err() bool { return it.err } | |
| 1293 | + | ||
| 1294 | + | // ScreenView is a zero-copy view over one wire-encoded Screen, yielded by ScreenIter. | |
| 1295 | + | // It shares the lifetime of the bytes it was taken from (for replies: until the Handler callback returns). Copy what you keep. | |
| 1296 | + | type ScreenView struct{ raw []byte } | |
| 1297 | + | ||
| 1298 | + | func (v ScreenView) Raw() []byte { return v.raw } | |
| 1299 | + | ||
| 1300 | + | // Size is the element's wire size, including trailing alignment. | |
| 1301 | + | func (v ScreenView) Size() int { return len(v.raw) } | |
| 1302 | + | func sizeScreen(p []byte) int { | |
| 1303 | + | if len(p) < 40 { | |
| 1304 | + | return -1 | |
| 1305 | + | } | |
| 1306 | + | v := ScreenView{raw: p} | |
| 1307 | + | _ = v | |
| 1308 | + | off := 40 | |
| 1309 | + | { | |
| 1310 | + | n := int(v.AllowedDepthsLen()) | |
| 1311 | + | if off > len(v.raw) || n < 0 || n > len(v.raw) { | |
| 1312 | + | return -1 | |
| 1313 | + | } | |
| 1314 | + | it := NewDepthIter(v.raw[off:], n) | |
| 1315 | + | for it.Next() { | |
| 1316 | + | off += it.Value().Size() | |
| 1317 | + | } | |
| 1318 | + | if it.Err() { | |
| 1319 | + | return -1 | |
| 1320 | + | } | |
| 1321 | + | } | |
| 1322 | + | if off > len(v.raw) { | |
| 1323 | + | return -1 | |
| 1324 | + | } | |
| 1325 | + | return off | |
| 1326 | + | } | |
| 1327 | + | func (v ScreenView) Root() Window { return Window(binary.LittleEndian.Uint32(v.raw[0:])) } | |
| 1328 | + | func (v ScreenView) DefaultColormap() Colormap { | |
| 1329 | + | return Colormap(binary.LittleEndian.Uint32(v.raw[4:])) | |
| 1330 | + | } | |
| 1331 | + | func (v ScreenView) WhitePixel() uint32 { return uint32(binary.LittleEndian.Uint32(v.raw[8:])) } | |
| 1332 | + | func (v ScreenView) BlackPixel() uint32 { return uint32(binary.LittleEndian.Uint32(v.raw[12:])) } | |
| 1333 | + | func (v ScreenView) CurrentInputMasks() EventMask { | |
| 1334 | + | return EventMask(binary.LittleEndian.Uint32(v.raw[16:])) | |
| 1335 | + | } | |
| 1336 | + | func (v ScreenView) WidthInPixels() uint16 { return uint16(binary.LittleEndian.Uint16(v.raw[20:])) } | |
| 1337 | + | func (v ScreenView) HeightInPixels() uint16 { return uint16(binary.LittleEndian.Uint16(v.raw[22:])) } | |
| 1338 | + | func (v ScreenView) WidthInMillimeters() uint16 { | |
| 1339 | + | return uint16(binary.LittleEndian.Uint16(v.raw[24:])) | |
| 1340 | + | } | |
| 1341 | + | func (v ScreenView) HeightInMillimeters() uint16 { | |
| 1342 | + | return uint16(binary.LittleEndian.Uint16(v.raw[26:])) | |
| 1343 | + | } | |
| 1344 | + | func (v ScreenView) MinInstalledMaps() uint16 { return uint16(binary.LittleEndian.Uint16(v.raw[28:])) } | |
| 1345 | + | func (v ScreenView) MaxInstalledMaps() uint16 { return uint16(binary.LittleEndian.Uint16(v.raw[30:])) } | |
| 1346 | + | func (v ScreenView) RootVisual() Visualid { return Visualid(binary.LittleEndian.Uint32(v.raw[32:])) } | |
| 1347 | + | func (v ScreenView) BackingStores() BackingStore { return BackingStore(v.raw[36:][0]) } | |
| 1348 | + | func (v ScreenView) SaveUnders() bool { return (v.raw[37:][0] != 0) } | |
| 1349 | + | func (v ScreenView) RootDepth() uint8 { return uint8(v.raw[38:][0]) } | |
| 1350 | + | func (v ScreenView) AllowedDepthsLen() uint8 { return uint8(v.raw[39:][0]) } | |
| 1351 | + | func (v ScreenView) AllowedDepths() DepthIter { | |
| 1352 | + | off := 40 | |
| 1353 | + | return NewDepthIter(v.raw[off:], int(v.AllowedDepthsLen())) | |
| 1354 | + | } | |
| 1355 | + | ||
| 1356 | + | // ScreenIter walks n consecutive Screen elements; Err reports a malformed length. | |
| 1357 | + | // It shares the lifetime of the bytes it walks. | |
| 1358 | + | type ScreenIter struct { | |
| 1359 | + | b []byte | |
| 1360 | + | n int | |
| 1361 | + | v ScreenView | |
| 1362 | + | err bool | |
| 1363 | + | } | |
| 1364 | + | ||
| 1365 | + | // NewScreenIter iterates n elements encoded at the start of b. | |
| 1366 | + | func NewScreenIter(b []byte, n int) ScreenIter { return ScreenIter{b: b, n: n} } | |
| 1367 | + | func (it *ScreenIter) Next() bool { | |
| 1368 | + | if it.n <= 0 || it.err { | |
| 1369 | + | return false | |
| 1370 | + | } | |
| 1371 | + | s := sizeScreen(it.b) | |
| 1372 | + | if s < 0 { | |
| 1373 | + | it.err = true | |
| 1374 | + | it.n = 0 | |
| 1375 | + | return false | |
| 1376 | + | } | |
| 1377 | + | it.v = ScreenView{raw: it.b[:s:s]} | |
| 1378 | + | it.b = it.b[s:] | |
| 1379 | + | it.n-- | |
| 1380 | + | return true | |
| 1381 | + | } | |
| 1382 | + | func (it *ScreenIter) Value() ScreenView { return it.v } | |
| 1383 | + | func (it *ScreenIter) Err() bool { return it.err } | |
| 1384 | + | ||
| 1385 | + | // SetupRequestView is a zero-copy view over one wire-encoded SetupRequest, yielded by SetupRequestIter. | |
| 1386 | + | // It shares the lifetime of the bytes it was taken from (for replies: until the Handler callback returns). Copy what you keep. | |
| 1387 | + | type SetupRequestView struct{ raw []byte } | |
| 1388 | + | ||
| 1389 | + | func (v SetupRequestView) Raw() []byte { return v.raw } | |
| 1390 | + | ||
| 1391 | + | // Size is the element's wire size, including trailing alignment. | |
| 1392 | + | func (v SetupRequestView) Size() int { return len(v.raw) } | |
| 1393 | + | func sizeSetupRequest(p []byte) int { | |
| 1394 | + | if len(p) < 12 { | |
| 1395 | + | return -1 | |
| 1396 | + | } | |
| 1397 | + | v := SetupRequestView{raw: p} | |
| 1398 | + | _ = v | |
| 1399 | + | off := 12 | |
| 1400 | + | { | |
| 1401 | + | n := int(v.AuthorizationProtocolNameLen()) | |
| 1402 | + | if n < 0 || n > len(v.raw) { | |
| 1403 | + | return -1 | |
| 1404 | + | } | |
| 1405 | + | off += n * 1 | |
| 1406 | + | } | |
| 1407 | + | if off > len(v.raw) { | |
| 1408 | + | return -1 | |
| 1409 | + | } | |
| 1410 | + | off = (off + 3) &^ 3 | |
| 1411 | + | { | |
| 1412 | + | n := int(v.AuthorizationProtocolDataLen()) | |
| 1413 | + | if n < 0 || n > len(v.raw) { | |
| 1414 | + | return -1 | |
| 1415 | + | } | |
| 1416 | + | off += n * 1 | |
| 1417 | + | } | |
| 1418 | + | if off > len(v.raw) { | |
| 1419 | + | return -1 | |
| 1420 | + | } | |
| 1421 | + | off = (off + 3) &^ 3 | |
| 1422 | + | if off > len(v.raw) { | |
| 1423 | + | return -1 | |
| 1424 | + | } | |
| 1425 | + | return off | |
| 1426 | + | } | |
| 1427 | + | func (v SetupRequestView) ByteOrder() uint8 { return uint8(v.raw[0:][0]) } | |
| 1428 | + | func (v SetupRequestView) ProtocolMajorVersion() uint16 { | |
| 1429 | + | return uint16(binary.LittleEndian.Uint16(v.raw[2:])) | |
| 1430 | + | } | |
| 1431 | + | func (v SetupRequestView) ProtocolMinorVersion() uint16 { | |
| 1432 | + | return uint16(binary.LittleEndian.Uint16(v.raw[4:])) | |
| 1433 | + | } | |
| 1434 | + | func (v SetupRequestView) AuthorizationProtocolNameLen() uint16 { | |
| 1435 | + | return uint16(binary.LittleEndian.Uint16(v.raw[6:])) | |
| 1436 | + | } | |
| 1437 | + | func (v SetupRequestView) AuthorizationProtocolDataLen() uint16 { | |
| 1438 | + | return uint16(binary.LittleEndian.Uint16(v.raw[8:])) | |
| 1439 | + | } | |
| 1440 | + | func (v SetupRequestView) AuthorizationProtocolName() []byte { | |
| 1441 | + | off := 12 | |
| 1442 | + | end := off + int(v.AuthorizationProtocolNameLen()) | |
| 1443 | + | return v.raw[off:end:end] | |
| 1444 | + | } | |
| 1445 | + | func (v SetupRequestView) AuthorizationProtocolData() []byte { | |
| 1446 | + | off := 12 | |
| 1447 | + | { | |
| 1448 | + | n := int(v.AuthorizationProtocolNameLen()) | |
| 1449 | + | off += n * 1 | |
| 1450 | + | } | |
| 1451 | + | off = (off + 3) &^ 3 | |
| 1452 | + | end := off + int(v.AuthorizationProtocolDataLen()) | |
| 1453 | + | return v.raw[off:end:end] | |
| 1454 | + | } | |
| 1455 | + | ||
| 1456 | + | // SetupRequestIter walks n consecutive SetupRequest elements; Err reports a malformed length. | |
| 1457 | + | // It shares the lifetime of the bytes it walks. | |
| 1458 | + | type SetupRequestIter struct { | |
| 1459 | + | b []byte | |
| 1460 | + | n int | |
| 1461 | + | v SetupRequestView | |
| 1462 | + | err bool | |
| 1463 | + | } | |
| 1464 | + | ||
| 1465 | + | // NewSetupRequestIter iterates n elements encoded at the start of b. | |
| 1466 | + | func NewSetupRequestIter(b []byte, n int) SetupRequestIter { return SetupRequestIter{b: b, n: n} } | |
| 1467 | + | func (it *SetupRequestIter) Next() bool { | |
| 1468 | + | if it.n <= 0 || it.err { | |
| 1469 | + | return false | |
| 1470 | + | } | |
| 1471 | + | s := sizeSetupRequest(it.b) | |
| 1472 | + | if s < 0 { | |
| 1473 | + | it.err = true | |
| 1474 | + | it.n = 0 | |
| 1475 | + | return false | |
| 1476 | + | } | |
| 1477 | + | it.v = SetupRequestView{raw: it.b[:s:s]} | |
| 1478 | + | it.b = it.b[s:] | |
| 1479 | + | it.n-- | |
| 1480 | + | return true | |
| 1481 | + | } | |
| 1482 | + | func (it *SetupRequestIter) Value() SetupRequestView { return it.v } | |
| 1483 | + | func (it *SetupRequestIter) Err() bool { return it.err } | |
| 1484 | + | ||
| 1485 | + | // SetupFailedView is a zero-copy view over one wire-encoded SetupFailed, yielded by SetupFailedIter. | |
| 1486 | + | // It shares the lifetime of the bytes it was taken from (for replies: until the Handler callback returns). Copy what you keep. | |
| 1487 | + | type SetupFailedView struct{ raw []byte } | |
| 1488 | + | ||
| 1489 | + | func (v SetupFailedView) Raw() []byte { return v.raw } | |
| 1490 | + | ||
| 1491 | + | // Size is the element's wire size, including trailing alignment. | |
| 1492 | + | func (v SetupFailedView) Size() int { return len(v.raw) } | |
| 1493 | + | func sizeSetupFailed(p []byte) int { | |
| 1494 | + | if len(p) < 8 { | |
| 1495 | + | return -1 | |
| 1496 | + | } | |
| 1497 | + | v := SetupFailedView{raw: p} | |
| 1498 | + | _ = v | |
| 1499 | + | off := 8 | |
| 1500 | + | { | |
| 1501 | + | n := int(v.ReasonLen()) | |
| 1502 | + | if n < 0 || n > len(v.raw) { | |
| 1503 | + | return -1 | |
| 1504 | + | } | |
| 1505 | + | off += n * 1 | |
| 1506 | + | } | |
| 1507 | + | if off > len(v.raw) { | |
| 1508 | + | return -1 | |
| 1509 | + | } | |
| 1510 | + | if off > len(v.raw) { | |
| 1511 | + | return -1 | |
| 1512 | + | } | |
| 1513 | + | return off | |
| 1514 | + | } | |
| 1515 | + | func (v SetupFailedView) Status() uint8 { return uint8(v.raw[0:][0]) } | |
| 1516 | + | func (v SetupFailedView) ReasonLen() uint8 { return uint8(v.raw[1:][0]) } | |
| 1517 | + | func (v SetupFailedView) ProtocolMajorVersion() uint16 { | |
| 1518 | + | return uint16(binary.LittleEndian.Uint16(v.raw[2:])) | |
| 1519 | + | } | |
| 1520 | + | func (v SetupFailedView) ProtocolMinorVersion() uint16 { | |
| 1521 | + | return uint16(binary.LittleEndian.Uint16(v.raw[4:])) | |
| 1522 | + | } | |
| 1523 | + | func (v SetupFailedView) Length() uint16 { return uint16(binary.LittleEndian.Uint16(v.raw[6:])) } | |
| 1524 | + | func (v SetupFailedView) Reason() []byte { | |
| 1525 | + | off := 8 | |
| 1526 | + | end := off + int(v.ReasonLen()) | |
| 1527 | + | return v.raw[off:end:end] | |
| 1528 | + | } | |
| 1529 | + | ||
| 1530 | + | // SetupFailedIter walks n consecutive SetupFailed elements; Err reports a malformed length. | |
| 1531 | + | // It shares the lifetime of the bytes it walks. | |
| 1532 | + | type SetupFailedIter struct { | |
| 1533 | + | b []byte | |
| 1534 | + | n int | |
| 1535 | + | v SetupFailedView | |
| 1536 | + | err bool | |
| 1537 | + | } | |
| 1538 | + | ||
| 1539 | + | // NewSetupFailedIter iterates n elements encoded at the start of b. | |
| 1540 | + | func NewSetupFailedIter(b []byte, n int) SetupFailedIter { return SetupFailedIter{b: b, n: n} } | |
| 1541 | + | func (it *SetupFailedIter) Next() bool { | |
| 1542 | + | if it.n <= 0 || it.err { | |
| 1543 | + | return false | |
| 1544 | + | } | |
| 1545 | + | s := sizeSetupFailed(it.b) | |
| 1546 | + | if s < 0 { | |
| 1547 | + | it.err = true | |
| 1548 | + | it.n = 0 | |
| 1549 | + | return false | |
| 1550 | + | } | |
| 1551 | + | it.v = SetupFailedView{raw: it.b[:s:s]} | |
| 1552 | + | it.b = it.b[s:] | |
| 1553 | + | it.n-- | |
| 1554 | + | return true | |
| 1555 | + | } | |
| 1556 | + | func (it *SetupFailedIter) Value() SetupFailedView { return it.v } | |
| 1557 | + | func (it *SetupFailedIter) Err() bool { return it.err } | |
| 1558 | + | ||
| 1559 | + | // SetupAuthenticateView is a zero-copy view over one wire-encoded SetupAuthenticate, yielded by SetupAuthenticateIter. | |
| 1560 | + | // It shares the lifetime of the bytes it was taken from (for replies: until the Handler callback returns). Copy what you keep. | |
| 1561 | + | type SetupAuthenticateView struct{ raw []byte } | |
| 1562 | + | ||
| 1563 | + | func (v SetupAuthenticateView) Raw() []byte { return v.raw } | |
| 1564 | + | ||
| 1565 | + | // Size is the element's wire size, including trailing alignment. | |
| 1566 | + | func (v SetupAuthenticateView) Size() int { return len(v.raw) } | |
| 1567 | + | func sizeSetupAuthenticate(p []byte) int { | |
| 1568 | + | if len(p) < 8 { | |
| 1569 | + | return -1 | |
| 1570 | + | } | |
| 1571 | + | v := SetupAuthenticateView{raw: p} | |
| 1572 | + | _ = v | |
| 1573 | + | off := 8 | |
| 1574 | + | { | |
| 1575 | + | n := (int(v.Length()) * 4) | |
| 1576 | + | if n < 0 || n > len(v.raw) { | |
| 1577 | + | return -1 | |
| 1578 | + | } | |
| 1579 | + | off += n * 1 | |
| 1580 | + | } | |
| 1581 | + | if off > len(v.raw) { | |
| 1582 | + | return -1 | |
| 1583 | + | } | |
| 1584 | + | if off > len(v.raw) { | |
| 1585 | + | return -1 | |
| 1586 | + | } | |
| 1587 | + | return off | |
| 1588 | + | } | |
| 1589 | + | func (v SetupAuthenticateView) Status() uint8 { return uint8(v.raw[0:][0]) } | |
| 1590 | + | func (v SetupAuthenticateView) Length() uint16 { return uint16(binary.LittleEndian.Uint16(v.raw[6:])) } | |
| 1591 | + | func (v SetupAuthenticateView) Reason() []byte { | |
| 1592 | + | off := 8 | |
| 1593 | + | end := off + (int(v.Length()) * 4) | |
| 1594 | + | return v.raw[off:end:end] | |
| 1595 | + | } | |
| 1596 | + | ||
| 1597 | + | // SetupAuthenticateIter walks n consecutive SetupAuthenticate elements; Err reports a malformed length. | |
| 1598 | + | // It shares the lifetime of the bytes it walks. | |
| 1599 | + | type SetupAuthenticateIter struct { | |
| 1600 | + | b []byte | |
| 1601 | + | n int | |
| 1602 | + | v SetupAuthenticateView | |
| 1603 | + | err bool | |
| 1604 | + | } | |
| 1605 | + | ||
| 1606 | + | // NewSetupAuthenticateIter iterates n elements encoded at the start of b. | |
| 1607 | + | func NewSetupAuthenticateIter(b []byte, n int) SetupAuthenticateIter { | |
| 1608 | + | return SetupAuthenticateIter{b: b, n: n} | |
| 1609 | + | } | |
| 1610 | + | func (it *SetupAuthenticateIter) Next() bool { | |
| 1611 | + | if it.n <= 0 || it.err { | |
| 1612 | + | return false | |
| 1613 | + | } | |
| 1614 | + | s := sizeSetupAuthenticate(it.b) | |
| 1615 | + | if s < 0 { | |
| 1616 | + | it.err = true | |
| 1617 | + | it.n = 0 | |
| 1618 | + | return false | |
| 1619 | + | } | |
| 1620 | + | it.v = SetupAuthenticateView{raw: it.b[:s:s]} | |
| 1621 | + | it.b = it.b[s:] | |
| 1622 | + | it.n-- | |
| 1623 | + | return true | |
| 1624 | + | } | |
| 1625 | + | func (it *SetupAuthenticateIter) Value() SetupAuthenticateView { return it.v } | |
| 1626 | + | func (it *SetupAuthenticateIter) Err() bool { return it.err } | |
| 1627 | + | ||
| 1628 | + | // SetupView is a zero-copy view over one wire-encoded Setup, yielded by SetupIter. | |
| 1629 | + | // It shares the lifetime of the bytes it was taken from (for replies: until the Handler callback returns). Copy what you keep. | |
| 1630 | + | type SetupView struct{ raw []byte } | |
| 1631 | + | ||
| 1632 | + | func (v SetupView) Raw() []byte { return v.raw } | |
| 1633 | + | ||
| 1634 | + | // Size is the element's wire size, including trailing alignment. | |
| 1635 | + | func (v SetupView) Size() int { return len(v.raw) } | |
| 1636 | + | func sizeSetup(p []byte) int { | |
| 1637 | + | if len(p) < 40 { | |
| 1638 | + | return -1 | |
| 1639 | + | } | |
| 1640 | + | v := SetupView{raw: p} | |
| 1641 | + | _ = v | |
| 1642 | + | off := 40 | |
| 1643 | + | { | |
| 1644 | + | n := int(v.VendorLen()) | |
| 1645 | + | if n < 0 || n > len(v.raw) { | |
| 1646 | + | return -1 | |
| 1647 | + | } | |
| 1648 | + | off += n * 1 | |
| 1649 | + | } | |
| 1650 | + | if off > len(v.raw) { | |
| 1651 | + | return -1 | |
| 1652 | + | } | |
| 1653 | + | off = (off + 3) &^ 3 | |
| 1654 | + | { | |
| 1655 | + | n := int(v.PixmapFormatsLen()) | |
| 1656 | + | if n < 0 || n > len(v.raw) { | |
| 1657 | + | return -1 | |
| 1658 | + | } | |
| 1659 | + | off += n * 8 | |
| 1660 | + | } | |
| 1661 | + | if off > len(v.raw) { | |
| 1662 | + | return -1 | |
| 1663 | + | } | |
| 1664 | + | { | |
| 1665 | + | n := int(v.RootsLen()) | |
| 1666 | + | if off > len(v.raw) || n < 0 || n > len(v.raw) { | |
| 1667 | + | return -1 | |
| 1668 | + | } | |
| 1669 | + | it := NewScreenIter(v.raw[off:], n) | |
| 1670 | + | for it.Next() { | |
| 1671 | + | off += it.Value().Size() | |
| 1672 | + | } | |
| 1673 | + | if it.Err() { | |
| 1674 | + | return -1 | |
| 1675 | + | } | |
| 1676 | + | } | |
| 1677 | + | if off > len(v.raw) { | |
| 1678 | + | return -1 | |
| 1679 | + | } | |
| 1680 | + | return off | |
| 1681 | + | } | |
| 1682 | + | func (v SetupView) Status() uint8 { return uint8(v.raw[0:][0]) } | |
| 1683 | + | func (v SetupView) ProtocolMajorVersion() uint16 { | |
| 1684 | + | return uint16(binary.LittleEndian.Uint16(v.raw[2:])) | |
| 1685 | + | } | |
| 1686 | + | func (v SetupView) ProtocolMinorVersion() uint16 { | |
| 1687 | + | return uint16(binary.LittleEndian.Uint16(v.raw[4:])) | |
| 1688 | + | } | |
| 1689 | + | func (v SetupView) Length() uint16 { return uint16(binary.LittleEndian.Uint16(v.raw[6:])) } | |
| 1690 | + | func (v SetupView) ReleaseNumber() uint32 { return uint32(binary.LittleEndian.Uint32(v.raw[8:])) } | |
| 1691 | + | func (v SetupView) ResourceIdBase() uint32 { return uint32(binary.LittleEndian.Uint32(v.raw[12:])) } | |
| 1692 | + | func (v SetupView) ResourceIdMask() uint32 { return uint32(binary.LittleEndian.Uint32(v.raw[16:])) } | |
| 1693 | + | func (v SetupView) MotionBufferSize() uint32 { return uint32(binary.LittleEndian.Uint32(v.raw[20:])) } | |
| 1694 | + | func (v SetupView) VendorLen() uint16 { return uint16(binary.LittleEndian.Uint16(v.raw[24:])) } | |
| 1695 | + | func (v SetupView) MaximumRequestLength() uint16 { | |
| 1696 | + | return uint16(binary.LittleEndian.Uint16(v.raw[26:])) | |
| 1697 | + | } | |
| 1698 | + | func (v SetupView) RootsLen() uint8 { return uint8(v.raw[28:][0]) } | |
| 1699 | + | func (v SetupView) PixmapFormatsLen() uint8 { return uint8(v.raw[29:][0]) } | |
| 1700 | + | func (v SetupView) ImageByteOrder() ImageOrder { return ImageOrder(v.raw[30:][0]) } | |
| 1701 | + | func (v SetupView) BitmapFormatBitOrder() ImageOrder { return ImageOrder(v.raw[31:][0]) } | |
| 1702 | + | func (v SetupView) BitmapFormatScanlineUnit() uint8 { return uint8(v.raw[32:][0]) } | |
| 1703 | + | func (v SetupView) BitmapFormatScanlinePad() uint8 { return uint8(v.raw[33:][0]) } | |
| 1704 | + | func (v SetupView) MinKeycode() Keycode { return Keycode(v.raw[34:][0]) } | |
| 1705 | + | func (v SetupView) MaxKeycode() Keycode { return Keycode(v.raw[35:][0]) } | |
| 1706 | + | func (v SetupView) Vendor() []byte { | |
| 1707 | + | off := 40 | |
| 1708 | + | end := off + int(v.VendorLen()) | |
| 1709 | + | return v.raw[off:end:end] | |
| 1710 | + | } | |
| 1711 | + | func (v SetupView) PixmapFormats() FormatList { | |
| 1712 | + | off := 40 | |
| 1713 | + | { | |
| 1714 | + | n := int(v.VendorLen()) | |
| 1715 | + | off += n * 1 | |
| 1716 | + | } | |
| 1717 | + | off = (off + 3) &^ 3 | |
| 1718 | + | end := off + (int(v.PixmapFormatsLen()))*8 | |
| 1719 | + | return FormatList{b: v.raw[off:end:end]} | |
| 1720 | + | } | |
| 1721 | + | func (v SetupView) Roots() ScreenIter { | |
| 1722 | + | off := 40 | |
| 1723 | + | { | |
| 1724 | + | n := int(v.VendorLen()) | |
| 1725 | + | off += n * 1 | |
| 1726 | + | } | |
| 1727 | + | off = (off + 3) &^ 3 | |
| 1728 | + | { | |
| 1729 | + | n := int(v.PixmapFormatsLen()) | |
| 1730 | + | off += n * 8 | |
| 1731 | + | } | |
| 1732 | + | return NewScreenIter(v.raw[off:], int(v.RootsLen())) | |
| 1733 | + | } | |
| 1734 | + | ||
| 1735 | + | // SetupIter walks n consecutive Setup elements; Err reports a malformed length. | |
| 1736 | + | // It shares the lifetime of the bytes it walks. | |
| 1737 | + | type SetupIter struct { | |
| 1738 | + | b []byte | |
| 1739 | + | n int | |
| 1740 | + | v SetupView | |
| 1741 | + | err bool | |
| 1742 | + | } | |
| 1743 | + | ||
| 1744 | + | // NewSetupIter iterates n elements encoded at the start of b. | |
| 1745 | + | func NewSetupIter(b []byte, n int) SetupIter { return SetupIter{b: b, n: n} } | |
| 1746 | + | func (it *SetupIter) Next() bool { | |
| 1747 | + | if it.n <= 0 || it.err { | |
| 1748 | + | return false | |
| 1749 | + | } | |
| 1750 | + | s := sizeSetup(it.b) | |
| 1751 | + | if s < 0 { | |
| 1752 | + | it.err = true | |
| 1753 | + | it.n = 0 | |
| 1754 | + | return false | |
| 1755 | + | } | |
| 1756 | + | it.v = SetupView{raw: it.b[:s:s]} | |
| 1757 | + | it.b = it.b[s:] | |
| 1758 | + | it.n-- | |
| 1759 | + | return true | |
| 1760 | + | } | |
| 1761 | + | func (it *SetupIter) Value() SetupView { return it.v } | |
| 1762 | + | func (it *SetupIter) Err() bool { return it.err } | |
| 1763 | + | ||
| 1764 | + | // StrView is a zero-copy view over one wire-encoded Str, yielded by StrIter. | |
| 1765 | + | // It shares the lifetime of the bytes it was taken from (for replies: until the Handler callback returns). Copy what you keep. | |
| 1766 | + | type StrView struct{ raw []byte } | |
| 1767 | + | ||
| 1768 | + | func (v StrView) Raw() []byte { return v.raw } | |
| 1769 | + | ||
| 1770 | + | // Size is the element's wire size, including trailing alignment. | |
| 1771 | + | func (v StrView) Size() int { return len(v.raw) } | |
| 1772 | + | func sizeStr(p []byte) int { | |
| 1773 | + | if len(p) < 1 { | |
| 1774 | + | return -1 | |
| 1775 | + | } | |
| 1776 | + | v := StrView{raw: p} | |
| 1777 | + | _ = v | |
| 1778 | + | off := 1 | |
| 1779 | + | { | |
| 1780 | + | n := int(v.NameLen()) | |
| 1781 | + | if n < 0 || n > len(v.raw) { | |
| 1782 | + | return -1 | |
| 1783 | + | } | |
| 1784 | + | off += n * 1 | |
| 1785 | + | } | |
| 1786 | + | if off > len(v.raw) { | |
| 1787 | + | return -1 | |
| 1788 | + | } | |
| 1789 | + | if off > len(v.raw) { | |
| 1790 | + | return -1 | |
| 1791 | + | } | |
| 1792 | + | return off | |
| 1793 | + | } | |
| 1794 | + | func (v StrView) NameLen() uint8 { return uint8(v.raw[0:][0]) } | |
| 1795 | + | func (v StrView) Name() []byte { off := 1; end := off + int(v.NameLen()); return v.raw[off:end:end] } | |
| 1796 | + | ||
| 1797 | + | // StrIter walks n consecutive Str elements; Err reports a malformed length. | |
| 1798 | + | // It shares the lifetime of the bytes it walks. | |
| 1799 | + | type StrIter struct { | |
| 1800 | + | b []byte | |
| 1801 | + | n int | |
| 1802 | + | v StrView | |
| 1803 | + | err bool | |
| 1804 | + | } | |
| 1805 | + | ||
| 1806 | + | // NewStrIter iterates n elements encoded at the start of b. | |
| 1807 | + | func NewStrIter(b []byte, n int) StrIter { return StrIter{b: b, n: n} } | |
| 1808 | + | func (it *StrIter) Next() bool { | |
| 1809 | + | if it.n <= 0 || it.err { | |
| 1810 | + | return false | |
| 1811 | + | } | |
| 1812 | + | s := sizeStr(it.b) | |
| 1813 | + | if s < 0 { | |
| 1814 | + | it.err = true | |
| 1815 | + | it.n = 0 | |
| 1816 | + | return false | |
| 1817 | + | } | |
| 1818 | + | it.v = StrView{raw: it.b[:s:s]} | |
| 1819 | + | it.b = it.b[s:] | |
| 1820 | + | it.n-- | |
| 1821 | + | return true | |
| 1822 | + | } | |
| 1823 | + | func (it *StrIter) Value() StrView { return it.v } | |
| 1824 | + | func (it *StrIter) Err() bool { return it.err } | |
| 1825 | + | ||
| 1826 | + | // HostView is a zero-copy view over one wire-encoded Host, yielded by HostIter. | |
| 1827 | + | // It shares the lifetime of the bytes it was taken from (for replies: until the Handler callback returns). Copy what you keep. | |
| 1828 | + | type HostView struct{ raw []byte } | |
| 1829 | + | ||
| 1830 | + | func (v HostView) Raw() []byte { return v.raw } | |
| 1831 | + | ||
| 1832 | + | // Size is the element's wire size, including trailing alignment. | |
| 1833 | + | func (v HostView) Size() int { return len(v.raw) } | |
| 1834 | + | func sizeHost(p []byte) int { | |
| 1835 | + | if len(p) < 4 { | |
| 1836 | + | return -1 | |
| 1837 | + | } | |
| 1838 | + | v := HostView{raw: p} | |
| 1839 | + | _ = v | |
| 1840 | + | off := 4 | |
| 1841 | + | { | |
| 1842 | + | n := int(v.AddressLen()) | |
| 1843 | + | if n < 0 || n > len(v.raw) { | |
| 1844 | + | return -1 | |
| 1845 | + | } | |
| 1846 | + | off += n * 1 | |
| 1847 | + | } | |
| 1848 | + | if off > len(v.raw) { | |
| 1849 | + | return -1 | |
| 1850 | + | } | |
| 1851 | + | off = (off + 3) &^ 3 | |
| 1852 | + | if off > len(v.raw) { | |
| 1853 | + | return -1 | |
| 1854 | + | } | |
| 1855 | + | return off | |
| 1856 | + | } | |
| 1857 | + | func (v HostView) Family() Family { return Family(v.raw[0:][0]) } | |
| 1858 | + | func (v HostView) AddressLen() uint16 { return uint16(binary.LittleEndian.Uint16(v.raw[2:])) } | |
| 1859 | + | func (v HostView) Address() []byte { | |
| 1860 | + | off := 4 | |
| 1861 | + | end := off + int(v.AddressLen()) | |
| 1862 | + | return v.raw[off:end:end] | |
| 1863 | + | } | |
| 1864 | + | ||
| 1865 | + | // HostIter walks n consecutive Host elements; Err reports a malformed length. | |
| 1866 | + | // It shares the lifetime of the bytes it walks. | |
| 1867 | + | type HostIter struct { | |
| 1868 | + | b []byte | |
| 1869 | + | n int | |
| 1870 | + | v HostView | |
| 1871 | + | err bool | |
| 1872 | + | } | |
| 1873 | + | ||
| 1874 | + | // NewHostIter iterates n elements encoded at the start of b. | |
| 1875 | + | func NewHostIter(b []byte, n int) HostIter { return HostIter{b: b, n: n} } | |
| 1876 | + | func (it *HostIter) Next() bool { | |
| 1877 | + | if it.n <= 0 || it.err { | |
| 1878 | + | return false | |
| 1879 | + | } | |
| 1880 | + | s := sizeHost(it.b) | |
| 1881 | + | if s < 0 { | |
| 1882 | + | it.err = true | |
| 1883 | + | it.n = 0 | |
| 1884 | + | return false | |
| 1885 | + | } | |
| 1886 | + | it.v = HostView{raw: it.b[:s:s]} | |
| 1887 | + | it.b = it.b[s:] | |
| 1888 | + | it.n-- | |
| 1889 | + | return true | |
| 1890 | + | } | |
| 1891 | + | func (it *HostIter) Value() HostView { return it.v } | |
| 1892 | + | func (it *HostIter) Err() bool { return it.err } | |
| 1893 | + | ||
| 1894 | + | // AtomList is a borrowed view over a wire list of Atom. It shares the lifetime of the bytes it was taken from; copy what you keep. | |
| 1895 | + | type AtomList struct{ b []byte } | |
| 1896 | + | ||
| 1897 | + | func (l AtomList) Len() int { return len(l.b) / 4 } | |
| 1898 | + | func (l AtomList) At(i int) Atom { return Atom(binary.LittleEndian.Uint32(l.b[i*4:])) } | |
| 1899 | + | ||
| 1900 | + | // CharinfoList is a borrowed view over a wire list of Charinfo. It shares the lifetime of the bytes it was taken from; copy what you keep. | |
| 1901 | + | type CharinfoList struct{ b []byte } | |
| 1902 | + | ||
| 1903 | + | func (l CharinfoList) Len() int { return len(l.b) / 12 } | |
| 1904 | + | func (l CharinfoList) At(i int) Charinfo { return GetCharinfo(l.b[i*12:]) } | |
| 1905 | + | ||
| 1906 | + | // ColormapList is a borrowed view over a wire list of Colormap. It shares the lifetime of the bytes it was taken from; copy what you keep. | |
| 1907 | + | type ColormapList struct{ b []byte } | |
| 1908 | + | ||
| 1909 | + | func (l ColormapList) Len() int { return len(l.b) / 4 } | |
| 1910 | + | func (l ColormapList) At(i int) Colormap { return Colormap(binary.LittleEndian.Uint32(l.b[i*4:])) } | |
| 1911 | + | ||
| 1912 | + | // FontpropList is a borrowed view over a wire list of Fontprop. It shares the lifetime of the bytes it was taken from; copy what you keep. | |
| 1913 | + | type FontpropList struct{ b []byte } | |
| 1914 | + | ||
| 1915 | + | func (l FontpropList) Len() int { return len(l.b) / 8 } | |
| 1916 | + | func (l FontpropList) At(i int) Fontprop { return GetFontprop(l.b[i*8:]) } | |
| 1917 | + | ||
| 1918 | + | // FormatList is a borrowed view over a wire list of Format. It shares the lifetime of the bytes it was taken from; copy what you keep. | |
| 1919 | + | type FormatList struct{ b []byte } | |
| 1920 | + | ||
| 1921 | + | func (l FormatList) Len() int { return len(l.b) / 8 } | |
| 1922 | + | func (l FormatList) At(i int) Format { return GetFormat(l.b[i*8:]) } | |
| 1923 | + | ||
| 1924 | + | // KeycodeList is a borrowed view over a wire list of Keycode. It shares the lifetime of the bytes it was taken from; copy what you keep. | |
| 1925 | + | type KeycodeList struct{ b []byte } | |
| 1926 | + | ||
| 1927 | + | func (l KeycodeList) Len() int { return len(l.b) / 1 } | |
| 1928 | + | func (l KeycodeList) At(i int) Keycode { return Keycode(l.b[i*1:][0]) } | |
| 1929 | + | ||
| 1930 | + | // KeysymList is a borrowed view over a wire list of Keysym. It shares the lifetime of the bytes it was taken from; copy what you keep. | |
| 1931 | + | type KeysymList struct{ b []byte } | |
| 1932 | + | ||
| 1933 | + | func (l KeysymList) Len() int { return len(l.b) / 4 } | |
| 1934 | + | func (l KeysymList) At(i int) Keysym { return Keysym(binary.LittleEndian.Uint32(l.b[i*4:])) } | |
| 1935 | + | ||
| 1936 | + | // RgbList is a borrowed view over a wire list of Rgb. It shares the lifetime of the bytes it was taken from; copy what you keep. | |
| 1937 | + | type RgbList struct{ b []byte } | |
| 1938 | + | ||
| 1939 | + | func (l RgbList) Len() int { return len(l.b) / 8 } | |
| 1940 | + | func (l RgbList) At(i int) Rgb { return GetRgb(l.b[i*8:]) } | |
| 1941 | + | ||
| 1942 | + | // TimecoordList is a borrowed view over a wire list of Timecoord. It shares the lifetime of the bytes it was taken from; copy what you keep. | |
| 1943 | + | type TimecoordList struct{ b []byte } | |
| 1944 | + | ||
| 1945 | + | func (l TimecoordList) Len() int { return len(l.b) / 8 } | |
| 1946 | + | func (l TimecoordList) At(i int) Timecoord { return GetTimecoord(l.b[i*8:]) } | |
| 1947 | + | ||
| 1948 | + | // Uint32List is a borrowed view over a wire list of uint32. It shares the lifetime of the bytes it was taken from; copy what you keep. | |
| 1949 | + | type Uint32List struct{ b []byte } | |
| 1950 | + | ||
| 1951 | + | func (l Uint32List) Len() int { return len(l.b) / 4 } | |
| 1952 | + | func (l Uint32List) At(i int) uint32 { return uint32(binary.LittleEndian.Uint32(l.b[i*4:])) } | |
| 1953 | + | ||
| 1954 | + | // VisualtypeList is a borrowed view over a wire list of Visualtype. It shares the lifetime of the bytes it was taken from; copy what you keep. | |
| 1955 | + | type VisualtypeList struct{ b []byte } | |
| 1956 | + | ||
| 1957 | + | func (l VisualtypeList) Len() int { return len(l.b) / 24 } | |
| 1958 | + | func (l VisualtypeList) At(i int) Visualtype { return GetVisualtype(l.b[i*24:]) } | |
| 1959 | + | ||
| 1960 | + | // WindowList is a borrowed view over a wire list of Window. It shares the lifetime of the bytes it was taken from; copy what you keep. | |
| 1961 | + | type WindowList struct{ b []byte } | |
| 1962 | + | ||
| 1963 | + | func (l WindowList) Len() int { return len(l.b) / 4 } | |
| 1964 | + | func (l WindowList) At(i int) Window { return Window(binary.LittleEndian.Uint32(l.b[i*4:])) } | |
A xproto/requests_generated.go +2780 -0
| @@ -0,0 +1,2780 @@ | |||
| 1 | + | // Code generated by xtgen; DO NOT EDIT. | |
| 2 | + | package xproto | |
| 3 | + | ||
| 4 | + | import "encoding/binary" | |
| 5 | + | import "math/bits" | |
| 6 | + | import "bnema.dev/xturbo" | |
| 7 | + | ||
| 8 | + | type CreateWindowValues struct { | |
| 9 | + | Mask Cw | |
| 10 | + | BackgroundPixmap Pixmap | |
| 11 | + | BackgroundPixel uint32 | |
| 12 | + | BorderPixmap Pixmap | |
| 13 | + | BorderPixel uint32 | |
| 14 | + | BitGravity Gravity | |
| 15 | + | WinGravity Gravity | |
| 16 | + | BackingStore BackingStore | |
| 17 | + | BackingPlanes uint32 | |
| 18 | + | BackingPixel uint32 | |
| 19 | + | OverrideRedirect bool | |
| 20 | + | SaveUnder bool | |
| 21 | + | EventMask EventMask | |
| 22 | + | DoNotPropogateMask EventMask | |
| 23 | + | Colormap Colormap | |
| 24 | + | Cursor Cursor | |
| 25 | + | } | |
| 26 | + | ||
| 27 | + | func (v *CreateWindowValues) SetBackgroundPixmap(x Pixmap) *CreateWindowValues { | |
| 28 | + | v.Mask |= CwBackPixmap | |
| 29 | + | v.BackgroundPixmap = x | |
| 30 | + | return v | |
| 31 | + | } | |
| 32 | + | func (v *CreateWindowValues) SetBackgroundPixel(x uint32) *CreateWindowValues { | |
| 33 | + | v.Mask |= CwBackPixel | |
| 34 | + | v.BackgroundPixel = x | |
| 35 | + | return v | |
| 36 | + | } | |
| 37 | + | func (v *CreateWindowValues) SetBorderPixmap(x Pixmap) *CreateWindowValues { | |
| 38 | + | v.Mask |= CwBorderPixmap | |
| 39 | + | v.BorderPixmap = x | |
| 40 | + | return v | |
| 41 | + | } | |
| 42 | + | func (v *CreateWindowValues) SetBorderPixel(x uint32) *CreateWindowValues { | |
| 43 | + | v.Mask |= CwBorderPixel | |
| 44 | + | v.BorderPixel = x | |
| 45 | + | return v | |
| 46 | + | } | |
| 47 | + | func (v *CreateWindowValues) SetBitGravity(x Gravity) *CreateWindowValues { | |
| 48 | + | v.Mask |= CwBitGravity | |
| 49 | + | v.BitGravity = x | |
| 50 | + | return v | |
| 51 | + | } | |
| 52 | + | func (v *CreateWindowValues) SetWinGravity(x Gravity) *CreateWindowValues { | |
| 53 | + | v.Mask |= CwWinGravity | |
| 54 | + | v.WinGravity = x | |
| 55 | + | return v | |
| 56 | + | } | |
| 57 | + | func (v *CreateWindowValues) SetBackingStore(x BackingStore) *CreateWindowValues { | |
| 58 | + | v.Mask |= CwBackingStore | |
| 59 | + | v.BackingStore = x | |
| 60 | + | return v | |
| 61 | + | } | |
| 62 | + | func (v *CreateWindowValues) SetBackingPlanes(x uint32) *CreateWindowValues { | |
| 63 | + | v.Mask |= CwBackingPlanes | |
| 64 | + | v.BackingPlanes = x | |
| 65 | + | return v | |
| 66 | + | } | |
| 67 | + | func (v *CreateWindowValues) SetBackingPixel(x uint32) *CreateWindowValues { | |
| 68 | + | v.Mask |= CwBackingPixel | |
| 69 | + | v.BackingPixel = x | |
| 70 | + | return v | |
| 71 | + | } | |
| 72 | + | func (v *CreateWindowValues) SetOverrideRedirect(x bool) *CreateWindowValues { | |
| 73 | + | v.Mask |= CwOverrideRedirect | |
| 74 | + | v.OverrideRedirect = x | |
| 75 | + | return v | |
| 76 | + | } | |
| 77 | + | func (v *CreateWindowValues) SetSaveUnder(x bool) *CreateWindowValues { | |
| 78 | + | v.Mask |= CwSaveUnder | |
| 79 | + | v.SaveUnder = x | |
| 80 | + | return v | |
| 81 | + | } | |
| 82 | + | func (v *CreateWindowValues) SetEventMask(x EventMask) *CreateWindowValues { | |
| 83 | + | v.Mask |= CwEventMask | |
| 84 | + | v.EventMask = x | |
| 85 | + | return v | |
| 86 | + | } | |
| 87 | + | func (v *CreateWindowValues) SetDoNotPropogateMask(x EventMask) *CreateWindowValues { | |
| 88 | + | v.Mask |= CwDontPropagate | |
| 89 | + | v.DoNotPropogateMask = x | |
| 90 | + | return v | |
| 91 | + | } | |
| 92 | + | func (v *CreateWindowValues) SetColormap(x Colormap) *CreateWindowValues { | |
| 93 | + | v.Mask |= CwColormap | |
| 94 | + | v.Colormap = x | |
| 95 | + | return v | |
| 96 | + | } | |
| 97 | + | func (v *CreateWindowValues) SetCursor(x Cursor) *CreateWindowValues { | |
| 98 | + | v.Mask |= CwCursor | |
| 99 | + | v.Cursor = x | |
| 100 | + | return v | |
| 101 | + | } | |
| 102 | + | func CreateWindow(b *xturbo.Buf, depth uint8, wid Window, parent Window, x int16, y int16, width uint16, height uint16, borderWidth uint16, class WindowClass, visual Visualid, v *CreateWindowValues) xturbo.Seq { | |
| 103 | + | p, seq := b.Request(1, uint8(int(depth)), 28+4*bits.OnesCount32(uint32(v.Mask))) | |
| 104 | + | if p == nil { | |
| 105 | + | return 0 | |
| 106 | + | } | |
| 107 | + | binary.LittleEndian.PutUint32(p[0:], uint32(wid)) | |
| 108 | + | binary.LittleEndian.PutUint32(p[4:], uint32(parent)) | |
| 109 | + | binary.LittleEndian.PutUint16(p[8:], uint16(x)) | |
| 110 | + | binary.LittleEndian.PutUint16(p[10:], uint16(y)) | |
| 111 | + | binary.LittleEndian.PutUint16(p[12:], uint16(width)) | |
| 112 | + | binary.LittleEndian.PutUint16(p[14:], uint16(height)) | |
| 113 | + | binary.LittleEndian.PutUint16(p[16:], uint16(borderWidth)) | |
| 114 | + | binary.LittleEndian.PutUint16(p[18:], uint16(class)) | |
| 115 | + | binary.LittleEndian.PutUint32(p[20:], uint32(visual)) | |
| 116 | + | binary.LittleEndian.PutUint32(p[24:], uint32(v.Mask)) | |
| 117 | + | off := 28 | |
| 118 | + | if v.Mask&CwBackPixmap != 0 { | |
| 119 | + | binary.LittleEndian.PutUint32(p[off:], uint32(v.BackgroundPixmap)) | |
| 120 | + | off += 4 | |
| 121 | + | } | |
| 122 | + | if v.Mask&CwBackPixel != 0 { | |
| 123 | + | binary.LittleEndian.PutUint32(p[off:], uint32(v.BackgroundPixel)) | |
| 124 | + | off += 4 | |
| 125 | + | } | |
| 126 | + | if v.Mask&CwBorderPixmap != 0 { | |
| 127 | + | binary.LittleEndian.PutUint32(p[off:], uint32(v.BorderPixmap)) | |
| 128 | + | off += 4 | |
| 129 | + | } | |
| 130 | + | if v.Mask&CwBorderPixel != 0 { | |
| 131 | + | binary.LittleEndian.PutUint32(p[off:], uint32(v.BorderPixel)) | |
| 132 | + | off += 4 | |
| 133 | + | } | |
| 134 | + | if v.Mask&CwBitGravity != 0 { | |
| 135 | + | binary.LittleEndian.PutUint32(p[off:], uint32(v.BitGravity)) | |
| 136 | + | off += 4 | |
| 137 | + | } | |
| 138 | + | if v.Mask&CwWinGravity != 0 { | |
| 139 | + | binary.LittleEndian.PutUint32(p[off:], uint32(v.WinGravity)) | |
| 140 | + | off += 4 | |
| 141 | + | } | |
| 142 | + | if v.Mask&CwBackingStore != 0 { | |
| 143 | + | binary.LittleEndian.PutUint32(p[off:], uint32(v.BackingStore)) | |
| 144 | + | off += 4 | |
| 145 | + | } | |
| 146 | + | if v.Mask&CwBackingPlanes != 0 { | |
| 147 | + | binary.LittleEndian.PutUint32(p[off:], uint32(v.BackingPlanes)) | |
| 148 | + | off += 4 | |
| 149 | + | } | |
| 150 | + | if v.Mask&CwBackingPixel != 0 { | |
| 151 | + | binary.LittleEndian.PutUint32(p[off:], uint32(v.BackingPixel)) | |
| 152 | + | off += 4 | |
| 153 | + | } | |
| 154 | + | if v.Mask&CwOverrideRedirect != 0 { | |
| 155 | + | if v.OverrideRedirect { | |
| 156 | + | binary.LittleEndian.PutUint32(p[off:], 1) | |
| 157 | + | } else { | |
| 158 | + | binary.LittleEndian.PutUint32(p[off:], 0) | |
| 159 | + | } | |
| 160 | + | off += 4 | |
| 161 | + | } | |
| 162 | + | if v.Mask&CwSaveUnder != 0 { | |
| 163 | + | if v.SaveUnder { | |
| 164 | + | binary.LittleEndian.PutUint32(p[off:], 1) | |
| 165 | + | } else { | |
| 166 | + | binary.LittleEndian.PutUint32(p[off:], 0) | |
| 167 | + | } | |
| 168 | + | off += 4 | |
| 169 | + | } | |
| 170 | + | if v.Mask&CwEventMask != 0 { | |
| 171 | + | binary.LittleEndian.PutUint32(p[off:], uint32(v.EventMask)) | |
| 172 | + | off += 4 | |
| 173 | + | } | |
| 174 | + | if v.Mask&CwDontPropagate != 0 { | |
| 175 | + | binary.LittleEndian.PutUint32(p[off:], uint32(v.DoNotPropogateMask)) | |
| 176 | + | off += 4 | |
| 177 | + | } | |
| 178 | + | if v.Mask&CwColormap != 0 { | |
| 179 | + | binary.LittleEndian.PutUint32(p[off:], uint32(v.Colormap)) | |
| 180 | + | off += 4 | |
| 181 | + | } | |
| 182 | + | if v.Mask&CwCursor != 0 { | |
| 183 | + | binary.LittleEndian.PutUint32(p[off:], uint32(v.Cursor)) | |
| 184 | + | off += 4 | |
| 185 | + | } | |
| 186 | + | _ = off | |
| 187 | + | return seq | |
| 188 | + | } | |
| 189 | + | ||
| 190 | + | type ChangeWindowAttributesValues struct { | |
| 191 | + | Mask Cw | |
| 192 | + | BackgroundPixmap Pixmap | |
| 193 | + | BackgroundPixel uint32 | |
| 194 | + | BorderPixmap Pixmap | |
| 195 | + | BorderPixel uint32 | |
| 196 | + | BitGravity Gravity | |
| 197 | + | WinGravity Gravity | |
| 198 | + | BackingStore BackingStore | |
| 199 | + | BackingPlanes uint32 | |
| 200 | + | BackingPixel uint32 | |
| 201 | + | OverrideRedirect bool | |
| 202 | + | SaveUnder bool | |
| 203 | + | EventMask EventMask | |
| 204 | + | DoNotPropogateMask EventMask | |
| 205 | + | Colormap Colormap | |
| 206 | + | Cursor Cursor | |
| 207 | + | } | |
| 208 | + | ||
| 209 | + | func (v *ChangeWindowAttributesValues) SetBackgroundPixmap(x Pixmap) *ChangeWindowAttributesValues { | |
| 210 | + | v.Mask |= CwBackPixmap | |
| 211 | + | v.BackgroundPixmap = x | |
| 212 | + | return v | |
| 213 | + | } | |
| 214 | + | func (v *ChangeWindowAttributesValues) SetBackgroundPixel(x uint32) *ChangeWindowAttributesValues { | |
| 215 | + | v.Mask |= CwBackPixel | |
| 216 | + | v.BackgroundPixel = x | |
| 217 | + | return v | |
| 218 | + | } | |
| 219 | + | func (v *ChangeWindowAttributesValues) SetBorderPixmap(x Pixmap) *ChangeWindowAttributesValues { | |
| 220 | + | v.Mask |= CwBorderPixmap | |
| 221 | + | v.BorderPixmap = x | |
| 222 | + | return v | |
| 223 | + | } | |
| 224 | + | func (v *ChangeWindowAttributesValues) SetBorderPixel(x uint32) *ChangeWindowAttributesValues { | |
| 225 | + | v.Mask |= CwBorderPixel | |
| 226 | + | v.BorderPixel = x | |
| 227 | + | return v | |
| 228 | + | } | |
| 229 | + | func (v *ChangeWindowAttributesValues) SetBitGravity(x Gravity) *ChangeWindowAttributesValues { | |
| 230 | + | v.Mask |= CwBitGravity | |
| 231 | + | v.BitGravity = x | |
| 232 | + | return v | |
| 233 | + | } | |
| 234 | + | func (v *ChangeWindowAttributesValues) SetWinGravity(x Gravity) *ChangeWindowAttributesValues { | |
| 235 | + | v.Mask |= CwWinGravity | |
| 236 | + | v.WinGravity = x | |
| 237 | + | return v | |
| 238 | + | } | |
| 239 | + | func (v *ChangeWindowAttributesValues) SetBackingStore(x BackingStore) *ChangeWindowAttributesValues { | |
| 240 | + | v.Mask |= CwBackingStore | |
| 241 | + | v.BackingStore = x | |
| 242 | + | return v | |
| 243 | + | } | |
| 244 | + | func (v *ChangeWindowAttributesValues) SetBackingPlanes(x uint32) *ChangeWindowAttributesValues { | |
| 245 | + | v.Mask |= CwBackingPlanes | |
| 246 | + | v.BackingPlanes = x | |
| 247 | + | return v | |
| 248 | + | } | |
| 249 | + | func (v *ChangeWindowAttributesValues) SetBackingPixel(x uint32) *ChangeWindowAttributesValues { | |
| 250 | + | v.Mask |= CwBackingPixel | |
| 251 | + | v.BackingPixel = x | |
| 252 | + | return v | |
| 253 | + | } | |
| 254 | + | func (v *ChangeWindowAttributesValues) SetOverrideRedirect(x bool) *ChangeWindowAttributesValues { | |
| 255 | + | v.Mask |= CwOverrideRedirect | |
| 256 | + | v.OverrideRedirect = x | |
| 257 | + | return v | |
| 258 | + | } | |
| 259 | + | func (v *ChangeWindowAttributesValues) SetSaveUnder(x bool) *ChangeWindowAttributesValues { | |
| 260 | + | v.Mask |= CwSaveUnder | |
| 261 | + | v.SaveUnder = x | |
| 262 | + | return v | |
| 263 | + | } | |
| 264 | + | func (v *ChangeWindowAttributesValues) SetEventMask(x EventMask) *ChangeWindowAttributesValues { | |
| 265 | + | v.Mask |= CwEventMask | |
| 266 | + | v.EventMask = x | |
| 267 | + | return v | |
| 268 | + | } | |
| 269 | + | func (v *ChangeWindowAttributesValues) SetDoNotPropogateMask(x EventMask) *ChangeWindowAttributesValues { | |
| 270 | + | v.Mask |= CwDontPropagate | |
| 271 | + | v.DoNotPropogateMask = x | |
| 272 | + | return v | |
| 273 | + | } | |
| 274 | + | func (v *ChangeWindowAttributesValues) SetColormap(x Colormap) *ChangeWindowAttributesValues { | |
| 275 | + | v.Mask |= CwColormap | |
| 276 | + | v.Colormap = x | |
| 277 | + | return v | |
| 278 | + | } | |
| 279 | + | func (v *ChangeWindowAttributesValues) SetCursor(x Cursor) *ChangeWindowAttributesValues { | |
| 280 | + | v.Mask |= CwCursor | |
| 281 | + | v.Cursor = x | |
| 282 | + | return v | |
| 283 | + | } | |
| 284 | + | func ChangeWindowAttributes(b *xturbo.Buf, window Window, v *ChangeWindowAttributesValues) xturbo.Seq { | |
| 285 | + | p, seq := b.Request(2, 0, 8+4*bits.OnesCount32(uint32(v.Mask))) | |
| 286 | + | if p == nil { | |
| 287 | + | return 0 | |
| 288 | + | } | |
| 289 | + | binary.LittleEndian.PutUint32(p[0:], uint32(window)) | |
| 290 | + | binary.LittleEndian.PutUint32(p[4:], uint32(v.Mask)) | |
| 291 | + | off := 8 | |
| 292 | + | if v.Mask&CwBackPixmap != 0 { | |
| 293 | + | binary.LittleEndian.PutUint32(p[off:], uint32(v.BackgroundPixmap)) | |
| 294 | + | off += 4 | |
| 295 | + | } | |
| 296 | + | if v.Mask&CwBackPixel != 0 { | |
| 297 | + | binary.LittleEndian.PutUint32(p[off:], uint32(v.BackgroundPixel)) | |
| 298 | + | off += 4 | |
| 299 | + | } | |
| 300 | + | if v.Mask&CwBorderPixmap != 0 { | |
| 301 | + | binary.LittleEndian.PutUint32(p[off:], uint32(v.BorderPixmap)) | |
| 302 | + | off += 4 | |
| 303 | + | } | |
| 304 | + | if v.Mask&CwBorderPixel != 0 { | |
| 305 | + | binary.LittleEndian.PutUint32(p[off:], uint32(v.BorderPixel)) | |
| 306 | + | off += 4 | |
| 307 | + | } | |
| 308 | + | if v.Mask&CwBitGravity != 0 { | |
| 309 | + | binary.LittleEndian.PutUint32(p[off:], uint32(v.BitGravity)) | |
| 310 | + | off += 4 | |
| 311 | + | } | |
| 312 | + | if v.Mask&CwWinGravity != 0 { | |
| 313 | + | binary.LittleEndian.PutUint32(p[off:], uint32(v.WinGravity)) | |
| 314 | + | off += 4 | |
| 315 | + | } | |
| 316 | + | if v.Mask&CwBackingStore != 0 { | |
| 317 | + | binary.LittleEndian.PutUint32(p[off:], uint32(v.BackingStore)) | |
| 318 | + | off += 4 | |
| 319 | + | } | |
| 320 | + | if v.Mask&CwBackingPlanes != 0 { | |
| 321 | + | binary.LittleEndian.PutUint32(p[off:], uint32(v.BackingPlanes)) | |
| 322 | + | off += 4 | |
| 323 | + | } | |
| 324 | + | if v.Mask&CwBackingPixel != 0 { | |
| 325 | + | binary.LittleEndian.PutUint32(p[off:], uint32(v.BackingPixel)) | |
| 326 | + | off += 4 | |
| 327 | + | } | |
| 328 | + | if v.Mask&CwOverrideRedirect != 0 { | |
| 329 | + | if v.OverrideRedirect { | |
| 330 | + | binary.LittleEndian.PutUint32(p[off:], 1) | |
| 331 | + | } else { | |
| 332 | + | binary.LittleEndian.PutUint32(p[off:], 0) | |
| 333 | + | } | |
| 334 | + | off += 4 | |
| 335 | + | } | |
| 336 | + | if v.Mask&CwSaveUnder != 0 { | |
| 337 | + | if v.SaveUnder { | |
| 338 | + | binary.LittleEndian.PutUint32(p[off:], 1) | |
| 339 | + | } else { | |
| 340 | + | binary.LittleEndian.PutUint32(p[off:], 0) | |
| 341 | + | } | |
| 342 | + | off += 4 | |
| 343 | + | } | |
| 344 | + | if v.Mask&CwEventMask != 0 { | |
| 345 | + | binary.LittleEndian.PutUint32(p[off:], uint32(v.EventMask)) | |
| 346 | + | off += 4 | |
| 347 | + | } | |
| 348 | + | if v.Mask&CwDontPropagate != 0 { | |
| 349 | + | binary.LittleEndian.PutUint32(p[off:], uint32(v.DoNotPropogateMask)) | |
| 350 | + | off += 4 | |
| 351 | + | } | |
| 352 | + | if v.Mask&CwColormap != 0 { | |
| 353 | + | binary.LittleEndian.PutUint32(p[off:], uint32(v.Colormap)) | |
| 354 | + | off += 4 | |
| 355 | + | } | |
| 356 | + | if v.Mask&CwCursor != 0 { | |
| 357 | + | binary.LittleEndian.PutUint32(p[off:], uint32(v.Cursor)) | |
| 358 | + | off += 4 | |
| 359 | + | } | |
| 360 | + | _ = off | |
| 361 | + | return seq | |
| 362 | + | } | |
| 363 | + | ||
| 364 | + | func GetWindowAttributes(b *xturbo.Buf, window Window) xturbo.Seq { | |
| 365 | + | p, seq := b.Request(3, 0, 4) | |
| 366 | + | if p == nil { | |
| 367 | + | return 0 | |
| 368 | + | } | |
| 369 | + | binary.LittleEndian.PutUint32(p[0:], uint32(window)) | |
| 370 | + | return seq | |
| 371 | + | } | |
| 372 | + | ||
| 373 | + | func DestroyWindow(b *xturbo.Buf, window Window) xturbo.Seq { | |
| 374 | + | p, seq := b.Request(4, 0, 4) | |
| 375 | + | if p == nil { | |
| 376 | + | return 0 | |
| 377 | + | } | |
| 378 | + | binary.LittleEndian.PutUint32(p[0:], uint32(window)) | |
| 379 | + | return seq | |
| 380 | + | } | |
| 381 | + | ||
| 382 | + | func DestroySubwindows(b *xturbo.Buf, window Window) xturbo.Seq { | |
| 383 | + | p, seq := b.Request(5, 0, 4) | |
| 384 | + | if p == nil { | |
| 385 | + | return 0 | |
| 386 | + | } | |
| 387 | + | binary.LittleEndian.PutUint32(p[0:], uint32(window)) | |
| 388 | + | return seq | |
| 389 | + | } | |
| 390 | + | ||
| 391 | + | func ChangeSaveSet(b *xturbo.Buf, mode SetMode, window Window) xturbo.Seq { | |
| 392 | + | p, seq := b.Request(6, uint8(int(mode)), 4) | |
| 393 | + | if p == nil { | |
| 394 | + | return 0 | |
| 395 | + | } | |
| 396 | + | binary.LittleEndian.PutUint32(p[0:], uint32(window)) | |
| 397 | + | return seq | |
| 398 | + | } | |
| 399 | + | ||
| 400 | + | func ReparentWindow(b *xturbo.Buf, window Window, parent Window, x int16, y int16) xturbo.Seq { | |
| 401 | + | p, seq := b.Request(7, 0, 12) | |
| 402 | + | if p == nil { | |
| 403 | + | return 0 | |
| 404 | + | } | |
| 405 | + | binary.LittleEndian.PutUint32(p[0:], uint32(window)) | |
| 406 | + | binary.LittleEndian.PutUint32(p[4:], uint32(parent)) | |
| 407 | + | binary.LittleEndian.PutUint16(p[8:], uint16(x)) | |
| 408 | + | binary.LittleEndian.PutUint16(p[10:], uint16(y)) | |
| 409 | + | return seq | |
| 410 | + | } | |
| 411 | + | ||
| 412 | + | func MapWindow(b *xturbo.Buf, window Window) xturbo.Seq { | |
| 413 | + | p, seq := b.Request(8, 0, 4) | |
| 414 | + | if p == nil { | |
| 415 | + | return 0 | |
| 416 | + | } | |
| 417 | + | binary.LittleEndian.PutUint32(p[0:], uint32(window)) | |
| 418 | + | return seq | |
| 419 | + | } | |
| 420 | + | ||
| 421 | + | func MapSubwindows(b *xturbo.Buf, window Window) xturbo.Seq { | |
| 422 | + | p, seq := b.Request(9, 0, 4) | |
| 423 | + | if p == nil { | |
| 424 | + | return 0 | |
| 425 | + | } | |
| 426 | + | binary.LittleEndian.PutUint32(p[0:], uint32(window)) | |
| 427 | + | return seq | |
| 428 | + | } | |
| 429 | + | ||
| 430 | + | func UnmapWindow(b *xturbo.Buf, window Window) xturbo.Seq { | |
| 431 | + | p, seq := b.Request(10, 0, 4) | |
| 432 | + | if p == nil { | |
| 433 | + | return 0 | |
| 434 | + | } | |
| 435 | + | binary.LittleEndian.PutUint32(p[0:], uint32(window)) | |
| 436 | + | return seq | |
| 437 | + | } | |
| 438 | + | ||
| 439 | + | func UnmapSubwindows(b *xturbo.Buf, window Window) xturbo.Seq { | |
| 440 | + | p, seq := b.Request(11, 0, 4) | |
| 441 | + | if p == nil { | |
| 442 | + | return 0 | |
| 443 | + | } | |
| 444 | + | binary.LittleEndian.PutUint32(p[0:], uint32(window)) | |
| 445 | + | return seq | |
| 446 | + | } | |
| 447 | + | ||
| 448 | + | type ConfigureWindowValues struct { | |
| 449 | + | Mask ConfigWindow | |
| 450 | + | X int32 | |
| 451 | + | Y int32 | |
| 452 | + | Width uint32 | |
| 453 | + | Height uint32 | |
| 454 | + | BorderWidth uint32 | |
| 455 | + | Sibling Window | |
| 456 | + | StackMode StackMode | |
| 457 | + | } | |
| 458 | + | ||
| 459 | + | func (v *ConfigureWindowValues) SetX(x int32) *ConfigureWindowValues { | |
| 460 | + | v.Mask |= ConfigWindowX | |
| 461 | + | v.X = x | |
| 462 | + | return v | |
| 463 | + | } | |
| 464 | + | func (v *ConfigureWindowValues) SetY(x int32) *ConfigureWindowValues { | |
| 465 | + | v.Mask |= ConfigWindowY | |
| 466 | + | v.Y = x | |
| 467 | + | return v | |
| 468 | + | } | |
| 469 | + | func (v *ConfigureWindowValues) SetWidth(x uint32) *ConfigureWindowValues { | |
| 470 | + | v.Mask |= ConfigWindowWidth | |
| 471 | + | v.Width = x | |
| 472 | + | return v | |
| 473 | + | } | |
| 474 | + | func (v *ConfigureWindowValues) SetHeight(x uint32) *ConfigureWindowValues { | |
| 475 | + | v.Mask |= ConfigWindowHeight | |
| 476 | + | v.Height = x | |
| 477 | + | return v | |
| 478 | + | } | |
| 479 | + | func (v *ConfigureWindowValues) SetBorderWidth(x uint32) *ConfigureWindowValues { | |
| 480 | + | v.Mask |= ConfigWindowBorderWidth | |
| 481 | + | v.BorderWidth = x | |
| 482 | + | return v | |
| 483 | + | } | |
| 484 | + | func (v *ConfigureWindowValues) SetSibling(x Window) *ConfigureWindowValues { | |
| 485 | + | v.Mask |= ConfigWindowSibling | |
| 486 | + | v.Sibling = x | |
| 487 | + | return v | |
| 488 | + | } | |
| 489 | + | func (v *ConfigureWindowValues) SetStackMode(x StackMode) *ConfigureWindowValues { | |
| 490 | + | v.Mask |= ConfigWindowStackMode | |
| 491 | + | v.StackMode = x | |
| 492 | + | return v | |
| 493 | + | } | |
| 494 | + | func ConfigureWindow(b *xturbo.Buf, window Window, v *ConfigureWindowValues) xturbo.Seq { | |
| 495 | + | p, seq := b.Request(12, 0, 8+4*bits.OnesCount32(uint32(v.Mask))) | |
| 496 | + | if p == nil { | |
| 497 | + | return 0 | |
| 498 | + | } | |
| 499 | + | binary.LittleEndian.PutUint32(p[0:], uint32(window)) | |
| 500 | + | binary.LittleEndian.PutUint16(p[4:], uint16(v.Mask)) | |
| 501 | + | off := 8 | |
| 502 | + | if v.Mask&ConfigWindowX != 0 { | |
| 503 | + | binary.LittleEndian.PutUint32(p[off:], uint32(v.X)) | |
| 504 | + | off += 4 | |
| 505 | + | } | |
| 506 | + | if v.Mask&ConfigWindowY != 0 { | |
| 507 | + | binary.LittleEndian.PutUint32(p[off:], uint32(v.Y)) | |
| 508 | + | off += 4 | |
| 509 | + | } | |
| 510 | + | if v.Mask&ConfigWindowWidth != 0 { | |
| 511 | + | binary.LittleEndian.PutUint32(p[off:], uint32(v.Width)) | |
| 512 | + | off += 4 | |
| 513 | + | } | |
| 514 | + | if v.Mask&ConfigWindowHeight != 0 { | |
| 515 | + | binary.LittleEndian.PutUint32(p[off:], uint32(v.Height)) | |
| 516 | + | off += 4 | |
| 517 | + | } | |
| 518 | + | if v.Mask&ConfigWindowBorderWidth != 0 { | |
| 519 | + | binary.LittleEndian.PutUint32(p[off:], uint32(v.BorderWidth)) | |
| 520 | + | off += 4 | |
| 521 | + | } | |
| 522 | + | if v.Mask&ConfigWindowSibling != 0 { | |
| 523 | + | binary.LittleEndian.PutUint32(p[off:], uint32(v.Sibling)) | |
| 524 | + | off += 4 | |
| 525 | + | } | |
| 526 | + | if v.Mask&ConfigWindowStackMode != 0 { | |
| 527 | + | binary.LittleEndian.PutUint32(p[off:], uint32(v.StackMode)) | |
| 528 | + | off += 4 | |
| 529 | + | } | |
| 530 | + | _ = off | |
| 531 | + | return seq | |
| 532 | + | } | |
| 533 | + | ||
| 534 | + | func CirculateWindow(b *xturbo.Buf, direction Circulate, window Window) xturbo.Seq { | |
| 535 | + | p, seq := b.Request(13, uint8(int(direction)), 4) | |
| 536 | + | if p == nil { | |
| 537 | + | return 0 | |
| 538 | + | } | |
| 539 | + | binary.LittleEndian.PutUint32(p[0:], uint32(window)) | |
| 540 | + | return seq | |
| 541 | + | } | |
| 542 | + | ||
| 543 | + | func GetGeometry(b *xturbo.Buf, drawable Drawable) xturbo.Seq { | |
| 544 | + | p, seq := b.Request(14, 0, 4) | |
| 545 | + | if p == nil { | |
| 546 | + | return 0 | |
| 547 | + | } | |
| 548 | + | binary.LittleEndian.PutUint32(p[0:], uint32(drawable)) | |
| 549 | + | return seq | |
| 550 | + | } | |
| 551 | + | ||
| 552 | + | func QueryTree(b *xturbo.Buf, window Window) xturbo.Seq { | |
| 553 | + | p, seq := b.Request(15, 0, 4) | |
| 554 | + | if p == nil { | |
| 555 | + | return 0 | |
| 556 | + | } | |
| 557 | + | binary.LittleEndian.PutUint32(p[0:], uint32(window)) | |
| 558 | + | return seq | |
| 559 | + | } | |
| 560 | + | ||
| 561 | + | func InternAtom(b *xturbo.Buf, onlyIfExists bool, name string) xturbo.Seq { | |
| 562 | + | if uint64(len(name)) > 65535 { | |
| 563 | + | b.Fail(xturbo.ErrBadLength) | |
| 564 | + | return 0 | |
| 565 | + | } | |
| 566 | + | size := 0 | |
| 567 | + | size += 2 | |
| 568 | + | size += 2 | |
| 569 | + | size += len(name) * 1 | |
| 570 | + | size = (size + 3) &^ 3 | |
| 571 | + | var data uint8 | |
| 572 | + | if onlyIfExists { | |
| 573 | + | data = 1 | |
| 574 | + | } | |
| 575 | + | p, seq := b.Request(16, data, size) | |
| 576 | + | if p == nil { | |
| 577 | + | return 0 | |
| 578 | + | } | |
| 579 | + | off := 0 | |
| 580 | + | binary.LittleEndian.PutUint16(p[off:], uint16(len(name))) | |
| 581 | + | off += 2 | |
| 582 | + | off += 2 | |
| 583 | + | copy(p[off:], name) | |
| 584 | + | off += len(name) | |
| 585 | + | return seq | |
| 586 | + | } | |
| 587 | + | ||
| 588 | + | func GetAtomName(b *xturbo.Buf, atom Atom) xturbo.Seq { | |
| 589 | + | p, seq := b.Request(17, 0, 4) | |
| 590 | + | if p == nil { | |
| 591 | + | return 0 | |
| 592 | + | } | |
| 593 | + | binary.LittleEndian.PutUint32(p[0:], uint32(atom)) | |
| 594 | + | return seq | |
| 595 | + | } | |
| 596 | + | ||
| 597 | + | func ChangeProperty(b *xturbo.Buf, mode PropMode, window Window, property Atom, type_ Atom, format uint8, dataLen uint32, data []byte) xturbo.Seq { | |
| 598 | + | if len(data) != ((int(dataLen) * int(format)) / 8) { | |
| 599 | + | b.Fail(xturbo.ErrBadLength) | |
| 600 | + | return 0 | |
| 601 | + | } | |
| 602 | + | size := 0 | |
| 603 | + | size += 4 | |
| 604 | + | size += 4 | |
| 605 | + | size += 4 | |
| 606 | + | size += 1 | |
| 607 | + | size += 3 | |
| 608 | + | size += 4 | |
| 609 | + | size += len(data) * 1 | |
| 610 | + | size = (size + 3) &^ 3 | |
| 611 | + | p, seq := b.Request(18, uint8(int(mode)), size) | |
| 612 | + | if p == nil { | |
| 613 | + | return 0 | |
| 614 | + | } | |
| 615 | + | off := 0 | |
| 616 | + | binary.LittleEndian.PutUint32(p[off:], uint32(window)) | |
| 617 | + | off += 4 | |
| 618 | + | binary.LittleEndian.PutUint32(p[off:], uint32(property)) | |
| 619 | + | off += 4 | |
| 620 | + | binary.LittleEndian.PutUint32(p[off:], uint32(type_)) | |
| 621 | + | off += 4 | |
| 622 | + | p[off:][0] = byte(format) | |
| 623 | + | off += 1 | |
| 624 | + | off += 3 | |
| 625 | + | binary.LittleEndian.PutUint32(p[off:], uint32(dataLen)) | |
| 626 | + | off += 4 | |
| 627 | + | copy(p[off:], data) | |
| 628 | + | off += len(data) | |
| 629 | + | return seq | |
| 630 | + | } | |
| 631 | + | ||
| 632 | + | func DeleteProperty(b *xturbo.Buf, window Window, property Atom) xturbo.Seq { | |
| 633 | + | p, seq := b.Request(19, 0, 8) | |
| 634 | + | if p == nil { | |
| 635 | + | return 0 | |
| 636 | + | } | |
| 637 | + | binary.LittleEndian.PutUint32(p[0:], uint32(window)) | |
| 638 | + | binary.LittleEndian.PutUint32(p[4:], uint32(property)) | |
| 639 | + | return seq | |
| 640 | + | } | |
| 641 | + | ||
| 642 | + | func GetProperty(b *xturbo.Buf, delete bool, window Window, property Atom, type_ Atom, longOffset uint32, longLength uint32) xturbo.Seq { | |
| 643 | + | var data uint8 | |
| 644 | + | if delete { | |
| 645 | + | data = 1 | |
| 646 | + | } | |
| 647 | + | p, seq := b.Request(20, data, 20) | |
| 648 | + | if p == nil { | |
| 649 | + | return 0 | |
| 650 | + | } | |
| 651 | + | binary.LittleEndian.PutUint32(p[0:], uint32(window)) | |
| 652 | + | binary.LittleEndian.PutUint32(p[4:], uint32(property)) | |
| 653 | + | binary.LittleEndian.PutUint32(p[8:], uint32(type_)) | |
| 654 | + | binary.LittleEndian.PutUint32(p[12:], uint32(longOffset)) | |
| 655 | + | binary.LittleEndian.PutUint32(p[16:], uint32(longLength)) | |
| 656 | + | return seq | |
| 657 | + | } | |
| 658 | + | ||
| 659 | + | func ListProperties(b *xturbo.Buf, window Window) xturbo.Seq { | |
| 660 | + | p, seq := b.Request(21, 0, 4) | |
| 661 | + | if p == nil { | |
| 662 | + | return 0 | |
| 663 | + | } | |
| 664 | + | binary.LittleEndian.PutUint32(p[0:], uint32(window)) | |
| 665 | + | return seq | |
| 666 | + | } | |
| 667 | + | ||
| 668 | + | func SetSelectionOwner(b *xturbo.Buf, owner Window, selection Atom, time Timestamp) xturbo.Seq { | |
| 669 | + | p, seq := b.Request(22, 0, 12) | |
| 670 | + | if p == nil { | |
| 671 | + | return 0 | |
| 672 | + | } | |
| 673 | + | binary.LittleEndian.PutUint32(p[0:], uint32(owner)) | |
| 674 | + | binary.LittleEndian.PutUint32(p[4:], uint32(selection)) | |
| 675 | + | binary.LittleEndian.PutUint32(p[8:], uint32(time)) | |
| 676 | + | return seq | |
| 677 | + | } | |
| 678 | + | ||
| 679 | + | func GetSelectionOwner(b *xturbo.Buf, selection Atom) xturbo.Seq { | |
| 680 | + | p, seq := b.Request(23, 0, 4) | |
| 681 | + | if p == nil { | |
| 682 | + | return 0 | |
| 683 | + | } | |
| 684 | + | binary.LittleEndian.PutUint32(p[0:], uint32(selection)) | |
| 685 | + | return seq | |
| 686 | + | } | |
| 687 | + | ||
| 688 | + | func ConvertSelection(b *xturbo.Buf, requestor Window, selection Atom, target Atom, property Atom, time Timestamp) xturbo.Seq { | |
| 689 | + | p, seq := b.Request(24, 0, 20) | |
| 690 | + | if p == nil { | |
| 691 | + | return 0 | |
| 692 | + | } | |
| 693 | + | binary.LittleEndian.PutUint32(p[0:], uint32(requestor)) | |
| 694 | + | binary.LittleEndian.PutUint32(p[4:], uint32(selection)) | |
| 695 | + | binary.LittleEndian.PutUint32(p[8:], uint32(target)) | |
| 696 | + | binary.LittleEndian.PutUint32(p[12:], uint32(property)) | |
| 697 | + | binary.LittleEndian.PutUint32(p[16:], uint32(time)) | |
| 698 | + | return seq | |
| 699 | + | } | |
| 700 | + | ||
| 701 | + | func SendEvent(b *xturbo.Buf, propagate bool, destination Window, eventMask EventMask, event *[32]byte) xturbo.Seq { | |
| 702 | + | if len(event) != 32 { | |
| 703 | + | b.Fail(xturbo.ErrBadLength) | |
| 704 | + | return 0 | |
| 705 | + | } | |
| 706 | + | size := 0 | |
| 707 | + | size += 4 | |
| 708 | + | size += 4 | |
| 709 | + | size += len(event) * 1 | |
| 710 | + | size = (size + 3) &^ 3 | |
| 711 | + | var data uint8 | |
| 712 | + | if propagate { | |
| 713 | + | data = 1 | |
| 714 | + | } | |
| 715 | + | p, seq := b.Request(25, data, size) | |
| 716 | + | if p == nil { | |
| 717 | + | return 0 | |
| 718 | + | } | |
| 719 | + | off := 0 | |
| 720 | + | binary.LittleEndian.PutUint32(p[off:], uint32(destination)) | |
| 721 | + | off += 4 | |
| 722 | + | binary.LittleEndian.PutUint32(p[off:], uint32(eventMask)) | |
| 723 | + | off += 4 | |
| 724 | + | copy(p[off:], event[:]) | |
| 725 | + | return seq | |
| 726 | + | } | |
| 727 | + | ||
| 728 | + | func GrabPointer(b *xturbo.Buf, ownerEvents bool, grabWindow Window, eventMask EventMask, pointerMode GrabMode, keyboardMode GrabMode, confineTo Window, cursor Cursor, time Timestamp) xturbo.Seq { | |
| 729 | + | var data uint8 | |
| 730 | + | if ownerEvents { | |
| 731 | + | data = 1 | |
| 732 | + | } | |
| 733 | + | p, seq := b.Request(26, data, 20) | |
| 734 | + | if p == nil { | |
| 735 | + | return 0 | |
| 736 | + | } | |
| 737 | + | binary.LittleEndian.PutUint32(p[0:], uint32(grabWindow)) | |
| 738 | + | binary.LittleEndian.PutUint16(p[4:], uint16(eventMask)) | |
| 739 | + | p[6:][0] = byte(pointerMode) | |
| 740 | + | p[7:][0] = byte(keyboardMode) | |
| 741 | + | binary.LittleEndian.PutUint32(p[8:], uint32(confineTo)) | |
| 742 | + | binary.LittleEndian.PutUint32(p[12:], uint32(cursor)) | |
| 743 | + | binary.LittleEndian.PutUint32(p[16:], uint32(time)) | |
| 744 | + | return seq | |
| 745 | + | } | |
| 746 | + | ||
| 747 | + | func UngrabPointer(b *xturbo.Buf, time Timestamp) xturbo.Seq { | |
| 748 | + | p, seq := b.Request(27, 0, 4) | |
| 749 | + | if p == nil { | |
| 750 | + | return 0 | |
| 751 | + | } | |
| 752 | + | binary.LittleEndian.PutUint32(p[0:], uint32(time)) | |
| 753 | + | return seq | |
| 754 | + | } | |
| 755 | + | ||
| 756 | + | func GrabButton(b *xturbo.Buf, ownerEvents bool, grabWindow Window, eventMask EventMask, pointerMode GrabMode, keyboardMode GrabMode, confineTo Window, cursor Cursor, button ButtonIndex, modifiers ModMask) xturbo.Seq { | |
| 757 | + | var data uint8 | |
| 758 | + | if ownerEvents { | |
| 759 | + | data = 1 | |
| 760 | + | } | |
| 761 | + | p, seq := b.Request(28, data, 20) | |
| 762 | + | if p == nil { | |
| 763 | + | return 0 | |
| 764 | + | } | |
| 765 | + | binary.LittleEndian.PutUint32(p[0:], uint32(grabWindow)) | |
| 766 | + | binary.LittleEndian.PutUint16(p[4:], uint16(eventMask)) | |
| 767 | + | p[6:][0] = byte(pointerMode) | |
| 768 | + | p[7:][0] = byte(keyboardMode) | |
| 769 | + | binary.LittleEndian.PutUint32(p[8:], uint32(confineTo)) | |
| 770 | + | binary.LittleEndian.PutUint32(p[12:], uint32(cursor)) | |
| 771 | + | p[16:][0] = byte(button) | |
| 772 | + | binary.LittleEndian.PutUint16(p[18:], uint16(modifiers)) | |
| 773 | + | return seq | |
| 774 | + | } | |
| 775 | + | ||
| 776 | + | func UngrabButton(b *xturbo.Buf, button ButtonIndex, grabWindow Window, modifiers ModMask) xturbo.Seq { | |
| 777 | + | p, seq := b.Request(29, uint8(int(button)), 8) | |
| 778 | + | if p == nil { | |
| 779 | + | return 0 | |
| 780 | + | } | |
| 781 | + | binary.LittleEndian.PutUint32(p[0:], uint32(grabWindow)) | |
| 782 | + | binary.LittleEndian.PutUint16(p[4:], uint16(modifiers)) | |
| 783 | + | return seq | |
| 784 | + | } | |
| 785 | + | ||
| 786 | + | func ChangeActivePointerGrab(b *xturbo.Buf, cursor Cursor, time Timestamp, eventMask EventMask) xturbo.Seq { | |
| 787 | + | p, seq := b.Request(30, 0, 12) | |
| 788 | + | if p == nil { | |
| 789 | + | return 0 | |
| 790 | + | } | |
| 791 | + | binary.LittleEndian.PutUint32(p[0:], uint32(cursor)) | |
| 792 | + | binary.LittleEndian.PutUint32(p[4:], uint32(time)) | |
| 793 | + | binary.LittleEndian.PutUint16(p[8:], uint16(eventMask)) | |
| 794 | + | return seq | |
| 795 | + | } | |
| 796 | + | ||
| 797 | + | func GrabKeyboard(b *xturbo.Buf, ownerEvents bool, grabWindow Window, time Timestamp, pointerMode GrabMode, keyboardMode GrabMode) xturbo.Seq { | |
| 798 | + | var data uint8 | |
| 799 | + | if ownerEvents { | |
| 800 | + | data = 1 | |
| 801 | + | } | |
| 802 | + | p, seq := b.Request(31, data, 12) | |
| 803 | + | if p == nil { | |
| 804 | + | return 0 | |
| 805 | + | } | |
| 806 | + | binary.LittleEndian.PutUint32(p[0:], uint32(grabWindow)) | |
| 807 | + | binary.LittleEndian.PutUint32(p[4:], uint32(time)) | |
| 808 | + | p[8:][0] = byte(pointerMode) | |
| 809 | + | p[9:][0] = byte(keyboardMode) | |
| 810 | + | return seq | |
| 811 | + | } | |
| 812 | + | ||
| 813 | + | func UngrabKeyboard(b *xturbo.Buf, time Timestamp) xturbo.Seq { | |
| 814 | + | p, seq := b.Request(32, 0, 4) | |
| 815 | + | if p == nil { | |
| 816 | + | return 0 | |
| 817 | + | } | |
| 818 | + | binary.LittleEndian.PutUint32(p[0:], uint32(time)) | |
| 819 | + | return seq | |
| 820 | + | } | |
| 821 | + | ||
| 822 | + | func GrabKey(b *xturbo.Buf, ownerEvents bool, grabWindow Window, modifiers ModMask, key Keycode, pointerMode GrabMode, keyboardMode GrabMode) xturbo.Seq { | |
| 823 | + | var data uint8 | |
| 824 | + | if ownerEvents { | |
| 825 | + | data = 1 | |
| 826 | + | } | |
| 827 | + | p, seq := b.Request(33, data, 12) | |
| 828 | + | if p == nil { | |
| 829 | + | return 0 | |
| 830 | + | } | |
| 831 | + | binary.LittleEndian.PutUint32(p[0:], uint32(grabWindow)) | |
| 832 | + | binary.LittleEndian.PutUint16(p[4:], uint16(modifiers)) | |
| 833 | + | p[6:][0] = byte(key) | |
| 834 | + | p[7:][0] = byte(pointerMode) | |
| 835 | + | p[8:][0] = byte(keyboardMode) | |
| 836 | + | return seq | |
| 837 | + | } | |
| 838 | + | ||
| 839 | + | func UngrabKey(b *xturbo.Buf, key Keycode, grabWindow Window, modifiers ModMask) xturbo.Seq { | |
| 840 | + | p, seq := b.Request(34, uint8(int(key)), 8) | |
| 841 | + | if p == nil { | |
| 842 | + | return 0 | |
| 843 | + | } | |
| 844 | + | binary.LittleEndian.PutUint32(p[0:], uint32(grabWindow)) | |
| 845 | + | binary.LittleEndian.PutUint16(p[4:], uint16(modifiers)) | |
| 846 | + | return seq | |
| 847 | + | } | |
| 848 | + | ||
| 849 | + | func AllowEvents(b *xturbo.Buf, mode Allow, time Timestamp) xturbo.Seq { | |
| 850 | + | p, seq := b.Request(35, uint8(int(mode)), 4) | |
| 851 | + | if p == nil { | |
| 852 | + | return 0 | |
| 853 | + | } | |
| 854 | + | binary.LittleEndian.PutUint32(p[0:], uint32(time)) | |
| 855 | + | return seq | |
| 856 | + | } | |
| 857 | + | ||
| 858 | + | func GrabServer(b *xturbo.Buf) xturbo.Seq { | |
| 859 | + | p, seq := b.Request(36, 0, 0) | |
| 860 | + | if p == nil { | |
| 861 | + | return 0 | |
| 862 | + | } | |
| 863 | + | return seq | |
| 864 | + | } | |
| 865 | + | ||
| 866 | + | func UngrabServer(b *xturbo.Buf) xturbo.Seq { | |
| 867 | + | p, seq := b.Request(37, 0, 0) | |
| 868 | + | if p == nil { | |
| 869 | + | return 0 | |
| 870 | + | } | |
| 871 | + | return seq | |
| 872 | + | } | |
| 873 | + | ||
| 874 | + | func QueryPointer(b *xturbo.Buf, window Window) xturbo.Seq { | |
| 875 | + | p, seq := b.Request(38, 0, 4) | |
| 876 | + | if p == nil { | |
| 877 | + | return 0 | |
| 878 | + | } | |
| 879 | + | binary.LittleEndian.PutUint32(p[0:], uint32(window)) | |
| 880 | + | return seq | |
| 881 | + | } | |
| 882 | + | ||
| 883 | + | func GetMotionEvents(b *xturbo.Buf, window Window, start Timestamp, stop Timestamp) xturbo.Seq { | |
| 884 | + | p, seq := b.Request(39, 0, 12) | |
| 885 | + | if p == nil { | |
| 886 | + | return 0 | |
| 887 | + | } | |
| 888 | + | binary.LittleEndian.PutUint32(p[0:], uint32(window)) | |
| 889 | + | binary.LittleEndian.PutUint32(p[4:], uint32(start)) | |
| 890 | + | binary.LittleEndian.PutUint32(p[8:], uint32(stop)) | |
| 891 | + | return seq | |
| 892 | + | } | |
| 893 | + | ||
| 894 | + | func TranslateCoordinates(b *xturbo.Buf, srcWindow Window, dstWindow Window, srcX int16, srcY int16) xturbo.Seq { | |
| 895 | + | p, seq := b.Request(40, 0, 12) | |
| 896 | + | if p == nil { | |
| 897 | + | return 0 | |
| 898 | + | } | |
| 899 | + | binary.LittleEndian.PutUint32(p[0:], uint32(srcWindow)) | |
| 900 | + | binary.LittleEndian.PutUint32(p[4:], uint32(dstWindow)) | |
| 901 | + | binary.LittleEndian.PutUint16(p[8:], uint16(srcX)) | |
| 902 | + | binary.LittleEndian.PutUint16(p[10:], uint16(srcY)) | |
| 903 | + | return seq | |
| 904 | + | } | |
| 905 | + | ||
| 906 | + | func WarpPointer(b *xturbo.Buf, srcWindow Window, dstWindow Window, srcX int16, srcY int16, srcWidth uint16, srcHeight uint16, dstX int16, dstY int16) xturbo.Seq { | |
| 907 | + | p, seq := b.Request(41, 0, 20) | |
| 908 | + | if p == nil { | |
| 909 | + | return 0 | |
| 910 | + | } | |
| 911 | + | binary.LittleEndian.PutUint32(p[0:], uint32(srcWindow)) | |
| 912 | + | binary.LittleEndian.PutUint32(p[4:], uint32(dstWindow)) | |
| 913 | + | binary.LittleEndian.PutUint16(p[8:], uint16(srcX)) | |
| 914 | + | binary.LittleEndian.PutUint16(p[10:], uint16(srcY)) | |
| 915 | + | binary.LittleEndian.PutUint16(p[12:], uint16(srcWidth)) | |
| 916 | + | binary.LittleEndian.PutUint16(p[14:], uint16(srcHeight)) | |
| 917 | + | binary.LittleEndian.PutUint16(p[16:], uint16(dstX)) | |
| 918 | + | binary.LittleEndian.PutUint16(p[18:], uint16(dstY)) | |
| 919 | + | return seq | |
| 920 | + | } | |
| 921 | + | ||
| 922 | + | func SetInputFocus(b *xturbo.Buf, revertTo InputFocus, focus Window, time Timestamp) xturbo.Seq { | |
| 923 | + | p, seq := b.Request(42, uint8(int(revertTo)), 8) | |
| 924 | + | if p == nil { | |
| 925 | + | return 0 | |
| 926 | + | } | |
| 927 | + | binary.LittleEndian.PutUint32(p[0:], uint32(focus)) | |
| 928 | + | binary.LittleEndian.PutUint32(p[4:], uint32(time)) | |
| 929 | + | return seq | |
| 930 | + | } | |
| 931 | + | ||
| 932 | + | func GetInputFocus(b *xturbo.Buf) xturbo.Seq { | |
| 933 | + | p, seq := b.Request(43, 0, 0) | |
| 934 | + | if p == nil { | |
| 935 | + | return 0 | |
| 936 | + | } | |
| 937 | + | return seq | |
| 938 | + | } | |
| 939 | + | ||
| 940 | + | func QueryKeymap(b *xturbo.Buf) xturbo.Seq { | |
| 941 | + | p, seq := b.Request(44, 0, 0) | |
| 942 | + | if p == nil { | |
| 943 | + | return 0 | |
| 944 | + | } | |
| 945 | + | return seq | |
| 946 | + | } | |
| 947 | + | ||
| 948 | + | func OpenFont(b *xturbo.Buf, fid Font, name string) xturbo.Seq { | |
| 949 | + | if uint64(len(name)) > 65535 { | |
| 950 | + | b.Fail(xturbo.ErrBadLength) | |
| 951 | + | return 0 | |
| 952 | + | } | |
| 953 | + | size := 0 | |
| 954 | + | size += 4 | |
| 955 | + | size += 2 | |
| 956 | + | size += 2 | |
| 957 | + | size += len(name) * 1 | |
| 958 | + | size = (size + 3) &^ 3 | |
| 959 | + | p, seq := b.Request(45, 0, size) | |
| 960 | + | if p == nil { | |
| 961 | + | return 0 | |
| 962 | + | } | |
| 963 | + | off := 0 | |
| 964 | + | binary.LittleEndian.PutUint32(p[off:], uint32(fid)) | |
| 965 | + | off += 4 | |
| 966 | + | binary.LittleEndian.PutUint16(p[off:], uint16(len(name))) | |
| 967 | + | off += 2 | |
| 968 | + | off += 2 | |
| 969 | + | copy(p[off:], name) | |
| 970 | + | off += len(name) | |
| 971 | + | return seq | |
| 972 | + | } | |
| 973 | + | ||
| 974 | + | func CloseFont(b *xturbo.Buf, font Font) xturbo.Seq { | |
| 975 | + | p, seq := b.Request(46, 0, 4) | |
| 976 | + | if p == nil { | |
| 977 | + | return 0 | |
| 978 | + | } | |
| 979 | + | binary.LittleEndian.PutUint32(p[0:], uint32(font)) | |
| 980 | + | return seq | |
| 981 | + | } | |
| 982 | + | ||
| 983 | + | func QueryFont(b *xturbo.Buf, font Fontable) xturbo.Seq { | |
| 984 | + | p, seq := b.Request(47, 0, 4) | |
| 985 | + | if p == nil { | |
| 986 | + | return 0 | |
| 987 | + | } | |
| 988 | + | binary.LittleEndian.PutUint32(p[0:], uint32(font)) | |
| 989 | + | return seq | |
| 990 | + | } | |
| 991 | + | ||
| 992 | + | func QueryTextExtents(b *xturbo.Buf, font Fontable, string []Char2b) xturbo.Seq { | |
| 993 | + | size := 0 | |
| 994 | + | size += 4 | |
| 995 | + | size += len(string) * 2 | |
| 996 | + | size = (size + 3) &^ 3 | |
| 997 | + | var data uint8 | |
| 998 | + | if (len(string) & 1) != 0 { | |
| 999 | + | data = 1 | |
| 1000 | + | } | |
| 1001 | + | p, seq := b.Request(48, data, size) | |
| 1002 | + | if p == nil { | |
| 1003 | + | return 0 | |
| 1004 | + | } | |
| 1005 | + | off := 0 | |
| 1006 | + | binary.LittleEndian.PutUint32(p[off:], uint32(font)) | |
| 1007 | + | off += 4 | |
| 1008 | + | for i := range string { | |
| 1009 | + | string[i].Put(p[off:]) | |
| 1010 | + | off += 2 | |
| 1011 | + | } | |
| 1012 | + | return seq | |
| 1013 | + | } | |
| 1014 | + | ||
| 1015 | + | func ListFonts(b *xturbo.Buf, maxNames uint16, pattern string) xturbo.Seq { | |
| 1016 | + | if uint64(len(pattern)) > 65535 { | |
| 1017 | + | b.Fail(xturbo.ErrBadLength) | |
| 1018 | + | return 0 | |
| 1019 | + | } | |
| 1020 | + | size := 0 | |
| 1021 | + | size += 2 | |
| 1022 | + | size += 2 | |
| 1023 | + | size += len(pattern) * 1 | |
| 1024 | + | size = (size + 3) &^ 3 | |
| 1025 | + | p, seq := b.Request(49, 0, size) | |
| 1026 | + | if p == nil { | |
| 1027 | + | return 0 | |
| 1028 | + | } | |
| 1029 | + | off := 0 | |
| 1030 | + | binary.LittleEndian.PutUint16(p[off:], uint16(maxNames)) | |
| 1031 | + | off += 2 | |
| 1032 | + | binary.LittleEndian.PutUint16(p[off:], uint16(len(pattern))) | |
| 1033 | + | off += 2 | |
| 1034 | + | copy(p[off:], pattern) | |
| 1035 | + | off += len(pattern) | |
| 1036 | + | return seq | |
| 1037 | + | } | |
| 1038 | + | ||
| 1039 | + | func ListFontsWithInfo(b *xturbo.Buf, maxNames uint16, pattern string) xturbo.Seq { | |
| 1040 | + | if uint64(len(pattern)) > 65535 { | |
| 1041 | + | b.Fail(xturbo.ErrBadLength) | |
| 1042 | + | return 0 | |
| 1043 | + | } | |
| 1044 | + | size := 0 | |
| 1045 | + | size += 2 | |
| 1046 | + | size += 2 | |
| 1047 | + | size += len(pattern) * 1 | |
| 1048 | + | size = (size + 3) &^ 3 | |
| 1049 | + | p, seq := b.Request(50, 0, size) | |
| 1050 | + | if p == nil { | |
| 1051 | + | return 0 | |
| 1052 | + | } | |
| 1053 | + | off := 0 | |
| 1054 | + | binary.LittleEndian.PutUint16(p[off:], uint16(maxNames)) | |
| 1055 | + | off += 2 | |
| 1056 | + | binary.LittleEndian.PutUint16(p[off:], uint16(len(pattern))) | |
| 1057 | + | off += 2 | |
| 1058 | + | copy(p[off:], pattern) | |
| 1059 | + | off += len(pattern) | |
| 1060 | + | return seq | |
| 1061 | + | } | |
| 1062 | + | ||
| 1063 | + | func SetFontPath(b *xturbo.Buf, font []Str) xturbo.Seq { | |
| 1064 | + | if uint64(len(font)) > 65535 { | |
| 1065 | + | b.Fail(xturbo.ErrBadLength) | |
| 1066 | + | return 0 | |
| 1067 | + | } | |
| 1068 | + | size := 0 | |
| 1069 | + | size += 2 | |
| 1070 | + | size += 2 | |
| 1071 | + | for i := range font { | |
| 1072 | + | size += font[i].Size() | |
| 1073 | + | } | |
| 1074 | + | size = (size + 3) &^ 3 | |
| 1075 | + | p, seq := b.Request(51, 0, size) | |
| 1076 | + | if p == nil { | |
| 1077 | + | return 0 | |
| 1078 | + | } | |
| 1079 | + | off := 0 | |
| 1080 | + | binary.LittleEndian.PutUint16(p[off:], uint16(len(font))) | |
| 1081 | + | off += 2 | |
| 1082 | + | off += 2 | |
| 1083 | + | for i := range font { | |
| 1084 | + | font[i].Put(p[off:]) | |
| 1085 | + | off += font[i].Size() | |
| 1086 | + | } | |
| 1087 | + | return seq | |
| 1088 | + | } | |
| 1089 | + | ||
| 1090 | + | func GetFontPath(b *xturbo.Buf) xturbo.Seq { | |
| 1091 | + | p, seq := b.Request(52, 0, 0) | |
| 1092 | + | if p == nil { | |
| 1093 | + | return 0 | |
| 1094 | + | } | |
| 1095 | + | return seq | |
| 1096 | + | } | |
| 1097 | + | ||
| 1098 | + | func CreatePixmap(b *xturbo.Buf, depth uint8, pid Pixmap, drawable Drawable, width uint16, height uint16) xturbo.Seq { | |
| 1099 | + | p, seq := b.Request(53, uint8(int(depth)), 12) | |
| 1100 | + | if p == nil { | |
| 1101 | + | return 0 | |
| 1102 | + | } | |
| 1103 | + | binary.LittleEndian.PutUint32(p[0:], uint32(pid)) | |
| 1104 | + | binary.LittleEndian.PutUint32(p[4:], uint32(drawable)) | |
| 1105 | + | binary.LittleEndian.PutUint16(p[8:], uint16(width)) | |
| 1106 | + | binary.LittleEndian.PutUint16(p[10:], uint16(height)) | |
| 1107 | + | return seq | |
| 1108 | + | } | |
| 1109 | + | ||
| 1110 | + | func FreePixmap(b *xturbo.Buf, pixmap Pixmap) xturbo.Seq { | |
| 1111 | + | p, seq := b.Request(54, 0, 4) | |
| 1112 | + | if p == nil { | |
| 1113 | + | return 0 | |
| 1114 | + | } | |
| 1115 | + | binary.LittleEndian.PutUint32(p[0:], uint32(pixmap)) | |
| 1116 | + | return seq | |
| 1117 | + | } | |
| 1118 | + | ||
| 1119 | + | type CreateGCValues struct { | |
| 1120 | + | Mask Gc | |
| 1121 | + | Function Gx | |
| 1122 | + | PlaneMask uint32 | |
| 1123 | + | Foreground uint32 | |
| 1124 | + | Background uint32 | |
| 1125 | + | LineWidth uint32 | |
| 1126 | + | LineStyle LineStyle | |
| 1127 | + | CapStyle CapStyle | |
| 1128 | + | JoinStyle JoinStyle | |
| 1129 | + | FillStyle FillStyle | |
| 1130 | + | FillRule FillRule | |
| 1131 | + | Tile Pixmap | |
| 1132 | + | Stipple Pixmap | |
| 1133 | + | TileStippleXOrigin int32 | |
| 1134 | + | TileStippleYOrigin int32 | |
| 1135 | + | Font Font | |
| 1136 | + | SubwindowMode SubwindowMode | |
| 1137 | + | GraphicsExposures bool | |
| 1138 | + | ClipXOrigin int32 | |
| 1139 | + | ClipYOrigin int32 | |
| 1140 | + | ClipMask Pixmap | |
| 1141 | + | DashOffset uint32 | |
| 1142 | + | Dashes uint32 | |
| 1143 | + | ArcMode ArcMode | |
| 1144 | + | } | |
| 1145 | + | ||
| 1146 | + | func (v *CreateGCValues) SetFunction(x Gx) *CreateGCValues { | |
| 1147 | + | v.Mask |= GcFunction | |
| 1148 | + | v.Function = x | |
| 1149 | + | return v | |
| 1150 | + | } | |
| 1151 | + | func (v *CreateGCValues) SetPlaneMask(x uint32) *CreateGCValues { | |
| 1152 | + | v.Mask |= GcPlaneMask | |
| 1153 | + | v.PlaneMask = x | |
| 1154 | + | return v | |
| 1155 | + | } | |
| 1156 | + | func (v *CreateGCValues) SetForeground(x uint32) *CreateGCValues { | |
| 1157 | + | v.Mask |= GcForeground | |
| 1158 | + | v.Foreground = x | |
| 1159 | + | return v | |
| 1160 | + | } | |
| 1161 | + | func (v *CreateGCValues) SetBackground(x uint32) *CreateGCValues { | |
| 1162 | + | v.Mask |= GcBackground | |
| 1163 | + | v.Background = x | |
| 1164 | + | return v | |
| 1165 | + | } | |
| 1166 | + | func (v *CreateGCValues) SetLineWidth(x uint32) *CreateGCValues { | |
| 1167 | + | v.Mask |= GcLineWidth | |
| 1168 | + | v.LineWidth = x | |
| 1169 | + | return v | |
| 1170 | + | } | |
| 1171 | + | func (v *CreateGCValues) SetLineStyle(x LineStyle) *CreateGCValues { | |
| 1172 | + | v.Mask |= GcLineStyle | |
| 1173 | + | v.LineStyle = x | |
| 1174 | + | return v | |
| 1175 | + | } | |
| 1176 | + | func (v *CreateGCValues) SetCapStyle(x CapStyle) *CreateGCValues { | |
| 1177 | + | v.Mask |= GcCapStyle | |
| 1178 | + | v.CapStyle = x | |
| 1179 | + | return v | |
| 1180 | + | } | |
| 1181 | + | func (v *CreateGCValues) SetJoinStyle(x JoinStyle) *CreateGCValues { | |
| 1182 | + | v.Mask |= GcJoinStyle | |
| 1183 | + | v.JoinStyle = x | |
| 1184 | + | return v | |
| 1185 | + | } | |
| 1186 | + | func (v *CreateGCValues) SetFillStyle(x FillStyle) *CreateGCValues { | |
| 1187 | + | v.Mask |= GcFillStyle | |
| 1188 | + | v.FillStyle = x | |
| 1189 | + | return v | |
| 1190 | + | } | |
| 1191 | + | func (v *CreateGCValues) SetFillRule(x FillRule) *CreateGCValues { | |
| 1192 | + | v.Mask |= GcFillRule | |
| 1193 | + | v.FillRule = x | |
| 1194 | + | return v | |
| 1195 | + | } | |
| 1196 | + | func (v *CreateGCValues) SetTile(x Pixmap) *CreateGCValues { v.Mask |= GcTile; v.Tile = x; return v } | |
| 1197 | + | func (v *CreateGCValues) SetStipple(x Pixmap) *CreateGCValues { | |
| 1198 | + | v.Mask |= GcStipple | |
| 1199 | + | v.Stipple = x | |
| 1200 | + | return v | |
| 1201 | + | } | |
| 1202 | + | func (v *CreateGCValues) SetTileStippleXOrigin(x int32) *CreateGCValues { | |
| 1203 | + | v.Mask |= GcTileStippleOriginX | |
| 1204 | + | v.TileStippleXOrigin = x | |
| 1205 | + | return v | |
| 1206 | + | } | |
| 1207 | + | func (v *CreateGCValues) SetTileStippleYOrigin(x int32) *CreateGCValues { | |
| 1208 | + | v.Mask |= GcTileStippleOriginY | |
| 1209 | + | v.TileStippleYOrigin = x | |
| 1210 | + | return v | |
| 1211 | + | } | |
| 1212 | + | func (v *CreateGCValues) SetFont(x Font) *CreateGCValues { v.Mask |= GcFont; v.Font = x; return v } | |
| 1213 | + | func (v *CreateGCValues) SetSubwindowMode(x SubwindowMode) *CreateGCValues { | |
| 1214 | + | v.Mask |= GcSubwindowMode | |
| 1215 | + | v.SubwindowMode = x | |
| 1216 | + | return v | |
| 1217 | + | } | |
| 1218 | + | func (v *CreateGCValues) SetGraphicsExposures(x bool) *CreateGCValues { | |
| 1219 | + | v.Mask |= GcGraphicsExposures | |
| 1220 | + | v.GraphicsExposures = x | |
| 1221 | + | return v | |
| 1222 | + | } | |
| 1223 | + | func (v *CreateGCValues) SetClipXOrigin(x int32) *CreateGCValues { | |
| 1224 | + | v.Mask |= GcClipOriginX | |
| 1225 | + | v.ClipXOrigin = x | |
| 1226 | + | return v | |
| 1227 | + | } | |
| 1228 | + | func (v *CreateGCValues) SetClipYOrigin(x int32) *CreateGCValues { | |
| 1229 | + | v.Mask |= GcClipOriginY | |
| 1230 | + | v.ClipYOrigin = x | |
| 1231 | + | return v | |
| 1232 | + | } | |
| 1233 | + | func (v *CreateGCValues) SetClipMask(x Pixmap) *CreateGCValues { | |
| 1234 | + | v.Mask |= GcClipMask | |
| 1235 | + | v.ClipMask = x | |
| 1236 | + | return v | |
| 1237 | + | } | |
| 1238 | + | func (v *CreateGCValues) SetDashOffset(x uint32) *CreateGCValues { | |
| 1239 | + | v.Mask |= GcDashOffset | |
| 1240 | + | v.DashOffset = x | |
| 1241 | + | return v | |
| 1242 | + | } | |
| 1243 | + | func (v *CreateGCValues) SetDashes(x uint32) *CreateGCValues { | |
| 1244 | + | v.Mask |= GcDashList | |
| 1245 | + | v.Dashes = x | |
| 1246 | + | return v | |
| 1247 | + | } | |
| 1248 | + | func (v *CreateGCValues) SetArcMode(x ArcMode) *CreateGCValues { | |
| 1249 | + | v.Mask |= GcArcMode | |
| 1250 | + | v.ArcMode = x | |
| 1251 | + | return v | |
| 1252 | + | } | |
| 1253 | + | func CreateGC(b *xturbo.Buf, cid Gcontext, drawable Drawable, v *CreateGCValues) xturbo.Seq { | |
| 1254 | + | p, seq := b.Request(55, 0, 12+4*bits.OnesCount32(uint32(v.Mask))) | |
| 1255 | + | if p == nil { | |
| 1256 | + | return 0 | |
| 1257 | + | } | |
| 1258 | + | binary.LittleEndian.PutUint32(p[0:], uint32(cid)) | |
| 1259 | + | binary.LittleEndian.PutUint32(p[4:], uint32(drawable)) | |
| 1260 | + | binary.LittleEndian.PutUint32(p[8:], uint32(v.Mask)) | |
| 1261 | + | off := 12 | |
| 1262 | + | if v.Mask&GcFunction != 0 { | |
| 1263 | + | binary.LittleEndian.PutUint32(p[off:], uint32(v.Function)) | |
| 1264 | + | off += 4 | |
| 1265 | + | } | |
| 1266 | + | if v.Mask&GcPlaneMask != 0 { | |
| 1267 | + | binary.LittleEndian.PutUint32(p[off:], uint32(v.PlaneMask)) | |
| 1268 | + | off += 4 | |
| 1269 | + | } | |
| 1270 | + | if v.Mask&GcForeground != 0 { | |
| 1271 | + | binary.LittleEndian.PutUint32(p[off:], uint32(v.Foreground)) | |
| 1272 | + | off += 4 | |
| 1273 | + | } | |
| 1274 | + | if v.Mask&GcBackground != 0 { | |
| 1275 | + | binary.LittleEndian.PutUint32(p[off:], uint32(v.Background)) | |
| 1276 | + | off += 4 | |
| 1277 | + | } | |
| 1278 | + | if v.Mask&GcLineWidth != 0 { | |
| 1279 | + | binary.LittleEndian.PutUint32(p[off:], uint32(v.LineWidth)) | |
| 1280 | + | off += 4 | |
| 1281 | + | } | |
| 1282 | + | if v.Mask&GcLineStyle != 0 { | |
| 1283 | + | binary.LittleEndian.PutUint32(p[off:], uint32(v.LineStyle)) | |
| 1284 | + | off += 4 | |
| 1285 | + | } | |
| 1286 | + | if v.Mask&GcCapStyle != 0 { | |
| 1287 | + | binary.LittleEndian.PutUint32(p[off:], uint32(v.CapStyle)) | |
| 1288 | + | off += 4 | |
| 1289 | + | } | |
| 1290 | + | if v.Mask&GcJoinStyle != 0 { | |
| 1291 | + | binary.LittleEndian.PutUint32(p[off:], uint32(v.JoinStyle)) | |
| 1292 | + | off += 4 | |
| 1293 | + | } | |
| 1294 | + | if v.Mask&GcFillStyle != 0 { | |
| 1295 | + | binary.LittleEndian.PutUint32(p[off:], uint32(v.FillStyle)) | |
| 1296 | + | off += 4 | |
| 1297 | + | } | |
| 1298 | + | if v.Mask&GcFillRule != 0 { | |
| 1299 | + | binary.LittleEndian.PutUint32(p[off:], uint32(v.FillRule)) | |
| 1300 | + | off += 4 | |
| 1301 | + | } | |
| 1302 | + | if v.Mask&GcTile != 0 { | |
| 1303 | + | binary.LittleEndian.PutUint32(p[off:], uint32(v.Tile)) | |
| 1304 | + | off += 4 | |
| 1305 | + | } | |
| 1306 | + | if v.Mask&GcStipple != 0 { | |
| 1307 | + | binary.LittleEndian.PutUint32(p[off:], uint32(v.Stipple)) | |
| 1308 | + | off += 4 | |
| 1309 | + | } | |
| 1310 | + | if v.Mask&GcTileStippleOriginX != 0 { | |
| 1311 | + | binary.LittleEndian.PutUint32(p[off:], uint32(v.TileStippleXOrigin)) | |
| 1312 | + | off += 4 | |
| 1313 | + | } | |
| 1314 | + | if v.Mask&GcTileStippleOriginY != 0 { | |
| 1315 | + | binary.LittleEndian.PutUint32(p[off:], uint32(v.TileStippleYOrigin)) | |
| 1316 | + | off += 4 | |
| 1317 | + | } | |
| 1318 | + | if v.Mask&GcFont != 0 { | |
| 1319 | + | binary.LittleEndian.PutUint32(p[off:], uint32(v.Font)) | |
| 1320 | + | off += 4 | |
| 1321 | + | } | |
| 1322 | + | if v.Mask&GcSubwindowMode != 0 { | |
| 1323 | + | binary.LittleEndian.PutUint32(p[off:], uint32(v.SubwindowMode)) | |
| 1324 | + | off += 4 | |
| 1325 | + | } | |
| 1326 | + | if v.Mask&GcGraphicsExposures != 0 { | |
| 1327 | + | if v.GraphicsExposures { | |
| 1328 | + | binary.LittleEndian.PutUint32(p[off:], 1) | |
| 1329 | + | } else { | |
| 1330 | + | binary.LittleEndian.PutUint32(p[off:], 0) | |
| 1331 | + | } | |
| 1332 | + | off += 4 | |
| 1333 | + | } | |
| 1334 | + | if v.Mask&GcClipOriginX != 0 { | |
| 1335 | + | binary.LittleEndian.PutUint32(p[off:], uint32(v.ClipXOrigin)) | |
| 1336 | + | off += 4 | |
| 1337 | + | } | |
| 1338 | + | if v.Mask&GcClipOriginY != 0 { | |
| 1339 | + | binary.LittleEndian.PutUint32(p[off:], uint32(v.ClipYOrigin)) | |
| 1340 | + | off += 4 | |
| 1341 | + | } | |
| 1342 | + | if v.Mask&GcClipMask != 0 { | |
| 1343 | + | binary.LittleEndian.PutUint32(p[off:], uint32(v.ClipMask)) | |
| 1344 | + | off += 4 | |
| 1345 | + | } | |
| 1346 | + | if v.Mask&GcDashOffset != 0 { | |
| 1347 | + | binary.LittleEndian.PutUint32(p[off:], uint32(v.DashOffset)) | |
| 1348 | + | off += 4 | |
| 1349 | + | } | |
| 1350 | + | if v.Mask&GcDashList != 0 { | |
| 1351 | + | binary.LittleEndian.PutUint32(p[off:], uint32(v.Dashes)) | |
| 1352 | + | off += 4 | |
| 1353 | + | } | |
| 1354 | + | if v.Mask&GcArcMode != 0 { | |
| 1355 | + | binary.LittleEndian.PutUint32(p[off:], uint32(v.ArcMode)) | |
| 1356 | + | off += 4 | |
| 1357 | + | } | |
| 1358 | + | _ = off | |
| 1359 | + | return seq | |
| 1360 | + | } | |
| 1361 | + | ||
| 1362 | + | type ChangeGCValues struct { | |
| 1363 | + | Mask Gc | |
| 1364 | + | Function Gx | |
| 1365 | + | PlaneMask uint32 | |
| 1366 | + | Foreground uint32 | |
| 1367 | + | Background uint32 | |
| 1368 | + | LineWidth uint32 | |
| 1369 | + | LineStyle LineStyle | |
| 1370 | + | CapStyle CapStyle | |
| 1371 | + | JoinStyle JoinStyle | |
| 1372 | + | FillStyle FillStyle | |
| 1373 | + | FillRule FillRule | |
| 1374 | + | Tile Pixmap | |
| 1375 | + | Stipple Pixmap | |
| 1376 | + | TileStippleXOrigin int32 | |
| 1377 | + | TileStippleYOrigin int32 | |
| 1378 | + | Font Font | |
| 1379 | + | SubwindowMode SubwindowMode | |
| 1380 | + | GraphicsExposures bool | |
| 1381 | + | ClipXOrigin int32 | |
| 1382 | + | ClipYOrigin int32 | |
| 1383 | + | ClipMask Pixmap | |
| 1384 | + | DashOffset uint32 | |
| 1385 | + | Dashes uint32 | |
| 1386 | + | ArcMode ArcMode | |
| 1387 | + | } | |
| 1388 | + | ||
| 1389 | + | func (v *ChangeGCValues) SetFunction(x Gx) *ChangeGCValues { | |
| 1390 | + | v.Mask |= GcFunction | |
| 1391 | + | v.Function = x | |
| 1392 | + | return v | |
| 1393 | + | } | |
| 1394 | + | func (v *ChangeGCValues) SetPlaneMask(x uint32) *ChangeGCValues { | |
| 1395 | + | v.Mask |= GcPlaneMask | |
| 1396 | + | v.PlaneMask = x | |
| 1397 | + | return v | |
| 1398 | + | } | |
| 1399 | + | func (v *ChangeGCValues) SetForeground(x uint32) *ChangeGCValues { | |
| 1400 | + | v.Mask |= GcForeground | |
| 1401 | + | v.Foreground = x | |
| 1402 | + | return v | |
| 1403 | + | } | |
| 1404 | + | func (v *ChangeGCValues) SetBackground(x uint32) *ChangeGCValues { | |
| 1405 | + | v.Mask |= GcBackground | |
| 1406 | + | v.Background = x | |
| 1407 | + | return v | |
| 1408 | + | } | |
| 1409 | + | func (v *ChangeGCValues) SetLineWidth(x uint32) *ChangeGCValues { | |
| 1410 | + | v.Mask |= GcLineWidth | |
| 1411 | + | v.LineWidth = x | |
| 1412 | + | return v | |
| 1413 | + | } | |
| 1414 | + | func (v *ChangeGCValues) SetLineStyle(x LineStyle) *ChangeGCValues { | |
| 1415 | + | v.Mask |= GcLineStyle | |
| 1416 | + | v.LineStyle = x | |
| 1417 | + | return v | |
| 1418 | + | } | |
| 1419 | + | func (v *ChangeGCValues) SetCapStyle(x CapStyle) *ChangeGCValues { | |
| 1420 | + | v.Mask |= GcCapStyle | |
| 1421 | + | v.CapStyle = x | |
| 1422 | + | return v | |
| 1423 | + | } | |
| 1424 | + | func (v *ChangeGCValues) SetJoinStyle(x JoinStyle) *ChangeGCValues { | |
| 1425 | + | v.Mask |= GcJoinStyle | |
| 1426 | + | v.JoinStyle = x | |
| 1427 | + | return v | |
| 1428 | + | } | |
| 1429 | + | func (v *ChangeGCValues) SetFillStyle(x FillStyle) *ChangeGCValues { | |
| 1430 | + | v.Mask |= GcFillStyle | |
| 1431 | + | v.FillStyle = x | |
| 1432 | + | return v | |
| 1433 | + | } | |
| 1434 | + | func (v *ChangeGCValues) SetFillRule(x FillRule) *ChangeGCValues { | |
| 1435 | + | v.Mask |= GcFillRule | |
| 1436 | + | v.FillRule = x | |
| 1437 | + | return v | |
| 1438 | + | } | |
| 1439 | + | func (v *ChangeGCValues) SetTile(x Pixmap) *ChangeGCValues { v.Mask |= GcTile; v.Tile = x; return v } | |
| 1440 | + | func (v *ChangeGCValues) SetStipple(x Pixmap) *ChangeGCValues { | |
| 1441 | + | v.Mask |= GcStipple | |
| 1442 | + | v.Stipple = x | |
| 1443 | + | return v | |
| 1444 | + | } | |
| 1445 | + | func (v *ChangeGCValues) SetTileStippleXOrigin(x int32) *ChangeGCValues { | |
| 1446 | + | v.Mask |= GcTileStippleOriginX | |
| 1447 | + | v.TileStippleXOrigin = x | |
| 1448 | + | return v | |
| 1449 | + | } | |
| 1450 | + | func (v *ChangeGCValues) SetTileStippleYOrigin(x int32) *ChangeGCValues { | |
| 1451 | + | v.Mask |= GcTileStippleOriginY | |
| 1452 | + | v.TileStippleYOrigin = x | |
| 1453 | + | return v | |
| 1454 | + | } | |
| 1455 | + | func (v *ChangeGCValues) SetFont(x Font) *ChangeGCValues { v.Mask |= GcFont; v.Font = x; return v } | |
| 1456 | + | func (v *ChangeGCValues) SetSubwindowMode(x SubwindowMode) *ChangeGCValues { | |
| 1457 | + | v.Mask |= GcSubwindowMode | |
| 1458 | + | v.SubwindowMode = x | |
| 1459 | + | return v | |
| 1460 | + | } | |
| 1461 | + | func (v *ChangeGCValues) SetGraphicsExposures(x bool) *ChangeGCValues { | |
| 1462 | + | v.Mask |= GcGraphicsExposures | |
| 1463 | + | v.GraphicsExposures = x | |
| 1464 | + | return v | |
| 1465 | + | } | |
| 1466 | + | func (v *ChangeGCValues) SetClipXOrigin(x int32) *ChangeGCValues { | |
| 1467 | + | v.Mask |= GcClipOriginX | |
| 1468 | + | v.ClipXOrigin = x | |
| 1469 | + | return v | |
| 1470 | + | } | |
| 1471 | + | func (v *ChangeGCValues) SetClipYOrigin(x int32) *ChangeGCValues { | |
| 1472 | + | v.Mask |= GcClipOriginY | |
| 1473 | + | v.ClipYOrigin = x | |
| 1474 | + | return v | |
| 1475 | + | } | |
| 1476 | + | func (v *ChangeGCValues) SetClipMask(x Pixmap) *ChangeGCValues { | |
| 1477 | + | v.Mask |= GcClipMask | |
| 1478 | + | v.ClipMask = x | |
| 1479 | + | return v | |
| 1480 | + | } | |
| 1481 | + | func (v *ChangeGCValues) SetDashOffset(x uint32) *ChangeGCValues { | |
| 1482 | + | v.Mask |= GcDashOffset | |
| 1483 | + | v.DashOffset = x | |
| 1484 | + | return v | |
| 1485 | + | } | |
| 1486 | + | func (v *ChangeGCValues) SetDashes(x uint32) *ChangeGCValues { | |
| 1487 | + | v.Mask |= GcDashList | |
| 1488 | + | v.Dashes = x | |
| 1489 | + | return v | |
| 1490 | + | } | |
| 1491 | + | func (v *ChangeGCValues) SetArcMode(x ArcMode) *ChangeGCValues { | |
| 1492 | + | v.Mask |= GcArcMode | |
| 1493 | + | v.ArcMode = x | |
| 1494 | + | return v | |
| 1495 | + | } | |
| 1496 | + | func ChangeGC(b *xturbo.Buf, gc Gcontext, v *ChangeGCValues) xturbo.Seq { | |
| 1497 | + | p, seq := b.Request(56, 0, 8+4*bits.OnesCount32(uint32(v.Mask))) | |
| 1498 | + | if p == nil { | |
| 1499 | + | return 0 | |
| 1500 | + | } | |
| 1501 | + | binary.LittleEndian.PutUint32(p[0:], uint32(gc)) | |
| 1502 | + | binary.LittleEndian.PutUint32(p[4:], uint32(v.Mask)) | |
| 1503 | + | off := 8 | |
| 1504 | + | if v.Mask&GcFunction != 0 { | |
| 1505 | + | binary.LittleEndian.PutUint32(p[off:], uint32(v.Function)) | |
| 1506 | + | off += 4 | |
| 1507 | + | } | |
| 1508 | + | if v.Mask&GcPlaneMask != 0 { | |
| 1509 | + | binary.LittleEndian.PutUint32(p[off:], uint32(v.PlaneMask)) | |
| 1510 | + | off += 4 | |
| 1511 | + | } | |
| 1512 | + | if v.Mask&GcForeground != 0 { | |
| 1513 | + | binary.LittleEndian.PutUint32(p[off:], uint32(v.Foreground)) | |
| 1514 | + | off += 4 | |
| 1515 | + | } | |
| 1516 | + | if v.Mask&GcBackground != 0 { | |
| 1517 | + | binary.LittleEndian.PutUint32(p[off:], uint32(v.Background)) | |
| 1518 | + | off += 4 | |
| 1519 | + | } | |
| 1520 | + | if v.Mask&GcLineWidth != 0 { | |
| 1521 | + | binary.LittleEndian.PutUint32(p[off:], uint32(v.LineWidth)) | |
| 1522 | + | off += 4 | |
| 1523 | + | } | |
| 1524 | + | if v.Mask&GcLineStyle != 0 { | |
| 1525 | + | binary.LittleEndian.PutUint32(p[off:], uint32(v.LineStyle)) | |
| 1526 | + | off += 4 | |
| 1527 | + | } | |
| 1528 | + | if v.Mask&GcCapStyle != 0 { | |
| 1529 | + | binary.LittleEndian.PutUint32(p[off:], uint32(v.CapStyle)) | |
| 1530 | + | off += 4 | |
| 1531 | + | } | |
| 1532 | + | if v.Mask&GcJoinStyle != 0 { | |
| 1533 | + | binary.LittleEndian.PutUint32(p[off:], uint32(v.JoinStyle)) | |
| 1534 | + | off += 4 | |
| 1535 | + | } | |
| 1536 | + | if v.Mask&GcFillStyle != 0 { | |
| 1537 | + | binary.LittleEndian.PutUint32(p[off:], uint32(v.FillStyle)) | |
| 1538 | + | off += 4 | |
| 1539 | + | } | |
| 1540 | + | if v.Mask&GcFillRule != 0 { | |
| 1541 | + | binary.LittleEndian.PutUint32(p[off:], uint32(v.FillRule)) | |
| 1542 | + | off += 4 | |
| 1543 | + | } | |
| 1544 | + | if v.Mask&GcTile != 0 { | |
| 1545 | + | binary.LittleEndian.PutUint32(p[off:], uint32(v.Tile)) | |
| 1546 | + | off += 4 | |
| 1547 | + | } | |
| 1548 | + | if v.Mask&GcStipple != 0 { | |
| 1549 | + | binary.LittleEndian.PutUint32(p[off:], uint32(v.Stipple)) | |
| 1550 | + | off += 4 | |
| 1551 | + | } | |
| 1552 | + | if v.Mask&GcTileStippleOriginX != 0 { | |
| 1553 | + | binary.LittleEndian.PutUint32(p[off:], uint32(v.TileStippleXOrigin)) | |
| 1554 | + | off += 4 | |
| 1555 | + | } | |
| 1556 | + | if v.Mask&GcTileStippleOriginY != 0 { | |
| 1557 | + | binary.LittleEndian.PutUint32(p[off:], uint32(v.TileStippleYOrigin)) | |
| 1558 | + | off += 4 | |
| 1559 | + | } | |
| 1560 | + | if v.Mask&GcFont != 0 { | |
| 1561 | + | binary.LittleEndian.PutUint32(p[off:], uint32(v.Font)) | |
| 1562 | + | off += 4 | |
| 1563 | + | } | |
| 1564 | + | if v.Mask&GcSubwindowMode != 0 { | |
| 1565 | + | binary.LittleEndian.PutUint32(p[off:], uint32(v.SubwindowMode)) | |
| 1566 | + | off += 4 | |
| 1567 | + | } | |
| 1568 | + | if v.Mask&GcGraphicsExposures != 0 { | |
| 1569 | + | if v.GraphicsExposures { | |
| 1570 | + | binary.LittleEndian.PutUint32(p[off:], 1) | |
| 1571 | + | } else { | |
| 1572 | + | binary.LittleEndian.PutUint32(p[off:], 0) | |
| 1573 | + | } | |
| 1574 | + | off += 4 | |
| 1575 | + | } | |
| 1576 | + | if v.Mask&GcClipOriginX != 0 { | |
| 1577 | + | binary.LittleEndian.PutUint32(p[off:], uint32(v.ClipXOrigin)) | |
| 1578 | + | off += 4 | |
| 1579 | + | } | |
| 1580 | + | if v.Mask&GcClipOriginY != 0 { | |
| 1581 | + | binary.LittleEndian.PutUint32(p[off:], uint32(v.ClipYOrigin)) | |
| 1582 | + | off += 4 | |
| 1583 | + | } | |
| 1584 | + | if v.Mask&GcClipMask != 0 { | |
| 1585 | + | binary.LittleEndian.PutUint32(p[off:], uint32(v.ClipMask)) | |
| 1586 | + | off += 4 | |
| 1587 | + | } | |
| 1588 | + | if v.Mask&GcDashOffset != 0 { | |
| 1589 | + | binary.LittleEndian.PutUint32(p[off:], uint32(v.DashOffset)) | |
| 1590 | + | off += 4 | |
| 1591 | + | } | |
| 1592 | + | if v.Mask&GcDashList != 0 { | |
| 1593 | + | binary.LittleEndian.PutUint32(p[off:], uint32(v.Dashes)) | |
| 1594 | + | off += 4 | |
| 1595 | + | } | |
| 1596 | + | if v.Mask&GcArcMode != 0 { | |
| 1597 | + | binary.LittleEndian.PutUint32(p[off:], uint32(v.ArcMode)) | |
| 1598 | + | off += 4 | |
| 1599 | + | } | |
| 1600 | + | _ = off | |
| 1601 | + | return seq | |
| 1602 | + | } | |
| 1603 | + | ||
| 1604 | + | func CopyGC(b *xturbo.Buf, srcGc Gcontext, dstGc Gcontext, valueMask Gc) xturbo.Seq { | |
| 1605 | + | p, seq := b.Request(57, 0, 12) | |
| 1606 | + | if p == nil { | |
| 1607 | + | return 0 | |
| 1608 | + | } | |
| 1609 | + | binary.LittleEndian.PutUint32(p[0:], uint32(srcGc)) | |
| 1610 | + | binary.LittleEndian.PutUint32(p[4:], uint32(dstGc)) | |
| 1611 | + | binary.LittleEndian.PutUint32(p[8:], uint32(valueMask)) | |
| 1612 | + | return seq | |
| 1613 | + | } | |
| 1614 | + | ||
| 1615 | + | func SetDashes(b *xturbo.Buf, gc Gcontext, dashOffset uint16, dashes []byte) xturbo.Seq { | |
| 1616 | + | if uint64(len(dashes)) > 65535 { | |
| 1617 | + | b.Fail(xturbo.ErrBadLength) | |
| 1618 | + | return 0 | |
| 1619 | + | } | |
| 1620 | + | size := 0 | |
| 1621 | + | size += 4 | |
| 1622 | + | size += 2 | |
| 1623 | + | size += 2 | |
| 1624 | + | size += len(dashes) * 1 | |
| 1625 | + | size = (size + 3) &^ 3 | |
| 1626 | + | p, seq := b.Request(58, 0, size) | |
| 1627 | + | if p == nil { | |
| 1628 | + | return 0 | |
| 1629 | + | } | |
| 1630 | + | off := 0 | |
| 1631 | + | binary.LittleEndian.PutUint32(p[off:], uint32(gc)) | |
| 1632 | + | off += 4 | |
| 1633 | + | binary.LittleEndian.PutUint16(p[off:], uint16(dashOffset)) | |
| 1634 | + | off += 2 | |
| 1635 | + | binary.LittleEndian.PutUint16(p[off:], uint16(len(dashes))) | |
| 1636 | + | off += 2 | |
| 1637 | + | copy(p[off:], dashes) | |
| 1638 | + | off += len(dashes) | |
| 1639 | + | return seq | |
| 1640 | + | } | |
| 1641 | + | ||
| 1642 | + | func SetClipRectangles(b *xturbo.Buf, ordering ClipOrdering, gc Gcontext, clipXOrigin int16, clipYOrigin int16, rectangles []Rectangle) xturbo.Seq { | |
| 1643 | + | size := 0 | |
| 1644 | + | size += 4 | |
| 1645 | + | size += 2 | |
| 1646 | + | size += 2 | |
| 1647 | + | size += len(rectangles) * 8 | |
| 1648 | + | size = (size + 3) &^ 3 | |
| 1649 | + | p, seq := b.Request(59, uint8(int(ordering)), size) | |
| 1650 | + | if p == nil { | |
| 1651 | + | return 0 | |
| 1652 | + | } | |
| 1653 | + | off := 0 | |
| 1654 | + | binary.LittleEndian.PutUint32(p[off:], uint32(gc)) | |
| 1655 | + | off += 4 | |
| 1656 | + | binary.LittleEndian.PutUint16(p[off:], uint16(clipXOrigin)) | |
| 1657 | + | off += 2 | |
| 1658 | + | binary.LittleEndian.PutUint16(p[off:], uint16(clipYOrigin)) | |
| 1659 | + | off += 2 | |
| 1660 | + | for i := range rectangles { | |
| 1661 | + | rectangles[i].Put(p[off:]) | |
| 1662 | + | off += 8 | |
| 1663 | + | } | |
| 1664 | + | return seq | |
| 1665 | + | } | |
| 1666 | + | ||
| 1667 | + | func FreeGC(b *xturbo.Buf, gc Gcontext) xturbo.Seq { | |
| 1668 | + | p, seq := b.Request(60, 0, 4) | |
| 1669 | + | if p == nil { | |
| 1670 | + | return 0 | |
| 1671 | + | } | |
| 1672 | + | binary.LittleEndian.PutUint32(p[0:], uint32(gc)) | |
| 1673 | + | return seq | |
| 1674 | + | } | |
| 1675 | + | ||
| 1676 | + | func ClearArea(b *xturbo.Buf, exposures bool, window Window, x int16, y int16, width uint16, height uint16) xturbo.Seq { | |
| 1677 | + | var data uint8 | |
| 1678 | + | if exposures { | |
| 1679 | + | data = 1 | |
| 1680 | + | } | |
| 1681 | + | p, seq := b.Request(61, data, 12) | |
| 1682 | + | if p == nil { | |
| 1683 | + | return 0 | |
| 1684 | + | } | |
| 1685 | + | binary.LittleEndian.PutUint32(p[0:], uint32(window)) | |
| 1686 | + | binary.LittleEndian.PutUint16(p[4:], uint16(x)) | |
| 1687 | + | binary.LittleEndian.PutUint16(p[6:], uint16(y)) | |
| 1688 | + | binary.LittleEndian.PutUint16(p[8:], uint16(width)) | |
| 1689 | + | binary.LittleEndian.PutUint16(p[10:], uint16(height)) | |
| 1690 | + | return seq | |
| 1691 | + | } | |
| 1692 | + | ||
| 1693 | + | func CopyArea(b *xturbo.Buf, srcDrawable Drawable, dstDrawable Drawable, gc Gcontext, srcX int16, srcY int16, dstX int16, dstY int16, width uint16, height uint16) xturbo.Seq { | |
| 1694 | + | p, seq := b.Request(62, 0, 24) | |
| 1695 | + | if p == nil { | |
| 1696 | + | return 0 | |
| 1697 | + | } | |
| 1698 | + | binary.LittleEndian.PutUint32(p[0:], uint32(srcDrawable)) | |
| 1699 | + | binary.LittleEndian.PutUint32(p[4:], uint32(dstDrawable)) | |
| 1700 | + | binary.LittleEndian.PutUint32(p[8:], uint32(gc)) | |
| 1701 | + | binary.LittleEndian.PutUint16(p[12:], uint16(srcX)) | |
| 1702 | + | binary.LittleEndian.PutUint16(p[14:], uint16(srcY)) | |
| 1703 | + | binary.LittleEndian.PutUint16(p[16:], uint16(dstX)) | |
| 1704 | + | binary.LittleEndian.PutUint16(p[18:], uint16(dstY)) | |
| 1705 | + | binary.LittleEndian.PutUint16(p[20:], uint16(width)) | |
| 1706 | + | binary.LittleEndian.PutUint16(p[22:], uint16(height)) | |
| 1707 | + | return seq | |
| 1708 | + | } | |
| 1709 | + | ||
| 1710 | + | func CopyPlane(b *xturbo.Buf, srcDrawable Drawable, dstDrawable Drawable, gc Gcontext, srcX int16, srcY int16, dstX int16, dstY int16, width uint16, height uint16, bitPlane uint32) xturbo.Seq { | |
| 1711 | + | p, seq := b.Request(63, 0, 28) | |
| 1712 | + | if p == nil { | |
| 1713 | + | return 0 | |
| 1714 | + | } | |
| 1715 | + | binary.LittleEndian.PutUint32(p[0:], uint32(srcDrawable)) | |
| 1716 | + | binary.LittleEndian.PutUint32(p[4:], uint32(dstDrawable)) | |
| 1717 | + | binary.LittleEndian.PutUint32(p[8:], uint32(gc)) | |
| 1718 | + | binary.LittleEndian.PutUint16(p[12:], uint16(srcX)) | |
| 1719 | + | binary.LittleEndian.PutUint16(p[14:], uint16(srcY)) | |
| 1720 | + | binary.LittleEndian.PutUint16(p[16:], uint16(dstX)) | |
| 1721 | + | binary.LittleEndian.PutUint16(p[18:], uint16(dstY)) | |
| 1722 | + | binary.LittleEndian.PutUint16(p[20:], uint16(width)) | |
| 1723 | + | binary.LittleEndian.PutUint16(p[22:], uint16(height)) | |
| 1724 | + | binary.LittleEndian.PutUint32(p[24:], uint32(bitPlane)) | |
| 1725 | + | return seq | |
| 1726 | + | } | |
| 1727 | + | ||
| 1728 | + | func PolyPoint(b *xturbo.Buf, coordinateMode CoordMode, drawable Drawable, gc Gcontext, points []Point) xturbo.Seq { | |
| 1729 | + | size := 0 | |
| 1730 | + | size += 4 | |
| 1731 | + | size += 4 | |
| 1732 | + | size += len(points) * 4 | |
| 1733 | + | size = (size + 3) &^ 3 | |
| 1734 | + | p, seq := b.Request(64, uint8(int(coordinateMode)), size) | |
| 1735 | + | if p == nil { | |
| 1736 | + | return 0 | |
| 1737 | + | } | |
| 1738 | + | off := 0 | |
| 1739 | + | binary.LittleEndian.PutUint32(p[off:], uint32(drawable)) | |
| 1740 | + | off += 4 | |
| 1741 | + | binary.LittleEndian.PutUint32(p[off:], uint32(gc)) | |
| 1742 | + | off += 4 | |
| 1743 | + | for i := range points { | |
| 1744 | + | points[i].Put(p[off:]) | |
| 1745 | + | off += 4 | |
| 1746 | + | } | |
| 1747 | + | return seq | |
| 1748 | + | } | |
| 1749 | + | ||
| 1750 | + | func PolyLine(b *xturbo.Buf, coordinateMode CoordMode, drawable Drawable, gc Gcontext, points []Point) xturbo.Seq { | |
| 1751 | + | size := 0 | |
| 1752 | + | size += 4 | |
| 1753 | + | size += 4 | |
| 1754 | + | size += len(points) * 4 | |
| 1755 | + | size = (size + 3) &^ 3 | |
| 1756 | + | p, seq := b.Request(65, uint8(int(coordinateMode)), size) | |
| 1757 | + | if p == nil { | |
| 1758 | + | return 0 | |
| 1759 | + | } | |
| 1760 | + | off := 0 | |
| 1761 | + | binary.LittleEndian.PutUint32(p[off:], uint32(drawable)) | |
| 1762 | + | off += 4 | |
| 1763 | + | binary.LittleEndian.PutUint32(p[off:], uint32(gc)) | |
| 1764 | + | off += 4 | |
| 1765 | + | for i := range points { | |
| 1766 | + | points[i].Put(p[off:]) | |
| 1767 | + | off += 4 | |
| 1768 | + | } | |
| 1769 | + | return seq | |
| 1770 | + | } | |
| 1771 | + | ||
| 1772 | + | func PolySegment(b *xturbo.Buf, drawable Drawable, gc Gcontext, segments []Segment) xturbo.Seq { | |
| 1773 | + | size := 0 | |
| 1774 | + | size += 4 | |
| 1775 | + | size += 4 | |
| 1776 | + | size += len(segments) * 8 | |
| 1777 | + | size = (size + 3) &^ 3 | |
| 1778 | + | p, seq := b.Request(66, 0, size) | |
| 1779 | + | if p == nil { | |
| 1780 | + | return 0 | |
| 1781 | + | } | |
| 1782 | + | off := 0 | |
| 1783 | + | binary.LittleEndian.PutUint32(p[off:], uint32(drawable)) | |
| 1784 | + | off += 4 | |
| 1785 | + | binary.LittleEndian.PutUint32(p[off:], uint32(gc)) | |
| 1786 | + | off += 4 | |
| 1787 | + | for i := range segments { | |
| 1788 | + | segments[i].Put(p[off:]) | |
| 1789 | + | off += 8 | |
| 1790 | + | } | |
| 1791 | + | return seq | |
| 1792 | + | } | |
| 1793 | + | ||
| 1794 | + | func PolyRectangle(b *xturbo.Buf, drawable Drawable, gc Gcontext, rectangles []Rectangle) xturbo.Seq { | |
| 1795 | + | size := 0 | |
| 1796 | + | size += 4 | |
| 1797 | + | size += 4 | |
| 1798 | + | size += len(rectangles) * 8 | |
| 1799 | + | size = (size + 3) &^ 3 | |
| 1800 | + | p, seq := b.Request(67, 0, size) | |
| 1801 | + | if p == nil { | |
| 1802 | + | return 0 | |
| 1803 | + | } | |
| 1804 | + | off := 0 | |
| 1805 | + | binary.LittleEndian.PutUint32(p[off:], uint32(drawable)) | |
| 1806 | + | off += 4 | |
| 1807 | + | binary.LittleEndian.PutUint32(p[off:], uint32(gc)) | |
| 1808 | + | off += 4 | |
| 1809 | + | for i := range rectangles { | |
| 1810 | + | rectangles[i].Put(p[off:]) | |
| 1811 | + | off += 8 | |
| 1812 | + | } | |
| 1813 | + | return seq | |
| 1814 | + | } | |
| 1815 | + | ||
| 1816 | + | func PolyArc(b *xturbo.Buf, drawable Drawable, gc Gcontext, arcs []Arc) xturbo.Seq { | |
| 1817 | + | size := 0 | |
| 1818 | + | size += 4 | |
| 1819 | + | size += 4 | |
| 1820 | + | size += len(arcs) * 12 | |
| 1821 | + | size = (size + 3) &^ 3 | |
| 1822 | + | p, seq := b.Request(68, 0, size) | |
| 1823 | + | if p == nil { | |
| 1824 | + | return 0 | |
| 1825 | + | } | |
| 1826 | + | off := 0 | |
| 1827 | + | binary.LittleEndian.PutUint32(p[off:], uint32(drawable)) | |
| 1828 | + | off += 4 | |
| 1829 | + | binary.LittleEndian.PutUint32(p[off:], uint32(gc)) | |
| 1830 | + | off += 4 | |
| 1831 | + | for i := range arcs { | |
| 1832 | + | arcs[i].Put(p[off:]) | |
| 1833 | + | off += 12 | |
| 1834 | + | } | |
| 1835 | + | return seq | |
| 1836 | + | } | |
| 1837 | + | ||
| 1838 | + | func FillPoly(b *xturbo.Buf, drawable Drawable, gc Gcontext, shape PolyShape, coordinateMode CoordMode, points []Point) xturbo.Seq { | |
| 1839 | + | size := 0 | |
| 1840 | + | size += 4 | |
| 1841 | + | size += 4 | |
| 1842 | + | size += 1 | |
| 1843 | + | size += 1 | |
| 1844 | + | size += 2 | |
| 1845 | + | size += len(points) * 4 | |
| 1846 | + | size = (size + 3) &^ 3 | |
| 1847 | + | p, seq := b.Request(69, 0, size) | |
| 1848 | + | if p == nil { | |
| 1849 | + | return 0 | |
| 1850 | + | } | |
| 1851 | + | off := 0 | |
| 1852 | + | binary.LittleEndian.PutUint32(p[off:], uint32(drawable)) | |
| 1853 | + | off += 4 | |
| 1854 | + | binary.LittleEndian.PutUint32(p[off:], uint32(gc)) | |
| 1855 | + | off += 4 | |
| 1856 | + | p[off:][0] = byte(shape) | |
| 1857 | + | off += 1 | |
| 1858 | + | p[off:][0] = byte(coordinateMode) | |
| 1859 | + | off += 1 | |
| 1860 | + | off += 2 | |
| 1861 | + | for i := range points { | |
| 1862 | + | points[i].Put(p[off:]) | |
| 1863 | + | off += 4 | |
| 1864 | + | } | |
| 1865 | + | return seq | |
| 1866 | + | } | |
| 1867 | + | ||
| 1868 | + | func PolyFillRectangle(b *xturbo.Buf, drawable Drawable, gc Gcontext, rectangles []Rectangle) xturbo.Seq { | |
| 1869 | + | size := 0 | |
| 1870 | + | size += 4 | |
| 1871 | + | size += 4 | |
| 1872 | + | size += len(rectangles) * 8 | |
| 1873 | + | size = (size + 3) &^ 3 | |
| 1874 | + | p, seq := b.Request(70, 0, size) | |
| 1875 | + | if p == nil { | |
| 1876 | + | return 0 | |
| 1877 | + | } | |
| 1878 | + | off := 0 | |
| 1879 | + | binary.LittleEndian.PutUint32(p[off:], uint32(drawable)) | |
| 1880 | + | off += 4 | |
| 1881 | + | binary.LittleEndian.PutUint32(p[off:], uint32(gc)) | |
| 1882 | + | off += 4 | |
| 1883 | + | for i := range rectangles { | |
| 1884 | + | rectangles[i].Put(p[off:]) | |
| 1885 | + | off += 8 | |
| 1886 | + | } | |
| 1887 | + | return seq | |
| 1888 | + | } | |
| 1889 | + | ||
| 1890 | + | func PolyFillArc(b *xturbo.Buf, drawable Drawable, gc Gcontext, arcs []Arc) xturbo.Seq { | |
| 1891 | + | size := 0 | |
| 1892 | + | size += 4 | |
| 1893 | + | size += 4 | |
| 1894 | + | size += len(arcs) * 12 | |
| 1895 | + | size = (size + 3) &^ 3 | |
| 1896 | + | p, seq := b.Request(71, 0, size) | |
| 1897 | + | if p == nil { | |
| 1898 | + | return 0 | |
| 1899 | + | } | |
| 1900 | + | off := 0 | |
| 1901 | + | binary.LittleEndian.PutUint32(p[off:], uint32(drawable)) | |
| 1902 | + | off += 4 | |
| 1903 | + | binary.LittleEndian.PutUint32(p[off:], uint32(gc)) | |
| 1904 | + | off += 4 | |
| 1905 | + | for i := range arcs { | |
| 1906 | + | arcs[i].Put(p[off:]) | |
| 1907 | + | off += 12 | |
| 1908 | + | } | |
| 1909 | + | return seq | |
| 1910 | + | } | |
| 1911 | + | ||
| 1912 | + | func PutImage(b *xturbo.Buf, format ImageFormat, drawable Drawable, gc Gcontext, width uint16, height uint16, dstX int16, dstY int16, leftPad uint8, depth uint8, data []byte) xturbo.Seq { | |
| 1913 | + | size := 0 | |
| 1914 | + | size += 4 | |
| 1915 | + | size += 4 | |
| 1916 | + | size += 2 | |
| 1917 | + | size += 2 | |
| 1918 | + | size += 2 | |
| 1919 | + | size += 2 | |
| 1920 | + | size += 1 | |
| 1921 | + | size += 1 | |
| 1922 | + | size += 2 | |
| 1923 | + | size += len(data) * 1 | |
| 1924 | + | size = (size + 3) &^ 3 | |
| 1925 | + | p, seq := b.Request(72, uint8(int(format)), size) | |
| 1926 | + | if p == nil { | |
| 1927 | + | return 0 | |
| 1928 | + | } | |
| 1929 | + | off := 0 | |
| 1930 | + | binary.LittleEndian.PutUint32(p[off:], uint32(drawable)) | |
| 1931 | + | off += 4 | |
| 1932 | + | binary.LittleEndian.PutUint32(p[off:], uint32(gc)) | |
| 1933 | + | off += 4 | |
| 1934 | + | binary.LittleEndian.PutUint16(p[off:], uint16(width)) | |
| 1935 | + | off += 2 | |
| 1936 | + | binary.LittleEndian.PutUint16(p[off:], uint16(height)) | |
| 1937 | + | off += 2 | |
| 1938 | + | binary.LittleEndian.PutUint16(p[off:], uint16(dstX)) | |
| 1939 | + | off += 2 | |
| 1940 | + | binary.LittleEndian.PutUint16(p[off:], uint16(dstY)) | |
| 1941 | + | off += 2 | |
| 1942 | + | p[off:][0] = byte(leftPad) | |
| 1943 | + | off += 1 | |
| 1944 | + | p[off:][0] = byte(depth) | |
| 1945 | + | off += 1 | |
| 1946 | + | off += 2 | |
| 1947 | + | copy(p[off:], data) | |
| 1948 | + | off += len(data) | |
| 1949 | + | return seq | |
| 1950 | + | } | |
| 1951 | + | ||
| 1952 | + | func GetImage(b *xturbo.Buf, format ImageFormat, drawable Drawable, x int16, y int16, width uint16, height uint16, planeMask uint32) xturbo.Seq { | |
| 1953 | + | p, seq := b.Request(73, uint8(int(format)), 16) | |
| 1954 | + | if p == nil { | |
| 1955 | + | return 0 | |
| 1956 | + | } | |
| 1957 | + | binary.LittleEndian.PutUint32(p[0:], uint32(drawable)) | |
| 1958 | + | binary.LittleEndian.PutUint16(p[4:], uint16(x)) | |
| 1959 | + | binary.LittleEndian.PutUint16(p[6:], uint16(y)) | |
| 1960 | + | binary.LittleEndian.PutUint16(p[8:], uint16(width)) | |
| 1961 | + | binary.LittleEndian.PutUint16(p[10:], uint16(height)) | |
| 1962 | + | binary.LittleEndian.PutUint32(p[12:], uint32(planeMask)) | |
| 1963 | + | return seq | |
| 1964 | + | } | |
| 1965 | + | ||
| 1966 | + | func PolyText8(b *xturbo.Buf, drawable Drawable, gc Gcontext, x int16, y int16, items []byte) xturbo.Seq { | |
| 1967 | + | size := 0 | |
| 1968 | + | size += 4 | |
| 1969 | + | size += 4 | |
| 1970 | + | size += 2 | |
| 1971 | + | size += 2 | |
| 1972 | + | size += len(items) * 1 | |
| 1973 | + | size = (size + 3) &^ 3 | |
| 1974 | + | p, seq := b.Request(74, 0, size) | |
| 1975 | + | if p == nil { | |
| 1976 | + | return 0 | |
| 1977 | + | } | |
| 1978 | + | off := 0 | |
| 1979 | + | binary.LittleEndian.PutUint32(p[off:], uint32(drawable)) | |
| 1980 | + | off += 4 | |
| 1981 | + | binary.LittleEndian.PutUint32(p[off:], uint32(gc)) | |
| 1982 | + | off += 4 | |
| 1983 | + | binary.LittleEndian.PutUint16(p[off:], uint16(x)) | |
| 1984 | + | off += 2 | |
| 1985 | + | binary.LittleEndian.PutUint16(p[off:], uint16(y)) | |
| 1986 | + | off += 2 | |
| 1987 | + | copy(p[off:], items) | |
| 1988 | + | off += len(items) | |
| 1989 | + | return seq | |
| 1990 | + | } | |
| 1991 | + | ||
| 1992 | + | func PolyText16(b *xturbo.Buf, drawable Drawable, gc Gcontext, x int16, y int16, items []byte) xturbo.Seq { | |
| 1993 | + | size := 0 | |
| 1994 | + | size += 4 | |
| 1995 | + | size += 4 | |
| 1996 | + | size += 2 | |
| 1997 | + | size += 2 | |
| 1998 | + | size += len(items) * 1 | |
| 1999 | + | size = (size + 3) &^ 3 | |
| 2000 | + | p, seq := b.Request(75, 0, size) | |
| 2001 | + | if p == nil { | |
| 2002 | + | return 0 | |
| 2003 | + | } | |
| 2004 | + | off := 0 | |
| 2005 | + | binary.LittleEndian.PutUint32(p[off:], uint32(drawable)) | |
| 2006 | + | off += 4 | |
| 2007 | + | binary.LittleEndian.PutUint32(p[off:], uint32(gc)) | |
| 2008 | + | off += 4 | |
| 2009 | + | binary.LittleEndian.PutUint16(p[off:], uint16(x)) | |
| 2010 | + | off += 2 | |
| 2011 | + | binary.LittleEndian.PutUint16(p[off:], uint16(y)) | |
| 2012 | + | off += 2 | |
| 2013 | + | copy(p[off:], items) | |
| 2014 | + | off += len(items) | |
| 2015 | + | return seq | |
| 2016 | + | } | |
| 2017 | + | ||
| 2018 | + | func ImageText8(b *xturbo.Buf, drawable Drawable, gc Gcontext, x int16, y int16, string string) xturbo.Seq { | |
| 2019 | + | if len(string) > 255 { | |
| 2020 | + | b.Fail(xturbo.ErrBadLength) | |
| 2021 | + | return 0 | |
| 2022 | + | } | |
| 2023 | + | size := 0 | |
| 2024 | + | size += 4 | |
| 2025 | + | size += 4 | |
| 2026 | + | size += 2 | |
| 2027 | + | size += 2 | |
| 2028 | + | size += len(string) * 1 | |
| 2029 | + | size = (size + 3) &^ 3 | |
| 2030 | + | p, seq := b.Request(76, uint8(len(string)), size) | |
| 2031 | + | if p == nil { | |
| 2032 | + | return 0 | |
| 2033 | + | } | |
| 2034 | + | off := 0 | |
| 2035 | + | binary.LittleEndian.PutUint32(p[off:], uint32(drawable)) | |
| 2036 | + | off += 4 | |
| 2037 | + | binary.LittleEndian.PutUint32(p[off:], uint32(gc)) | |
| 2038 | + | off += 4 | |
| 2039 | + | binary.LittleEndian.PutUint16(p[off:], uint16(x)) | |
| 2040 | + | off += 2 | |
| 2041 | + | binary.LittleEndian.PutUint16(p[off:], uint16(y)) | |
| 2042 | + | off += 2 | |
| 2043 | + | copy(p[off:], string) | |
| 2044 | + | off += len(string) | |
| 2045 | + | return seq | |
| 2046 | + | } | |
| 2047 | + | ||
| 2048 | + | func ImageText16(b *xturbo.Buf, drawable Drawable, gc Gcontext, x int16, y int16, string []Char2b) xturbo.Seq { | |
| 2049 | + | if len(string) > 255 { | |
| 2050 | + | b.Fail(xturbo.ErrBadLength) | |
| 2051 | + | return 0 | |
| 2052 | + | } | |
| 2053 | + | size := 0 | |
| 2054 | + | size += 4 | |
| 2055 | + | size += 4 | |
| 2056 | + | size += 2 | |
| 2057 | + | size += 2 | |
| 2058 | + | size += len(string) * 2 | |
| 2059 | + | size = (size + 3) &^ 3 | |
| 2060 | + | p, seq := b.Request(77, uint8(len(string)), size) | |
| 2061 | + | if p == nil { | |
| 2062 | + | return 0 | |
| 2063 | + | } | |
| 2064 | + | off := 0 | |
| 2065 | + | binary.LittleEndian.PutUint32(p[off:], uint32(drawable)) | |
| 2066 | + | off += 4 | |
| 2067 | + | binary.LittleEndian.PutUint32(p[off:], uint32(gc)) | |
| 2068 | + | off += 4 | |
| 2069 | + | binary.LittleEndian.PutUint16(p[off:], uint16(x)) | |
| 2070 | + | off += 2 | |
| 2071 | + | binary.LittleEndian.PutUint16(p[off:], uint16(y)) | |
| 2072 | + | off += 2 | |
| 2073 | + | for i := range string { | |
| 2074 | + | string[i].Put(p[off:]) | |
| 2075 | + | off += 2 | |
| 2076 | + | } | |
| 2077 | + | return seq | |
| 2078 | + | } | |
| 2079 | + | ||
| 2080 | + | func CreateColormap(b *xturbo.Buf, alloc ColormapAlloc, mid Colormap, window Window, visual Visualid) xturbo.Seq { | |
| 2081 | + | p, seq := b.Request(78, uint8(int(alloc)), 12) | |
| 2082 | + | if p == nil { | |
| 2083 | + | return 0 | |
| 2084 | + | } | |
| 2085 | + | binary.LittleEndian.PutUint32(p[0:], uint32(mid)) | |
| 2086 | + | binary.LittleEndian.PutUint32(p[4:], uint32(window)) | |
| 2087 | + | binary.LittleEndian.PutUint32(p[8:], uint32(visual)) | |
| 2088 | + | return seq | |
| 2089 | + | } | |
| 2090 | + | ||
| 2091 | + | func FreeColormap(b *xturbo.Buf, cmap Colormap) xturbo.Seq { | |
| 2092 | + | p, seq := b.Request(79, 0, 4) | |
| 2093 | + | if p == nil { | |
| 2094 | + | return 0 | |
| 2095 | + | } | |
| 2096 | + | binary.LittleEndian.PutUint32(p[0:], uint32(cmap)) | |
| 2097 | + | return seq | |
| 2098 | + | } | |
| 2099 | + | ||
| 2100 | + | func CopyColormapAndFree(b *xturbo.Buf, mid Colormap, srcCmap Colormap) xturbo.Seq { | |
| 2101 | + | p, seq := b.Request(80, 0, 8) | |
| 2102 | + | if p == nil { | |
| 2103 | + | return 0 | |
| 2104 | + | } | |
| 2105 | + | binary.LittleEndian.PutUint32(p[0:], uint32(mid)) | |
| 2106 | + | binary.LittleEndian.PutUint32(p[4:], uint32(srcCmap)) | |
| 2107 | + | return seq | |
| 2108 | + | } | |
| 2109 | + | ||
| 2110 | + | func InstallColormap(b *xturbo.Buf, cmap Colormap) xturbo.Seq { | |
| 2111 | + | p, seq := b.Request(81, 0, 4) | |
| 2112 | + | if p == nil { | |
| 2113 | + | return 0 | |
| 2114 | + | } | |
| 2115 | + | binary.LittleEndian.PutUint32(p[0:], uint32(cmap)) | |
| 2116 | + | return seq | |
| 2117 | + | } | |
| 2118 | + | ||
| 2119 | + | func UninstallColormap(b *xturbo.Buf, cmap Colormap) xturbo.Seq { | |
| 2120 | + | p, seq := b.Request(82, 0, 4) | |
| 2121 | + | if p == nil { | |
| 2122 | + | return 0 | |
| 2123 | + | } | |
| 2124 | + | binary.LittleEndian.PutUint32(p[0:], uint32(cmap)) | |
| 2125 | + | return seq | |
| 2126 | + | } | |
| 2127 | + | ||
| 2128 | + | func ListInstalledColormaps(b *xturbo.Buf, window Window) xturbo.Seq { | |
| 2129 | + | p, seq := b.Request(83, 0, 4) | |
| 2130 | + | if p == nil { | |
| 2131 | + | return 0 | |
| 2132 | + | } | |
| 2133 | + | binary.LittleEndian.PutUint32(p[0:], uint32(window)) | |
| 2134 | + | return seq | |
| 2135 | + | } | |
| 2136 | + | ||
| 2137 | + | func AllocColor(b *xturbo.Buf, cmap Colormap, red uint16, green uint16, blue uint16) xturbo.Seq { | |
| 2138 | + | p, seq := b.Request(84, 0, 12) | |
| 2139 | + | if p == nil { | |
| 2140 | + | return 0 | |
| 2141 | + | } | |
| 2142 | + | binary.LittleEndian.PutUint32(p[0:], uint32(cmap)) | |
| 2143 | + | binary.LittleEndian.PutUint16(p[4:], uint16(red)) | |
| 2144 | + | binary.LittleEndian.PutUint16(p[6:], uint16(green)) | |
| 2145 | + | binary.LittleEndian.PutUint16(p[8:], uint16(blue)) | |
| 2146 | + | return seq | |
| 2147 | + | } | |
| 2148 | + | ||
| 2149 | + | func AllocNamedColor(b *xturbo.Buf, cmap Colormap, name string) xturbo.Seq { | |
| 2150 | + | if uint64(len(name)) > 65535 { | |
| 2151 | + | b.Fail(xturbo.ErrBadLength) | |
| 2152 | + | return 0 | |
| 2153 | + | } | |
| 2154 | + | size := 0 | |
| 2155 | + | size += 4 | |
| 2156 | + | size += 2 | |
| 2157 | + | size += 2 | |
| 2158 | + | size += len(name) * 1 | |
| 2159 | + | size = (size + 3) &^ 3 | |
| 2160 | + | p, seq := b.Request(85, 0, size) | |
| 2161 | + | if p == nil { | |
| 2162 | + | return 0 | |
| 2163 | + | } | |
| 2164 | + | off := 0 | |
| 2165 | + | binary.LittleEndian.PutUint32(p[off:], uint32(cmap)) | |
| 2166 | + | off += 4 | |
| 2167 | + | binary.LittleEndian.PutUint16(p[off:], uint16(len(name))) | |
| 2168 | + | off += 2 | |
| 2169 | + | off += 2 | |
| 2170 | + | copy(p[off:], name) | |
| 2171 | + | off += len(name) | |
| 2172 | + | return seq | |
| 2173 | + | } | |
| 2174 | + | ||
| 2175 | + | func AllocColorCells(b *xturbo.Buf, contiguous bool, cmap Colormap, colors uint16, planes uint16) xturbo.Seq { | |
| 2176 | + | var data uint8 | |
| 2177 | + | if contiguous { | |
| 2178 | + | data = 1 | |
| 2179 | + | } | |
| 2180 | + | p, seq := b.Request(86, data, 8) | |
| 2181 | + | if p == nil { | |
| 2182 | + | return 0 | |
| 2183 | + | } | |
| 2184 | + | binary.LittleEndian.PutUint32(p[0:], uint32(cmap)) | |
| 2185 | + | binary.LittleEndian.PutUint16(p[4:], uint16(colors)) | |
| 2186 | + | binary.LittleEndian.PutUint16(p[6:], uint16(planes)) | |
| 2187 | + | return seq | |
| 2188 | + | } | |
| 2189 | + | ||
| 2190 | + | func AllocColorPlanes(b *xturbo.Buf, contiguous bool, cmap Colormap, colors uint16, reds uint16, greens uint16, blues uint16) xturbo.Seq { | |
| 2191 | + | var data uint8 | |
| 2192 | + | if contiguous { | |
| 2193 | + | data = 1 | |
| 2194 | + | } | |
| 2195 | + | p, seq := b.Request(87, data, 12) | |
| 2196 | + | if p == nil { | |
| 2197 | + | return 0 | |
| 2198 | + | } | |
| 2199 | + | binary.LittleEndian.PutUint32(p[0:], uint32(cmap)) | |
| 2200 | + | binary.LittleEndian.PutUint16(p[4:], uint16(colors)) | |
| 2201 | + | binary.LittleEndian.PutUint16(p[6:], uint16(reds)) | |
| 2202 | + | binary.LittleEndian.PutUint16(p[8:], uint16(greens)) | |
| 2203 | + | binary.LittleEndian.PutUint16(p[10:], uint16(blues)) | |
| 2204 | + | return seq | |
| 2205 | + | } | |
| 2206 | + | ||
| 2207 | + | func FreeColors(b *xturbo.Buf, cmap Colormap, planeMask uint32, pixels []uint32) xturbo.Seq { | |
| 2208 | + | size := 0 | |
| 2209 | + | size += 4 | |
| 2210 | + | size += 4 | |
| 2211 | + | size += len(pixels) * 4 | |
| 2212 | + | size = (size + 3) &^ 3 | |
| 2213 | + | p, seq := b.Request(88, 0, size) | |
| 2214 | + | if p == nil { | |
| 2215 | + | return 0 | |
| 2216 | + | } | |
| 2217 | + | off := 0 | |
| 2218 | + | binary.LittleEndian.PutUint32(p[off:], uint32(cmap)) | |
| 2219 | + | off += 4 | |
| 2220 | + | binary.LittleEndian.PutUint32(p[off:], uint32(planeMask)) | |
| 2221 | + | off += 4 | |
| 2222 | + | for i := range pixels { | |
| 2223 | + | binary.LittleEndian.PutUint32(p[off:], uint32(pixels[i])) | |
| 2224 | + | off += 4 | |
| 2225 | + | } | |
| 2226 | + | return seq | |
| 2227 | + | } | |
| 2228 | + | ||
| 2229 | + | func StoreColors(b *xturbo.Buf, cmap Colormap, items []Coloritem) xturbo.Seq { | |
| 2230 | + | size := 0 | |
| 2231 | + | size += 4 | |
| 2232 | + | size += len(items) * 12 | |
| 2233 | + | size = (size + 3) &^ 3 | |
| 2234 | + | p, seq := b.Request(89, 0, size) | |
| 2235 | + | if p == nil { | |
| 2236 | + | return 0 | |
| 2237 | + | } | |
| 2238 | + | off := 0 | |
| 2239 | + | binary.LittleEndian.PutUint32(p[off:], uint32(cmap)) | |
| 2240 | + | off += 4 | |
| 2241 | + | for i := range items { | |
| 2242 | + | items[i].Put(p[off:]) | |
| 2243 | + | off += 12 | |
| 2244 | + | } | |
| 2245 | + | return seq | |
| 2246 | + | } | |
| 2247 | + | ||
| 2248 | + | func StoreNamedColor(b *xturbo.Buf, flags ColorFlag, cmap Colormap, pixel uint32, name string) xturbo.Seq { | |
| 2249 | + | if uint64(len(name)) > 65535 { | |
| 2250 | + | b.Fail(xturbo.ErrBadLength) | |
| 2251 | + | return 0 | |
| 2252 | + | } | |
| 2253 | + | size := 0 | |
| 2254 | + | size += 4 | |
| 2255 | + | size += 4 | |
| 2256 | + | size += 2 | |
| 2257 | + | size += 2 | |
| 2258 | + | size += len(name) * 1 | |
| 2259 | + | size = (size + 3) &^ 3 | |
| 2260 | + | p, seq := b.Request(90, uint8(int(flags)), size) | |
| 2261 | + | if p == nil { | |
| 2262 | + | return 0 | |
| 2263 | + | } | |
| 2264 | + | off := 0 | |
| 2265 | + | binary.LittleEndian.PutUint32(p[off:], uint32(cmap)) | |
| 2266 | + | off += 4 | |
| 2267 | + | binary.LittleEndian.PutUint32(p[off:], uint32(pixel)) | |
| 2268 | + | off += 4 | |
| 2269 | + | binary.LittleEndian.PutUint16(p[off:], uint16(len(name))) | |
| 2270 | + | off += 2 | |
| 2271 | + | off += 2 | |
| 2272 | + | copy(p[off:], name) | |
| 2273 | + | off += len(name) | |
| 2274 | + | return seq | |
| 2275 | + | } | |
| 2276 | + | ||
| 2277 | + | func QueryColors(b *xturbo.Buf, cmap Colormap, pixels []uint32) xturbo.Seq { | |
| 2278 | + | size := 0 | |
| 2279 | + | size += 4 | |
| 2280 | + | size += len(pixels) * 4 | |
| 2281 | + | size = (size + 3) &^ 3 | |
| 2282 | + | p, seq := b.Request(91, 0, size) | |
| 2283 | + | if p == nil { | |
| 2284 | + | return 0 | |
| 2285 | + | } | |
| 2286 | + | off := 0 | |
| 2287 | + | binary.LittleEndian.PutUint32(p[off:], uint32(cmap)) | |
| 2288 | + | off += 4 | |
| 2289 | + | for i := range pixels { | |
| 2290 | + | binary.LittleEndian.PutUint32(p[off:], uint32(pixels[i])) | |
| 2291 | + | off += 4 | |
| 2292 | + | } | |
| 2293 | + | return seq | |
| 2294 | + | } | |
| 2295 | + | ||
| 2296 | + | func LookupColor(b *xturbo.Buf, cmap Colormap, name string) xturbo.Seq { | |
| 2297 | + | if uint64(len(name)) > 65535 { | |
| 2298 | + | b.Fail(xturbo.ErrBadLength) | |
| 2299 | + | return 0 | |
| 2300 | + | } | |
| 2301 | + | size := 0 | |
| 2302 | + | size += 4 | |
| 2303 | + | size += 2 | |
| 2304 | + | size += 2 | |
| 2305 | + | size += len(name) * 1 | |
| 2306 | + | size = (size + 3) &^ 3 | |
| 2307 | + | p, seq := b.Request(92, 0, size) | |
| 2308 | + | if p == nil { | |
| 2309 | + | return 0 | |
| 2310 | + | } | |
| 2311 | + | off := 0 | |
| 2312 | + | binary.LittleEndian.PutUint32(p[off:], uint32(cmap)) | |
| 2313 | + | off += 4 | |
| 2314 | + | binary.LittleEndian.PutUint16(p[off:], uint16(len(name))) | |
| 2315 | + | off += 2 | |
| 2316 | + | off += 2 | |
| 2317 | + | copy(p[off:], name) | |
| 2318 | + | off += len(name) | |
| 2319 | + | return seq | |
| 2320 | + | } | |
| 2321 | + | ||
| 2322 | + | func CreateCursor(b *xturbo.Buf, cid Cursor, source Pixmap, mask Pixmap, foreRed uint16, foreGreen uint16, foreBlue uint16, backRed uint16, backGreen uint16, backBlue uint16, x uint16, y uint16) xturbo.Seq { | |
| 2323 | + | p, seq := b.Request(93, 0, 28) | |
| 2324 | + | if p == nil { | |
| 2325 | + | return 0 | |
| 2326 | + | } | |
| 2327 | + | binary.LittleEndian.PutUint32(p[0:], uint32(cid)) | |
| 2328 | + | binary.LittleEndian.PutUint32(p[4:], uint32(source)) | |
| 2329 | + | binary.LittleEndian.PutUint32(p[8:], uint32(mask)) | |
| 2330 | + | binary.LittleEndian.PutUint16(p[12:], uint16(foreRed)) | |
| 2331 | + | binary.LittleEndian.PutUint16(p[14:], uint16(foreGreen)) | |
| 2332 | + | binary.LittleEndian.PutUint16(p[16:], uint16(foreBlue)) | |
| 2333 | + | binary.LittleEndian.PutUint16(p[18:], uint16(backRed)) | |
| 2334 | + | binary.LittleEndian.PutUint16(p[20:], uint16(backGreen)) | |
| 2335 | + | binary.LittleEndian.PutUint16(p[22:], uint16(backBlue)) | |
| 2336 | + | binary.LittleEndian.PutUint16(p[24:], uint16(x)) | |
| 2337 | + | binary.LittleEndian.PutUint16(p[26:], uint16(y)) | |
| 2338 | + | return seq | |
| 2339 | + | } | |
| 2340 | + | ||
| 2341 | + | func CreateGlyphCursor(b *xturbo.Buf, cid Cursor, sourceFont Font, maskFont Font, sourceChar uint16, maskChar uint16, foreRed uint16, foreGreen uint16, foreBlue uint16, backRed uint16, backGreen uint16, backBlue uint16) xturbo.Seq { | |
| 2342 | + | p, seq := b.Request(94, 0, 28) | |
| 2343 | + | if p == nil { | |
| 2344 | + | return 0 | |
| 2345 | + | } | |
| 2346 | + | binary.LittleEndian.PutUint32(p[0:], uint32(cid)) | |
| 2347 | + | binary.LittleEndian.PutUint32(p[4:], uint32(sourceFont)) | |
| 2348 | + | binary.LittleEndian.PutUint32(p[8:], uint32(maskFont)) | |
| 2349 | + | binary.LittleEndian.PutUint16(p[12:], uint16(sourceChar)) | |
| 2350 | + | binary.LittleEndian.PutUint16(p[14:], uint16(maskChar)) | |
| 2351 | + | binary.LittleEndian.PutUint16(p[16:], uint16(foreRed)) | |
| 2352 | + | binary.LittleEndian.PutUint16(p[18:], uint16(foreGreen)) | |
| 2353 | + | binary.LittleEndian.PutUint16(p[20:], uint16(foreBlue)) | |
| 2354 | + | binary.LittleEndian.PutUint16(p[22:], uint16(backRed)) | |
| 2355 | + | binary.LittleEndian.PutUint16(p[24:], uint16(backGreen)) | |
| 2356 | + | binary.LittleEndian.PutUint16(p[26:], uint16(backBlue)) | |
| 2357 | + | return seq | |
| 2358 | + | } | |
| 2359 | + | ||
| 2360 | + | func FreeCursor(b *xturbo.Buf, cursor Cursor) xturbo.Seq { | |
| 2361 | + | p, seq := b.Request(95, 0, 4) | |
| 2362 | + | if p == nil { | |
| 2363 | + | return 0 | |
| 2364 | + | } | |
| 2365 | + | binary.LittleEndian.PutUint32(p[0:], uint32(cursor)) | |
| 2366 | + | return seq | |
| 2367 | + | } | |
| 2368 | + | ||
| 2369 | + | func RecolorCursor(b *xturbo.Buf, cursor Cursor, foreRed uint16, foreGreen uint16, foreBlue uint16, backRed uint16, backGreen uint16, backBlue uint16) xturbo.Seq { | |
| 2370 | + | p, seq := b.Request(96, 0, 16) | |
| 2371 | + | if p == nil { | |
| 2372 | + | return 0 | |
| 2373 | + | } | |
| 2374 | + | binary.LittleEndian.PutUint32(p[0:], uint32(cursor)) | |
| 2375 | + | binary.LittleEndian.PutUint16(p[4:], uint16(foreRed)) | |
| 2376 | + | binary.LittleEndian.PutUint16(p[6:], uint16(foreGreen)) | |
| 2377 | + | binary.LittleEndian.PutUint16(p[8:], uint16(foreBlue)) | |
| 2378 | + | binary.LittleEndian.PutUint16(p[10:], uint16(backRed)) | |
| 2379 | + | binary.LittleEndian.PutUint16(p[12:], uint16(backGreen)) | |
| 2380 | + | binary.LittleEndian.PutUint16(p[14:], uint16(backBlue)) | |
| 2381 | + | return seq | |
| 2382 | + | } | |
| 2383 | + | ||
| 2384 | + | func QueryBestSize(b *xturbo.Buf, class QueryShapeOf, drawable Drawable, width uint16, height uint16) xturbo.Seq { | |
| 2385 | + | p, seq := b.Request(97, uint8(int(class)), 8) | |
| 2386 | + | if p == nil { | |
| 2387 | + | return 0 | |
| 2388 | + | } | |
| 2389 | + | binary.LittleEndian.PutUint32(p[0:], uint32(drawable)) | |
| 2390 | + | binary.LittleEndian.PutUint16(p[4:], uint16(width)) | |
| 2391 | + | binary.LittleEndian.PutUint16(p[6:], uint16(height)) | |
| 2392 | + | return seq | |
| 2393 | + | } | |
| 2394 | + | ||
| 2395 | + | func QueryExtension(b *xturbo.Buf, name string) xturbo.Seq { | |
| 2396 | + | if uint64(len(name)) > 65535 { | |
| 2397 | + | b.Fail(xturbo.ErrBadLength) | |
| 2398 | + | return 0 | |
| 2399 | + | } | |
| 2400 | + | size := 0 | |
| 2401 | + | size += 2 | |
| 2402 | + | size += 2 | |
| 2403 | + | size += len(name) * 1 | |
| 2404 | + | size = (size + 3) &^ 3 | |
| 2405 | + | p, seq := b.Request(98, 0, size) | |
| 2406 | + | if p == nil { | |
| 2407 | + | return 0 | |
| 2408 | + | } | |
| 2409 | + | off := 0 | |
| 2410 | + | binary.LittleEndian.PutUint16(p[off:], uint16(len(name))) | |
| 2411 | + | off += 2 | |
| 2412 | + | off += 2 | |
| 2413 | + | copy(p[off:], name) | |
| 2414 | + | off += len(name) | |
| 2415 | + | return seq | |
| 2416 | + | } | |
| 2417 | + | ||
| 2418 | + | func ListExtensions(b *xturbo.Buf) xturbo.Seq { | |
| 2419 | + | p, seq := b.Request(99, 0, 0) | |
| 2420 | + | if p == nil { | |
| 2421 | + | return 0 | |
| 2422 | + | } | |
| 2423 | + | return seq | |
| 2424 | + | } | |
| 2425 | + | ||
| 2426 | + | func ChangeKeyboardMapping(b *xturbo.Buf, keycodeCount uint8, firstKeycode Keycode, keysymsPerKeycode uint8, keysyms []Keysym) xturbo.Seq { | |
| 2427 | + | if len(keysyms) != (int(keycodeCount) * int(keysymsPerKeycode)) { | |
| 2428 | + | b.Fail(xturbo.ErrBadLength) | |
| 2429 | + | return 0 | |
| 2430 | + | } | |
| 2431 | + | size := 0 | |
| 2432 | + | size += 1 | |
| 2433 | + | size += 1 | |
| 2434 | + | size += 2 | |
| 2435 | + | size += len(keysyms) * 4 | |
| 2436 | + | size = (size + 3) &^ 3 | |
| 2437 | + | p, seq := b.Request(100, uint8(int(keycodeCount)), size) | |
| 2438 | + | if p == nil { | |
| 2439 | + | return 0 | |
| 2440 | + | } | |
| 2441 | + | off := 0 | |
| 2442 | + | p[off:][0] = byte(firstKeycode) | |
| 2443 | + | off += 1 | |
| 2444 | + | p[off:][0] = byte(keysymsPerKeycode) | |
| 2445 | + | off += 1 | |
| 2446 | + | off += 2 | |
| 2447 | + | for i := range keysyms { | |
| 2448 | + | binary.LittleEndian.PutUint32(p[off:], uint32(keysyms[i])) | |
| 2449 | + | off += 4 | |
| 2450 | + | } | |
| 2451 | + | return seq | |
| 2452 | + | } | |
| 2453 | + | ||
| 2454 | + | func GetKeyboardMapping(b *xturbo.Buf, firstKeycode Keycode, count uint8) xturbo.Seq { | |
| 2455 | + | p, seq := b.Request(101, 0, 4) | |
| 2456 | + | if p == nil { | |
| 2457 | + | return 0 | |
| 2458 | + | } | |
| 2459 | + | p[0:][0] = byte(firstKeycode) | |
| 2460 | + | p[1:][0] = byte(count) | |
| 2461 | + | return seq | |
| 2462 | + | } | |
| 2463 | + | ||
| 2464 | + | type ChangeKeyboardControlValues struct { | |
| 2465 | + | Mask Kb | |
| 2466 | + | KeyClickPercent int32 | |
| 2467 | + | BellPercent int32 | |
| 2468 | + | BellPitch int32 | |
| 2469 | + | BellDuration int32 | |
| 2470 | + | Led uint32 | |
| 2471 | + | LedMode LedMode | |
| 2472 | + | Key Keycode32 | |
| 2473 | + | AutoRepeatMode AutoRepeatMode | |
| 2474 | + | } | |
| 2475 | + | ||
| 2476 | + | func (v *ChangeKeyboardControlValues) SetKeyClickPercent(x int32) *ChangeKeyboardControlValues { | |
| 2477 | + | v.Mask |= KbKeyClickPercent | |
| 2478 | + | v.KeyClickPercent = x | |
| 2479 | + | return v | |
| 2480 | + | } | |
| 2481 | + | func (v *ChangeKeyboardControlValues) SetBellPercent(x int32) *ChangeKeyboardControlValues { | |
| 2482 | + | v.Mask |= KbBellPercent | |
| 2483 | + | v.BellPercent = x | |
| 2484 | + | return v | |
| 2485 | + | } | |
| 2486 | + | func (v *ChangeKeyboardControlValues) SetBellPitch(x int32) *ChangeKeyboardControlValues { | |
| 2487 | + | v.Mask |= KbBellPitch | |
| 2488 | + | v.BellPitch = x | |
| 2489 | + | return v | |
| 2490 | + | } | |
| 2491 | + | func (v *ChangeKeyboardControlValues) SetBellDuration(x int32) *ChangeKeyboardControlValues { | |
| 2492 | + | v.Mask |= KbBellDuration | |
| 2493 | + | v.BellDuration = x | |
| 2494 | + | return v | |
| 2495 | + | } | |
| 2496 | + | func (v *ChangeKeyboardControlValues) SetLed(x uint32) *ChangeKeyboardControlValues { | |
| 2497 | + | v.Mask |= KbLed | |
| 2498 | + | v.Led = x | |
| 2499 | + | return v | |
| 2500 | + | } | |
| 2501 | + | func (v *ChangeKeyboardControlValues) SetLedMode(x LedMode) *ChangeKeyboardControlValues { | |
| 2502 | + | v.Mask |= KbLedMode | |
| 2503 | + | v.LedMode = x | |
| 2504 | + | return v | |
| 2505 | + | } | |
| 2506 | + | func (v *ChangeKeyboardControlValues) SetKey(x Keycode32) *ChangeKeyboardControlValues { | |
| 2507 | + | v.Mask |= KbKey | |
| 2508 | + | v.Key = x | |
| 2509 | + | return v | |
| 2510 | + | } | |
| 2511 | + | func (v *ChangeKeyboardControlValues) SetAutoRepeatMode(x AutoRepeatMode) *ChangeKeyboardControlValues { | |
| 2512 | + | v.Mask |= KbAutoRepeatMode | |
| 2513 | + | v.AutoRepeatMode = x | |
| 2514 | + | return v | |
| 2515 | + | } | |
| 2516 | + | func ChangeKeyboardControl(b *xturbo.Buf, v *ChangeKeyboardControlValues) xturbo.Seq { | |
| 2517 | + | p, seq := b.Request(102, 0, 4+4*bits.OnesCount32(uint32(v.Mask))) | |
| 2518 | + | if p == nil { | |
| 2519 | + | return 0 | |
| 2520 | + | } | |
| 2521 | + | binary.LittleEndian.PutUint32(p[0:], uint32(v.Mask)) | |
| 2522 | + | off := 4 | |
| 2523 | + | if v.Mask&KbKeyClickPercent != 0 { | |
| 2524 | + | binary.LittleEndian.PutUint32(p[off:], uint32(v.KeyClickPercent)) | |
| 2525 | + | off += 4 | |
| 2526 | + | } | |
| 2527 | + | if v.Mask&KbBellPercent != 0 { | |
| 2528 | + | binary.LittleEndian.PutUint32(p[off:], uint32(v.BellPercent)) | |
| 2529 | + | off += 4 | |
| 2530 | + | } | |
| 2531 | + | if v.Mask&KbBellPitch != 0 { | |
| 2532 | + | binary.LittleEndian.PutUint32(p[off:], uint32(v.BellPitch)) | |
| 2533 | + | off += 4 | |
| 2534 | + | } | |
| 2535 | + | if v.Mask&KbBellDuration != 0 { | |
| 2536 | + | binary.LittleEndian.PutUint32(p[off:], uint32(v.BellDuration)) | |
| 2537 | + | off += 4 | |
| 2538 | + | } | |
| 2539 | + | if v.Mask&KbLed != 0 { | |
| 2540 | + | binary.LittleEndian.PutUint32(p[off:], uint32(v.Led)) | |
| 2541 | + | off += 4 | |
| 2542 | + | } | |
| 2543 | + | if v.Mask&KbLedMode != 0 { | |
| 2544 | + | binary.LittleEndian.PutUint32(p[off:], uint32(v.LedMode)) | |
| 2545 | + | off += 4 | |
| 2546 | + | } | |
| 2547 | + | if v.Mask&KbKey != 0 { | |
| 2548 | + | binary.LittleEndian.PutUint32(p[off:], uint32(v.Key)) | |
| 2549 | + | off += 4 | |
| 2550 | + | } | |
| 2551 | + | if v.Mask&KbAutoRepeatMode != 0 { | |
| 2552 | + | binary.LittleEndian.PutUint32(p[off:], uint32(v.AutoRepeatMode)) | |
| 2553 | + | off += 4 | |
| 2554 | + | } | |
| 2555 | + | _ = off | |
| 2556 | + | return seq | |
| 2557 | + | } | |
| 2558 | + | ||
| 2559 | + | func GetKeyboardControl(b *xturbo.Buf) xturbo.Seq { | |
| 2560 | + | p, seq := b.Request(103, 0, 0) | |
| 2561 | + | if p == nil { | |
| 2562 | + | return 0 | |
| 2563 | + | } | |
| 2564 | + | return seq | |
| 2565 | + | } | |
| 2566 | + | ||
| 2567 | + | func Bell(b *xturbo.Buf, percent int8) xturbo.Seq { | |
| 2568 | + | p, seq := b.Request(104, uint8(int(percent)), 0) | |
| 2569 | + | if p == nil { | |
| 2570 | + | return 0 | |
| 2571 | + | } | |
| 2572 | + | return seq | |
| 2573 | + | } | |
| 2574 | + | ||
| 2575 | + | func ChangePointerControl(b *xturbo.Buf, accelerationNumerator int16, accelerationDenominator int16, threshold int16, doAcceleration bool, doThreshold bool) xturbo.Seq { | |
| 2576 | + | p, seq := b.Request(105, 0, 8) | |
| 2577 | + | if p == nil { | |
| 2578 | + | return 0 | |
| 2579 | + | } | |
| 2580 | + | binary.LittleEndian.PutUint16(p[0:], uint16(accelerationNumerator)) | |
| 2581 | + | binary.LittleEndian.PutUint16(p[2:], uint16(accelerationDenominator)) | |
| 2582 | + | binary.LittleEndian.PutUint16(p[4:], uint16(threshold)) | |
| 2583 | + | if doAcceleration { | |
| 2584 | + | p[6:][0] = 1 | |
| 2585 | + | } else { | |
| 2586 | + | p[6:][0] = 0 | |
| 2587 | + | } | |
| 2588 | + | if doThreshold { | |
| 2589 | + | p[7:][0] = 1 | |
| 2590 | + | } else { | |
| 2591 | + | p[7:][0] = 0 | |
| 2592 | + | } | |
| 2593 | + | return seq | |
| 2594 | + | } | |
| 2595 | + | ||
| 2596 | + | func GetPointerControl(b *xturbo.Buf) xturbo.Seq { | |
| 2597 | + | p, seq := b.Request(106, 0, 0) | |
| 2598 | + | if p == nil { | |
| 2599 | + | return 0 | |
| 2600 | + | } | |
| 2601 | + | return seq | |
| 2602 | + | } | |
| 2603 | + | ||
| 2604 | + | func SetScreenSaver(b *xturbo.Buf, timeout int16, interval int16, preferBlanking Blanking, allowExposures Exposures) xturbo.Seq { | |
| 2605 | + | p, seq := b.Request(107, 0, 8) | |
| 2606 | + | if p == nil { | |
| 2607 | + | return 0 | |
| 2608 | + | } | |
| 2609 | + | binary.LittleEndian.PutUint16(p[0:], uint16(timeout)) | |
| 2610 | + | binary.LittleEndian.PutUint16(p[2:], uint16(interval)) | |
| 2611 | + | p[4:][0] = byte(preferBlanking) | |
| 2612 | + | p[5:][0] = byte(allowExposures) | |
| 2613 | + | return seq | |
| 2614 | + | } | |
| 2615 | + | ||
| 2616 | + | func GetScreenSaver(b *xturbo.Buf) xturbo.Seq { | |
| 2617 | + | p, seq := b.Request(108, 0, 0) | |
| 2618 | + | if p == nil { | |
| 2619 | + | return 0 | |
| 2620 | + | } | |
| 2621 | + | return seq | |
| 2622 | + | } | |
| 2623 | + | ||
| 2624 | + | func ChangeHosts(b *xturbo.Buf, mode HostMode, family Family, address []byte) xturbo.Seq { | |
| 2625 | + | if uint64(len(address)) > 65535 { | |
| 2626 | + | b.Fail(xturbo.ErrBadLength) | |
| 2627 | + | return 0 | |
| 2628 | + | } | |
| 2629 | + | size := 0 | |
| 2630 | + | size += 1 | |
| 2631 | + | size += 1 | |
| 2632 | + | size += 2 | |
| 2633 | + | size += len(address) * 1 | |
| 2634 | + | size = (size + 3) &^ 3 | |
| 2635 | + | p, seq := b.Request(109, uint8(int(mode)), size) | |
| 2636 | + | if p == nil { | |
| 2637 | + | return 0 | |
| 2638 | + | } | |
| 2639 | + | off := 0 | |
| 2640 | + | p[off:][0] = byte(family) | |
| 2641 | + | off += 1 | |
| 2642 | + | off += 1 | |
| 2643 | + | binary.LittleEndian.PutUint16(p[off:], uint16(len(address))) | |
| 2644 | + | off += 2 | |
| 2645 | + | copy(p[off:], address) | |
| 2646 | + | off += len(address) | |
| 2647 | + | return seq | |
| 2648 | + | } | |
| 2649 | + | ||
| 2650 | + | func ListHosts(b *xturbo.Buf) xturbo.Seq { | |
| 2651 | + | p, seq := b.Request(110, 0, 0) | |
| 2652 | + | if p == nil { | |
| 2653 | + | return 0 | |
| 2654 | + | } | |
| 2655 | + | return seq | |
| 2656 | + | } | |
| 2657 | + | ||
| 2658 | + | func SetAccessControl(b *xturbo.Buf, mode AccessControl) xturbo.Seq { | |
| 2659 | + | p, seq := b.Request(111, uint8(int(mode)), 0) | |
| 2660 | + | if p == nil { | |
| 2661 | + | return 0 | |
| 2662 | + | } | |
| 2663 | + | return seq | |
| 2664 | + | } | |
| 2665 | + | ||
| 2666 | + | func SetCloseDownMode(b *xturbo.Buf, mode CloseDown) xturbo.Seq { | |
| 2667 | + | p, seq := b.Request(112, uint8(int(mode)), 0) | |
| 2668 | + | if p == nil { | |
| 2669 | + | return 0 | |
| 2670 | + | } | |
| 2671 | + | return seq | |
| 2672 | + | } | |
| 2673 | + | ||
| 2674 | + | func KillClient(b *xturbo.Buf, resource uint32) xturbo.Seq { | |
| 2675 | + | p, seq := b.Request(113, 0, 4) | |
| 2676 | + | if p == nil { | |
| 2677 | + | return 0 | |
| 2678 | + | } | |
| 2679 | + | binary.LittleEndian.PutUint32(p[0:], uint32(resource)) | |
| 2680 | + | return seq | |
| 2681 | + | } | |
| 2682 | + | ||
| 2683 | + | func RotateProperties(b *xturbo.Buf, window Window, delta int16, atoms []Atom) xturbo.Seq { | |
| 2684 | + | if uint64(len(atoms)) > 65535 { | |
| 2685 | + | b.Fail(xturbo.ErrBadLength) | |
| 2686 | + | return 0 | |
| 2687 | + | } | |
| 2688 | + | size := 0 | |
| 2689 | + | size += 4 | |
| 2690 | + | size += 2 | |
| 2691 | + | size += 2 | |
| 2692 | + | size += len(atoms) * 4 | |
| 2693 | + | size = (size + 3) &^ 3 | |
| 2694 | + | p, seq := b.Request(114, 0, size) | |
| 2695 | + | if p == nil { | |
| 2696 | + | return 0 | |
| 2697 | + | } | |
| 2698 | + | off := 0 | |
| 2699 | + | binary.LittleEndian.PutUint32(p[off:], uint32(window)) | |
| 2700 | + | off += 4 | |
| 2701 | + | binary.LittleEndian.PutUint16(p[off:], uint16(len(atoms))) | |
| 2702 | + | off += 2 | |
| 2703 | + | binary.LittleEndian.PutUint16(p[off:], uint16(delta)) | |
| 2704 | + | off += 2 | |
| 2705 | + | for i := range atoms { | |
| 2706 | + | binary.LittleEndian.PutUint32(p[off:], uint32(atoms[i])) | |
| 2707 | + | off += 4 | |
| 2708 | + | } | |
| 2709 | + | return seq | |
| 2710 | + | } | |
| 2711 | + | ||
| 2712 | + | func ForceScreenSaver(b *xturbo.Buf, mode ScreenSaver) xturbo.Seq { | |
| 2713 | + | p, seq := b.Request(115, uint8(int(mode)), 0) | |
| 2714 | + | if p == nil { | |
| 2715 | + | return 0 | |
| 2716 | + | } | |
| 2717 | + | return seq | |
| 2718 | + | } | |
| 2719 | + | ||
| 2720 | + | func SetPointerMapping(b *xturbo.Buf, map_ []byte) xturbo.Seq { | |
| 2721 | + | if len(map_) > 255 { | |
| 2722 | + | b.Fail(xturbo.ErrBadLength) | |
| 2723 | + | return 0 | |
| 2724 | + | } | |
| 2725 | + | size := 0 | |
| 2726 | + | size += len(map_) * 1 | |
| 2727 | + | size = (size + 3) &^ 3 | |
| 2728 | + | p, seq := b.Request(116, uint8(len(map_)), size) | |
| 2729 | + | if p == nil { | |
| 2730 | + | return 0 | |
| 2731 | + | } | |
| 2732 | + | off := 0 | |
| 2733 | + | copy(p[off:], map_) | |
| 2734 | + | off += len(map_) | |
| 2735 | + | return seq | |
| 2736 | + | } | |
| 2737 | + | ||
| 2738 | + | func GetPointerMapping(b *xturbo.Buf) xturbo.Seq { | |
| 2739 | + | p, seq := b.Request(117, 0, 0) | |
| 2740 | + | if p == nil { | |
| 2741 | + | return 0 | |
| 2742 | + | } | |
| 2743 | + | return seq | |
| 2744 | + | } | |
| 2745 | + | ||
| 2746 | + | func SetModifierMapping(b *xturbo.Buf, keycodesPerModifier uint8, keycodes []Keycode) xturbo.Seq { | |
| 2747 | + | if len(keycodes) != (int(keycodesPerModifier) * 8) { | |
| 2748 | + | b.Fail(xturbo.ErrBadLength) | |
| 2749 | + | return 0 | |
| 2750 | + | } | |
| 2751 | + | size := 0 | |
| 2752 | + | size += len(keycodes) * 1 | |
| 2753 | + | size = (size + 3) &^ 3 | |
| 2754 | + | p, seq := b.Request(118, uint8(int(keycodesPerModifier)), size) | |
| 2755 | + | if p == nil { | |
| 2756 | + | return 0 | |
| 2757 | + | } | |
| 2758 | + | off := 0 | |
| 2759 | + | for i := range keycodes { | |
| 2760 | + | p[off:][0] = byte(keycodes[i]) | |
| 2761 | + | off += 1 | |
| 2762 | + | } | |
| 2763 | + | return seq | |
| 2764 | + | } | |
| 2765 | + | ||
| 2766 | + | func GetModifierMapping(b *xturbo.Buf) xturbo.Seq { | |
| 2767 | + | p, seq := b.Request(119, 0, 0) | |
| 2768 | + | if p == nil { | |
| 2769 | + | return 0 | |
| 2770 | + | } | |
| 2771 | + | return seq | |
| 2772 | + | } | |
| 2773 | + | ||
| 2774 | + | func NoOperation(b *xturbo.Buf) xturbo.Seq { | |
| 2775 | + | p, seq := b.Request(127, 0, 0) | |
| 2776 | + | if p == nil { | |
| 2777 | + | return 0 | |
| 2778 | + | } | |
| 2779 | + | return seq | |
| 2780 | + | } | |
A xproto/requests_test.go +83 -0
| @@ -0,0 +1,83 @@ | |||
| 1 | + | package xproto | |
| 2 | + | ||
| 3 | + | import ( | |
| 4 | + | "bnema.dev/xturbo" | |
| 5 | + | "testing" | |
| 6 | + | ) | |
| 7 | + | ||
| 8 | + | func BenchmarkConfigureWindow(b *testing.B) { | |
| 9 | + | buf := xturbo.NewBuf(0) | |
| 10 | + | var v ConfigureWindowValues | |
| 11 | + | v.SetX(-1).SetY(-2).SetWidth(800).SetHeight(600).SetBorderWidth(1).SetSibling(2).SetStackMode(StackModeAbove) | |
| 12 | + | batch := 0 | |
| 13 | + | b.ReportAllocs() | |
| 14 | + | b.ResetTimer() | |
| 15 | + | for i := 0; i < b.N; i++ { | |
| 16 | + | if batch == 60000 { | |
| 17 | + | b.StopTimer() | |
| 18 | + | buf = xturbo.NewBuf(0) | |
| 19 | + | batch = 0 | |
| 20 | + | b.StartTimer() | |
| 21 | + | } | |
| 22 | + | buf.Reset() | |
| 23 | + | ConfigureWindow(buf, 1, &v) | |
| 24 | + | batch++ | |
| 25 | + | } | |
| 26 | + | if buf.Err() != nil { | |
| 27 | + | b.Fatal(buf.Err()) | |
| 28 | + | } | |
| 29 | + | } | |
| 30 | + | ||
| 31 | + | func BenchmarkMapWindow(b *testing.B) { | |
| 32 | + | buf := xturbo.NewBuf(0) | |
| 33 | + | batch := 0 | |
| 34 | + | b.ReportAllocs() | |
| 35 | + | b.ResetTimer() | |
| 36 | + | for i := 0; i < b.N; i++ { | |
| 37 | + | if batch == 60000 { | |
| 38 | + | b.StopTimer() | |
| 39 | + | buf = xturbo.NewBuf(0) | |
| 40 | + | batch = 0 | |
| 41 | + | b.StartTimer() | |
| 42 | + | } | |
| 43 | + | buf.Reset() | |
| 44 | + | MapWindow(buf, 1) | |
| 45 | + | batch++ | |
| 46 | + | } | |
| 47 | + | } | |
| 48 | + | ||
| 49 | + | func BenchmarkInternAtom(b *testing.B) { | |
| 50 | + | buf := xturbo.NewBuf(0) | |
| 51 | + | batch := 0 | |
| 52 | + | b.ReportAllocs() | |
| 53 | + | b.ResetTimer() | |
| 54 | + | for i := 0; i < b.N; i++ { | |
| 55 | + | if batch == 60000 { | |
| 56 | + | b.StopTimer() | |
| 57 | + | buf = xturbo.NewBuf(0) | |
| 58 | + | batch = 0 | |
| 59 | + | b.StartTimer() | |
| 60 | + | } | |
| 61 | + | buf.Reset() | |
| 62 | + | InternAtom(buf, false, "WM_CLASS") | |
| 63 | + | batch++ | |
| 64 | + | } | |
| 65 | + | } | |
| 66 | + | func BenchmarkChangeProperty4KiB(b *testing.B) { | |
| 67 | + | buf := xturbo.NewBuf(0) | |
| 68 | + | data := make([]byte, 4096) | |
| 69 | + | batch := 0 | |
| 70 | + | b.ReportAllocs() | |
| 71 | + | b.ResetTimer() | |
| 72 | + | for i := 0; i < b.N; i++ { | |
| 73 | + | if batch == 60000 { | |
| 74 | + | b.StopTimer() | |
| 75 | + | buf = xturbo.NewBuf(0) | |
| 76 | + | batch = 0 | |
| 77 | + | b.StartTimer() | |
| 78 | + | } | |
| 79 | + | buf.Reset() | |
| 80 | + | ChangeProperty(buf, 0, 1, 1, 1, 8, 4096, data) | |
| 81 | + | batch++ | |
| 82 | + | } | |
| 83 | + | } | |
A xproto/sizes_test.go +293 -0
| @@ -0,0 +1,293 @@ | |||
| 1 | + | // Code generated by xtgen; DO NOT EDIT. | |
| 2 | + | package xproto | |
| 3 | + | ||
| 4 | + | import "testing" | |
| 5 | + | ||
| 6 | + | func TestWireSizes(t *testing.T) { | |
| 7 | + | if Char2bSize != 2 { | |
| 8 | + | t.Errorf("Char2b fixed prefix = %d", Char2bSize) | |
| 9 | + | } | |
| 10 | + | if PointSize != 4 { | |
| 11 | + | t.Errorf("Point fixed prefix = %d", PointSize) | |
| 12 | + | } | |
| 13 | + | if RectangleSize != 8 { | |
| 14 | + | t.Errorf("Rectangle fixed prefix = %d", RectangleSize) | |
| 15 | + | } | |
| 16 | + | if ArcSize != 12 { | |
| 17 | + | t.Errorf("Arc fixed prefix = %d", ArcSize) | |
| 18 | + | } | |
| 19 | + | if FormatSize != 8 { | |
| 20 | + | t.Errorf("Format fixed prefix = %d", FormatSize) | |
| 21 | + | } | |
| 22 | + | if VisualtypeSize != 24 { | |
| 23 | + | t.Errorf("Visualtype fixed prefix = %d", VisualtypeSize) | |
| 24 | + | } | |
| 25 | + | if DepthSize != 8 { | |
| 26 | + | t.Errorf("Depth fixed prefix = %d", DepthSize) | |
| 27 | + | } | |
| 28 | + | if ScreenSize != 40 { | |
| 29 | + | t.Errorf("Screen fixed prefix = %d", ScreenSize) | |
| 30 | + | } | |
| 31 | + | if SetupRequestSize != 12 { | |
| 32 | + | t.Errorf("SetupRequest fixed prefix = %d", SetupRequestSize) | |
| 33 | + | } | |
| 34 | + | if SetupFailedSize != 8 { | |
| 35 | + | t.Errorf("SetupFailed fixed prefix = %d", SetupFailedSize) | |
| 36 | + | } | |
| 37 | + | if SetupAuthenticateSize != 8 { | |
| 38 | + | t.Errorf("SetupAuthenticate fixed prefix = %d", SetupAuthenticateSize) | |
| 39 | + | } | |
| 40 | + | if SetupSize != 40 { | |
| 41 | + | t.Errorf("Setup fixed prefix = %d", SetupSize) | |
| 42 | + | } | |
| 43 | + | if ClientMessageDataSize != 20 { | |
| 44 | + | t.Errorf("ClientMessageData fixed prefix = %d", ClientMessageDataSize) | |
| 45 | + | } | |
| 46 | + | if TimecoordSize != 8 { | |
| 47 | + | t.Errorf("Timecoord fixed prefix = %d", TimecoordSize) | |
| 48 | + | } | |
| 49 | + | if FontpropSize != 8 { | |
| 50 | + | t.Errorf("Fontprop fixed prefix = %d", FontpropSize) | |
| 51 | + | } | |
| 52 | + | if CharinfoSize != 12 { | |
| 53 | + | t.Errorf("Charinfo fixed prefix = %d", CharinfoSize) | |
| 54 | + | } | |
| 55 | + | if StrSize != 1 { | |
| 56 | + | t.Errorf("Str fixed prefix = %d", StrSize) | |
| 57 | + | } | |
| 58 | + | if SegmentSize != 8 { | |
| 59 | + | t.Errorf("Segment fixed prefix = %d", SegmentSize) | |
| 60 | + | } | |
| 61 | + | if ColoritemSize != 12 { | |
| 62 | + | t.Errorf("Coloritem fixed prefix = %d", ColoritemSize) | |
| 63 | + | } | |
| 64 | + | if RgbSize != 8 { | |
| 65 | + | t.Errorf("Rgb fixed prefix = %d", RgbSize) | |
| 66 | + | } | |
| 67 | + | if HostSize != 4 { | |
| 68 | + | t.Errorf("Host fixed prefix = %d", HostSize) | |
| 69 | + | } | |
| 70 | + | if got := 32; got != 32 { | |
| 71 | + | t.Errorf("event KeyPress fixed size = %d", got) | |
| 72 | + | } | |
| 73 | + | if got := 32; got != 32 { | |
| 74 | + | t.Errorf("event KeyRelease fixed size = %d", got) | |
| 75 | + | } | |
| 76 | + | if got := 32; got != 32 { | |
| 77 | + | t.Errorf("event ButtonPress fixed size = %d", got) | |
| 78 | + | } | |
| 79 | + | if got := 32; got != 32 { | |
| 80 | + | t.Errorf("event ButtonRelease fixed size = %d", got) | |
| 81 | + | } | |
| 82 | + | if got := 32; got != 32 { | |
| 83 | + | t.Errorf("event MotionNotify fixed size = %d", got) | |
| 84 | + | } | |
| 85 | + | if got := 32; got != 32 { | |
| 86 | + | t.Errorf("event EnterNotify fixed size = %d", got) | |
| 87 | + | } | |
| 88 | + | if got := 32; got != 32 { | |
| 89 | + | t.Errorf("event LeaveNotify fixed size = %d", got) | |
| 90 | + | } | |
| 91 | + | if got := 32; got != 32 { | |
| 92 | + | t.Errorf("event FocusIn fixed size = %d", got) | |
| 93 | + | } | |
| 94 | + | if got := 32; got != 32 { | |
| 95 | + | t.Errorf("event FocusOut fixed size = %d", got) | |
| 96 | + | } | |
| 97 | + | if got := 32; got != 32 { | |
| 98 | + | t.Errorf("event KeymapNotify fixed size = %d", got) | |
| 99 | + | } | |
| 100 | + | if got := 32; got != 32 { | |
| 101 | + | t.Errorf("event Expose fixed size = %d", got) | |
| 102 | + | } | |
| 103 | + | if got := 32; got != 32 { | |
| 104 | + | t.Errorf("event GraphicsExposure fixed size = %d", got) | |
| 105 | + | } | |
| 106 | + | if got := 32; got != 32 { | |
| 107 | + | t.Errorf("event NoExposure fixed size = %d", got) | |
| 108 | + | } | |
| 109 | + | if got := 32; got != 32 { | |
| 110 | + | t.Errorf("event VisibilityNotify fixed size = %d", got) | |
| 111 | + | } | |
| 112 | + | if got := 32; got != 32 { | |
| 113 | + | t.Errorf("event CreateNotify fixed size = %d", got) | |
| 114 | + | } | |
| 115 | + | if got := 32; got != 32 { | |
| 116 | + | t.Errorf("event DestroyNotify fixed size = %d", got) | |
| 117 | + | } | |
| 118 | + | if got := 32; got != 32 { | |
| 119 | + | t.Errorf("event UnmapNotify fixed size = %d", got) | |
| 120 | + | } | |
| 121 | + | if got := 32; got != 32 { | |
| 122 | + | t.Errorf("event MapNotify fixed size = %d", got) | |
| 123 | + | } | |
| 124 | + | if got := 32; got != 32 { | |
| 125 | + | t.Errorf("event MapRequest fixed size = %d", got) | |
| 126 | + | } | |
| 127 | + | if got := 32; got != 32 { | |
| 128 | + | t.Errorf("event ReparentNotify fixed size = %d", got) | |
| 129 | + | } | |
| 130 | + | if got := 32; got != 32 { | |
| 131 | + | t.Errorf("event ConfigureNotify fixed size = %d", got) | |
| 132 | + | } | |
| 133 | + | if got := 32; got != 32 { | |
| 134 | + | t.Errorf("event ConfigureRequest fixed size = %d", got) | |
| 135 | + | } | |
| 136 | + | if got := 32; got != 32 { | |
| 137 | + | t.Errorf("event GravityNotify fixed size = %d", got) | |
| 138 | + | } | |
| 139 | + | if got := 32; got != 32 { | |
| 140 | + | t.Errorf("event ResizeRequest fixed size = %d", got) | |
| 141 | + | } | |
| 142 | + | if got := 32; got != 32 { | |
| 143 | + | t.Errorf("event CirculateNotify fixed size = %d", got) | |
| 144 | + | } | |
| 145 | + | if got := 32; got != 32 { | |
| 146 | + | t.Errorf("event CirculateRequest fixed size = %d", got) | |
| 147 | + | } | |
| 148 | + | if got := 32; got != 32 { | |
| 149 | + | t.Errorf("event PropertyNotify fixed size = %d", got) | |
| 150 | + | } | |
| 151 | + | if got := 32; got != 32 { | |
| 152 | + | t.Errorf("event SelectionClear fixed size = %d", got) | |
| 153 | + | } | |
| 154 | + | if got := 32; got != 32 { | |
| 155 | + | t.Errorf("event SelectionRequest fixed size = %d", got) | |
| 156 | + | } | |
| 157 | + | if got := 32; got != 32 { | |
| 158 | + | t.Errorf("event SelectionNotify fixed size = %d", got) | |
| 159 | + | } | |
| 160 | + | if got := 32; got != 32 { | |
| 161 | + | t.Errorf("event ColormapNotify fixed size = %d", got) | |
| 162 | + | } | |
| 163 | + | if got := 32; got != 32 { | |
| 164 | + | t.Errorf("event ClientMessage fixed size = %d", got) | |
| 165 | + | } | |
| 166 | + | if got := 32; got != 32 { | |
| 167 | + | t.Errorf("event MappingNotify fixed size = %d", got) | |
| 168 | + | } | |
| 169 | + | if got := 32; got != 32 { | |
| 170 | + | t.Errorf("event GeGeneric fixed size = %d", got) | |
| 171 | + | } | |
| 172 | + | if got := 44; got != 44 { | |
| 173 | + | t.Errorf("reply GetWindowAttributes fixed size = %d", got) | |
| 174 | + | } | |
| 175 | + | if got := 32; got != 32 { | |
| 176 | + | t.Errorf("reply GetGeometry fixed size = %d", got) | |
| 177 | + | } | |
| 178 | + | if got := 32; got != 32 { | |
| 179 | + | t.Errorf("reply QueryTree fixed size = %d", got) | |
| 180 | + | } | |
| 181 | + | if got := 32; got != 32 { | |
| 182 | + | t.Errorf("reply InternAtom fixed size = %d", got) | |
| 183 | + | } | |
| 184 | + | if got := 32; got != 32 { | |
| 185 | + | t.Errorf("reply GetAtomName fixed size = %d", got) | |
| 186 | + | } | |
| 187 | + | if got := 32; got != 32 { | |
| 188 | + | t.Errorf("reply GetProperty fixed size = %d", got) | |
| 189 | + | } | |
| 190 | + | if got := 32; got != 32 { | |
| 191 | + | t.Errorf("reply ListProperties fixed size = %d", got) | |
| 192 | + | } | |
| 193 | + | if got := 32; got != 32 { | |
| 194 | + | t.Errorf("reply GetSelectionOwner fixed size = %d", got) | |
| 195 | + | } | |
| 196 | + | if got := 32; got != 32 { | |
| 197 | + | t.Errorf("reply GrabPointer fixed size = %d", got) | |
| 198 | + | } | |
| 199 | + | if got := 32; got != 32 { | |
| 200 | + | t.Errorf("reply GrabKeyboard fixed size = %d", got) | |
| 201 | + | } | |
| 202 | + | if got := 32; got != 32 { | |
| 203 | + | t.Errorf("reply QueryPointer fixed size = %d", got) | |
| 204 | + | } | |
| 205 | + | if got := 32; got != 32 { | |
| 206 | + | t.Errorf("reply GetMotionEvents fixed size = %d", got) | |
| 207 | + | } | |
| 208 | + | if got := 32; got != 32 { | |
| 209 | + | t.Errorf("reply TranslateCoordinates fixed size = %d", got) | |
| 210 | + | } | |
| 211 | + | if got := 32; got != 32 { | |
| 212 | + | t.Errorf("reply GetInputFocus fixed size = %d", got) | |
| 213 | + | } | |
| 214 | + | if got := 40; got != 40 { | |
| 215 | + | t.Errorf("reply QueryKeymap fixed size = %d", got) | |
| 216 | + | } | |
| 217 | + | if got := 60; got != 60 { | |
| 218 | + | t.Errorf("reply QueryFont fixed size = %d", got) | |
| 219 | + | } | |
| 220 | + | if got := 32; got != 32 { | |
| 221 | + | t.Errorf("reply QueryTextExtents fixed size = %d", got) | |
| 222 | + | } | |
| 223 | + | if got := 32; got != 32 { | |
| 224 | + | t.Errorf("reply ListFonts fixed size = %d", got) | |
| 225 | + | } | |
| 226 | + | if got := 60; got != 60 { | |
| 227 | + | t.Errorf("reply ListFontsWithInfo fixed size = %d", got) | |
| 228 | + | } | |
| 229 | + | if got := 32; got != 32 { | |
| 230 | + | t.Errorf("reply GetFontPath fixed size = %d", got) | |
| 231 | + | } | |
| 232 | + | if got := 32; got != 32 { | |
| 233 | + | t.Errorf("reply GetImage fixed size = %d", got) | |
| 234 | + | } | |
| 235 | + | if got := 32; got != 32 { | |
| 236 | + | t.Errorf("reply ListInstalledColormaps fixed size = %d", got) | |
| 237 | + | } | |
| 238 | + | if got := 32; got != 32 { | |
| 239 | + | t.Errorf("reply AllocColor fixed size = %d", got) | |
| 240 | + | } | |
| 241 | + | if got := 32; got != 32 { | |
| 242 | + | t.Errorf("reply AllocNamedColor fixed size = %d", got) | |
| 243 | + | } | |
| 244 | + | if got := 32; got != 32 { | |
| 245 | + | t.Errorf("reply AllocColorCells fixed size = %d", got) | |
| 246 | + | } | |
| 247 | + | if got := 32; got != 32 { | |
| 248 | + | t.Errorf("reply AllocColorPlanes fixed size = %d", got) | |
| 249 | + | } | |
| 250 | + | if got := 32; got != 32 { | |
| 251 | + | t.Errorf("reply QueryColors fixed size = %d", got) | |
| 252 | + | } | |
| 253 | + | if got := 32; got != 32 { | |
| 254 | + | t.Errorf("reply LookupColor fixed size = %d", got) | |
| 255 | + | } | |
| 256 | + | if got := 32; got != 32 { | |
| 257 | + | t.Errorf("reply QueryBestSize fixed size = %d", got) | |
| 258 | + | } | |
| 259 | + | if got := 32; got != 32 { | |
| 260 | + | t.Errorf("reply QueryExtension fixed size = %d", got) | |
| 261 | + | } | |
| 262 | + | if got := 32; got != 32 { | |
| 263 | + | t.Errorf("reply ListExtensions fixed size = %d", got) | |
| 264 | + | } | |
| 265 | + | if got := 32; got != 32 { | |
| 266 | + | t.Errorf("reply GetKeyboardMapping fixed size = %d", got) | |
| 267 | + | } | |
| 268 | + | if got := 52; got != 52 { | |
| 269 | + | t.Errorf("reply GetKeyboardControl fixed size = %d", got) | |
| 270 | + | } | |
| 271 | + | if got := 32; got != 32 { | |
| 272 | + | t.Errorf("reply GetPointerControl fixed size = %d", got) | |
| 273 | + | } | |
| 274 | + | if got := 32; got != 32 { | |
| 275 | + | t.Errorf("reply GetScreenSaver fixed size = %d", got) | |
| 276 | + | } | |
| 277 | + | if got := 32; got != 32 { | |
| 278 | + | t.Errorf("reply ListHosts fixed size = %d", got) | |
| 279 | + | } | |
| 280 | + | if got := 32; got != 32 { | |
| 281 | + | t.Errorf("reply SetPointerMapping fixed size = %d", got) | |
| 282 | + | } | |
| 283 | + | if got := 32; got != 32 { | |
| 284 | + | t.Errorf("reply GetPointerMapping fixed size = %d", got) | |
| 285 | + | } | |
| 286 | + | if got := 32; got != 32 { | |
| 287 | + | t.Errorf("reply SetModifierMapping fixed size = %d", got) | |
| 288 | + | } | |
| 289 | + | if got := 32; got != 32 { | |
| 290 | + | t.Errorf("reply GetModifierMapping fixed size = %d", got) | |
| 291 | + | } | |
| 292 | + | ||
| 293 | + | } | |
A xproto/types_generated.go +1353 -0
A xproto/types_test.go +54 -0
Comments4 open / 4
bnema outdated
T2.1 implemented: strict source-located XML AST for all 9 pinned modules, rejection tests, parser fuzz seed. Local make check and CGO_ENABLED=0 go build ./... pass; 3-second parser fuzz run passed (416270 executions). T1.1 is on main (ba4ad52), CI run 221 green, repo public. Stopped before T2.2/T2.3 for a public naming-contract decision: xproto WINDOW xidtype and Window enum both map to Go Window under the specified rules (likewise ATOM/Atom, CURSOR/Cursor, PIXMAP/Pixmap, FONT/Font; render PICTURE/Picture). Should these enums reuse the XID type for constants, or receive a distinct name (please specify the naming rule)? No workaround chosen. T2.4 must wait for T2.2/T2.3; AST preserves expressions, imports, attributes and XML field order. No goldens captured yet.
bnema outdated
T2.2 (85a51dd) and T2.3 are implemented. Applied the decided enum/XID type reuse rule; other declaration collisions are fatal. All nine packages compile; manifest-ordered root ExtIDs, type/struct/union encoders and size checks are generated. Fixed requests include core data-byte handling, negotiated extension major opcodes, padding and sticky-error guards. Full make check passed independently after each task (unfiltered output), CGO-disabled build passed, request/Buf allocation tests passed, and benchmarks show 0 B/op, 0 allocs/op. Local xtrace is glibc execution tracing, so the permitted raw socketpair tee fallback captures independent reference encodings accepted by Xvfb. Three request goldens committed; capture update also passes with race enabled. Decisions: variable structs have owned encoding forms now (borrowed View/Iter APIs remain with list/reply tasks); generation wiring brought forward so gen-check verifies this work. xfixes signatures use render/shape types where the XML imports require them (matching actual wire types). T2.4: extend resolveRequests beyond its explicit list/switch gate, lower AST length expressions with renderExpr, add derived-length and mismatch handling, extend independent capture encoder for InternAtom/ChangeProperty/res.QueryClientIds. Buf already supports aligned reservation, zeroing, sticky errors and growth; transport/ack updates remain Phase 3. CI 222 and 223 green; checking latest run next. Keep this MR draft; do not merge.
bnema outdated
Final verification: CI 224 logs show make check and make xserver passed, as did gen-check. Additional local 10-second parser fuzz run passed (~3.57 million executions); clean CGO_ENABLED=0 go test -count=1 ./... and go build ./... passed. Both signed task commits verified with GPG. Working trees clean, origin is ermite only; MR remains WIP/unmerged.
bnema outdated
T2.4 completed in signed commit 582be88. Full make check and make xserver passed; CGO_ENABLED=0 build passed; independent raw socketpair/Xvfb tee captured InternAtom, ChangeProperty (GetProperty read-back), and XRes QueryClientIds (negotiated XRes 1.2). Race-enabled capture update passed. Allocation tests cover InternAtom, 4 KiB ChangeProperty, and fixed struct lists; all zero. Benchmarks: InternAtom 7.714 ns/op, ChangeProperty4KiB 73.58 ns/op, both 0 B/op and 0 allocs/op. Decisions: support implicit list-name_len refs used by QueryTextExtents only when no explicit field exists; reject derived length truncation with ErrBadLength; bring SendEvent fixed-array signature forward from the explicit public contract. T2.5 should remove the switch gate in resolveRequests and implement typed Values structs/setters; request list sizes/offsets now use running body offsets, with final four-byte rounding. Shared lengths stay explicit (e.g. render AddGlyphs); variable structs use Size/Put. T2.5–T2.8 and T3.1–T3.5 not started; stopping at this clean boundary due to long context. Same branch/worktree, MR draft, no tag.