fix(xtgen): encode EventData into a local array before storing to dst
<Name>EventData.Put cleared dst before reading borrowed fields, so re-encoding a ClientMessage into the Event.Raw its Data union views zeroed the payload. Put now encodes into a local [32]byte and stores it last. Add an in-place regression test for ClientMessage and KeymapNotify (zero allocations) and an in-place round trip in FuzzEventViews. make xserver now compares every captured request, reply, event and error with the committed goldens against a live Xvfb and fails on a difference, ignoring only per-run server timestamps; -update still rewrites them. The capture is skipped when Xvfb is not installed.
- commit
- d5bc75b1a17817c06b0248a3d6689de9f2838797
- author
- brice · · 2026-10-22 07:56 UTC
- committer
- brice · · 2026-10-22 08:14 UTC
- parent
- 7f3ee2e
- signature
- GPG Verified
CD88F9E564E0102646FB6077A1A07C7C7C3E349D· arch-gpg Verified for the committer email
6 files · +572 -269
M cmd/xtgen/events.go +8 -3
| @@ -132,7 +132,7 @@ func dataField(c *container, mem member) (field, put string, err error) { | |||
| 132 | 132 | name += "_" | |
| 133 | 133 | } | |
| 134 | 134 | src := "d." + name | |
| 135 | - | at := fmt.Sprintf("dst[%d:]", mem.Static) | |
| 135 | + | at := fmt.Sprintf("tmp[%d:]", mem.Static) | |
| 136 | 136 | switch { | |
| 137 | 137 | case mem.Kind == "field" && isScalar(mem.Type): | |
| 138 | 138 | return name + " " + mem.GoType, putScalar(mem.Type, src, at), nil | |
| @@ -143,7 +143,7 @@ func dataField(c *container, mem member) (field, put string, err error) { | |||
| 143 | 143 | elem := mem.Elem | |
| 144 | 144 | var b strings.Builder | |
| 145 | 145 | fmt.Fprintf(&b, "for i := range %s {", src) | |
| 146 | - | target := fmt.Sprintf("dst[%d+i*%d:]", mem.Static, mem.Type.Size) | |
| 146 | + | target := fmt.Sprintf("tmp[%d+i*%d:]", mem.Static, mem.Type.Size) | |
| 147 | 147 | if isScalar(mem.Type) { | |
| 148 | 148 | b.WriteString(putScalar(mem.Type, src+"[i]", target)) | |
| 149 | 149 | } else { | |
| @@ -207,7 +207,9 @@ func eventDecl(m *Module, e *eventIR, lists map[string]string) (string, error) { | |||
| 207 | 207 | puts = append(puts, p) | |
| 208 | 208 | } | |
| 209 | 209 | fmt.Fprintf(&b, "// %sEventData encodes a %s event for SendEvent.\ntype %sEventData struct {\n%s\n};\n", e.Name, e.Name, e.Name, strings.Join(fields, "\n")) | |
| 210 | - | fmt.Fprintf(&b, "// Put writes the event (code %d, pads and sequence zeroed) into dst.\nfunc (d *%sEventData) Put(dst *[32]byte) { clear(dst[:]); dst[0] = %d; %s };\n", e.Code, e.Name, e.Code, strings.Join(puts, "")) | |
| 210 | + | // Encode into a local array and store it last: borrowed fields (union | |
| 211 | + | // views such as ClientMessageData) may alias dst, e.g. d.Put(&ev.Raw). | |
| 212 | + | fmt.Fprintf(&b, "// Put writes the event (code %d, pads and sequence zeroed) into dst. dst may alias\n// memory that d's borrowed fields view, such as the Event.Raw they were read from.\nfunc (d *%sEventData) Put(dst *[32]byte) { var tmp [32]byte; tmp[0] = %d; %s; *dst = tmp };\n", e.Code, e.Name, e.Code, strings.Join(puts, "")) | |
| 211 | 213 | return b.String(), nil | |
| 212 | 214 | } | |
| 213 | 215 | ||
| @@ -409,6 +411,9 @@ func emitEventFuzz(m *Module, events []*eventIR) error { | |||
| 409 | 411 | fmt.Fprintf(&b, "if out[0] != %d { t.Fatal(\"%s code\") };", e.Code, e.Name) | |
| 410 | 412 | b.WriteString("back := xturbo.Event{Raw: out};") | |
| 411 | 413 | fmt.Fprintf(&b, "w := %sOf(&back); %s", e.Name, strings.Join(checks, "")) | |
| 414 | + | // In place: dst aliases the Raw that d's borrowed fields view. | |
| 415 | + | fmt.Fprintf(&b, "in := xturbo.Event{Raw: ev.Raw}; vi := %sOf(&in); di := %sEventData{%s}; di.Put(&in.Raw); if in.Raw != out { t.Fatal(%q) };", | |
| 416 | + | e.Name, e.Name, strings.ReplaceAll(strings.Join(fields, ", "), v+".", "vi."), e.Name+" in-place Put") | |
| 412 | 417 | } | |
| 413 | 418 | b.WriteString("};\n") | |
| 414 | 419 | } | |
| @@ -132,7 +132,7 @@ func dataField(c *container, mem member) (field, put string, err error) { | |||||
| 132 | name += "_" | 132 | name += "_" | ||
| 133 | } | 133 | } | ||
| 134 | src := "d." + name | 134 | src := "d." + name | ||
| 135 | - | at := fmt.Sprintf("dst[%d:]", mem.Static) | 135 | + | at := fmt.Sprintf("tmp[%d:]", mem.Static) |
| 136 | switch { | 136 | switch { | ||
| 137 | case mem.Kind == "field" && isScalar(mem.Type): | 137 | case mem.Kind == "field" && isScalar(mem.Type): | ||
| 138 | return name + " " + mem.GoType, putScalar(mem.Type, src, at), nil | 138 | return name + " " + mem.GoType, putScalar(mem.Type, src, at), nil | ||
| @@ -143,7 +143,7 @@ func dataField(c *container, mem member) (field, put string, err error) { | |||||
| 143 | elem := mem.Elem | 143 | elem := mem.Elem | ||
| 144 | var b strings.Builder | 144 | var b strings.Builder | ||
| 145 | fmt.Fprintf(&b, "for i := range %s {", src) | 145 | fmt.Fprintf(&b, "for i := range %s {", src) | ||
| 146 | - | target := fmt.Sprintf("dst[%d+i*%d:]", mem.Static, mem.Type.Size) | 146 | + | target := fmt.Sprintf("tmp[%d+i*%d:]", mem.Static, mem.Type.Size) |
| 147 | if isScalar(mem.Type) { | 147 | if isScalar(mem.Type) { | ||
| 148 | b.WriteString(putScalar(mem.Type, src+"[i]", target)) | 148 | b.WriteString(putScalar(mem.Type, src+"[i]", target)) | ||
| 149 | } else { | 149 | } else { | ||
| @@ -207,7 +207,9 @@ func eventDecl(m *Module, e *eventIR, lists map[string]string) (string, error) { | |||||
| 207 | puts = append(puts, p) | 207 | puts = append(puts, p) | ||
| 208 | } | 208 | } | ||
| 209 | fmt.Fprintf(&b, "// %sEventData encodes a %s event for SendEvent.\ntype %sEventData struct {\n%s\n};\n", e.Name, e.Name, e.Name, strings.Join(fields, "\n")) | 209 | fmt.Fprintf(&b, "// %sEventData encodes a %s event for SendEvent.\ntype %sEventData struct {\n%s\n};\n", e.Name, e.Name, e.Name, strings.Join(fields, "\n")) | ||
| 210 | - | fmt.Fprintf(&b, "// Put writes the event (code %d, pads and sequence zeroed) into dst.\nfunc (d *%sEventData) Put(dst *[32]byte) { clear(dst[:]); dst[0] = %d; %s };\n", e.Code, e.Name, e.Code, strings.Join(puts, "")) | 210 | + | // Encode into a local array and store it last: borrowed fields (union |
| 211 | + | // views such as ClientMessageData) may alias dst, e.g. d.Put(&ev.Raw). | |||
| 212 | + | fmt.Fprintf(&b, "// Put writes the event (code %d, pads and sequence zeroed) into dst. dst may alias\n// memory that d's borrowed fields view, such as the Event.Raw they were read from.\nfunc (d *%sEventData) Put(dst *[32]byte) { var tmp [32]byte; tmp[0] = %d; %s; *dst = tmp };\n", e.Code, e.Name, e.Code, strings.Join(puts, "")) | |||
| 211 | return b.String(), nil | 213 | return b.String(), nil | ||
| 212 | } | 214 | } | ||
| 213 | 215 | ||||
| @@ -409,6 +411,9 @@ func emitEventFuzz(m *Module, events []*eventIR) error { | |||||
| 409 | fmt.Fprintf(&b, "if out[0] != %d { t.Fatal(\"%s code\") };", e.Code, e.Name) | 411 | fmt.Fprintf(&b, "if out[0] != %d { t.Fatal(\"%s code\") };", e.Code, e.Name) | ||
| 410 | b.WriteString("back := xturbo.Event{Raw: out};") | 412 | b.WriteString("back := xturbo.Event{Raw: out};") | ||
| 411 | fmt.Fprintf(&b, "w := %sOf(&back); %s", e.Name, strings.Join(checks, "")) | 413 | fmt.Fprintf(&b, "w := %sOf(&back); %s", e.Name, strings.Join(checks, "")) | ||
| 414 | + | // In place: dst aliases the Raw that d's borrowed fields view. | |||
| 415 | + | fmt.Fprintf(&b, "in := xturbo.Event{Raw: ev.Raw}; vi := %sOf(&in); di := %sEventData{%s}; di.Put(&in.Raw); if in.Raw != out { t.Fatal(%q) };", | |||
| 416 | + | e.Name, e.Name, strings.ReplaceAll(strings.Join(fields, ", "), v+".", "vi."), e.Name+" in-place Put") | |||
| 412 | } | 417 | } | ||
| 413 | b.WriteString("};\n") | 418 | b.WriteString("};\n") | ||
| 414 | } | 419 | } | ||
M events_test.go +28 -0
| @@ -209,6 +209,34 @@ func TestEventGoldens(t *testing.T) { | |||
| 209 | 209 | }) | |
| 210 | 210 | } | |
| 211 | 211 | ||
| 212 | + | // TestEventDataPutInPlace re-encodes events into the Event.Raw their fields | |
| 213 | + | // were read from. ClientMessage's Data is a union view over Raw; KeymapNotify's | |
| 214 | + | // Keys is a slice view over Raw. Put must read every field before writing dst. | |
| 215 | + | func TestEventDataPutInPlace(t *testing.T) { | |
| 216 | + | raw := loadEvent(t, "xproto/ClientMessage") | |
| 217 | + | ev := decode(t, raw, nil) | |
| 218 | + | e := xproto.ClientMessageOf(&ev) | |
| 219 | + | d := xproto.ClientMessageEventData{Format: e.Format(), Window: e.Window(), Type: e.Type(), Data: e.Data()} | |
| 220 | + | d.Put(&ev.Raw) | |
| 221 | + | want := [32]byte(raw) | |
| 222 | + | want[0] &^= 0x80 | |
| 223 | + | want[2], want[3] = 0, 0 | |
| 224 | + | if ev.Raw != want { | |
| 225 | + | t.Fatalf("ClientMessage in place %x want %x", ev.Raw, want) | |
| 226 | + | } | |
| 227 | + | if n := testing.AllocsPerRun(1000, func() { d.Data = e.Data(); d.Put(&ev.Raw) }); n != 0 { | |
| 228 | + | t.Fatalf("in-place Put allocates %v times", n) | |
| 229 | + | } | |
| 230 | + | raw = loadEvent(t, "xproto/KeymapNotify") | |
| 231 | + | ev = decode(t, raw, nil) | |
| 232 | + | keys := xproto.KeymapNotifyOf(&ev).Keys() | |
| 233 | + | k := xproto.KeymapNotifyEventData{Keys: [31]uint8(keys)} | |
| 234 | + | k.Put(&ev.Raw) | |
| 235 | + | if ev.Raw != [32]byte(raw) || !bytes.Equal(keys, raw[1:]) { | |
| 236 | + | t.Fatalf("KeymapNotify in place %x", ev.Raw) | |
| 237 | + | } | |
| 238 | + | } | |
| 239 | + | ||
| 212 | 240 | func TestEventCopyAliases(t *testing.T) { | |
| 213 | 241 | if xproto.KindButtonRelease != 5 || xproto.KindKeyRelease != 3 || xproto.KindLeaveNotify != 8 || xproto.KindFocusOut != 10 || xproto.KindCirculateRequest != 27 { | |
| 214 | 242 | t.Fatal("eventcopy kinds") | |
| @@ -209,6 +209,34 @@ func TestEventGoldens(t *testing.T) { | |||||
| 209 | }) | 209 | }) | ||
| 210 | } | 210 | } | ||
| 211 | 211 | ||||
| 212 | + | // TestEventDataPutInPlace re-encodes events into the Event.Raw their fields | |||
| 213 | + | // were read from. ClientMessage's Data is a union view over Raw; KeymapNotify's | |||
| 214 | + | // Keys is a slice view over Raw. Put must read every field before writing dst. | |||
| 215 | + | func TestEventDataPutInPlace(t *testing.T) { | |||
| 216 | + | raw := loadEvent(t, "xproto/ClientMessage") | |||
| 217 | + | ev := decode(t, raw, nil) | |||
| 218 | + | e := xproto.ClientMessageOf(&ev) | |||
| 219 | + | d := xproto.ClientMessageEventData{Format: e.Format(), Window: e.Window(), Type: e.Type(), Data: e.Data()} | |||
| 220 | + | d.Put(&ev.Raw) | |||
| 221 | + | want := [32]byte(raw) | |||
| 222 | + | want[0] &^= 0x80 | |||
| 223 | + | want[2], want[3] = 0, 0 | |||
| 224 | + | if ev.Raw != want { | |||
| 225 | + | t.Fatalf("ClientMessage in place %x want %x", ev.Raw, want) | |||
| 226 | + | } | |||
| 227 | + | if n := testing.AllocsPerRun(1000, func() { d.Data = e.Data(); d.Put(&ev.Raw) }); n != 0 { | |||
| 228 | + | t.Fatalf("in-place Put allocates %v times", n) | |||
| 229 | + | } | |||
| 230 | + | raw = loadEvent(t, "xproto/KeymapNotify") | |||
| 231 | + | ev = decode(t, raw, nil) | |||
| 232 | + | keys := xproto.KeymapNotifyOf(&ev).Keys() | |||
| 233 | + | k := xproto.KeymapNotifyEventData{Keys: [31]uint8(keys)} | |||
| 234 | + | k.Put(&ev.Raw) | |||
| 235 | + | if ev.Raw != [32]byte(raw) || !bytes.Equal(keys, raw[1:]) { | |||
| 236 | + | t.Fatalf("KeymapNotify in place %x", ev.Raw) | |||
| 237 | + | } | |||
| 238 | + | } | |||
| 239 | + | ||||
| 212 | func TestEventCopyAliases(t *testing.T) { | 240 | func TestEventCopyAliases(t *testing.T) { | ||
| 213 | if xproto.KindButtonRelease != 5 || xproto.KindKeyRelease != 3 || xproto.KindLeaveNotify != 8 || xproto.KindFocusOut != 10 || xproto.KindCirculateRequest != 27 { | 241 | if xproto.KindButtonRelease != 5 || xproto.KindKeyRelease != 3 || xproto.KindLeaveNotify != 8 || xproto.KindFocusOut != 10 || xproto.KindCirculateRequest != 27 { | ||
| 214 | t.Fatal("eventcopy kinds") | 242 | t.Fatal("eventcopy kinds") | ||
M internal/xtest/README.md +5 -1
| @@ -1,6 +1,10 @@ | |||
| 1 | 1 | # Wire goldens | |
| 2 | 2 | ||
| 3 | - | Refresh the request fixtures from the repository root: | |
| 3 | + | `make xserver` captures from a fresh Xvfb and compares every packet with the | |
| 4 | + | committed golden, failing on any difference. Server timestamps | |
| 5 | + | (PropertyNotify time, XFIXES SelectionNotify timestamps) vary per run and are | |
| 6 | + | excluded from the comparison. The test is skipped when Xvfb is not installed. | |
| 7 | + | Rewrite the goldens from the repository root with: | |
| 4 | 8 | ||
| 5 | 9 | ``` | |
| 6 | 10 | PATH="$PATH:/usr/sbin" go test -tags xserver ./internal/xtest -update | |
| @@ -1,6 +1,10 @@ | |||||
| 1 | # Wire goldens | 1 | # Wire goldens | ||
| 2 | 2 | ||||
| 3 | - | Refresh the request fixtures from the repository root: | 3 | + | `make xserver` captures from a fresh Xvfb and compares every packet with the |
| 4 | + | committed golden, failing on any difference. Server timestamps | |||
| 5 | + | (PropertyNotify time, XFIXES SelectionNotify timestamps) vary per run and are | |||
| 6 | + | excluded from the comparison. The test is skipped when Xvfb is not installed. | |||
| 7 | + | Rewrite the goldens from the repository root with: | |||
| 4 | 8 | ||||
| 5 | ``` | 9 | ``` | ||
| 6 | PATH="$PATH:/usr/sbin" go test -tags xserver ./internal/xtest -update | 10 | PATH="$PATH:/usr/sbin" go test -tags xserver ./internal/xtest -update | ||
M internal/xtest/capture_test.go +36 -22
| @@ -21,11 +21,21 @@ import ( | |||
| 21 | 21 | "golang.org/x/sys/unix" | |
| 22 | 22 | ) | |
| 23 | 23 | ||
| 24 | - | var update = flag.Bool("update", false, "refresh request goldens using Xvfb and a raw socketpair tee") | |
| 24 | + | var update = flag.Bool("update", false, "rewrite wire goldens from Xvfb instead of comparing against them") | |
| 25 | 25 | ||
| 26 | + | // volatile lists server-time fields that differ on every run; comparison | |
| 27 | + | // ignores these byte ranges [from, to). Everything else must match exactly. | |
| 28 | + | var volatile = map[string][][2]int{ | |
| 29 | + | "xproto/PropertyNotify.event.hex": {{12, 16}}, // time | |
| 30 | + | "xfixes/SelectionNotify.event.hex": {{16, 24}}, // timestamp, selection_timestamp | |
| 31 | + | } | |
| 32 | + | ||
| 33 | + | // TestCaptureRequests drives a fresh Xvfb through a raw socketpair tee. By | |
| 34 | + | // default it compares every captured packet with the committed golden and | |
| 35 | + | // fails on a difference; -update rewrites the goldens instead. | |
| 26 | 36 | func TestCaptureRequests(t *testing.T) { | |
| 27 | - | if !*update { | |
| 28 | - | t.Skip("pass -update to capture request goldens") | |
| 37 | + | if _, err := exec.LookPath("Xvfb"); err != nil { | |
| 38 | + | t.Skip("Xvfb not installed") | |
| 29 | 39 | } | |
| 30 | 40 | // displayfd avoids display-number races and tells us when Xvfb is ready. | |
| 31 | 41 | r, w, err := os.Pipe() | |
| @@ -503,10 +513,10 @@ func TestCaptureRequests(t *testing.T) { | |||
| 503 | 513 | t.Fatalf("captured %d events, %d errors", len(events), len(xerrors)) | |
| 504 | 514 | } | |
| 505 | 515 | for name, p := range events { | |
| 506 | - | writeGolden(t, name+".event.hex", "# source: Xvfb event via raw socketpair tee; triggered by an independent second client or reference request\n", p) | |
| 516 | + | golden(t, name+".event.hex", "# source: Xvfb event via raw socketpair tee; triggered by an independent second client or reference request\n", p) | |
| 507 | 517 | } | |
| 508 | 518 | for name, p := range xerrors { | |
| 509 | - | writeGolden(t, name+".error.hex", "# source: Xvfb error via raw socketpair tee to an independent reference request\n", p) | |
| 519 | + | golden(t, name+".error.hex", "# source: Xvfb error via raw socketpair tee to an independent reference request\n", p) | |
| 510 | 520 | } | |
| 511 | 521 | // Closing the client drains the request direction; wait before inspecting tee. | |
| 512 | 522 | client.Close() | |
| @@ -568,30 +578,34 @@ func TestCaptureRequests(t *testing.T) { | |||
| 568 | 578 | t.Fatal("missing captured requests or replies") | |
| 569 | 579 | } | |
| 570 | 580 | for name, p := range replies { | |
| 571 | - | path := filepath.Join("../../testdata/golden", name+".reply.hex") | |
| 572 | - | if err := os.MkdirAll(filepath.Dir(path), 0755); err != nil { | |
| 573 | - | t.Fatal(err) | |
| 574 | - | } | |
| 575 | - | text := "# source: Xvfb reply via raw socketpair tee to an independent reference request\n# xtrace fallback: local xtrace is glibc's execution tracer, not X11 xtrace\n" + hex.EncodeToString(p) + "\n" | |
| 576 | - | if err := os.WriteFile(path, []byte(text), 0644); err != nil { | |
| 577 | - | t.Fatal(err) | |
| 578 | - | } | |
| 581 | + | golden(t, name+".reply.hex", "# source: Xvfb reply via raw socketpair tee to an independent reference request\n", p) | |
| 579 | 582 | } | |
| 580 | 583 | for name, p := range captured { | |
| 581 | - | path := filepath.Join("../../testdata/golden", name+".req.hex") | |
| 582 | - | if err := os.MkdirAll(filepath.Dir(path), 0755); err != nil { | |
| 583 | - | t.Fatal(err) | |
| 584 | - | } | |
| 585 | - | text := "# source: Xvfb via raw socketpair tee; independent reference encoder; server accepted\n# xtrace fallback: local xtrace is glibc's execution tracer, not X11 xtrace\n" + hex.EncodeToString(p) + "\n" | |
| 586 | - | if err := os.WriteFile(path, []byte(text), 0644); err != nil { | |
| 587 | - | t.Fatal(err) | |
| 588 | - | } | |
| 584 | + | golden(t, name+".req.hex", "# source: Xvfb via raw socketpair tee; independent reference encoder; server accepted\n", p) | |
| 589 | 585 | } | |
| 590 | 586 | } | |
| 591 | 587 | ||
| 592 | - | func writeGolden(t *testing.T, name, source string, p []byte) { | |
| 588 | + | // golden writes p (with -update) or compares it with the committed golden. | |
| 589 | + | func golden(t *testing.T, name, source string, p []byte) { | |
| 593 | 590 | t.Helper() | |
| 594 | 591 | path := filepath.Join("../../testdata/golden", name) | |
| 592 | + | if !*update { | |
| 593 | + | want, err := LoadHex(path) | |
| 594 | + | if err != nil { | |
| 595 | + | t.Errorf("%s: %v (run with -update to create it)", name, err) | |
| 596 | + | return | |
| 597 | + | } | |
| 598 | + | got := bytes.Clone(p) | |
| 599 | + | if len(got) == len(want) { | |
| 600 | + | for _, r := range volatile[name] { | |
| 601 | + | copy(got[r[0]:r[1]], want[r[0]:r[1]]) | |
| 602 | + | } | |
| 603 | + | } | |
| 604 | + | if !bytes.Equal(got, want) { | |
| 605 | + | t.Errorf("%s differs from live Xvfb:\n got %x\nwant %x", name, p, want) | |
| 606 | + | } | |
| 607 | + | return | |
| 608 | + | } | |
| 595 | 609 | if err := os.MkdirAll(filepath.Dir(path), 0755); err != nil { | |
| 596 | 610 | t.Fatal(err) | |
| 597 | 611 | } | |
| @@ -21,11 +21,21 @@ import ( | |||||
| 21 | "golang.org/x/sys/unix" | 21 | "golang.org/x/sys/unix" | ||
| 22 | ) | 22 | ) | ||
| 23 | 23 | ||||
| 24 | - | var update = flag.Bool("update", false, "refresh request goldens using Xvfb and a raw socketpair tee") | 24 | + | var update = flag.Bool("update", false, "rewrite wire goldens from Xvfb instead of comparing against them") |
| 25 | 25 | ||||
| 26 | + | // volatile lists server-time fields that differ on every run; comparison | |||
| 27 | + | // ignores these byte ranges [from, to). Everything else must match exactly. | |||
| 28 | + | var volatile = map[string][][2]int{ | |||
| 29 | + | "xproto/PropertyNotify.event.hex": {{12, 16}}, // time | |||
| 30 | + | "xfixes/SelectionNotify.event.hex": {{16, 24}}, // timestamp, selection_timestamp | |||
| 31 | + | } | |||
| 32 | + | ||||
| 33 | + | // TestCaptureRequests drives a fresh Xvfb through a raw socketpair tee. By | |||
| 34 | + | // default it compares every captured packet with the committed golden and | |||
| 35 | + | // fails on a difference; -update rewrites the goldens instead. | |||
| 26 | func TestCaptureRequests(t *testing.T) { | 36 | func TestCaptureRequests(t *testing.T) { | ||
| 27 | - | if !*update { | 37 | + | if _, err := exec.LookPath("Xvfb"); err != nil { |
| 28 | - | t.Skip("pass -update to capture request goldens") | 38 | + | t.Skip("Xvfb not installed") |
| 29 | } | 39 | } | ||
| 30 | // displayfd avoids display-number races and tells us when Xvfb is ready. | 40 | // displayfd avoids display-number races and tells us when Xvfb is ready. | ||
| 31 | r, w, err := os.Pipe() | 41 | r, w, err := os.Pipe() | ||
| @@ -503,10 +513,10 @@ func TestCaptureRequests(t *testing.T) { | |||||
| 503 | t.Fatalf("captured %d events, %d errors", len(events), len(xerrors)) | 513 | t.Fatalf("captured %d events, %d errors", len(events), len(xerrors)) | ||
| 504 | } | 514 | } | ||
| 505 | for name, p := range events { | 515 | for name, p := range events { | ||
| 506 | - | writeGolden(t, name+".event.hex", "# source: Xvfb event via raw socketpair tee; triggered by an independent second client or reference request\n", p) | 516 | + | golden(t, name+".event.hex", "# source: Xvfb event via raw socketpair tee; triggered by an independent second client or reference request\n", p) |
| 507 | } | 517 | } | ||
| 508 | for name, p := range xerrors { | 518 | for name, p := range xerrors { | ||
| 509 | - | writeGolden(t, name+".error.hex", "# source: Xvfb error via raw socketpair tee to an independent reference request\n", p) | 519 | + | golden(t, name+".error.hex", "# source: Xvfb error via raw socketpair tee to an independent reference request\n", p) |
| 510 | } | 520 | } | ||
| 511 | // Closing the client drains the request direction; wait before inspecting tee. | 521 | // Closing the client drains the request direction; wait before inspecting tee. | ||
| 512 | client.Close() | 522 | client.Close() | ||
| @@ -568,30 +578,34 @@ func TestCaptureRequests(t *testing.T) { | |||||
| 568 | t.Fatal("missing captured requests or replies") | 578 | t.Fatal("missing captured requests or replies") | ||
| 569 | } | 579 | } | ||
| 570 | for name, p := range replies { | 580 | for name, p := range replies { | ||
| 571 | - | path := filepath.Join("../../testdata/golden", name+".reply.hex") | 581 | + | golden(t, name+".reply.hex", "# source: Xvfb reply via raw socketpair tee to an independent reference request\n", p) |
| 572 | - | if err := os.MkdirAll(filepath.Dir(path), 0755); err != nil { | |||
| 573 | - | t.Fatal(err) | |||
| 574 | - | } | |||
| 575 | - | text := "# source: Xvfb reply via raw socketpair tee to an independent reference request\n# xtrace fallback: local xtrace is glibc's execution tracer, not X11 xtrace\n" + hex.EncodeToString(p) + "\n" | |||
| 576 | - | if err := os.WriteFile(path, []byte(text), 0644); err != nil { | |||
| 577 | - | t.Fatal(err) | |||
| 578 | - | } | |||
| 579 | } | 582 | } | ||
| 580 | for name, p := range captured { | 583 | for name, p := range captured { | ||
| 581 | - | path := filepath.Join("../../testdata/golden", name+".req.hex") | 584 | + | golden(t, name+".req.hex", "# source: Xvfb via raw socketpair tee; independent reference encoder; server accepted\n", p) |
| 582 | - | if err := os.MkdirAll(filepath.Dir(path), 0755); err != nil { | |||
| 583 | - | t.Fatal(err) | |||
| 584 | - | } | |||
| 585 | - | text := "# source: Xvfb via raw socketpair tee; independent reference encoder; server accepted\n# xtrace fallback: local xtrace is glibc's execution tracer, not X11 xtrace\n" + hex.EncodeToString(p) + "\n" | |||
| 586 | - | if err := os.WriteFile(path, []byte(text), 0644); err != nil { | |||
| 587 | - | t.Fatal(err) | |||
| 588 | - | } | |||
| 589 | } | 585 | } | ||
| 590 | } | 586 | } | ||
| 591 | 587 | ||||
| 592 | - | func writeGolden(t *testing.T, name, source string, p []byte) { | 588 | + | // golden writes p (with -update) or compares it with the committed golden. |
| 589 | + | func golden(t *testing.T, name, source string, p []byte) { | |||
| 593 | t.Helper() | 590 | t.Helper() | ||
| 594 | path := filepath.Join("../../testdata/golden", name) | 591 | path := filepath.Join("../../testdata/golden", name) | ||
| 592 | + | if !*update { | |||
| 593 | + | want, err := LoadHex(path) | |||
| 594 | + | if err != nil { | |||
| 595 | + | t.Errorf("%s: %v (run with -update to create it)", name, err) | |||
| 596 | + | return | |||
| 597 | + | } | |||
| 598 | + | got := bytes.Clone(p) | |||
| 599 | + | if len(got) == len(want) { | |||
| 600 | + | for _, r := range volatile[name] { | |||
| 601 | + | copy(got[r[0]:r[1]], want[r[0]:r[1]]) | |||
| 602 | + | } | |||
| 603 | + | } | |||
| 604 | + | if !bytes.Equal(got, want) { | |||
| 605 | + | t.Errorf("%s differs from live Xvfb:\n got %x\nwant %x", name, p, want) | |||
| 606 | + | } | |||
| 607 | + | return | |||
| 608 | + | } | |||
| 595 | if err := os.MkdirAll(filepath.Dir(path), 0755); err != nil { | 609 | if err := os.MkdirAll(filepath.Dir(path), 0755); err != nil { | ||
| 596 | t.Fatal(err) | 610 | t.Fatal(err) | ||
| 597 | } | 611 | } | ||
M xproto/events_fuzz_test.go +196 -0
| @@ -124,6 +124,13 @@ func FuzzEventViews(f *testing.F) { | |||
| 124 | 124 | if w.SameScreen() != vKeyPress.SameScreen() { | |
| 125 | 125 | t.Fatal("KeyPress.SameScreen") | |
| 126 | 126 | } | |
| 127 | + | in := xturbo.Event{Raw: ev.Raw} | |
| 128 | + | vi := KeyPressOf(&in) | |
| 129 | + | di := KeyPressEventData{Detail: vi.Detail(), Time: vi.Time(), Root: vi.Root(), Event: vi.Event(), Child: vi.Child(), RootX: vi.RootX(), RootY: vi.RootY(), EventX: vi.EventX(), EventY: vi.EventY(), State: vi.State(), SameScreen: vi.SameScreen()} | |
| 130 | + | di.Put(&in.Raw) | |
| 131 | + | if in.Raw != out { | |
| 132 | + | t.Fatal("KeyPress in-place Put") | |
| 133 | + | } | |
| 127 | 134 | } | |
| 128 | 135 | _ = KeyReleaseOf(&ev) | |
| 129 | 136 | { | |
| @@ -180,6 +187,13 @@ func FuzzEventViews(f *testing.F) { | |||
| 180 | 187 | if w.SameScreen() != vButtonPress.SameScreen() { | |
| 181 | 188 | t.Fatal("ButtonPress.SameScreen") | |
| 182 | 189 | } | |
| 190 | + | in := xturbo.Event{Raw: ev.Raw} | |
| 191 | + | vi := ButtonPressOf(&in) | |
| 192 | + | di := ButtonPressEventData{Detail: vi.Detail(), Time: vi.Time(), Root: vi.Root(), Event: vi.Event(), Child: vi.Child(), RootX: vi.RootX(), RootY: vi.RootY(), EventX: vi.EventX(), EventY: vi.EventY(), State: vi.State(), SameScreen: vi.SameScreen()} | |
| 193 | + | di.Put(&in.Raw) | |
| 194 | + | if in.Raw != out { | |
| 195 | + | t.Fatal("ButtonPress in-place Put") | |
| 196 | + | } | |
| 183 | 197 | } | |
| 184 | 198 | _ = ButtonReleaseOf(&ev) | |
| 185 | 199 | { | |
| @@ -236,6 +250,13 @@ func FuzzEventViews(f *testing.F) { | |||
| 236 | 250 | if w.SameScreen() != vMotionNotify.SameScreen() { | |
| 237 | 251 | t.Fatal("MotionNotify.SameScreen") | |
| 238 | 252 | } | |
| 253 | + | in := xturbo.Event{Raw: ev.Raw} | |
| 254 | + | vi := MotionNotifyOf(&in) | |
| 255 | + | di := MotionNotifyEventData{Detail: vi.Detail(), Time: vi.Time(), Root: vi.Root(), Event: vi.Event(), Child: vi.Child(), RootX: vi.RootX(), RootY: vi.RootY(), EventX: vi.EventX(), EventY: vi.EventY(), State: vi.State(), SameScreen: vi.SameScreen()} | |
| 256 | + | di.Put(&in.Raw) | |
| 257 | + | if in.Raw != out { | |
| 258 | + | t.Fatal("MotionNotify in-place Put") | |
| 259 | + | } | |
| 239 | 260 | } | |
| 240 | 261 | { | |
| 241 | 262 | vEnterNotify := EnterNotifyOf(&ev) | |
| @@ -295,6 +316,13 @@ func FuzzEventViews(f *testing.F) { | |||
| 295 | 316 | if w.SameScreenFocus() != vEnterNotify.SameScreenFocus() { | |
| 296 | 317 | t.Fatal("EnterNotify.SameScreenFocus") | |
| 297 | 318 | } | |
| 319 | + | in := xturbo.Event{Raw: ev.Raw} | |
| 320 | + | vi := EnterNotifyOf(&in) | |
| 321 | + | di := EnterNotifyEventData{Detail: vi.Detail(), Time: vi.Time(), Root: vi.Root(), Event: vi.Event(), Child: vi.Child(), RootX: vi.RootX(), RootY: vi.RootY(), EventX: vi.EventX(), EventY: vi.EventY(), State: vi.State(), Mode: vi.Mode(), SameScreenFocus: vi.SameScreenFocus()} | |
| 322 | + | di.Put(&in.Raw) | |
| 323 | + | if in.Raw != out { | |
| 324 | + | t.Fatal("EnterNotify in-place Put") | |
| 325 | + | } | |
| 298 | 326 | } | |
| 299 | 327 | _ = LeaveNotifyOf(&ev) | |
| 300 | 328 | { | |
| @@ -319,6 +347,13 @@ func FuzzEventViews(f *testing.F) { | |||
| 319 | 347 | if w.Mode() != vFocusIn.Mode() { | |
| 320 | 348 | t.Fatal("FocusIn.Mode") | |
| 321 | 349 | } | |
| 350 | + | in := xturbo.Event{Raw: ev.Raw} | |
| 351 | + | vi := FocusInOf(&in) | |
| 352 | + | di := FocusInEventData{Detail: vi.Detail(), Event: vi.Event(), Mode: vi.Mode()} | |
| 353 | + | di.Put(&in.Raw) | |
| 354 | + | if in.Raw != out { | |
| 355 | + | t.Fatal("FocusIn in-place Put") | |
| 356 | + | } | |
| 322 | 357 | } | |
| 323 | 358 | _ = FocusOutOf(&ev) | |
| 324 | 359 | { | |
| @@ -335,6 +370,13 @@ func FuzzEventViews(f *testing.F) { | |||
| 335 | 370 | if !bytes.Equal(w.Keys(), vKeymapNotify.Keys()) { | |
| 336 | 371 | t.Fatal("KeymapNotify.Keys") | |
| 337 | 372 | } | |
| 373 | + | in := xturbo.Event{Raw: ev.Raw} | |
| 374 | + | vi := KeymapNotifyOf(&in) | |
| 375 | + | di := KeymapNotifyEventData{Keys: [31]uint8(vi.Keys())} | |
| 376 | + | di.Put(&in.Raw) | |
| 377 | + | if in.Raw != out { | |
| 378 | + | t.Fatal("KeymapNotify in-place Put") | |
| 379 | + | } | |
| 338 | 380 | } | |
| 339 | 381 | { | |
| 340 | 382 | vExpose := ExposeOf(&ev) | |
| @@ -370,6 +412,13 @@ func FuzzEventViews(f *testing.F) { | |||
| 370 | 412 | if w.Count() != vExpose.Count() { | |
| 371 | 413 | t.Fatal("Expose.Count") | |
| 372 | 414 | } | |
| 415 | + | in := xturbo.Event{Raw: ev.Raw} | |
| 416 | + | vi := ExposeOf(&in) | |
| 417 | + | di := ExposeEventData{Window: vi.Window(), X: vi.X(), Y: vi.Y(), Width: vi.Width(), Height: vi.Height(), Count: vi.Count()} | |
| 418 | + | di.Put(&in.Raw) | |
| 419 | + | if in.Raw != out { | |
| 420 | + | t.Fatal("Expose in-place Put") | |
| 421 | + | } | |
| 373 | 422 | } | |
| 374 | 423 | { | |
| 375 | 424 | vGraphicsExposure := GraphicsExposureOf(&ev) | |
| @@ -413,6 +462,13 @@ func FuzzEventViews(f *testing.F) { | |||
| 413 | 462 | if w.MajorOpcode() != vGraphicsExposure.MajorOpcode() { | |
| 414 | 463 | t.Fatal("GraphicsExposure.MajorOpcode") | |
| 415 | 464 | } | |
| 465 | + | in := xturbo.Event{Raw: ev.Raw} | |
| 466 | + | vi := GraphicsExposureOf(&in) | |
| 467 | + | di := GraphicsExposureEventData{Drawable: vi.Drawable(), X: vi.X(), Y: vi.Y(), Width: vi.Width(), Height: vi.Height(), MinorOpcode: vi.MinorOpcode(), Count: vi.Count(), MajorOpcode: vi.MajorOpcode()} | |
| 468 | + | di.Put(&in.Raw) | |
| 469 | + | if in.Raw != out { | |
| 470 | + | t.Fatal("GraphicsExposure in-place Put") | |
| 471 | + | } | |
| 416 | 472 | } | |
| 417 | 473 | { | |
| 418 | 474 | vNoExposure := NoExposureOf(&ev) | |
| @@ -436,6 +492,13 @@ func FuzzEventViews(f *testing.F) { | |||
| 436 | 492 | if w.MajorOpcode() != vNoExposure.MajorOpcode() { | |
| 437 | 493 | t.Fatal("NoExposure.MajorOpcode") | |
| 438 | 494 | } | |
| 495 | + | in := xturbo.Event{Raw: ev.Raw} | |
| 496 | + | vi := NoExposureOf(&in) | |
| 497 | + | di := NoExposureEventData{Drawable: vi.Drawable(), MinorOpcode: vi.MinorOpcode(), MajorOpcode: vi.MajorOpcode()} | |
| 498 | + | di.Put(&in.Raw) | |
| 499 | + | if in.Raw != out { | |
| 500 | + | t.Fatal("NoExposure in-place Put") | |
| 501 | + | } | |
| 439 | 502 | } | |
| 440 | 503 | { | |
| 441 | 504 | vVisibilityNotify := VisibilityNotifyOf(&ev) | |
| @@ -455,6 +518,13 @@ func FuzzEventViews(f *testing.F) { | |||
| 455 | 518 | if w.State() != vVisibilityNotify.State() { | |
| 456 | 519 | t.Fatal("VisibilityNotify.State") | |
| 457 | 520 | } | |
| 521 | + | in := xturbo.Event{Raw: ev.Raw} | |
| 522 | + | vi := VisibilityNotifyOf(&in) | |
| 523 | + | di := VisibilityNotifyEventData{Window: vi.Window(), State: vi.State()} | |
| 524 | + | di.Put(&in.Raw) | |
| 525 | + | if in.Raw != out { | |
| 526 | + | t.Fatal("VisibilityNotify in-place Put") | |
| 527 | + | } | |
| 458 | 528 | } | |
| 459 | 529 | { | |
| 460 | 530 | vCreateNotify := CreateNotifyOf(&ev) | |
| @@ -498,6 +568,13 @@ func FuzzEventViews(f *testing.F) { | |||
| 498 | 568 | if w.OverrideRedirect() != vCreateNotify.OverrideRedirect() { | |
| 499 | 569 | t.Fatal("CreateNotify.OverrideRedirect") | |
| 500 | 570 | } | |
| 571 | + | in := xturbo.Event{Raw: ev.Raw} | |
| 572 | + | vi := CreateNotifyOf(&in) | |
| 573 | + | di := CreateNotifyEventData{Parent: vi.Parent(), Window: vi.Window(), X: vi.X(), Y: vi.Y(), Width: vi.Width(), Height: vi.Height(), BorderWidth: vi.BorderWidth(), OverrideRedirect: vi.OverrideRedirect()} | |
| 574 | + | di.Put(&in.Raw) | |
| 575 | + | if in.Raw != out { | |
| 576 | + | t.Fatal("CreateNotify in-place Put") | |
| 577 | + | } | |
| 501 | 578 | } | |
| 502 | 579 | { | |
| 503 | 580 | vDestroyNotify := DestroyNotifyOf(&ev) | |
| @@ -517,6 +594,13 @@ func FuzzEventViews(f *testing.F) { | |||
| 517 | 594 | if w.Window() != vDestroyNotify.Window() { | |
| 518 | 595 | t.Fatal("DestroyNotify.Window") | |
| 519 | 596 | } | |
| 597 | + | in := xturbo.Event{Raw: ev.Raw} | |
| 598 | + | vi := DestroyNotifyOf(&in) | |
| 599 | + | di := DestroyNotifyEventData{Event: vi.Event(), Window: vi.Window()} | |
| 600 | + | di.Put(&in.Raw) | |
| 601 | + | if in.Raw != out { | |
| 602 | + | t.Fatal("DestroyNotify in-place Put") | |
| 603 | + | } | |
| 520 | 604 | } | |
| 521 | 605 | { | |
| 522 | 606 | vUnmapNotify := UnmapNotifyOf(&ev) | |
| @@ -540,6 +624,13 @@ func FuzzEventViews(f *testing.F) { | |||
| 540 | 624 | if w.FromConfigure() != vUnmapNotify.FromConfigure() { | |
| 541 | 625 | t.Fatal("UnmapNotify.FromConfigure") | |
| 542 | 626 | } | |
| 627 | + | in := xturbo.Event{Raw: ev.Raw} | |
| 628 | + | vi := UnmapNotifyOf(&in) | |
| 629 | + | di := UnmapNotifyEventData{Event: vi.Event(), Window: vi.Window(), FromConfigure: vi.FromConfigure()} | |
| 630 | + | di.Put(&in.Raw) | |
| 631 | + | if in.Raw != out { | |
| 632 | + | t.Fatal("UnmapNotify in-place Put") | |
| 633 | + | } | |
| 543 | 634 | } | |
| 544 | 635 | { | |
| 545 | 636 | vMapNotify := MapNotifyOf(&ev) | |
| @@ -563,6 +654,13 @@ func FuzzEventViews(f *testing.F) { | |||
| 563 | 654 | if w.OverrideRedirect() != vMapNotify.OverrideRedirect() { | |
| 564 | 655 | t.Fatal("MapNotify.OverrideRedirect") | |
| 565 | 656 | } | |
| 657 | + | in := xturbo.Event{Raw: ev.Raw} | |
| 658 | + | vi := MapNotifyOf(&in) | |
| 659 | + | di := MapNotifyEventData{Event: vi.Event(), Window: vi.Window(), OverrideRedirect: vi.OverrideRedirect()} | |
| 660 | + | di.Put(&in.Raw) | |
| 661 | + | if in.Raw != out { | |
| 662 | + | t.Fatal("MapNotify in-place Put") | |
| 663 | + | } | |
| 566 | 664 | } | |
| 567 | 665 | { | |
| 568 | 666 | vMapRequest := MapRequestOf(&ev) | |
| @@ -582,6 +680,13 @@ func FuzzEventViews(f *testing.F) { | |||
| 582 | 680 | if w.Window() != vMapRequest.Window() { | |
| 583 | 681 | t.Fatal("MapRequest.Window") | |
| 584 | 682 | } | |
| 683 | + | in := xturbo.Event{Raw: ev.Raw} | |
| 684 | + | vi := MapRequestOf(&in) | |
| 685 | + | di := MapRequestEventData{Parent: vi.Parent(), Window: vi.Window()} | |
| 686 | + | di.Put(&in.Raw) | |
| 687 | + | if in.Raw != out { | |
| 688 | + | t.Fatal("MapRequest in-place Put") | |
| 689 | + | } | |
| 585 | 690 | } | |
| 586 | 691 | { | |
| 587 | 692 | vReparentNotify := ReparentNotifyOf(&ev) | |
| @@ -617,6 +722,13 @@ func FuzzEventViews(f *testing.F) { | |||
| 617 | 722 | if w.OverrideRedirect() != vReparentNotify.OverrideRedirect() { | |
| 618 | 723 | t.Fatal("ReparentNotify.OverrideRedirect") | |
| 619 | 724 | } | |
| 725 | + | in := xturbo.Event{Raw: ev.Raw} | |
| 726 | + | vi := ReparentNotifyOf(&in) | |
| 727 | + | di := ReparentNotifyEventData{Event: vi.Event(), Window: vi.Window(), Parent: vi.Parent(), X: vi.X(), Y: vi.Y(), OverrideRedirect: vi.OverrideRedirect()} | |
| 728 | + | di.Put(&in.Raw) | |
| 729 | + | if in.Raw != out { | |
| 730 | + | t.Fatal("ReparentNotify in-place Put") | |
| 731 | + | } | |
| 620 | 732 | } | |
| 621 | 733 | { | |
| 622 | 734 | vConfigureNotify := ConfigureNotifyOf(&ev) | |
| @@ -664,6 +776,13 @@ func FuzzEventViews(f *testing.F) { | |||
| 664 | 776 | if w.OverrideRedirect() != vConfigureNotify.OverrideRedirect() { | |
| 665 | 777 | t.Fatal("ConfigureNotify.OverrideRedirect") | |
| 666 | 778 | } | |
| 779 | + | in := xturbo.Event{Raw: ev.Raw} | |
| 780 | + | vi := ConfigureNotifyOf(&in) | |
| 781 | + | di := ConfigureNotifyEventData{Event: vi.Event(), Window: vi.Window(), AboveSibling: vi.AboveSibling(), X: vi.X(), Y: vi.Y(), Width: vi.Width(), Height: vi.Height(), BorderWidth: vi.BorderWidth(), OverrideRedirect: vi.OverrideRedirect()} | |
| 782 | + | di.Put(&in.Raw) | |
| 783 | + | if in.Raw != out { | |
| 784 | + | t.Fatal("ConfigureNotify in-place Put") | |
| 785 | + | } | |
| 667 | 786 | } | |
| 668 | 787 | { | |
| 669 | 788 | vConfigureRequest := ConfigureRequestOf(&ev) | |
| @@ -715,6 +834,13 @@ func FuzzEventViews(f *testing.F) { | |||
| 715 | 834 | if w.ValueMask() != vConfigureRequest.ValueMask() { | |
| 716 | 835 | t.Fatal("ConfigureRequest.ValueMask") | |
| 717 | 836 | } | |
| 837 | + | in := xturbo.Event{Raw: ev.Raw} | |
| 838 | + | vi := ConfigureRequestOf(&in) | |
| 839 | + | di := ConfigureRequestEventData{StackMode: vi.StackMode(), Parent: vi.Parent(), Window: vi.Window(), Sibling: vi.Sibling(), X: vi.X(), Y: vi.Y(), Width: vi.Width(), Height: vi.Height(), BorderWidth: vi.BorderWidth(), ValueMask: vi.ValueMask()} | |
| 840 | + | di.Put(&in.Raw) | |
| 841 | + | if in.Raw != out { | |
| 842 | + | t.Fatal("ConfigureRequest in-place Put") | |
| 843 | + | } | |
| 718 | 844 | } | |
| 719 | 845 | { | |
| 720 | 846 | vGravityNotify := GravityNotifyOf(&ev) | |
| @@ -742,6 +868,13 @@ func FuzzEventViews(f *testing.F) { | |||
| 742 | 868 | if w.Y() != vGravityNotify.Y() { | |
| 743 | 869 | t.Fatal("GravityNotify.Y") | |
| 744 | 870 | } | |
| 871 | + | in := xturbo.Event{Raw: ev.Raw} | |
| 872 | + | vi := GravityNotifyOf(&in) | |
| 873 | + | di := GravityNotifyEventData{Event: vi.Event(), Window: vi.Window(), X: vi.X(), Y: vi.Y()} | |
| 874 | + | di.Put(&in.Raw) | |
| 875 | + | if in.Raw != out { | |
| 876 | + | t.Fatal("GravityNotify in-place Put") | |
| 877 | + | } | |
| 745 | 878 | } | |
| 746 | 879 | { | |
| 747 | 880 | vResizeRequest := ResizeRequestOf(&ev) | |
| @@ -765,6 +898,13 @@ func FuzzEventViews(f *testing.F) { | |||
| 765 | 898 | if w.Height() != vResizeRequest.Height() { | |
| 766 | 899 | t.Fatal("ResizeRequest.Height") | |
| 767 | 900 | } | |
| 901 | + | in := xturbo.Event{Raw: ev.Raw} | |
| 902 | + | vi := ResizeRequestOf(&in) | |
| 903 | + | di := ResizeRequestEventData{Window: vi.Window(), Width: vi.Width(), Height: vi.Height()} | |
| 904 | + | di.Put(&in.Raw) | |
| 905 | + | if in.Raw != out { | |
| 906 | + | t.Fatal("ResizeRequest in-place Put") | |
| 907 | + | } | |
| 768 | 908 | } | |
| 769 | 909 | { | |
| 770 | 910 | vCirculateNotify := CirculateNotifyOf(&ev) | |
| @@ -788,6 +928,13 @@ func FuzzEventViews(f *testing.F) { | |||
| 788 | 928 | if w.Place() != vCirculateNotify.Place() { | |
| 789 | 929 | t.Fatal("CirculateNotify.Place") | |
| 790 | 930 | } | |
| 931 | + | in := xturbo.Event{Raw: ev.Raw} | |
| 932 | + | vi := CirculateNotifyOf(&in) | |
| 933 | + | di := CirculateNotifyEventData{Event: vi.Event(), Window: vi.Window(), Place: vi.Place()} | |
| 934 | + | di.Put(&in.Raw) | |
| 935 | + | if in.Raw != out { | |
| 936 | + | t.Fatal("CirculateNotify in-place Put") | |
| 937 | + | } | |
| 791 | 938 | } | |
| 792 | 939 | _ = CirculateRequestOf(&ev) | |
| 793 | 940 | { | |
| @@ -816,6 +963,13 @@ func FuzzEventViews(f *testing.F) { | |||
| 816 | 963 | if w.State() != vPropertyNotify.State() { | |
| 817 | 964 | t.Fatal("PropertyNotify.State") | |
| 818 | 965 | } | |
| 966 | + | in := xturbo.Event{Raw: ev.Raw} | |
| 967 | + | vi := PropertyNotifyOf(&in) | |
| 968 | + | di := PropertyNotifyEventData{Window: vi.Window(), Atom: vi.Atom(), Time: vi.Time(), State: vi.State()} | |
| 969 | + | di.Put(&in.Raw) | |
| 970 | + | if in.Raw != out { | |
| 971 | + | t.Fatal("PropertyNotify in-place Put") | |
| 972 | + | } | |
| 819 | 973 | } | |
| 820 | 974 | { | |
| 821 | 975 | vSelectionClear := SelectionClearOf(&ev) | |
| @@ -839,6 +993,13 @@ func FuzzEventViews(f *testing.F) { | |||
| 839 | 993 | if w.Selection() != vSelectionClear.Selection() { | |
| 840 | 994 | t.Fatal("SelectionClear.Selection") | |
| 841 | 995 | } | |
| 996 | + | in := xturbo.Event{Raw: ev.Raw} | |
| 997 | + | vi := SelectionClearOf(&in) | |
| 998 | + | di := SelectionClearEventData{Time: vi.Time(), Owner: vi.Owner(), Selection: vi.Selection()} | |
| 999 | + | di.Put(&in.Raw) | |
| 1000 | + | if in.Raw != out { | |
| 1001 | + | t.Fatal("SelectionClear in-place Put") | |
| 1002 | + | } | |
| 842 | 1003 | } | |
| 843 | 1004 | { | |
| 844 | 1005 | vSelectionRequest := SelectionRequestOf(&ev) | |
| @@ -874,6 +1035,13 @@ func FuzzEventViews(f *testing.F) { | |||
| 874 | 1035 | if w.Property() != vSelectionRequest.Property() { | |
| 875 | 1036 | t.Fatal("SelectionRequest.Property") | |
| 876 | 1037 | } | |
| 1038 | + | in := xturbo.Event{Raw: ev.Raw} | |
| 1039 | + | vi := SelectionRequestOf(&in) | |
| 1040 | + | di := SelectionRequestEventData{Time: vi.Time(), Owner: vi.Owner(), Requestor: vi.Requestor(), Selection: vi.Selection(), Target: vi.Target(), Property: vi.Property()} | |
| 1041 | + | di.Put(&in.Raw) | |
| 1042 | + | if in.Raw != out { | |
| 1043 | + | t.Fatal("SelectionRequest in-place Put") | |
| 1044 | + | } | |
| 877 | 1045 | } | |
| 878 | 1046 | { | |
| 879 | 1047 | vSelectionNotify := SelectionNotifyOf(&ev) | |
| @@ -905,6 +1073,13 @@ func FuzzEventViews(f *testing.F) { | |||
| 905 | 1073 | if w.Property() != vSelectionNotify.Property() { | |
| 906 | 1074 | t.Fatal("SelectionNotify.Property") | |
| 907 | 1075 | } | |
| 1076 | + | in := xturbo.Event{Raw: ev.Raw} | |
| 1077 | + | vi := SelectionNotifyOf(&in) | |
| 1078 | + | di := SelectionNotifyEventData{Time: vi.Time(), Requestor: vi.Requestor(), Selection: vi.Selection(), Target: vi.Target(), Property: vi.Property()} | |
| 1079 | + | di.Put(&in.Raw) | |
| 1080 | + | if in.Raw != out { | |
| 1081 | + | t.Fatal("SelectionNotify in-place Put") | |
| 1082 | + | } | |
| 908 | 1083 | } | |
| 909 | 1084 | { | |
| 910 | 1085 | vColormapNotify := ColormapNotifyOf(&ev) | |
| @@ -932,6 +1107,13 @@ func FuzzEventViews(f *testing.F) { | |||
| 932 | 1107 | if w.State() != vColormapNotify.State() { | |
| 933 | 1108 | t.Fatal("ColormapNotify.State") | |
| 934 | 1109 | } | |
| 1110 | + | in := xturbo.Event{Raw: ev.Raw} | |
| 1111 | + | vi := ColormapNotifyOf(&in) | |
| 1112 | + | di := ColormapNotifyEventData{Window: vi.Window(), Colormap: vi.Colormap(), New: vi.New(), State: vi.State()} | |
| 1113 | + | di.Put(&in.Raw) | |
| 1114 | + | if in.Raw != out { | |
| 1115 | + | t.Fatal("ColormapNotify in-place Put") | |
| 1116 | + | } | |
| 935 | 1117 | } | |
| 936 | 1118 | { | |
| 937 | 1119 | vClientMessage := ClientMessageOf(&ev) | |
| @@ -959,6 +1141,13 @@ func FuzzEventViews(f *testing.F) { | |||
| 959 | 1141 | if !bytes.Equal(out[12:32], ev.Raw[12:32]) { | |
| 960 | 1142 | t.Fatal("ClientMessage.Data") | |
| 961 | 1143 | } | |
| 1144 | + | in := xturbo.Event{Raw: ev.Raw} | |
| 1145 | + | vi := ClientMessageOf(&in) | |
| 1146 | + | di := ClientMessageEventData{Format: vi.Format(), Window: vi.Window(), Type: vi.Type(), Data: vi.Data()} | |
| 1147 | + | di.Put(&in.Raw) | |
| 1148 | + | if in.Raw != out { | |
| 1149 | + | t.Fatal("ClientMessage in-place Put") | |
| 1150 | + | } | |
| 962 | 1151 | } | |
| 963 | 1152 | { | |
| 964 | 1153 | vMappingNotify := MappingNotifyOf(&ev) | |
| @@ -982,6 +1171,13 @@ func FuzzEventViews(f *testing.F) { | |||
| 982 | 1171 | if w.Count() != vMappingNotify.Count() { | |
| 983 | 1172 | t.Fatal("MappingNotify.Count") | |
| 984 | 1173 | } | |
| 1174 | + | in := xturbo.Event{Raw: ev.Raw} | |
| 1175 | + | vi := MappingNotifyOf(&in) | |
| 1176 | + | di := MappingNotifyEventData{Request: vi.Request(), FirstKeycode: vi.FirstKeycode(), Count: vi.Count()} | |
| 1177 | + | di.Put(&in.Raw) | |
| 1178 | + | if in.Raw != out { | |
| 1179 | + | t.Fatal("MappingNotify in-place Put") | |
| 1180 | + | } | |
| 985 | 1181 | } | |
| 986 | 1182 | if vGeGeneric, ok := GeGenericOf(&ev); ok { | |
| 987 | 1183 | _ = vGeGeneric.Extension() | |
| @@ -124,6 +124,13 @@ func FuzzEventViews(f *testing.F) { | |||||
| 124 | if w.SameScreen() != vKeyPress.SameScreen() { | 124 | if w.SameScreen() != vKeyPress.SameScreen() { | ||
| 125 | t.Fatal("KeyPress.SameScreen") | 125 | t.Fatal("KeyPress.SameScreen") | ||
| 126 | } | 126 | } | ||
| 127 | + | in := xturbo.Event{Raw: ev.Raw} | |||
| 128 | + | vi := KeyPressOf(&in) | |||
| 129 | + | di := KeyPressEventData{Detail: vi.Detail(), Time: vi.Time(), Root: vi.Root(), Event: vi.Event(), Child: vi.Child(), RootX: vi.RootX(), RootY: vi.RootY(), EventX: vi.EventX(), EventY: vi.EventY(), State: vi.State(), SameScreen: vi.SameScreen()} | |||
| 130 | + | di.Put(&in.Raw) | |||
| 131 | + | if in.Raw != out { | |||
| 132 | + | t.Fatal("KeyPress in-place Put") | |||
| 133 | + | } | |||
| 127 | } | 134 | } | ||
| 128 | _ = KeyReleaseOf(&ev) | 135 | _ = KeyReleaseOf(&ev) | ||
| 129 | { | 136 | { | ||
| @@ -180,6 +187,13 @@ func FuzzEventViews(f *testing.F) { | |||||
| 180 | if w.SameScreen() != vButtonPress.SameScreen() { | 187 | if w.SameScreen() != vButtonPress.SameScreen() { | ||
| 181 | t.Fatal("ButtonPress.SameScreen") | 188 | t.Fatal("ButtonPress.SameScreen") | ||
| 182 | } | 189 | } | ||
| 190 | + | in := xturbo.Event{Raw: ev.Raw} | |||
| 191 | + | vi := ButtonPressOf(&in) | |||
| 192 | + | di := ButtonPressEventData{Detail: vi.Detail(), Time: vi.Time(), Root: vi.Root(), Event: vi.Event(), Child: vi.Child(), RootX: vi.RootX(), RootY: vi.RootY(), EventX: vi.EventX(), EventY: vi.EventY(), State: vi.State(), SameScreen: vi.SameScreen()} | |||
| 193 | + | di.Put(&in.Raw) | |||
| 194 | + | if in.Raw != out { | |||
| 195 | + | t.Fatal("ButtonPress in-place Put") | |||
| 196 | + | } | |||
| 183 | } | 197 | } | ||
| 184 | _ = ButtonReleaseOf(&ev) | 198 | _ = ButtonReleaseOf(&ev) | ||
| 185 | { | 199 | { | ||
| @@ -236,6 +250,13 @@ func FuzzEventViews(f *testing.F) { | |||||
| 236 | if w.SameScreen() != vMotionNotify.SameScreen() { | 250 | if w.SameScreen() != vMotionNotify.SameScreen() { | ||
| 237 | t.Fatal("MotionNotify.SameScreen") | 251 | t.Fatal("MotionNotify.SameScreen") | ||
| 238 | } | 252 | } | ||
| 253 | + | in := xturbo.Event{Raw: ev.Raw} | |||
| 254 | + | vi := MotionNotifyOf(&in) | |||
| 255 | + | di := MotionNotifyEventData{Detail: vi.Detail(), Time: vi.Time(), Root: vi.Root(), Event: vi.Event(), Child: vi.Child(), RootX: vi.RootX(), RootY: vi.RootY(), EventX: vi.EventX(), EventY: vi.EventY(), State: vi.State(), SameScreen: vi.SameScreen()} | |||
| 256 | + | di.Put(&in.Raw) | |||
| 257 | + | if in.Raw != out { | |||
| 258 | + | t.Fatal("MotionNotify in-place Put") | |||
| 259 | + | } | |||
| 239 | } | 260 | } | ||
| 240 | { | 261 | { | ||
| 241 | vEnterNotify := EnterNotifyOf(&ev) | 262 | vEnterNotify := EnterNotifyOf(&ev) | ||
| @@ -295,6 +316,13 @@ func FuzzEventViews(f *testing.F) { | |||||
| 295 | if w.SameScreenFocus() != vEnterNotify.SameScreenFocus() { | 316 | if w.SameScreenFocus() != vEnterNotify.SameScreenFocus() { | ||
| 296 | t.Fatal("EnterNotify.SameScreenFocus") | 317 | t.Fatal("EnterNotify.SameScreenFocus") | ||
| 297 | } | 318 | } | ||
| 319 | + | in := xturbo.Event{Raw: ev.Raw} | |||
| 320 | + | vi := EnterNotifyOf(&in) | |||
| 321 | + | di := EnterNotifyEventData{Detail: vi.Detail(), Time: vi.Time(), Root: vi.Root(), Event: vi.Event(), Child: vi.Child(), RootX: vi.RootX(), RootY: vi.RootY(), EventX: vi.EventX(), EventY: vi.EventY(), State: vi.State(), Mode: vi.Mode(), SameScreenFocus: vi.SameScreenFocus()} | |||
| 322 | + | di.Put(&in.Raw) | |||
| 323 | + | if in.Raw != out { | |||
| 324 | + | t.Fatal("EnterNotify in-place Put") | |||
| 325 | + | } | |||
| 298 | } | 326 | } | ||
| 299 | _ = LeaveNotifyOf(&ev) | 327 | _ = LeaveNotifyOf(&ev) | ||
| 300 | { | 328 | { | ||
| @@ -319,6 +347,13 @@ func FuzzEventViews(f *testing.F) { | |||||
| 319 | if w.Mode() != vFocusIn.Mode() { | 347 | if w.Mode() != vFocusIn.Mode() { | ||
| 320 | t.Fatal("FocusIn.Mode") | 348 | t.Fatal("FocusIn.Mode") | ||
| 321 | } | 349 | } | ||
| 350 | + | in := xturbo.Event{Raw: ev.Raw} | |||
| 351 | + | vi := FocusInOf(&in) | |||
| 352 | + | di := FocusInEventData{Detail: vi.Detail(), Event: vi.Event(), Mode: vi.Mode()} | |||
| 353 | + | di.Put(&in.Raw) | |||
| 354 | + | if in.Raw != out { | |||
| 355 | + | t.Fatal("FocusIn in-place Put") | |||
| 356 | + | } | |||
| 322 | } | 357 | } | ||
| 323 | _ = FocusOutOf(&ev) | 358 | _ = FocusOutOf(&ev) | ||
| 324 | { | 359 | { | ||
| @@ -335,6 +370,13 @@ func FuzzEventViews(f *testing.F) { | |||||
| 335 | if !bytes.Equal(w.Keys(), vKeymapNotify.Keys()) { | 370 | if !bytes.Equal(w.Keys(), vKeymapNotify.Keys()) { | ||
| 336 | t.Fatal("KeymapNotify.Keys") | 371 | t.Fatal("KeymapNotify.Keys") | ||
| 337 | } | 372 | } | ||
| 373 | + | in := xturbo.Event{Raw: ev.Raw} | |||
| 374 | + | vi := KeymapNotifyOf(&in) | |||
| 375 | + | di := KeymapNotifyEventData{Keys: [31]uint8(vi.Keys())} | |||
| 376 | + | di.Put(&in.Raw) | |||
| 377 | + | if in.Raw != out { | |||
| 378 | + | t.Fatal("KeymapNotify in-place Put") | |||
| 379 | + | } | |||
| 338 | } | 380 | } | ||
| 339 | { | 381 | { | ||
| 340 | vExpose := ExposeOf(&ev) | 382 | vExpose := ExposeOf(&ev) | ||
| @@ -370,6 +412,13 @@ func FuzzEventViews(f *testing.F) { | |||||
| 370 | if w.Count() != vExpose.Count() { | 412 | if w.Count() != vExpose.Count() { | ||
| 371 | t.Fatal("Expose.Count") | 413 | t.Fatal("Expose.Count") | ||
| 372 | } | 414 | } | ||
| 415 | + | in := xturbo.Event{Raw: ev.Raw} | |||
| 416 | + | vi := ExposeOf(&in) | |||
| 417 | + | di := ExposeEventData{Window: vi.Window(), X: vi.X(), Y: vi.Y(), Width: vi.Width(), Height: vi.Height(), Count: vi.Count()} | |||
| 418 | + | di.Put(&in.Raw) | |||
| 419 | + | if in.Raw != out { | |||
| 420 | + | t.Fatal("Expose in-place Put") | |||
| 421 | + | } | |||
| 373 | } | 422 | } | ||
| 374 | { | 423 | { | ||
| 375 | vGraphicsExposure := GraphicsExposureOf(&ev) | 424 | vGraphicsExposure := GraphicsExposureOf(&ev) | ||
| @@ -413,6 +462,13 @@ func FuzzEventViews(f *testing.F) { | |||||
| 413 | if w.MajorOpcode() != vGraphicsExposure.MajorOpcode() { | 462 | if w.MajorOpcode() != vGraphicsExposure.MajorOpcode() { | ||
| 414 | t.Fatal("GraphicsExposure.MajorOpcode") | 463 | t.Fatal("GraphicsExposure.MajorOpcode") | ||
| 415 | } | 464 | } | ||
| 465 | + | in := xturbo.Event{Raw: ev.Raw} | |||
| 466 | + | vi := GraphicsExposureOf(&in) | |||
| 467 | + | di := GraphicsExposureEventData{Drawable: vi.Drawable(), X: vi.X(), Y: vi.Y(), Width: vi.Width(), Height: vi.Height(), MinorOpcode: vi.MinorOpcode(), Count: vi.Count(), MajorOpcode: vi.MajorOpcode()} | |||
| 468 | + | di.Put(&in.Raw) | |||
| 469 | + | if in.Raw != out { | |||
| 470 | + | t.Fatal("GraphicsExposure in-place Put") | |||
| 471 | + | } | |||
| 416 | } | 472 | } | ||
| 417 | { | 473 | { | ||
| 418 | vNoExposure := NoExposureOf(&ev) | 474 | vNoExposure := NoExposureOf(&ev) | ||
| @@ -436,6 +492,13 @@ func FuzzEventViews(f *testing.F) { | |||||
| 436 | if w.MajorOpcode() != vNoExposure.MajorOpcode() { | 492 | if w.MajorOpcode() != vNoExposure.MajorOpcode() { | ||
| 437 | t.Fatal("NoExposure.MajorOpcode") | 493 | t.Fatal("NoExposure.MajorOpcode") | ||
| 438 | } | 494 | } | ||
| 495 | + | in := xturbo.Event{Raw: ev.Raw} | |||
| 496 | + | vi := NoExposureOf(&in) | |||
| 497 | + | di := NoExposureEventData{Drawable: vi.Drawable(), MinorOpcode: vi.MinorOpcode(), MajorOpcode: vi.MajorOpcode()} | |||
| 498 | + | di.Put(&in.Raw) | |||
| 499 | + | if in.Raw != out { | |||
| 500 | + | t.Fatal("NoExposure in-place Put") | |||
| 501 | + | } | |||
| 439 | } | 502 | } | ||
| 440 | { | 503 | { | ||
| 441 | vVisibilityNotify := VisibilityNotifyOf(&ev) | 504 | vVisibilityNotify := VisibilityNotifyOf(&ev) | ||
| @@ -455,6 +518,13 @@ func FuzzEventViews(f *testing.F) { | |||||
| 455 | if w.State() != vVisibilityNotify.State() { | 518 | if w.State() != vVisibilityNotify.State() { | ||
| 456 | t.Fatal("VisibilityNotify.State") | 519 | t.Fatal("VisibilityNotify.State") | ||
| 457 | } | 520 | } | ||
| 521 | + | in := xturbo.Event{Raw: ev.Raw} | |||
| 522 | + | vi := VisibilityNotifyOf(&in) | |||
| 523 | + | di := VisibilityNotifyEventData{Window: vi.Window(), State: vi.State()} | |||
| 524 | + | di.Put(&in.Raw) | |||
| 525 | + | if in.Raw != out { | |||
| 526 | + | t.Fatal("VisibilityNotify in-place Put") | |||
| 527 | + | } | |||
| 458 | } | 528 | } | ||
| 459 | { | 529 | { | ||
| 460 | vCreateNotify := CreateNotifyOf(&ev) | 530 | vCreateNotify := CreateNotifyOf(&ev) | ||
| @@ -498,6 +568,13 @@ func FuzzEventViews(f *testing.F) { | |||||
| 498 | if w.OverrideRedirect() != vCreateNotify.OverrideRedirect() { | 568 | if w.OverrideRedirect() != vCreateNotify.OverrideRedirect() { | ||
| 499 | t.Fatal("CreateNotify.OverrideRedirect") | 569 | t.Fatal("CreateNotify.OverrideRedirect") | ||
| 500 | } | 570 | } | ||
| 571 | + | in := xturbo.Event{Raw: ev.Raw} | |||
| 572 | + | vi := CreateNotifyOf(&in) | |||
| 573 | + | di := CreateNotifyEventData{Parent: vi.Parent(), Window: vi.Window(), X: vi.X(), Y: vi.Y(), Width: vi.Width(), Height: vi.Height(), BorderWidth: vi.BorderWidth(), OverrideRedirect: vi.OverrideRedirect()} | |||
| 574 | + | di.Put(&in.Raw) | |||
| 575 | + | if in.Raw != out { | |||
| 576 | + | t.Fatal("CreateNotify in-place Put") | |||
| 577 | + | } | |||
| 501 | } | 578 | } | ||
| 502 | { | 579 | { | ||
| 503 | vDestroyNotify := DestroyNotifyOf(&ev) | 580 | vDestroyNotify := DestroyNotifyOf(&ev) | ||
| @@ -517,6 +594,13 @@ func FuzzEventViews(f *testing.F) { | |||||
| 517 | if w.Window() != vDestroyNotify.Window() { | 594 | if w.Window() != vDestroyNotify.Window() { | ||
| 518 | t.Fatal("DestroyNotify.Window") | 595 | t.Fatal("DestroyNotify.Window") | ||
| 519 | } | 596 | } | ||
| 597 | + | in := xturbo.Event{Raw: ev.Raw} | |||
| 598 | + | vi := DestroyNotifyOf(&in) | |||
| 599 | + | di := DestroyNotifyEventData{Event: vi.Event(), Window: vi.Window()} | |||
| 600 | + | di.Put(&in.Raw) | |||
| 601 | + | if in.Raw != out { | |||
| 602 | + | t.Fatal("DestroyNotify in-place Put") | |||
| 603 | + | } | |||
| 520 | } | 604 | } | ||
| 521 | { | 605 | { | ||
| 522 | vUnmapNotify := UnmapNotifyOf(&ev) | 606 | vUnmapNotify := UnmapNotifyOf(&ev) | ||
| @@ -540,6 +624,13 @@ func FuzzEventViews(f *testing.F) { | |||||
| 540 | if w.FromConfigure() != vUnmapNotify.FromConfigure() { | 624 | if w.FromConfigure() != vUnmapNotify.FromConfigure() { | ||
| 541 | t.Fatal("UnmapNotify.FromConfigure") | 625 | t.Fatal("UnmapNotify.FromConfigure") | ||
| 542 | } | 626 | } | ||
| 627 | + | in := xturbo.Event{Raw: ev.Raw} | |||
| 628 | + | vi := UnmapNotifyOf(&in) | |||
| 629 | + | di := UnmapNotifyEventData{Event: vi.Event(), Window: vi.Window(), FromConfigure: vi.FromConfigure()} | |||
| 630 | + | di.Put(&in.Raw) | |||
| 631 | + | if in.Raw != out { | |||
| 632 | + | t.Fatal("UnmapNotify in-place Put") | |||
| 633 | + | } | |||
| 543 | } | 634 | } | ||
| 544 | { | 635 | { | ||
| 545 | vMapNotify := MapNotifyOf(&ev) | 636 | vMapNotify := MapNotifyOf(&ev) | ||
| @@ -563,6 +654,13 @@ func FuzzEventViews(f *testing.F) { | |||||
| 563 | if w.OverrideRedirect() != vMapNotify.OverrideRedirect() { | 654 | if w.OverrideRedirect() != vMapNotify.OverrideRedirect() { | ||
| 564 | t.Fatal("MapNotify.OverrideRedirect") | 655 | t.Fatal("MapNotify.OverrideRedirect") | ||
| 565 | } | 656 | } | ||
| 657 | + | in := xturbo.Event{Raw: ev.Raw} | |||
| 658 | + | vi := MapNotifyOf(&in) | |||
| 659 | + | di := MapNotifyEventData{Event: vi.Event(), Window: vi.Window(), OverrideRedirect: vi.OverrideRedirect()} | |||
| 660 | + | di.Put(&in.Raw) | |||
| 661 | + | if in.Raw != out { | |||
| 662 | + | t.Fatal("MapNotify in-place Put") | |||
| 663 | + | } | |||
| 566 | } | 664 | } | ||
| 567 | { | 665 | { | ||
| 568 | vMapRequest := MapRequestOf(&ev) | 666 | vMapRequest := MapRequestOf(&ev) | ||
| @@ -582,6 +680,13 @@ func FuzzEventViews(f *testing.F) { | |||||
| 582 | if w.Window() != vMapRequest.Window() { | 680 | if w.Window() != vMapRequest.Window() { | ||
| 583 | t.Fatal("MapRequest.Window") | 681 | t.Fatal("MapRequest.Window") | ||
| 584 | } | 682 | } | ||
| 683 | + | in := xturbo.Event{Raw: ev.Raw} | |||
| 684 | + | vi := MapRequestOf(&in) | |||
| 685 | + | di := MapRequestEventData{Parent: vi.Parent(), Window: vi.Window()} | |||
| 686 | + | di.Put(&in.Raw) | |||
| 687 | + | if in.Raw != out { | |||
| 688 | + | t.Fatal("MapRequest in-place Put") | |||
| 689 | + | } | |||
| 585 | } | 690 | } | ||
| 586 | { | 691 | { | ||
| 587 | vReparentNotify := ReparentNotifyOf(&ev) | 692 | vReparentNotify := ReparentNotifyOf(&ev) | ||
| @@ -617,6 +722,13 @@ func FuzzEventViews(f *testing.F) { | |||||
| 617 | if w.OverrideRedirect() != vReparentNotify.OverrideRedirect() { | 722 | if w.OverrideRedirect() != vReparentNotify.OverrideRedirect() { | ||
| 618 | t.Fatal("ReparentNotify.OverrideRedirect") | 723 | t.Fatal("ReparentNotify.OverrideRedirect") | ||
| 619 | } | 724 | } | ||
| 725 | + | in := xturbo.Event{Raw: ev.Raw} | |||
| 726 | + | vi := ReparentNotifyOf(&in) | |||
| 727 | + | di := ReparentNotifyEventData{Event: vi.Event(), Window: vi.Window(), Parent: vi.Parent(), X: vi.X(), Y: vi.Y(), OverrideRedirect: vi.OverrideRedirect()} | |||
| 728 | + | di.Put(&in.Raw) | |||
| 729 | + | if in.Raw != out { | |||
| 730 | + | t.Fatal("ReparentNotify in-place Put") | |||
| 731 | + | } | |||
| 620 | } | 732 | } | ||
| 621 | { | 733 | { | ||
| 622 | vConfigureNotify := ConfigureNotifyOf(&ev) | 734 | vConfigureNotify := ConfigureNotifyOf(&ev) | ||
| @@ -664,6 +776,13 @@ func FuzzEventViews(f *testing.F) { | |||||
| 664 | if w.OverrideRedirect() != vConfigureNotify.OverrideRedirect() { | 776 | if w.OverrideRedirect() != vConfigureNotify.OverrideRedirect() { | ||
| 665 | t.Fatal("ConfigureNotify.OverrideRedirect") | 777 | t.Fatal("ConfigureNotify.OverrideRedirect") | ||
| 666 | } | 778 | } | ||
| 779 | + | in := xturbo.Event{Raw: ev.Raw} | |||
| 780 | + | vi := ConfigureNotifyOf(&in) | |||
| 781 | + | di := ConfigureNotifyEventData{Event: vi.Event(), Window: vi.Window(), AboveSibling: vi.AboveSibling(), X: vi.X(), Y: vi.Y(), Width: vi.Width(), Height: vi.Height(), BorderWidth: vi.BorderWidth(), OverrideRedirect: vi.OverrideRedirect()} | |||
| 782 | + | di.Put(&in.Raw) | |||
| 783 | + | if in.Raw != out { | |||
| 784 | + | t.Fatal("ConfigureNotify in-place Put") | |||
| 785 | + | } | |||
| 667 | } | 786 | } | ||
| 668 | { | 787 | { | ||
| 669 | vConfigureRequest := ConfigureRequestOf(&ev) | 788 | vConfigureRequest := ConfigureRequestOf(&ev) | ||
| @@ -715,6 +834,13 @@ func FuzzEventViews(f *testing.F) { | |||||
| 715 | if w.ValueMask() != vConfigureRequest.ValueMask() { | 834 | if w.ValueMask() != vConfigureRequest.ValueMask() { | ||
| 716 | t.Fatal("ConfigureRequest.ValueMask") | 835 | t.Fatal("ConfigureRequest.ValueMask") | ||
| 717 | } | 836 | } | ||
| 837 | + | in := xturbo.Event{Raw: ev.Raw} | |||
| 838 | + | vi := ConfigureRequestOf(&in) | |||
| 839 | + | di := ConfigureRequestEventData{StackMode: vi.StackMode(), Parent: vi.Parent(), Window: vi.Window(), Sibling: vi.Sibling(), X: vi.X(), Y: vi.Y(), Width: vi.Width(), Height: vi.Height(), BorderWidth: vi.BorderWidth(), ValueMask: vi.ValueMask()} | |||
| 840 | + | di.Put(&in.Raw) | |||
| 841 | + | if in.Raw != out { | |||
| 842 | + | t.Fatal("ConfigureRequest in-place Put") | |||
| 843 | + | } | |||
| 718 | } | 844 | } | ||
| 719 | { | 845 | { | ||
| 720 | vGravityNotify := GravityNotifyOf(&ev) | 846 | vGravityNotify := GravityNotifyOf(&ev) | ||
| @@ -742,6 +868,13 @@ func FuzzEventViews(f *testing.F) { | |||||
| 742 | if w.Y() != vGravityNotify.Y() { | 868 | if w.Y() != vGravityNotify.Y() { | ||
| 743 | t.Fatal("GravityNotify.Y") | 869 | t.Fatal("GravityNotify.Y") | ||
| 744 | } | 870 | } | ||
| 871 | + | in := xturbo.Event{Raw: ev.Raw} | |||
| 872 | + | vi := GravityNotifyOf(&in) | |||
| 873 | + | di := GravityNotifyEventData{Event: vi.Event(), Window: vi.Window(), X: vi.X(), Y: vi.Y()} | |||
| 874 | + | di.Put(&in.Raw) | |||
| 875 | + | if in.Raw != out { | |||
| 876 | + | t.Fatal("GravityNotify in-place Put") | |||
| 877 | + | } | |||
| 745 | } | 878 | } | ||
| 746 | { | 879 | { | ||
| 747 | vResizeRequest := ResizeRequestOf(&ev) | 880 | vResizeRequest := ResizeRequestOf(&ev) | ||
| @@ -765,6 +898,13 @@ func FuzzEventViews(f *testing.F) { | |||||
| 765 | if w.Height() != vResizeRequest.Height() { | 898 | if w.Height() != vResizeRequest.Height() { | ||
| 766 | t.Fatal("ResizeRequest.Height") | 899 | t.Fatal("ResizeRequest.Height") | ||
| 767 | } | 900 | } | ||
| 901 | + | in := xturbo.Event{Raw: ev.Raw} | |||
| 902 | + | vi := ResizeRequestOf(&in) | |||
| 903 | + | di := ResizeRequestEventData{Window: vi.Window(), Width: vi.Width(), Height: vi.Height()} | |||
| 904 | + | di.Put(&in.Raw) | |||
| 905 | + | if in.Raw != out { | |||
| 906 | + | t.Fatal("ResizeRequest in-place Put") | |||
| 907 | + | } | |||
| 768 | } | 908 | } | ||
| 769 | { | 909 | { | ||
| 770 | vCirculateNotify := CirculateNotifyOf(&ev) | 910 | vCirculateNotify := CirculateNotifyOf(&ev) | ||
| @@ -788,6 +928,13 @@ func FuzzEventViews(f *testing.F) { | |||||
| 788 | if w.Place() != vCirculateNotify.Place() { | 928 | if w.Place() != vCirculateNotify.Place() { | ||
| 789 | t.Fatal("CirculateNotify.Place") | 929 | t.Fatal("CirculateNotify.Place") | ||
| 790 | } | 930 | } | ||
| 931 | + | in := xturbo.Event{Raw: ev.Raw} | |||
| 932 | + | vi := CirculateNotifyOf(&in) | |||
| 933 | + | di := CirculateNotifyEventData{Event: vi.Event(), Window: vi.Window(), Place: vi.Place()} | |||
| 934 | + | di.Put(&in.Raw) | |||
| 935 | + | if in.Raw != out { | |||
| 936 | + | t.Fatal("CirculateNotify in-place Put") | |||
| 937 | + | } | |||
| 791 | } | 938 | } | ||
| 792 | _ = CirculateRequestOf(&ev) | 939 | _ = CirculateRequestOf(&ev) | ||
| 793 | { | 940 | { | ||
| @@ -816,6 +963,13 @@ func FuzzEventViews(f *testing.F) { | |||||
| 816 | if w.State() != vPropertyNotify.State() { | 963 | if w.State() != vPropertyNotify.State() { | ||
| 817 | t.Fatal("PropertyNotify.State") | 964 | t.Fatal("PropertyNotify.State") | ||
| 818 | } | 965 | } | ||
| 966 | + | in := xturbo.Event{Raw: ev.Raw} | |||
| 967 | + | vi := PropertyNotifyOf(&in) | |||
| 968 | + | di := PropertyNotifyEventData{Window: vi.Window(), Atom: vi.Atom(), Time: vi.Time(), State: vi.State()} | |||
| 969 | + | di.Put(&in.Raw) | |||
| 970 | + | if in.Raw != out { | |||
| 971 | + | t.Fatal("PropertyNotify in-place Put") | |||
| 972 | + | } | |||
| 819 | } | 973 | } | ||
| 820 | { | 974 | { | ||
| 821 | vSelectionClear := SelectionClearOf(&ev) | 975 | vSelectionClear := SelectionClearOf(&ev) | ||
| @@ -839,6 +993,13 @@ func FuzzEventViews(f *testing.F) { | |||||
| 839 | if w.Selection() != vSelectionClear.Selection() { | 993 | if w.Selection() != vSelectionClear.Selection() { | ||
| 840 | t.Fatal("SelectionClear.Selection") | 994 | t.Fatal("SelectionClear.Selection") | ||
| 841 | } | 995 | } | ||
| 996 | + | in := xturbo.Event{Raw: ev.Raw} | |||
| 997 | + | vi := SelectionClearOf(&in) | |||
| 998 | + | di := SelectionClearEventData{Time: vi.Time(), Owner: vi.Owner(), Selection: vi.Selection()} | |||
| 999 | + | di.Put(&in.Raw) | |||
| 1000 | + | if in.Raw != out { | |||
| 1001 | + | t.Fatal("SelectionClear in-place Put") | |||
| 1002 | + | } | |||
| 842 | } | 1003 | } | ||
| 843 | { | 1004 | { | ||
| 844 | vSelectionRequest := SelectionRequestOf(&ev) | 1005 | vSelectionRequest := SelectionRequestOf(&ev) | ||
| @@ -874,6 +1035,13 @@ func FuzzEventViews(f *testing.F) { | |||||
| 874 | if w.Property() != vSelectionRequest.Property() { | 1035 | if w.Property() != vSelectionRequest.Property() { | ||
| 875 | t.Fatal("SelectionRequest.Property") | 1036 | t.Fatal("SelectionRequest.Property") | ||
| 876 | } | 1037 | } | ||
| 1038 | + | in := xturbo.Event{Raw: ev.Raw} | |||
| 1039 | + | vi := SelectionRequestOf(&in) | |||
| 1040 | + | di := SelectionRequestEventData{Time: vi.Time(), Owner: vi.Owner(), Requestor: vi.Requestor(), Selection: vi.Selection(), Target: vi.Target(), Property: vi.Property()} | |||
| 1041 | + | di.Put(&in.Raw) | |||
| 1042 | + | if in.Raw != out { | |||
| 1043 | + | t.Fatal("SelectionRequest in-place Put") | |||
| 1044 | + | } | |||
| 877 | } | 1045 | } | ||
| 878 | { | 1046 | { | ||
| 879 | vSelectionNotify := SelectionNotifyOf(&ev) | 1047 | vSelectionNotify := SelectionNotifyOf(&ev) | ||
| @@ -905,6 +1073,13 @@ func FuzzEventViews(f *testing.F) { | |||||
| 905 | if w.Property() != vSelectionNotify.Property() { | 1073 | if w.Property() != vSelectionNotify.Property() { | ||
| 906 | t.Fatal("SelectionNotify.Property") | 1074 | t.Fatal("SelectionNotify.Property") | ||
| 907 | } | 1075 | } | ||
| 1076 | + | in := xturbo.Event{Raw: ev.Raw} | |||
| 1077 | + | vi := SelectionNotifyOf(&in) | |||
| 1078 | + | di := SelectionNotifyEventData{Time: vi.Time(), Requestor: vi.Requestor(), Selection: vi.Selection(), Target: vi.Target(), Property: vi.Property()} | |||
| 1079 | + | di.Put(&in.Raw) | |||
| 1080 | + | if in.Raw != out { | |||
| 1081 | + | t.Fatal("SelectionNotify in-place Put") | |||
| 1082 | + | } | |||
| 908 | } | 1083 | } | ||
| 909 | { | 1084 | { | ||
| 910 | vColormapNotify := ColormapNotifyOf(&ev) | 1085 | vColormapNotify := ColormapNotifyOf(&ev) | ||
| @@ -932,6 +1107,13 @@ func FuzzEventViews(f *testing.F) { | |||||
| 932 | if w.State() != vColormapNotify.State() { | 1107 | if w.State() != vColormapNotify.State() { | ||
| 933 | t.Fatal("ColormapNotify.State") | 1108 | t.Fatal("ColormapNotify.State") | ||
| 934 | } | 1109 | } | ||
| 1110 | + | in := xturbo.Event{Raw: ev.Raw} | |||
| 1111 | + | vi := ColormapNotifyOf(&in) | |||
| 1112 | + | di := ColormapNotifyEventData{Window: vi.Window(), Colormap: vi.Colormap(), New: vi.New(), State: vi.State()} | |||
| 1113 | + | di.Put(&in.Raw) | |||
| 1114 | + | if in.Raw != out { | |||
| 1115 | + | t.Fatal("ColormapNotify in-place Put") | |||
| 1116 | + | } | |||
| 935 | } | 1117 | } | ||
| 936 | { | 1118 | { | ||
| 937 | vClientMessage := ClientMessageOf(&ev) | 1119 | vClientMessage := ClientMessageOf(&ev) | ||
| @@ -959,6 +1141,13 @@ func FuzzEventViews(f *testing.F) { | |||||
| 959 | if !bytes.Equal(out[12:32], ev.Raw[12:32]) { | 1141 | if !bytes.Equal(out[12:32], ev.Raw[12:32]) { | ||
| 960 | t.Fatal("ClientMessage.Data") | 1142 | t.Fatal("ClientMessage.Data") | ||
| 961 | } | 1143 | } | ||
| 1144 | + | in := xturbo.Event{Raw: ev.Raw} | |||
| 1145 | + | vi := ClientMessageOf(&in) | |||
| 1146 | + | di := ClientMessageEventData{Format: vi.Format(), Window: vi.Window(), Type: vi.Type(), Data: vi.Data()} | |||
| 1147 | + | di.Put(&in.Raw) | |||
| 1148 | + | if in.Raw != out { | |||
| 1149 | + | t.Fatal("ClientMessage in-place Put") | |||
| 1150 | + | } | |||
| 962 | } | 1151 | } | ||
| 963 | { | 1152 | { | ||
| 964 | vMappingNotify := MappingNotifyOf(&ev) | 1153 | vMappingNotify := MappingNotifyOf(&ev) | ||
| @@ -982,6 +1171,13 @@ func FuzzEventViews(f *testing.F) { | |||||
| 982 | if w.Count() != vMappingNotify.Count() { | 1171 | if w.Count() != vMappingNotify.Count() { | ||
| 983 | t.Fatal("MappingNotify.Count") | 1172 | t.Fatal("MappingNotify.Count") | ||
| 984 | } | 1173 | } | ||
| 1174 | + | in := xturbo.Event{Raw: ev.Raw} | |||
| 1175 | + | vi := MappingNotifyOf(&in) | |||
| 1176 | + | di := MappingNotifyEventData{Request: vi.Request(), FirstKeycode: vi.FirstKeycode(), Count: vi.Count()} | |||
| 1177 | + | di.Put(&in.Raw) | |||
| 1178 | + | if in.Raw != out { | |||
| 1179 | + | t.Fatal("MappingNotify in-place Put") | |||
| 1180 | + | } | |||
| 985 | } | 1181 | } | ||
| 986 | if vGeGeneric, ok := GeGenericOf(&ev); ok { | 1182 | if vGeGeneric, ok := GeGenericOf(&ev); ok { | ||
| 987 | _ = vGeGeneric.Extension() | 1183 | _ = vGeGeneric.Extension() | ||
M xproto/events_generated.go +299 -243
| @@ -40,25 +40,27 @@ type KeyPressEventData struct { | |||
| 40 | 40 | SameScreen bool | |
| 41 | 41 | } | |
| 42 | 42 | ||
| 43 | - | // Put writes the event (code 2, pads and sequence zeroed) into dst. | |
| 43 | + | // Put writes the event (code 2, pads and sequence zeroed) into dst. dst may alias | |
| 44 | + | // memory that d's borrowed fields view, such as the Event.Raw they were read from. | |
| 44 | 45 | func (d *KeyPressEventData) Put(dst *[32]byte) { | |
| 45 | - | clear(dst[:]) | |
| 46 | - | dst[0] = 2 | |
| 47 | - | dst[1:][0] = byte(d.Detail) | |
| 48 | - | binary.LittleEndian.PutUint32(dst[4:], uint32(d.Time)) | |
| 49 | - | binary.LittleEndian.PutUint32(dst[8:], uint32(d.Root)) | |
| 50 | - | binary.LittleEndian.PutUint32(dst[12:], uint32(d.Event)) | |
| 51 | - | binary.LittleEndian.PutUint32(dst[16:], uint32(d.Child)) | |
| 52 | - | binary.LittleEndian.PutUint16(dst[20:], uint16(d.RootX)) | |
| 53 | - | binary.LittleEndian.PutUint16(dst[22:], uint16(d.RootY)) | |
| 54 | - | binary.LittleEndian.PutUint16(dst[24:], uint16(d.EventX)) | |
| 55 | - | binary.LittleEndian.PutUint16(dst[26:], uint16(d.EventY)) | |
| 56 | - | binary.LittleEndian.PutUint16(dst[28:], uint16(d.State)) | |
| 46 | + | var tmp [32]byte | |
| 47 | + | tmp[0] = 2 | |
| 48 | + | tmp[1:][0] = byte(d.Detail) | |
| 49 | + | binary.LittleEndian.PutUint32(tmp[4:], uint32(d.Time)) | |
| 50 | + | binary.LittleEndian.PutUint32(tmp[8:], uint32(d.Root)) | |
| 51 | + | binary.LittleEndian.PutUint32(tmp[12:], uint32(d.Event)) | |
| 52 | + | binary.LittleEndian.PutUint32(tmp[16:], uint32(d.Child)) | |
| 53 | + | binary.LittleEndian.PutUint16(tmp[20:], uint16(d.RootX)) | |
| 54 | + | binary.LittleEndian.PutUint16(tmp[22:], uint16(d.RootY)) | |
| 55 | + | binary.LittleEndian.PutUint16(tmp[24:], uint16(d.EventX)) | |
| 56 | + | binary.LittleEndian.PutUint16(tmp[26:], uint16(d.EventY)) | |
| 57 | + | binary.LittleEndian.PutUint16(tmp[28:], uint16(d.State)) | |
| 57 | 58 | if d.SameScreen { | |
| 58 | - | dst[30:][0] = 1 | |
| 59 | + | tmp[30:][0] = 1 | |
| 59 | 60 | } else { | |
| 60 | - | dst[30:][0] = 0 | |
| 61 | + | tmp[30:][0] = 0 | |
| 61 | 62 | } | |
| 63 | + | *dst = tmp | |
| 62 | 64 | } | |
| 63 | 65 | ||
| 64 | 66 | // KindKeyRelease identifies KeyRelease events in xturbo.Event.Kind. | |
| @@ -114,25 +116,27 @@ type ButtonPressEventData struct { | |||
| 114 | 116 | SameScreen bool | |
| 115 | 117 | } | |
| 116 | 118 | ||
| 117 | - | // Put writes the event (code 4, pads and sequence zeroed) into dst. | |
| 119 | + | // Put writes the event (code 4, pads and sequence zeroed) into dst. dst may alias | |
| 120 | + | // memory that d's borrowed fields view, such as the Event.Raw they were read from. | |
| 118 | 121 | func (d *ButtonPressEventData) Put(dst *[32]byte) { | |
| 119 | - | clear(dst[:]) | |
| 120 | - | dst[0] = 4 | |
| 121 | - | dst[1:][0] = byte(d.Detail) | |
| 122 | - | binary.LittleEndian.PutUint32(dst[4:], uint32(d.Time)) | |
| 123 | - | binary.LittleEndian.PutUint32(dst[8:], uint32(d.Root)) | |
| 124 | - | binary.LittleEndian.PutUint32(dst[12:], uint32(d.Event)) | |
| 125 | - | binary.LittleEndian.PutUint32(dst[16:], uint32(d.Child)) | |
| 126 | - | binary.LittleEndian.PutUint16(dst[20:], uint16(d.RootX)) | |
| 127 | - | binary.LittleEndian.PutUint16(dst[22:], uint16(d.RootY)) | |
| 128 | - | binary.LittleEndian.PutUint16(dst[24:], uint16(d.EventX)) | |
| 129 | - | binary.LittleEndian.PutUint16(dst[26:], uint16(d.EventY)) | |
| 130 | - | binary.LittleEndian.PutUint16(dst[28:], uint16(d.State)) | |
| 122 | + | var tmp [32]byte | |
| 123 | + | tmp[0] = 4 | |
| 124 | + | tmp[1:][0] = byte(d.Detail) | |
| 125 | + | binary.LittleEndian.PutUint32(tmp[4:], uint32(d.Time)) | |
| 126 | + | binary.LittleEndian.PutUint32(tmp[8:], uint32(d.Root)) | |
| 127 | + | binary.LittleEndian.PutUint32(tmp[12:], uint32(d.Event)) | |
| 128 | + | binary.LittleEndian.PutUint32(tmp[16:], uint32(d.Child)) | |
| 129 | + | binary.LittleEndian.PutUint16(tmp[20:], uint16(d.RootX)) | |
| 130 | + | binary.LittleEndian.PutUint16(tmp[22:], uint16(d.RootY)) | |
| 131 | + | binary.LittleEndian.PutUint16(tmp[24:], uint16(d.EventX)) | |
| 132 | + | binary.LittleEndian.PutUint16(tmp[26:], uint16(d.EventY)) | |
| 133 | + | binary.LittleEndian.PutUint16(tmp[28:], uint16(d.State)) | |
| 131 | 134 | if d.SameScreen { | |
| 132 | - | dst[30:][0] = 1 | |
| 135 | + | tmp[30:][0] = 1 | |
| 133 | 136 | } else { | |
| 134 | - | dst[30:][0] = 0 | |
| 137 | + | tmp[30:][0] = 0 | |
| 135 | 138 | } | |
| 139 | + | *dst = tmp | |
| 136 | 140 | } | |
| 137 | 141 | ||
| 138 | 142 | // KindButtonRelease identifies ButtonRelease events in xturbo.Event.Kind. | |
| @@ -188,25 +192,27 @@ type MotionNotifyEventData struct { | |||
| 188 | 192 | SameScreen bool | |
| 189 | 193 | } | |
| 190 | 194 | ||
| 191 | - | // Put writes the event (code 6, pads and sequence zeroed) into dst. | |
| 195 | + | // Put writes the event (code 6, pads and sequence zeroed) into dst. dst may alias | |
| 196 | + | // memory that d's borrowed fields view, such as the Event.Raw they were read from. | |
| 192 | 197 | func (d *MotionNotifyEventData) Put(dst *[32]byte) { | |
| 193 | - | clear(dst[:]) | |
| 194 | - | dst[0] = 6 | |
| 195 | - | dst[1:][0] = byte(d.Detail) | |
| 196 | - | binary.LittleEndian.PutUint32(dst[4:], uint32(d.Time)) | |
| 197 | - | binary.LittleEndian.PutUint32(dst[8:], uint32(d.Root)) | |
| 198 | - | binary.LittleEndian.PutUint32(dst[12:], uint32(d.Event)) | |
| 199 | - | binary.LittleEndian.PutUint32(dst[16:], uint32(d.Child)) | |
| 200 | - | binary.LittleEndian.PutUint16(dst[20:], uint16(d.RootX)) | |
| 201 | - | binary.LittleEndian.PutUint16(dst[22:], uint16(d.RootY)) | |
| 202 | - | binary.LittleEndian.PutUint16(dst[24:], uint16(d.EventX)) | |
| 203 | - | binary.LittleEndian.PutUint16(dst[26:], uint16(d.EventY)) | |
| 204 | - | binary.LittleEndian.PutUint16(dst[28:], uint16(d.State)) | |
| 198 | + | var tmp [32]byte | |
| 199 | + | tmp[0] = 6 | |
| 200 | + | tmp[1:][0] = byte(d.Detail) | |
| 201 | + | binary.LittleEndian.PutUint32(tmp[4:], uint32(d.Time)) | |
| 202 | + | binary.LittleEndian.PutUint32(tmp[8:], uint32(d.Root)) | |
| 203 | + | binary.LittleEndian.PutUint32(tmp[12:], uint32(d.Event)) | |
| 204 | + | binary.LittleEndian.PutUint32(tmp[16:], uint32(d.Child)) | |
| 205 | + | binary.LittleEndian.PutUint16(tmp[20:], uint16(d.RootX)) | |
| 206 | + | binary.LittleEndian.PutUint16(tmp[22:], uint16(d.RootY)) | |
| 207 | + | binary.LittleEndian.PutUint16(tmp[24:], uint16(d.EventX)) | |
| 208 | + | binary.LittleEndian.PutUint16(tmp[26:], uint16(d.EventY)) | |
| 209 | + | binary.LittleEndian.PutUint16(tmp[28:], uint16(d.State)) | |
| 205 | 210 | if d.SameScreen { | |
| 206 | - | dst[30:][0] = 1 | |
| 211 | + | tmp[30:][0] = 1 | |
| 207 | 212 | } else { | |
| 208 | - | dst[30:][0] = 0 | |
| 213 | + | tmp[30:][0] = 0 | |
| 209 | 214 | } | |
| 215 | + | *dst = tmp | |
| 210 | 216 | } | |
| 211 | 217 | ||
| 212 | 218 | // KindEnterNotify identifies EnterNotify events in xturbo.Event.Kind. | |
| @@ -249,22 +255,24 @@ type EnterNotifyEventData struct { | |||
| 249 | 255 | SameScreenFocus byte | |
| 250 | 256 | } | |
| 251 | 257 | ||
| 252 | - | // Put writes the event (code 7, pads and sequence zeroed) into dst. | |
| 258 | + | // Put writes the event (code 7, pads and sequence zeroed) into dst. dst may alias | |
| 259 | + | // memory that d's borrowed fields view, such as the Event.Raw they were read from. | |
| 253 | 260 | func (d *EnterNotifyEventData) Put(dst *[32]byte) { | |
| 254 | - | clear(dst[:]) | |
| 255 | - | dst[0] = 7 | |
| 256 | - | dst[1:][0] = byte(d.Detail) | |
| 257 | - | binary.LittleEndian.PutUint32(dst[4:], uint32(d.Time)) | |
| 258 | - | binary.LittleEndian.PutUint32(dst[8:], uint32(d.Root)) | |
| 259 | - | binary.LittleEndian.PutUint32(dst[12:], uint32(d.Event)) | |
| 260 | - | binary.LittleEndian.PutUint32(dst[16:], uint32(d.Child)) | |
| 261 | - | binary.LittleEndian.PutUint16(dst[20:], uint16(d.RootX)) | |
| 262 | - | binary.LittleEndian.PutUint16(dst[22:], uint16(d.RootY)) | |
| 263 | - | binary.LittleEndian.PutUint16(dst[24:], uint16(d.EventX)) | |
| 264 | - | binary.LittleEndian.PutUint16(dst[26:], uint16(d.EventY)) | |
| 265 | - | binary.LittleEndian.PutUint16(dst[28:], uint16(d.State)) | |
| 266 | - | dst[30:][0] = byte(d.Mode) | |
| 267 | - | dst[31:][0] = byte(d.SameScreenFocus) | |
| 261 | + | var tmp [32]byte | |
| 262 | + | tmp[0] = 7 | |
| 263 | + | tmp[1:][0] = byte(d.Detail) | |
| 264 | + | binary.LittleEndian.PutUint32(tmp[4:], uint32(d.Time)) | |
| 265 | + | binary.LittleEndian.PutUint32(tmp[8:], uint32(d.Root)) | |
| 266 | + | binary.LittleEndian.PutUint32(tmp[12:], uint32(d.Event)) | |
| 267 | + | binary.LittleEndian.PutUint32(tmp[16:], uint32(d.Child)) | |
| 268 | + | binary.LittleEndian.PutUint16(tmp[20:], uint16(d.RootX)) | |
| 269 | + | binary.LittleEndian.PutUint16(tmp[22:], uint16(d.RootY)) | |
| 270 | + | binary.LittleEndian.PutUint16(tmp[24:], uint16(d.EventX)) | |
| 271 | + | binary.LittleEndian.PutUint16(tmp[26:], uint16(d.EventY)) | |
| 272 | + | binary.LittleEndian.PutUint16(tmp[28:], uint16(d.State)) | |
| 273 | + | tmp[30:][0] = byte(d.Mode) | |
| 274 | + | tmp[31:][0] = byte(d.SameScreenFocus) | |
| 275 | + | *dst = tmp | |
| 268 | 276 | } | |
| 269 | 277 | ||
| 270 | 278 | // KindLeaveNotify identifies LeaveNotify events in xturbo.Event.Kind. | |
| @@ -302,13 +310,15 @@ type FocusInEventData struct { | |||
| 302 | 310 | Mode NotifyMode | |
| 303 | 311 | } | |
| 304 | 312 | ||
| 305 | - | // Put writes the event (code 9, pads and sequence zeroed) into dst. | |
| 313 | + | // Put writes the event (code 9, pads and sequence zeroed) into dst. dst may alias | |
| 314 | + | // memory that d's borrowed fields view, such as the Event.Raw they were read from. | |
| 306 | 315 | func (d *FocusInEventData) Put(dst *[32]byte) { | |
| 307 | - | clear(dst[:]) | |
| 308 | - | dst[0] = 9 | |
| 309 | - | dst[1:][0] = byte(d.Detail) | |
| 310 | - | binary.LittleEndian.PutUint32(dst[4:], uint32(d.Event)) | |
| 311 | - | dst[8:][0] = byte(d.Mode) | |
| 316 | + | var tmp [32]byte | |
| 317 | + | tmp[0] = 9 | |
| 318 | + | tmp[1:][0] = byte(d.Detail) | |
| 319 | + | binary.LittleEndian.PutUint32(tmp[4:], uint32(d.Event)) | |
| 320 | + | tmp[8:][0] = byte(d.Mode) | |
| 321 | + | *dst = tmp | |
| 312 | 322 | } | |
| 313 | 323 | ||
| 314 | 324 | // KindFocusOut identifies FocusOut events in xturbo.Event.Kind. | |
| @@ -342,13 +352,15 @@ type KeymapNotifyEventData struct { | |||
| 342 | 352 | Keys [31]uint8 | |
| 343 | 353 | } | |
| 344 | 354 | ||
| 345 | - | // Put writes the event (code 11, pads and sequence zeroed) into dst. | |
| 355 | + | // Put writes the event (code 11, pads and sequence zeroed) into dst. dst may alias | |
| 356 | + | // memory that d's borrowed fields view, such as the Event.Raw they were read from. | |
| 346 | 357 | func (d *KeymapNotifyEventData) Put(dst *[32]byte) { | |
| 347 | - | clear(dst[:]) | |
| 348 | - | dst[0] = 11 | |
| 358 | + | var tmp [32]byte | |
| 359 | + | tmp[0] = 11 | |
| 349 | 360 | for i := range d.Keys { | |
| 350 | - | dst[1+i*1:][0] = byte(d.Keys[i]) | |
| 361 | + | tmp[1+i*1:][0] = byte(d.Keys[i]) | |
| 351 | 362 | } | |
| 363 | + | *dst = tmp | |
| 352 | 364 | } | |
| 353 | 365 | ||
| 354 | 366 | // KindExpose identifies Expose events in xturbo.Event.Kind. | |
| @@ -377,16 +389,18 @@ type ExposeEventData struct { | |||
| 377 | 389 | Count uint16 | |
| 378 | 390 | } | |
| 379 | 391 | ||
| 380 | - | // Put writes the event (code 12, pads and sequence zeroed) into dst. | |
| 392 | + | // Put writes the event (code 12, pads and sequence zeroed) into dst. dst may alias | |
| 393 | + | // memory that d's borrowed fields view, such as the Event.Raw they were read from. | |
| 381 | 394 | func (d *ExposeEventData) Put(dst *[32]byte) { | |
| 382 | - | clear(dst[:]) | |
| 383 | - | dst[0] = 12 | |
| 384 | - | binary.LittleEndian.PutUint32(dst[4:], uint32(d.Window)) | |
| 385 | - | binary.LittleEndian.PutUint16(dst[8:], uint16(d.X)) | |
| 386 | - | binary.LittleEndian.PutUint16(dst[10:], uint16(d.Y)) | |
| 387 | - | binary.LittleEndian.PutUint16(dst[12:], uint16(d.Width)) | |
| 388 | - | binary.LittleEndian.PutUint16(dst[14:], uint16(d.Height)) | |
| 389 | - | binary.LittleEndian.PutUint16(dst[16:], uint16(d.Count)) | |
| 395 | + | var tmp [32]byte | |
| 396 | + | tmp[0] = 12 | |
| 397 | + | binary.LittleEndian.PutUint32(tmp[4:], uint32(d.Window)) | |
| 398 | + | binary.LittleEndian.PutUint16(tmp[8:], uint16(d.X)) | |
| 399 | + | binary.LittleEndian.PutUint16(tmp[10:], uint16(d.Y)) | |
| 400 | + | binary.LittleEndian.PutUint16(tmp[12:], uint16(d.Width)) | |
| 401 | + | binary.LittleEndian.PutUint16(tmp[14:], uint16(d.Height)) | |
| 402 | + | binary.LittleEndian.PutUint16(tmp[16:], uint16(d.Count)) | |
| 403 | + | *dst = tmp | |
| 390 | 404 | } | |
| 391 | 405 | ||
| 392 | 406 | // KindGraphicsExposure identifies GraphicsExposure events in xturbo.Event.Kind. | |
| @@ -425,18 +439,20 @@ type GraphicsExposureEventData struct { | |||
| 425 | 439 | MajorOpcode uint8 | |
| 426 | 440 | } | |
| 427 | 441 | ||
| 428 | - | // Put writes the event (code 13, pads and sequence zeroed) into dst. | |
| 442 | + | // Put writes the event (code 13, pads and sequence zeroed) into dst. dst may alias | |
| 443 | + | // memory that d's borrowed fields view, such as the Event.Raw they were read from. | |
| 429 | 444 | func (d *GraphicsExposureEventData) Put(dst *[32]byte) { | |
| 430 | - | clear(dst[:]) | |
| 431 | - | dst[0] = 13 | |
| 432 | - | binary.LittleEndian.PutUint32(dst[4:], uint32(d.Drawable)) | |
| 433 | - | binary.LittleEndian.PutUint16(dst[8:], uint16(d.X)) | |
| 434 | - | binary.LittleEndian.PutUint16(dst[10:], uint16(d.Y)) | |
| 435 | - | binary.LittleEndian.PutUint16(dst[12:], uint16(d.Width)) | |
| 436 | - | binary.LittleEndian.PutUint16(dst[14:], uint16(d.Height)) | |
| 437 | - | binary.LittleEndian.PutUint16(dst[16:], uint16(d.MinorOpcode)) | |
| 438 | - | binary.LittleEndian.PutUint16(dst[18:], uint16(d.Count)) | |
| 439 | - | dst[20:][0] = byte(d.MajorOpcode) | |
| 445 | + | var tmp [32]byte | |
| 446 | + | tmp[0] = 13 | |
| 447 | + | binary.LittleEndian.PutUint32(tmp[4:], uint32(d.Drawable)) | |
| 448 | + | binary.LittleEndian.PutUint16(tmp[8:], uint16(d.X)) | |
| 449 | + | binary.LittleEndian.PutUint16(tmp[10:], uint16(d.Y)) | |
| 450 | + | binary.LittleEndian.PutUint16(tmp[12:], uint16(d.Width)) | |
| 451 | + | binary.LittleEndian.PutUint16(tmp[14:], uint16(d.Height)) | |
| 452 | + | binary.LittleEndian.PutUint16(tmp[16:], uint16(d.MinorOpcode)) | |
| 453 | + | binary.LittleEndian.PutUint16(tmp[18:], uint16(d.Count)) | |
| 454 | + | tmp[20:][0] = byte(d.MajorOpcode) | |
| 455 | + | *dst = tmp | |
| 440 | 456 | } | |
| 441 | 457 | ||
| 442 | 458 | // KindNoExposure identifies NoExposure events in xturbo.Event.Kind. | |
| @@ -459,13 +475,15 @@ type NoExposureEventData struct { | |||
| 459 | 475 | MajorOpcode uint8 | |
| 460 | 476 | } | |
| 461 | 477 | ||
| 462 | - | // Put writes the event (code 14, pads and sequence zeroed) into dst. | |
| 478 | + | // Put writes the event (code 14, pads and sequence zeroed) into dst. dst may alias | |
| 479 | + | // memory that d's borrowed fields view, such as the Event.Raw they were read from. | |
| 463 | 480 | func (d *NoExposureEventData) Put(dst *[32]byte) { | |
| 464 | - | clear(dst[:]) | |
| 465 | - | dst[0] = 14 | |
| 466 | - | binary.LittleEndian.PutUint32(dst[4:], uint32(d.Drawable)) | |
| 467 | - | binary.LittleEndian.PutUint16(dst[8:], uint16(d.MinorOpcode)) | |
| 468 | - | dst[10:][0] = byte(d.MajorOpcode) | |
| 481 | + | var tmp [32]byte | |
| 482 | + | tmp[0] = 14 | |
| 483 | + | binary.LittleEndian.PutUint32(tmp[4:], uint32(d.Drawable)) | |
| 484 | + | binary.LittleEndian.PutUint16(tmp[8:], uint16(d.MinorOpcode)) | |
| 485 | + | tmp[10:][0] = byte(d.MajorOpcode) | |
| 486 | + | *dst = tmp | |
| 469 | 487 | } | |
| 470 | 488 | ||
| 471 | 489 | // KindVisibilityNotify identifies VisibilityNotify events in xturbo.Event.Kind. | |
| @@ -488,12 +506,14 @@ type VisibilityNotifyEventData struct { | |||
| 488 | 506 | State Visibility | |
| 489 | 507 | } | |
| 490 | 508 | ||
| 491 | - | // Put writes the event (code 15, pads and sequence zeroed) into dst. | |
| 509 | + | // Put writes the event (code 15, pads and sequence zeroed) into dst. dst may alias | |
| 510 | + | // memory that d's borrowed fields view, such as the Event.Raw they were read from. | |
| 492 | 511 | func (d *VisibilityNotifyEventData) Put(dst *[32]byte) { | |
| 493 | - | clear(dst[:]) | |
| 494 | - | dst[0] = 15 | |
| 495 | - | binary.LittleEndian.PutUint32(dst[4:], uint32(d.Window)) | |
| 496 | - | dst[8:][0] = byte(d.State) | |
| 512 | + | var tmp [32]byte | |
| 513 | + | tmp[0] = 15 | |
| 514 | + | binary.LittleEndian.PutUint32(tmp[4:], uint32(d.Window)) | |
| 515 | + | tmp[8:][0] = byte(d.State) | |
| 516 | + | *dst = tmp | |
| 497 | 517 | } | |
| 498 | 518 | ||
| 499 | 519 | // KindCreateNotify identifies CreateNotify events in xturbo.Event.Kind. | |
| @@ -528,22 +548,24 @@ type CreateNotifyEventData struct { | |||
| 528 | 548 | OverrideRedirect bool | |
| 529 | 549 | } | |
| 530 | 550 | ||
| 531 | - | // Put writes the event (code 16, pads and sequence zeroed) into dst. | |
| 551 | + | // Put writes the event (code 16, pads and sequence zeroed) into dst. dst may alias | |
| 552 | + | // memory that d's borrowed fields view, such as the Event.Raw they were read from. | |
| 532 | 553 | func (d *CreateNotifyEventData) Put(dst *[32]byte) { | |
| 533 | - | clear(dst[:]) | |
| 534 | - | dst[0] = 16 | |
| 535 | - | binary.LittleEndian.PutUint32(dst[4:], uint32(d.Parent)) | |
| 536 | - | binary.LittleEndian.PutUint32(dst[8:], uint32(d.Window)) | |
| 537 | - | binary.LittleEndian.PutUint16(dst[12:], uint16(d.X)) | |
| 538 | - | binary.LittleEndian.PutUint16(dst[14:], uint16(d.Y)) | |
| 539 | - | binary.LittleEndian.PutUint16(dst[16:], uint16(d.Width)) | |
| 540 | - | binary.LittleEndian.PutUint16(dst[18:], uint16(d.Height)) | |
| 541 | - | binary.LittleEndian.PutUint16(dst[20:], uint16(d.BorderWidth)) | |
| 554 | + | var tmp [32]byte | |
| 555 | + | tmp[0] = 16 | |
| 556 | + | binary.LittleEndian.PutUint32(tmp[4:], uint32(d.Parent)) | |
| 557 | + | binary.LittleEndian.PutUint32(tmp[8:], uint32(d.Window)) | |
| 558 | + | binary.LittleEndian.PutUint16(tmp[12:], uint16(d.X)) | |
| 559 | + | binary.LittleEndian.PutUint16(tmp[14:], uint16(d.Y)) | |
| 560 | + | binary.LittleEndian.PutUint16(tmp[16:], uint16(d.Width)) | |
| 561 | + | binary.LittleEndian.PutUint16(tmp[18:], uint16(d.Height)) | |
| 562 | + | binary.LittleEndian.PutUint16(tmp[20:], uint16(d.BorderWidth)) | |
| 542 | 563 | if d.OverrideRedirect { | |
| 543 | - | dst[22:][0] = 1 | |
| 564 | + | tmp[22:][0] = 1 | |
| 544 | 565 | } else { | |
| 545 | - | dst[22:][0] = 0 | |
| 566 | + | tmp[22:][0] = 0 | |
| 546 | 567 | } | |
| 568 | + | *dst = tmp | |
| 547 | 569 | } | |
| 548 | 570 | ||
| 549 | 571 | // KindDestroyNotify identifies DestroyNotify events in xturbo.Event.Kind. | |
| @@ -564,12 +586,14 @@ type DestroyNotifyEventData struct { | |||
| 564 | 586 | Window Window | |
| 565 | 587 | } | |
| 566 | 588 | ||
| 567 | - | // Put writes the event (code 17, pads and sequence zeroed) into dst. | |
| 589 | + | // Put writes the event (code 17, pads and sequence zeroed) into dst. dst may alias | |
| 590 | + | // memory that d's borrowed fields view, such as the Event.Raw they were read from. | |
| 568 | 591 | func (d *DestroyNotifyEventData) Put(dst *[32]byte) { | |
| 569 | - | clear(dst[:]) | |
| 570 | - | dst[0] = 17 | |
| 571 | - | binary.LittleEndian.PutUint32(dst[4:], uint32(d.Event)) | |
| 572 | - | binary.LittleEndian.PutUint32(dst[8:], uint32(d.Window)) | |
| 592 | + | var tmp [32]byte | |
| 593 | + | tmp[0] = 17 | |
| 594 | + | binary.LittleEndian.PutUint32(tmp[4:], uint32(d.Event)) | |
| 595 | + | binary.LittleEndian.PutUint32(tmp[8:], uint32(d.Window)) | |
| 596 | + | *dst = tmp | |
| 573 | 597 | } | |
| 574 | 598 | ||
| 575 | 599 | // KindUnmapNotify identifies UnmapNotify events in xturbo.Event.Kind. | |
| @@ -592,17 +616,19 @@ type UnmapNotifyEventData struct { | |||
| 592 | 616 | FromConfigure bool | |
| 593 | 617 | } | |
| 594 | 618 | ||
| 595 | - | // Put writes the event (code 18, pads and sequence zeroed) into dst. | |
| 619 | + | // Put writes the event (code 18, pads and sequence zeroed) into dst. dst may alias | |
| 620 | + | // memory that d's borrowed fields view, such as the Event.Raw they were read from. | |
| 596 | 621 | func (d *UnmapNotifyEventData) Put(dst *[32]byte) { | |
| 597 | - | clear(dst[:]) | |
| 598 | - | dst[0] = 18 | |
| 599 | - | binary.LittleEndian.PutUint32(dst[4:], uint32(d.Event)) | |
| 600 | - | binary.LittleEndian.PutUint32(dst[8:], uint32(d.Window)) | |
| 622 | + | var tmp [32]byte | |
| 623 | + | tmp[0] = 18 | |
| 624 | + | binary.LittleEndian.PutUint32(tmp[4:], uint32(d.Event)) | |
| 625 | + | binary.LittleEndian.PutUint32(tmp[8:], uint32(d.Window)) | |
| 601 | 626 | if d.FromConfigure { | |
| 602 | - | dst[12:][0] = 1 | |
| 627 | + | tmp[12:][0] = 1 | |
| 603 | 628 | } else { | |
| 604 | - | dst[12:][0] = 0 | |
| 629 | + | tmp[12:][0] = 0 | |
| 605 | 630 | } | |
| 631 | + | *dst = tmp | |
| 606 | 632 | } | |
| 607 | 633 | ||
| 608 | 634 | // KindMapNotify identifies MapNotify events in xturbo.Event.Kind. | |
| @@ -625,17 +651,19 @@ type MapNotifyEventData struct { | |||
| 625 | 651 | OverrideRedirect bool | |
| 626 | 652 | } | |
| 627 | 653 | ||
| 628 | - | // Put writes the event (code 19, pads and sequence zeroed) into dst. | |
| 654 | + | // Put writes the event (code 19, pads and sequence zeroed) into dst. dst may alias | |
| 655 | + | // memory that d's borrowed fields view, such as the Event.Raw they were read from. | |
| 629 | 656 | func (d *MapNotifyEventData) Put(dst *[32]byte) { | |
| 630 | - | clear(dst[:]) | |
| 631 | - | dst[0] = 19 | |
| 632 | - | binary.LittleEndian.PutUint32(dst[4:], uint32(d.Event)) | |
| 633 | - | binary.LittleEndian.PutUint32(dst[8:], uint32(d.Window)) | |
| 657 | + | var tmp [32]byte | |
| 658 | + | tmp[0] = 19 | |
| 659 | + | binary.LittleEndian.PutUint32(tmp[4:], uint32(d.Event)) | |
| 660 | + | binary.LittleEndian.PutUint32(tmp[8:], uint32(d.Window)) | |
| 634 | 661 | if d.OverrideRedirect { | |
| 635 | - | dst[12:][0] = 1 | |
| 662 | + | tmp[12:][0] = 1 | |
| 636 | 663 | } else { | |
| 637 | - | dst[12:][0] = 0 | |
| 664 | + | tmp[12:][0] = 0 | |
| 638 | 665 | } | |
| 666 | + | *dst = tmp | |
| 639 | 667 | } | |
| 640 | 668 | ||
| 641 | 669 | // KindMapRequest identifies MapRequest events in xturbo.Event.Kind. | |
| @@ -656,12 +684,14 @@ type MapRequestEventData struct { | |||
| 656 | 684 | Window Window | |
| 657 | 685 | } | |
| 658 | 686 | ||
| 659 | - | // Put writes the event (code 20, pads and sequence zeroed) into dst. | |
| 687 | + | // Put writes the event (code 20, pads and sequence zeroed) into dst. dst may alias | |
| 688 | + | // memory that d's borrowed fields view, such as the Event.Raw they were read from. | |
| 660 | 689 | func (d *MapRequestEventData) Put(dst *[32]byte) { | |
| 661 | - | clear(dst[:]) | |
| 662 | - | dst[0] = 20 | |
| 663 | - | binary.LittleEndian.PutUint32(dst[4:], uint32(d.Parent)) | |
| 664 | - | binary.LittleEndian.PutUint32(dst[8:], uint32(d.Window)) | |
| 690 | + | var tmp [32]byte | |
| 691 | + | tmp[0] = 20 | |
| 692 | + | binary.LittleEndian.PutUint32(tmp[4:], uint32(d.Parent)) | |
| 693 | + | binary.LittleEndian.PutUint32(tmp[8:], uint32(d.Window)) | |
| 694 | + | *dst = tmp | |
| 665 | 695 | } | |
| 666 | 696 | ||
| 667 | 697 | // KindReparentNotify identifies ReparentNotify events in xturbo.Event.Kind. | |
| @@ -690,20 +720,22 @@ type ReparentNotifyEventData struct { | |||
| 690 | 720 | OverrideRedirect bool | |
| 691 | 721 | } | |
| 692 | 722 | ||
| 693 | - | // Put writes the event (code 21, pads and sequence zeroed) into dst. | |
| 723 | + | // Put writes the event (code 21, pads and sequence zeroed) into dst. dst may alias | |
| 724 | + | // memory that d's borrowed fields view, such as the Event.Raw they were read from. | |
| 694 | 725 | func (d *ReparentNotifyEventData) Put(dst *[32]byte) { | |
| 695 | - | clear(dst[:]) | |
| 696 | - | dst[0] = 21 | |
| 697 | - | binary.LittleEndian.PutUint32(dst[4:], uint32(d.Event)) | |
| 698 | - | binary.LittleEndian.PutUint32(dst[8:], uint32(d.Window)) | |
| 699 | - | binary.LittleEndian.PutUint32(dst[12:], uint32(d.Parent)) | |
| 700 | - | binary.LittleEndian.PutUint16(dst[16:], uint16(d.X)) | |
| 701 | - | binary.LittleEndian.PutUint16(dst[18:], uint16(d.Y)) | |
| 726 | + | var tmp [32]byte | |
| 727 | + | tmp[0] = 21 | |
| 728 | + | binary.LittleEndian.PutUint32(tmp[4:], uint32(d.Event)) | |
| 729 | + | binary.LittleEndian.PutUint32(tmp[8:], uint32(d.Window)) | |
| 730 | + | binary.LittleEndian.PutUint32(tmp[12:], uint32(d.Parent)) | |
| 731 | + | binary.LittleEndian.PutUint16(tmp[16:], uint16(d.X)) | |
| 732 | + | binary.LittleEndian.PutUint16(tmp[18:], uint16(d.Y)) | |
| 702 | 733 | if d.OverrideRedirect { | |
| 703 | - | dst[20:][0] = 1 | |
| 734 | + | tmp[20:][0] = 1 | |
| 704 | 735 | } else { | |
| 705 | - | dst[20:][0] = 0 | |
| 736 | + | tmp[20:][0] = 0 | |
| 706 | 737 | } | |
| 738 | + | *dst = tmp | |
| 707 | 739 | } | |
| 708 | 740 | ||
| 709 | 741 | // KindConfigureNotify identifies ConfigureNotify events in xturbo.Event.Kind. | |
| @@ -744,23 +776,25 @@ type ConfigureNotifyEventData struct { | |||
| 744 | 776 | OverrideRedirect bool | |
| 745 | 777 | } | |
| 746 | 778 | ||
| 747 | - | // Put writes the event (code 22, pads and sequence zeroed) into dst. | |
| 779 | + | // Put writes the event (code 22, pads and sequence zeroed) into dst. dst may alias | |
| 780 | + | // memory that d's borrowed fields view, such as the Event.Raw they were read from. | |
| 748 | 781 | func (d *ConfigureNotifyEventData) Put(dst *[32]byte) { | |
| 749 | - | clear(dst[:]) | |
| 750 | - | dst[0] = 22 | |
| 751 | - | binary.LittleEndian.PutUint32(dst[4:], uint32(d.Event)) | |
| 752 | - | binary.LittleEndian.PutUint32(dst[8:], uint32(d.Window)) | |
| 753 | - | binary.LittleEndian.PutUint32(dst[12:], uint32(d.AboveSibling)) | |
| 754 | - | binary.LittleEndian.PutUint16(dst[16:], uint16(d.X)) | |
| 755 | - | binary.LittleEndian.PutUint16(dst[18:], uint16(d.Y)) | |
| 756 | - | binary.LittleEndian.PutUint16(dst[20:], uint16(d.Width)) | |
| 757 | - | binary.LittleEndian.PutUint16(dst[22:], uint16(d.Height)) | |
| 758 | - | binary.LittleEndian.PutUint16(dst[24:], uint16(d.BorderWidth)) | |
| 782 | + | var tmp [32]byte | |
| 783 | + | tmp[0] = 22 | |
| 784 | + | binary.LittleEndian.PutUint32(tmp[4:], uint32(d.Event)) | |
| 785 | + | binary.LittleEndian.PutUint32(tmp[8:], uint32(d.Window)) | |
| 786 | + | binary.LittleEndian.PutUint32(tmp[12:], uint32(d.AboveSibling)) | |
| 787 | + | binary.LittleEndian.PutUint16(tmp[16:], uint16(d.X)) | |
| 788 | + | binary.LittleEndian.PutUint16(tmp[18:], uint16(d.Y)) | |
| 789 | + | binary.LittleEndian.PutUint16(tmp[20:], uint16(d.Width)) | |
| 790 | + | binary.LittleEndian.PutUint16(tmp[22:], uint16(d.Height)) | |
| 791 | + | binary.LittleEndian.PutUint16(tmp[24:], uint16(d.BorderWidth)) | |
| 759 | 792 | if d.OverrideRedirect { | |
| 760 | - | dst[26:][0] = 1 | |
| 793 | + | tmp[26:][0] = 1 | |
| 761 | 794 | } else { | |
| 762 | - | dst[26:][0] = 0 | |
| 795 | + | tmp[26:][0] = 0 | |
| 763 | 796 | } | |
| 797 | + | *dst = tmp | |
| 764 | 798 | } | |
| 765 | 799 | ||
| 766 | 800 | // KindConfigureRequest identifies ConfigureRequest events in xturbo.Event.Kind. | |
| @@ -805,20 +839,22 @@ type ConfigureRequestEventData struct { | |||
| 805 | 839 | ValueMask ConfigWindow | |
| 806 | 840 | } | |
| 807 | 841 | ||
| 808 | - | // Put writes the event (code 23, pads and sequence zeroed) into dst. | |
| 842 | + | // Put writes the event (code 23, pads and sequence zeroed) into dst. dst may alias | |
| 843 | + | // memory that d's borrowed fields view, such as the Event.Raw they were read from. | |
| 809 | 844 | func (d *ConfigureRequestEventData) Put(dst *[32]byte) { | |
| 810 | - | clear(dst[:]) | |
| 811 | - | dst[0] = 23 | |
| 812 | - | dst[1:][0] = byte(d.StackMode) | |
| 813 | - | binary.LittleEndian.PutUint32(dst[4:], uint32(d.Parent)) | |
| 814 | - | binary.LittleEndian.PutUint32(dst[8:], uint32(d.Window)) | |
| 815 | - | binary.LittleEndian.PutUint32(dst[12:], uint32(d.Sibling)) | |
| 816 | - | binary.LittleEndian.PutUint16(dst[16:], uint16(d.X)) | |
| 817 | - | binary.LittleEndian.PutUint16(dst[18:], uint16(d.Y)) | |
| 818 | - | binary.LittleEndian.PutUint16(dst[20:], uint16(d.Width)) | |
| 819 | - | binary.LittleEndian.PutUint16(dst[22:], uint16(d.Height)) | |
| 820 | - | binary.LittleEndian.PutUint16(dst[24:], uint16(d.BorderWidth)) | |
| 821 | - | binary.LittleEndian.PutUint16(dst[26:], uint16(d.ValueMask)) | |
| 845 | + | var tmp [32]byte | |
| 846 | + | tmp[0] = 23 | |
| 847 | + | tmp[1:][0] = byte(d.StackMode) | |
| 848 | + | binary.LittleEndian.PutUint32(tmp[4:], uint32(d.Parent)) | |
| 849 | + | binary.LittleEndian.PutUint32(tmp[8:], uint32(d.Window)) | |
| 850 | + | binary.LittleEndian.PutUint32(tmp[12:], uint32(d.Sibling)) | |
| 851 | + | binary.LittleEndian.PutUint16(tmp[16:], uint16(d.X)) | |
| 852 | + | binary.LittleEndian.PutUint16(tmp[18:], uint16(d.Y)) | |
| 853 | + | binary.LittleEndian.PutUint16(tmp[20:], uint16(d.Width)) | |
| 854 | + | binary.LittleEndian.PutUint16(tmp[22:], uint16(d.Height)) | |
| 855 | + | binary.LittleEndian.PutUint16(tmp[24:], uint16(d.BorderWidth)) | |
| 856 | + | binary.LittleEndian.PutUint16(tmp[26:], uint16(d.ValueMask)) | |
| 857 | + | *dst = tmp | |
| 822 | 858 | } | |
| 823 | 859 | ||
| 824 | 860 | // KindGravityNotify identifies GravityNotify events in xturbo.Event.Kind. | |
| @@ -843,14 +879,16 @@ type GravityNotifyEventData struct { | |||
| 843 | 879 | Y int16 | |
| 844 | 880 | } | |
| 845 | 881 | ||
| 846 | - | // Put writes the event (code 24, pads and sequence zeroed) into dst. | |
| 882 | + | // Put writes the event (code 24, pads and sequence zeroed) into dst. dst may alias | |
| 883 | + | // memory that d's borrowed fields view, such as the Event.Raw they were read from. | |
| 847 | 884 | func (d *GravityNotifyEventData) Put(dst *[32]byte) { | |
| 848 | - | clear(dst[:]) | |
| 849 | - | dst[0] = 24 | |
| 850 | - | binary.LittleEndian.PutUint32(dst[4:], uint32(d.Event)) | |
| 851 | - | binary.LittleEndian.PutUint32(dst[8:], uint32(d.Window)) | |
| 852 | - | binary.LittleEndian.PutUint16(dst[12:], uint16(d.X)) | |
| 853 | - | binary.LittleEndian.PutUint16(dst[14:], uint16(d.Y)) | |
| 885 | + | var tmp [32]byte | |
| 886 | + | tmp[0] = 24 | |
| 887 | + | binary.LittleEndian.PutUint32(tmp[4:], uint32(d.Event)) | |
| 888 | + | binary.LittleEndian.PutUint32(tmp[8:], uint32(d.Window)) | |
| 889 | + | binary.LittleEndian.PutUint16(tmp[12:], uint16(d.X)) | |
| 890 | + | binary.LittleEndian.PutUint16(tmp[14:], uint16(d.Y)) | |
| 891 | + | *dst = tmp | |
| 854 | 892 | } | |
| 855 | 893 | ||
| 856 | 894 | // KindResizeRequest identifies ResizeRequest events in xturbo.Event.Kind. | |
| @@ -873,13 +911,15 @@ type ResizeRequestEventData struct { | |||
| 873 | 911 | Height uint16 | |
| 874 | 912 | } | |
| 875 | 913 | ||
| 876 | - | // Put writes the event (code 25, pads and sequence zeroed) into dst. | |
| 914 | + | // Put writes the event (code 25, pads and sequence zeroed) into dst. dst may alias | |
| 915 | + | // memory that d's borrowed fields view, such as the Event.Raw they were read from. | |
| 877 | 916 | func (d *ResizeRequestEventData) Put(dst *[32]byte) { | |
| 878 | - | clear(dst[:]) | |
| 879 | - | dst[0] = 25 | |
| 880 | - | binary.LittleEndian.PutUint32(dst[4:], uint32(d.Window)) | |
| 881 | - | binary.LittleEndian.PutUint16(dst[8:], uint16(d.Width)) | |
| 882 | - | binary.LittleEndian.PutUint16(dst[10:], uint16(d.Height)) | |
| 917 | + | var tmp [32]byte | |
| 918 | + | tmp[0] = 25 | |
| 919 | + | binary.LittleEndian.PutUint32(tmp[4:], uint32(d.Window)) | |
| 920 | + | binary.LittleEndian.PutUint16(tmp[8:], uint16(d.Width)) | |
| 921 | + | binary.LittleEndian.PutUint16(tmp[10:], uint16(d.Height)) | |
| 922 | + | *dst = tmp | |
| 883 | 923 | } | |
| 884 | 924 | ||
| 885 | 925 | // KindCirculateNotify identifies CirculateNotify events in xturbo.Event.Kind. | |
| @@ -904,13 +944,15 @@ type CirculateNotifyEventData struct { | |||
| 904 | 944 | Place Place | |
| 905 | 945 | } | |
| 906 | 946 | ||
| 907 | - | // Put writes the event (code 26, pads and sequence zeroed) into dst. | |
| 947 | + | // Put writes the event (code 26, pads and sequence zeroed) into dst. dst may alias | |
| 948 | + | // memory that d's borrowed fields view, such as the Event.Raw they were read from. | |
| 908 | 949 | func (d *CirculateNotifyEventData) Put(dst *[32]byte) { | |
| 909 | - | clear(dst[:]) | |
| 910 | - | dst[0] = 26 | |
| 911 | - | binary.LittleEndian.PutUint32(dst[4:], uint32(d.Event)) | |
| 912 | - | binary.LittleEndian.PutUint32(dst[8:], uint32(d.Window)) | |
| 913 | - | dst[16:][0] = byte(d.Place) | |
| 950 | + | var tmp [32]byte | |
| 951 | + | tmp[0] = 26 | |
| 952 | + | binary.LittleEndian.PutUint32(tmp[4:], uint32(d.Event)) | |
| 953 | + | binary.LittleEndian.PutUint32(tmp[8:], uint32(d.Window)) | |
| 954 | + | tmp[16:][0] = byte(d.Place) | |
| 955 | + | *dst = tmp | |
| 914 | 956 | } | |
| 915 | 957 | ||
| 916 | 958 | // KindCirculateRequest identifies CirculateRequest events in xturbo.Event.Kind. | |
| @@ -955,14 +997,16 @@ type PropertyNotifyEventData struct { | |||
| 955 | 997 | State Property | |
| 956 | 998 | } | |
| 957 | 999 | ||
| 958 | - | // Put writes the event (code 28, pads and sequence zeroed) into dst. | |
| 1000 | + | // Put writes the event (code 28, pads and sequence zeroed) into dst. dst may alias | |
| 1001 | + | // memory that d's borrowed fields view, such as the Event.Raw they were read from. | |
| 959 | 1002 | func (d *PropertyNotifyEventData) Put(dst *[32]byte) { | |
| 960 | - | clear(dst[:]) | |
| 961 | - | dst[0] = 28 | |
| 962 | - | binary.LittleEndian.PutUint32(dst[4:], uint32(d.Window)) | |
| 963 | - | binary.LittleEndian.PutUint32(dst[8:], uint32(d.Atom)) | |
| 964 | - | binary.LittleEndian.PutUint32(dst[12:], uint32(d.Time)) | |
| 965 | - | dst[16:][0] = byte(d.State) | |
| 1003 | + | var tmp [32]byte | |
| 1004 | + | tmp[0] = 28 | |
| 1005 | + | binary.LittleEndian.PutUint32(tmp[4:], uint32(d.Window)) | |
| 1006 | + | binary.LittleEndian.PutUint32(tmp[8:], uint32(d.Atom)) | |
| 1007 | + | binary.LittleEndian.PutUint32(tmp[12:], uint32(d.Time)) | |
| 1008 | + | tmp[16:][0] = byte(d.State) | |
| 1009 | + | *dst = tmp | |
| 966 | 1010 | } | |
| 967 | 1011 | ||
| 968 | 1012 | // KindSelectionClear identifies SelectionClear events in xturbo.Event.Kind. | |
| @@ -987,13 +1031,15 @@ type SelectionClearEventData struct { | |||
| 987 | 1031 | Selection Atom | |
| 988 | 1032 | } | |
| 989 | 1033 | ||
| 990 | - | // Put writes the event (code 29, pads and sequence zeroed) into dst. | |
| 1034 | + | // Put writes the event (code 29, pads and sequence zeroed) into dst. dst may alias | |
| 1035 | + | // memory that d's borrowed fields view, such as the Event.Raw they were read from. | |
| 991 | 1036 | func (d *SelectionClearEventData) Put(dst *[32]byte) { | |
| 992 | - | clear(dst[:]) | |
| 993 | - | dst[0] = 29 | |
| 994 | - | binary.LittleEndian.PutUint32(dst[4:], uint32(d.Time)) | |
| 995 | - | binary.LittleEndian.PutUint32(dst[8:], uint32(d.Owner)) | |
| 996 | - | binary.LittleEndian.PutUint32(dst[12:], uint32(d.Selection)) | |
| 1037 | + | var tmp [32]byte | |
| 1038 | + | tmp[0] = 29 | |
| 1039 | + | binary.LittleEndian.PutUint32(tmp[4:], uint32(d.Time)) | |
| 1040 | + | binary.LittleEndian.PutUint32(tmp[8:], uint32(d.Owner)) | |
| 1041 | + | binary.LittleEndian.PutUint32(tmp[12:], uint32(d.Selection)) | |
| 1042 | + | *dst = tmp | |
| 997 | 1043 | } | |
| 998 | 1044 | ||
| 999 | 1045 | // KindSelectionRequest identifies SelectionRequest events in xturbo.Event.Kind. | |
| @@ -1028,16 +1074,18 @@ type SelectionRequestEventData struct { | |||
| 1028 | 1074 | Property Atom | |
| 1029 | 1075 | } | |
| 1030 | 1076 | ||
| 1031 | - | // Put writes the event (code 30, pads and sequence zeroed) into dst. | |
| 1077 | + | // Put writes the event (code 30, pads and sequence zeroed) into dst. dst may alias | |
| 1078 | + | // memory that d's borrowed fields view, such as the Event.Raw they were read from. | |
| 1032 | 1079 | func (d *SelectionRequestEventData) Put(dst *[32]byte) { | |
| 1033 | - | clear(dst[:]) | |
| 1034 | - | dst[0] = 30 | |
| 1035 | - | binary.LittleEndian.PutUint32(dst[4:], uint32(d.Time)) | |
| 1036 | - | binary.LittleEndian.PutUint32(dst[8:], uint32(d.Owner)) | |
| 1037 | - | binary.LittleEndian.PutUint32(dst[12:], uint32(d.Requestor)) | |
| 1038 | - | binary.LittleEndian.PutUint32(dst[16:], uint32(d.Selection)) | |
| 1039 | - | binary.LittleEndian.PutUint32(dst[20:], uint32(d.Target)) | |
| 1040 | - | binary.LittleEndian.PutUint32(dst[24:], uint32(d.Property)) | |
| 1080 | + | var tmp [32]byte | |
| 1081 | + | tmp[0] = 30 | |
| 1082 | + | binary.LittleEndian.PutUint32(tmp[4:], uint32(d.Time)) | |
| 1083 | + | binary.LittleEndian.PutUint32(tmp[8:], uint32(d.Owner)) | |
| 1084 | + | binary.LittleEndian.PutUint32(tmp[12:], uint32(d.Requestor)) | |
| 1085 | + | binary.LittleEndian.PutUint32(tmp[16:], uint32(d.Selection)) | |
| 1086 | + | binary.LittleEndian.PutUint32(tmp[20:], uint32(d.Target)) | |
| 1087 | + | binary.LittleEndian.PutUint32(tmp[24:], uint32(d.Property)) | |
| 1088 | + | *dst = tmp | |
| 1041 | 1089 | } | |
| 1042 | 1090 | ||
| 1043 | 1091 | // KindSelectionNotify identifies SelectionNotify events in xturbo.Event.Kind. | |
| @@ -1070,15 +1118,17 @@ type SelectionNotifyEventData struct { | |||
| 1070 | 1118 | Property Atom | |
| 1071 | 1119 | } | |
| 1072 | 1120 | ||
| 1073 | - | // Put writes the event (code 31, pads and sequence zeroed) into dst. | |
| 1121 | + | // Put writes the event (code 31, pads and sequence zeroed) into dst. dst may alias | |
| 1122 | + | // memory that d's borrowed fields view, such as the Event.Raw they were read from. | |
| 1074 | 1123 | func (d *SelectionNotifyEventData) Put(dst *[32]byte) { | |
| 1075 | - | clear(dst[:]) | |
| 1076 | - | dst[0] = 31 | |
| 1077 | - | binary.LittleEndian.PutUint32(dst[4:], uint32(d.Time)) | |
| 1078 | - | binary.LittleEndian.PutUint32(dst[8:], uint32(d.Requestor)) | |
| 1079 | - | binary.LittleEndian.PutUint32(dst[12:], uint32(d.Selection)) | |
| 1080 | - | binary.LittleEndian.PutUint32(dst[16:], uint32(d.Target)) | |
| 1081 | - | binary.LittleEndian.PutUint32(dst[20:], uint32(d.Property)) | |
| 1124 | + | var tmp [32]byte | |
| 1125 | + | tmp[0] = 31 | |
| 1126 | + | binary.LittleEndian.PutUint32(tmp[4:], uint32(d.Time)) | |
| 1127 | + | binary.LittleEndian.PutUint32(tmp[8:], uint32(d.Requestor)) | |
| 1128 | + | binary.LittleEndian.PutUint32(tmp[12:], uint32(d.Selection)) | |
| 1129 | + | binary.LittleEndian.PutUint32(tmp[16:], uint32(d.Target)) | |
| 1130 | + | binary.LittleEndian.PutUint32(tmp[20:], uint32(d.Property)) | |
| 1131 | + | *dst = tmp | |
| 1082 | 1132 | } | |
| 1083 | 1133 | ||
| 1084 | 1134 | // KindColormapNotify identifies ColormapNotify events in xturbo.Event.Kind. | |
| @@ -1105,18 +1155,20 @@ type ColormapNotifyEventData struct { | |||
| 1105 | 1155 | State ColormapState | |
| 1106 | 1156 | } | |
| 1107 | 1157 | ||
| 1108 | - | // Put writes the event (code 32, pads and sequence zeroed) into dst. | |
| 1158 | + | // Put writes the event (code 32, pads and sequence zeroed) into dst. dst may alias | |
| 1159 | + | // memory that d's borrowed fields view, such as the Event.Raw they were read from. | |
| 1109 | 1160 | func (d *ColormapNotifyEventData) Put(dst *[32]byte) { | |
| 1110 | - | clear(dst[:]) | |
| 1111 | - | dst[0] = 32 | |
| 1112 | - | binary.LittleEndian.PutUint32(dst[4:], uint32(d.Window)) | |
| 1113 | - | binary.LittleEndian.PutUint32(dst[8:], uint32(d.Colormap)) | |
| 1161 | + | var tmp [32]byte | |
| 1162 | + | tmp[0] = 32 | |
| 1163 | + | binary.LittleEndian.PutUint32(tmp[4:], uint32(d.Window)) | |
| 1164 | + | binary.LittleEndian.PutUint32(tmp[8:], uint32(d.Colormap)) | |
| 1114 | 1165 | if d.New { | |
| 1115 | - | dst[12:][0] = 1 | |
| 1166 | + | tmp[12:][0] = 1 | |
| 1116 | 1167 | } else { | |
| 1117 | - | dst[12:][0] = 0 | |
| 1168 | + | tmp[12:][0] = 0 | |
| 1118 | 1169 | } | |
| 1119 | - | dst[13:][0] = byte(d.State) | |
| 1170 | + | tmp[13:][0] = byte(d.State) | |
| 1171 | + | *dst = tmp | |
| 1120 | 1172 | } | |
| 1121 | 1173 | ||
| 1122 | 1174 | // KindClientMessage identifies ClientMessage events in xturbo.Event.Kind. | |
| @@ -1141,14 +1193,16 @@ type ClientMessageEventData struct { | |||
| 1141 | 1193 | Data ClientMessageData | |
| 1142 | 1194 | } | |
| 1143 | 1195 | ||
| 1144 | - | // Put writes the event (code 33, pads and sequence zeroed) into dst. | |
| 1196 | + | // Put writes the event (code 33, pads and sequence zeroed) into dst. dst may alias | |
| 1197 | + | // memory that d's borrowed fields view, such as the Event.Raw they were read from. | |
| 1145 | 1198 | func (d *ClientMessageEventData) Put(dst *[32]byte) { | |
| 1146 | - | clear(dst[:]) | |
| 1147 | - | dst[0] = 33 | |
| 1148 | - | dst[1:][0] = byte(d.Format) | |
| 1149 | - | binary.LittleEndian.PutUint32(dst[4:], uint32(d.Window)) | |
| 1150 | - | binary.LittleEndian.PutUint32(dst[8:], uint32(d.Type)) | |
| 1151 | - | d.Data.Put(dst[12:]) | |
| 1199 | + | var tmp [32]byte | |
| 1200 | + | tmp[0] = 33 | |
| 1201 | + | tmp[1:][0] = byte(d.Format) | |
| 1202 | + | binary.LittleEndian.PutUint32(tmp[4:], uint32(d.Window)) | |
| 1203 | + | binary.LittleEndian.PutUint32(tmp[8:], uint32(d.Type)) | |
| 1204 | + | d.Data.Put(tmp[12:]) | |
| 1205 | + | *dst = tmp | |
| 1152 | 1206 | } | |
| 1153 | 1207 | ||
| 1154 | 1208 | // KindMappingNotify identifies MappingNotify events in xturbo.Event.Kind. | |
| @@ -1171,13 +1225,15 @@ type MappingNotifyEventData struct { | |||
| 1171 | 1225 | Count uint8 | |
| 1172 | 1226 | } | |
| 1173 | 1227 | ||
| 1174 | - | // Put writes the event (code 34, pads and sequence zeroed) into dst. | |
| 1228 | + | // Put writes the event (code 34, pads and sequence zeroed) into dst. dst may alias | |
| 1229 | + | // memory that d's borrowed fields view, such as the Event.Raw they were read from. | |
| 1175 | 1230 | func (d *MappingNotifyEventData) Put(dst *[32]byte) { | |
| 1176 | - | clear(dst[:]) | |
| 1177 | - | dst[0] = 34 | |
| 1178 | - | dst[4:][0] = byte(d.Request) | |
| 1179 | - | dst[5:][0] = byte(d.FirstKeycode) | |
| 1180 | - | dst[6:][0] = byte(d.Count) | |
| 1231 | + | var tmp [32]byte | |
| 1232 | + | tmp[0] = 34 | |
| 1233 | + | tmp[4:][0] = byte(d.Request) | |
| 1234 | + | tmp[5:][0] = byte(d.FirstKeycode) | |
| 1235 | + | tmp[6:][0] = byte(d.Count) | |
| 1236 | + | *dst = tmp | |
| 1181 | 1237 | } | |
| 1182 | 1238 | ||
| 1183 | 1239 | // GeGenericEvent is a view over a GeGeneric generic event: the copied Event.Raw plus the borrowed Event.Tail. | |
| @@ -40,25 +40,27 @@ type KeyPressEventData struct { | |||||
| 40 | SameScreen bool | 40 | SameScreen bool | ||
| 41 | } | 41 | } | ||
| 42 | 42 | ||||
| 43 | - | // Put writes the event (code 2, pads and sequence zeroed) into dst. | 43 | + | // Put writes the event (code 2, pads and sequence zeroed) into dst. dst may alias |
| 44 | + | // memory that d's borrowed fields view, such as the Event.Raw they were read from. | |||
| 44 | func (d *KeyPressEventData) Put(dst *[32]byte) { | 45 | func (d *KeyPressEventData) Put(dst *[32]byte) { | ||
| 45 | - | clear(dst[:]) | 46 | + | var tmp [32]byte |
| 46 | - | dst[0] = 2 | 47 | + | tmp[0] = 2 |
| 47 | - | dst[1:][0] = byte(d.Detail) | 48 | + | tmp[1:][0] = byte(d.Detail) |
| 48 | - | binary.LittleEndian.PutUint32(dst[4:], uint32(d.Time)) | 49 | + | binary.LittleEndian.PutUint32(tmp[4:], uint32(d.Time)) |
| 49 | - | binary.LittleEndian.PutUint32(dst[8:], uint32(d.Root)) | 50 | + | binary.LittleEndian.PutUint32(tmp[8:], uint32(d.Root)) |
| 50 | - | binary.LittleEndian.PutUint32(dst[12:], uint32(d.Event)) | 51 | + | binary.LittleEndian.PutUint32(tmp[12:], uint32(d.Event)) |
| 51 | - | binary.LittleEndian.PutUint32(dst[16:], uint32(d.Child)) | 52 | + | binary.LittleEndian.PutUint32(tmp[16:], uint32(d.Child)) |
| 52 | - | binary.LittleEndian.PutUint16(dst[20:], uint16(d.RootX)) | 53 | + | binary.LittleEndian.PutUint16(tmp[20:], uint16(d.RootX)) |
| 53 | - | binary.LittleEndian.PutUint16(dst[22:], uint16(d.RootY)) | 54 | + | binary.LittleEndian.PutUint16(tmp[22:], uint16(d.RootY)) |
| 54 | - | binary.LittleEndian.PutUint16(dst[24:], uint16(d.EventX)) | 55 | + | binary.LittleEndian.PutUint16(tmp[24:], uint16(d.EventX)) |
| 55 | - | binary.LittleEndian.PutUint16(dst[26:], uint16(d.EventY)) | 56 | + | binary.LittleEndian.PutUint16(tmp[26:], uint16(d.EventY)) |
| 56 | - | binary.LittleEndian.PutUint16(dst[28:], uint16(d.State)) | 57 | + | binary.LittleEndian.PutUint16(tmp[28:], uint16(d.State)) |
| 57 | if d.SameScreen { | 58 | if d.SameScreen { | ||
| 58 | - | dst[30:][0] = 1 | 59 | + | tmp[30:][0] = 1 |
| 59 | } else { | 60 | } else { | ||
| 60 | - | dst[30:][0] = 0 | 61 | + | tmp[30:][0] = 0 |
| 61 | } | 62 | } | ||
| 63 | + | *dst = tmp | |||
| 62 | } | 64 | } | ||
| 63 | 65 | ||||
| 64 | // KindKeyRelease identifies KeyRelease events in xturbo.Event.Kind. | 66 | // KindKeyRelease identifies KeyRelease events in xturbo.Event.Kind. | ||
| @@ -114,25 +116,27 @@ type ButtonPressEventData struct { | |||||
| 114 | SameScreen bool | 116 | SameScreen bool | ||
| 115 | } | 117 | } | ||
| 116 | 118 | ||||
| 117 | - | // Put writes the event (code 4, pads and sequence zeroed) into dst. | 119 | + | // Put writes the event (code 4, pads and sequence zeroed) into dst. dst may alias |
| 120 | + | // memory that d's borrowed fields view, such as the Event.Raw they were read from. | |||
| 118 | func (d *ButtonPressEventData) Put(dst *[32]byte) { | 121 | func (d *ButtonPressEventData) Put(dst *[32]byte) { | ||
| 119 | - | clear(dst[:]) | 122 | + | var tmp [32]byte |
| 120 | - | dst[0] = 4 | 123 | + | tmp[0] = 4 |
| 121 | - | dst[1:][0] = byte(d.Detail) | 124 | + | tmp[1:][0] = byte(d.Detail) |
| 122 | - | binary.LittleEndian.PutUint32(dst[4:], uint32(d.Time)) | 125 | + | binary.LittleEndian.PutUint32(tmp[4:], uint32(d.Time)) |
| 123 | - | binary.LittleEndian.PutUint32(dst[8:], uint32(d.Root)) | 126 | + | binary.LittleEndian.PutUint32(tmp[8:], uint32(d.Root)) |
| 124 | - | binary.LittleEndian.PutUint32(dst[12:], uint32(d.Event)) | 127 | + | binary.LittleEndian.PutUint32(tmp[12:], uint32(d.Event)) |
| 125 | - | binary.LittleEndian.PutUint32(dst[16:], uint32(d.Child)) | 128 | + | binary.LittleEndian.PutUint32(tmp[16:], uint32(d.Child)) |
| 126 | - | binary.LittleEndian.PutUint16(dst[20:], uint16(d.RootX)) | 129 | + | binary.LittleEndian.PutUint16(tmp[20:], uint16(d.RootX)) |
| 127 | - | binary.LittleEndian.PutUint16(dst[22:], uint16(d.RootY)) | 130 | + | binary.LittleEndian.PutUint16(tmp[22:], uint16(d.RootY)) |
| 128 | - | binary.LittleEndian.PutUint16(dst[24:], uint16(d.EventX)) | 131 | + | binary.LittleEndian.PutUint16(tmp[24:], uint16(d.EventX)) |
| 129 | - | binary.LittleEndian.PutUint16(dst[26:], uint16(d.EventY)) | 132 | + | binary.LittleEndian.PutUint16(tmp[26:], uint16(d.EventY)) |
| 130 | - | binary.LittleEndian.PutUint16(dst[28:], uint16(d.State)) | 133 | + | binary.LittleEndian.PutUint16(tmp[28:], uint16(d.State)) |
| 131 | if d.SameScreen { | 134 | if d.SameScreen { | ||
| 132 | - | dst[30:][0] = 1 | 135 | + | tmp[30:][0] = 1 |
| 133 | } else { | 136 | } else { | ||
| 134 | - | dst[30:][0] = 0 | 137 | + | tmp[30:][0] = 0 |
| 135 | } | 138 | } | ||
| 139 | + | *dst = tmp | |||
| 136 | } | 140 | } | ||
| 137 | 141 | ||||
| 138 | // KindButtonRelease identifies ButtonRelease events in xturbo.Event.Kind. | 142 | // KindButtonRelease identifies ButtonRelease events in xturbo.Event.Kind. | ||
| @@ -188,25 +192,27 @@ type MotionNotifyEventData struct { | |||||
| 188 | SameScreen bool | 192 | SameScreen bool | ||
| 189 | } | 193 | } | ||
| 190 | 194 | ||||
| 191 | - | // Put writes the event (code 6, pads and sequence zeroed) into dst. | 195 | + | // Put writes the event (code 6, pads and sequence zeroed) into dst. dst may alias |
| 196 | + | // memory that d's borrowed fields view, such as the Event.Raw they were read from. | |||
| 192 | func (d *MotionNotifyEventData) Put(dst *[32]byte) { | 197 | func (d *MotionNotifyEventData) Put(dst *[32]byte) { | ||
| 193 | - | clear(dst[:]) | 198 | + | var tmp [32]byte |
| 194 | - | dst[0] = 6 | 199 | + | tmp[0] = 6 |
| 195 | - | dst[1:][0] = byte(d.Detail) | 200 | + | tmp[1:][0] = byte(d.Detail) |
| 196 | - | binary.LittleEndian.PutUint32(dst[4:], uint32(d.Time)) | 201 | + | binary.LittleEndian.PutUint32(tmp[4:], uint32(d.Time)) |
| 197 | - | binary.LittleEndian.PutUint32(dst[8:], uint32(d.Root)) | 202 | + | binary.LittleEndian.PutUint32(tmp[8:], uint32(d.Root)) |
| 198 | - | binary.LittleEndian.PutUint32(dst[12:], uint32(d.Event)) | 203 | + | binary.LittleEndian.PutUint32(tmp[12:], uint32(d.Event)) |
| 199 | - | binary.LittleEndian.PutUint32(dst[16:], uint32(d.Child)) | 204 | + | binary.LittleEndian.PutUint32(tmp[16:], uint32(d.Child)) |
| 200 | - | binary.LittleEndian.PutUint16(dst[20:], uint16(d.RootX)) | 205 | + | binary.LittleEndian.PutUint16(tmp[20:], uint16(d.RootX)) |
| 201 | - | binary.LittleEndian.PutUint16(dst[22:], uint16(d.RootY)) | 206 | + | binary.LittleEndian.PutUint16(tmp[22:], uint16(d.RootY)) |
| 202 | - | binary.LittleEndian.PutUint16(dst[24:], uint16(d.EventX)) | 207 | + | binary.LittleEndian.PutUint16(tmp[24:], uint16(d.EventX)) |
| 203 | - | binary.LittleEndian.PutUint16(dst[26:], uint16(d.EventY)) | 208 | + | binary.LittleEndian.PutUint16(tmp[26:], uint16(d.EventY)) |
| 204 | - | binary.LittleEndian.PutUint16(dst[28:], uint16(d.State)) | 209 | + | binary.LittleEndian.PutUint16(tmp[28:], uint16(d.State)) |
| 205 | if d.SameScreen { | 210 | if d.SameScreen { | ||
| 206 | - | dst[30:][0] = 1 | 211 | + | tmp[30:][0] = 1 |
| 207 | } else { | 212 | } else { | ||
| 208 | - | dst[30:][0] = 0 | 213 | + | tmp[30:][0] = 0 |
| 209 | } | 214 | } | ||
| 215 | + | *dst = tmp | |||
| 210 | } | 216 | } | ||
| 211 | 217 | ||||
| 212 | // KindEnterNotify identifies EnterNotify events in xturbo.Event.Kind. | 218 | // KindEnterNotify identifies EnterNotify events in xturbo.Event.Kind. | ||
| @@ -249,22 +255,24 @@ type EnterNotifyEventData struct { | |||||
| 249 | SameScreenFocus byte | 255 | SameScreenFocus byte | ||
| 250 | } | 256 | } | ||
| 251 | 257 | ||||
| 252 | - | // Put writes the event (code 7, pads and sequence zeroed) into dst. | 258 | + | // Put writes the event (code 7, pads and sequence zeroed) into dst. dst may alias |
| 259 | + | // memory that d's borrowed fields view, such as the Event.Raw they were read from. | |||
| 253 | func (d *EnterNotifyEventData) Put(dst *[32]byte) { | 260 | func (d *EnterNotifyEventData) Put(dst *[32]byte) { | ||
| 254 | - | clear(dst[:]) | 261 | + | var tmp [32]byte |
| 255 | - | dst[0] = 7 | 262 | + | tmp[0] = 7 |
| 256 | - | dst[1:][0] = byte(d.Detail) | 263 | + | tmp[1:][0] = byte(d.Detail) |
| 257 | - | binary.LittleEndian.PutUint32(dst[4:], uint32(d.Time)) | 264 | + | binary.LittleEndian.PutUint32(tmp[4:], uint32(d.Time)) |
| 258 | - | binary.LittleEndian.PutUint32(dst[8:], uint32(d.Root)) | 265 | + | binary.LittleEndian.PutUint32(tmp[8:], uint32(d.Root)) |
| 259 | - | binary.LittleEndian.PutUint32(dst[12:], uint32(d.Event)) | 266 | + | binary.LittleEndian.PutUint32(tmp[12:], uint32(d.Event)) |
| 260 | - | binary.LittleEndian.PutUint32(dst[16:], uint32(d.Child)) | 267 | + | binary.LittleEndian.PutUint32(tmp[16:], uint32(d.Child)) |
| 261 | - | binary.LittleEndian.PutUint16(dst[20:], uint16(d.RootX)) | 268 | + | binary.LittleEndian.PutUint16(tmp[20:], uint16(d.RootX)) |
| 262 | - | binary.LittleEndian.PutUint16(dst[22:], uint16(d.RootY)) | 269 | + | binary.LittleEndian.PutUint16(tmp[22:], uint16(d.RootY)) |
| 263 | - | binary.LittleEndian.PutUint16(dst[24:], uint16(d.EventX)) | 270 | + | binary.LittleEndian.PutUint16(tmp[24:], uint16(d.EventX)) |
| 264 | - | binary.LittleEndian.PutUint16(dst[26:], uint16(d.EventY)) | 271 | + | binary.LittleEndian.PutUint16(tmp[26:], uint16(d.EventY)) |
| 265 | - | binary.LittleEndian.PutUint16(dst[28:], uint16(d.State)) | 272 | + | binary.LittleEndian.PutUint16(tmp[28:], uint16(d.State)) |
| 266 | - | dst[30:][0] = byte(d.Mode) | 273 | + | tmp[30:][0] = byte(d.Mode) |
| 267 | - | dst[31:][0] = byte(d.SameScreenFocus) | 274 | + | tmp[31:][0] = byte(d.SameScreenFocus) |
| 275 | + | *dst = tmp | |||
| 268 | } | 276 | } | ||
| 269 | 277 | ||||
| 270 | // KindLeaveNotify identifies LeaveNotify events in xturbo.Event.Kind. | 278 | // KindLeaveNotify identifies LeaveNotify events in xturbo.Event.Kind. | ||
| @@ -302,13 +310,15 @@ type FocusInEventData struct { | |||||
| 302 | Mode NotifyMode | 310 | Mode NotifyMode | ||
| 303 | } | 311 | } | ||
| 304 | 312 | ||||
| 305 | - | // Put writes the event (code 9, pads and sequence zeroed) into dst. | 313 | + | // Put writes the event (code 9, pads and sequence zeroed) into dst. dst may alias |
| 314 | + | // memory that d's borrowed fields view, such as the Event.Raw they were read from. | |||
| 306 | func (d *FocusInEventData) Put(dst *[32]byte) { | 315 | func (d *FocusInEventData) Put(dst *[32]byte) { | ||
| 307 | - | clear(dst[:]) | 316 | + | var tmp [32]byte |
| 308 | - | dst[0] = 9 | 317 | + | tmp[0] = 9 |
| 309 | - | dst[1:][0] = byte(d.Detail) | 318 | + | tmp[1:][0] = byte(d.Detail) |
| 310 | - | binary.LittleEndian.PutUint32(dst[4:], uint32(d.Event)) | 319 | + | binary.LittleEndian.PutUint32(tmp[4:], uint32(d.Event)) |
| 311 | - | dst[8:][0] = byte(d.Mode) | 320 | + | tmp[8:][0] = byte(d.Mode) |
| 321 | + | *dst = tmp | |||
| 312 | } | 322 | } | ||
| 313 | 323 | ||||
| 314 | // KindFocusOut identifies FocusOut events in xturbo.Event.Kind. | 324 | // KindFocusOut identifies FocusOut events in xturbo.Event.Kind. | ||
| @@ -342,13 +352,15 @@ type KeymapNotifyEventData struct { | |||||
| 342 | Keys [31]uint8 | 352 | Keys [31]uint8 | ||
| 343 | } | 353 | } | ||
| 344 | 354 | ||||
| 345 | - | // Put writes the event (code 11, pads and sequence zeroed) into dst. | 355 | + | // Put writes the event (code 11, pads and sequence zeroed) into dst. dst may alias |
| 356 | + | // memory that d's borrowed fields view, such as the Event.Raw they were read from. | |||
| 346 | func (d *KeymapNotifyEventData) Put(dst *[32]byte) { | 357 | func (d *KeymapNotifyEventData) Put(dst *[32]byte) { | ||
| 347 | - | clear(dst[:]) | 358 | + | var tmp [32]byte |
| 348 | - | dst[0] = 11 | 359 | + | tmp[0] = 11 |
| 349 | for i := range d.Keys { | 360 | for i := range d.Keys { | ||
| 350 | - | dst[1+i*1:][0] = byte(d.Keys[i]) | 361 | + | tmp[1+i*1:][0] = byte(d.Keys[i]) |
| 351 | } | 362 | } | ||
| 363 | + | *dst = tmp | |||
| 352 | } | 364 | } | ||
| 353 | 365 | ||||
| 354 | // KindExpose identifies Expose events in xturbo.Event.Kind. | 366 | // KindExpose identifies Expose events in xturbo.Event.Kind. | ||
| @@ -377,16 +389,18 @@ type ExposeEventData struct { | |||||
| 377 | Count uint16 | 389 | Count uint16 | ||
| 378 | } | 390 | } | ||
| 379 | 391 | ||||
| 380 | - | // Put writes the event (code 12, pads and sequence zeroed) into dst. | 392 | + | // Put writes the event (code 12, pads and sequence zeroed) into dst. dst may alias |
| 393 | + | // memory that d's borrowed fields view, such as the Event.Raw they were read from. | |||
| 381 | func (d *ExposeEventData) Put(dst *[32]byte) { | 394 | func (d *ExposeEventData) Put(dst *[32]byte) { | ||
| 382 | - | clear(dst[:]) | 395 | + | var tmp [32]byte |
| 383 | - | dst[0] = 12 | 396 | + | tmp[0] = 12 |
| 384 | - | binary.LittleEndian.PutUint32(dst[4:], uint32(d.Window)) | 397 | + | binary.LittleEndian.PutUint32(tmp[4:], uint32(d.Window)) |
| 385 | - | binary.LittleEndian.PutUint16(dst[8:], uint16(d.X)) | 398 | + | binary.LittleEndian.PutUint16(tmp[8:], uint16(d.X)) |
| 386 | - | binary.LittleEndian.PutUint16(dst[10:], uint16(d.Y)) | 399 | + | binary.LittleEndian.PutUint16(tmp[10:], uint16(d.Y)) |
| 387 | - | binary.LittleEndian.PutUint16(dst[12:], uint16(d.Width)) | 400 | + | binary.LittleEndian.PutUint16(tmp[12:], uint16(d.Width)) |
| 388 | - | binary.LittleEndian.PutUint16(dst[14:], uint16(d.Height)) | 401 | + | binary.LittleEndian.PutUint16(tmp[14:], uint16(d.Height)) |
| 389 | - | binary.LittleEndian.PutUint16(dst[16:], uint16(d.Count)) | 402 | + | binary.LittleEndian.PutUint16(tmp[16:], uint16(d.Count)) |
| 403 | + | *dst = tmp | |||
| 390 | } | 404 | } | ||
| 391 | 405 | ||||
| 392 | // KindGraphicsExposure identifies GraphicsExposure events in xturbo.Event.Kind. | 406 | // KindGraphicsExposure identifies GraphicsExposure events in xturbo.Event.Kind. | ||
| @@ -425,18 +439,20 @@ type GraphicsExposureEventData struct { | |||||
| 425 | MajorOpcode uint8 | 439 | MajorOpcode uint8 | ||
| 426 | } | 440 | } | ||
| 427 | 441 | ||||
| 428 | - | // Put writes the event (code 13, pads and sequence zeroed) into dst. | 442 | + | // Put writes the event (code 13, pads and sequence zeroed) into dst. dst may alias |
| 443 | + | // memory that d's borrowed fields view, such as the Event.Raw they were read from. | |||
| 429 | func (d *GraphicsExposureEventData) Put(dst *[32]byte) { | 444 | func (d *GraphicsExposureEventData) Put(dst *[32]byte) { | ||
| 430 | - | clear(dst[:]) | 445 | + | var tmp [32]byte |
| 431 | - | dst[0] = 13 | 446 | + | tmp[0] = 13 |
| 432 | - | binary.LittleEndian.PutUint32(dst[4:], uint32(d.Drawable)) | 447 | + | binary.LittleEndian.PutUint32(tmp[4:], uint32(d.Drawable)) |
| 433 | - | binary.LittleEndian.PutUint16(dst[8:], uint16(d.X)) | 448 | + | binary.LittleEndian.PutUint16(tmp[8:], uint16(d.X)) |
| 434 | - | binary.LittleEndian.PutUint16(dst[10:], uint16(d.Y)) | 449 | + | binary.LittleEndian.PutUint16(tmp[10:], uint16(d.Y)) |
| 435 | - | binary.LittleEndian.PutUint16(dst[12:], uint16(d.Width)) | 450 | + | binary.LittleEndian.PutUint16(tmp[12:], uint16(d.Width)) |
| 436 | - | binary.LittleEndian.PutUint16(dst[14:], uint16(d.Height)) | 451 | + | binary.LittleEndian.PutUint16(tmp[14:], uint16(d.Height)) |
| 437 | - | binary.LittleEndian.PutUint16(dst[16:], uint16(d.MinorOpcode)) | 452 | + | binary.LittleEndian.PutUint16(tmp[16:], uint16(d.MinorOpcode)) |
| 438 | - | binary.LittleEndian.PutUint16(dst[18:], uint16(d.Count)) | 453 | + | binary.LittleEndian.PutUint16(tmp[18:], uint16(d.Count)) |
| 439 | - | dst[20:][0] = byte(d.MajorOpcode) | 454 | + | tmp[20:][0] = byte(d.MajorOpcode) |
| 455 | + | *dst = tmp | |||
| 440 | } | 456 | } | ||
| 441 | 457 | ||||
| 442 | // KindNoExposure identifies NoExposure events in xturbo.Event.Kind. | 458 | // KindNoExposure identifies NoExposure events in xturbo.Event.Kind. | ||
| @@ -459,13 +475,15 @@ type NoExposureEventData struct { | |||||
| 459 | MajorOpcode uint8 | 475 | MajorOpcode uint8 | ||
| 460 | } | 476 | } | ||
| 461 | 477 | ||||
| 462 | - | // Put writes the event (code 14, pads and sequence zeroed) into dst. | 478 | + | // Put writes the event (code 14, pads and sequence zeroed) into dst. dst may alias |
| 479 | + | // memory that d's borrowed fields view, such as the Event.Raw they were read from. | |||
| 463 | func (d *NoExposureEventData) Put(dst *[32]byte) { | 480 | func (d *NoExposureEventData) Put(dst *[32]byte) { | ||
| 464 | - | clear(dst[:]) | 481 | + | var tmp [32]byte |
| 465 | - | dst[0] = 14 | 482 | + | tmp[0] = 14 |
| 466 | - | binary.LittleEndian.PutUint32(dst[4:], uint32(d.Drawable)) | 483 | + | binary.LittleEndian.PutUint32(tmp[4:], uint32(d.Drawable)) |
| 467 | - | binary.LittleEndian.PutUint16(dst[8:], uint16(d.MinorOpcode)) | 484 | + | binary.LittleEndian.PutUint16(tmp[8:], uint16(d.MinorOpcode)) |
| 468 | - | dst[10:][0] = byte(d.MajorOpcode) | 485 | + | tmp[10:][0] = byte(d.MajorOpcode) |
| 486 | + | *dst = tmp | |||
| 469 | } | 487 | } | ||
| 470 | 488 | ||||
| 471 | // KindVisibilityNotify identifies VisibilityNotify events in xturbo.Event.Kind. | 489 | // KindVisibilityNotify identifies VisibilityNotify events in xturbo.Event.Kind. | ||
| @@ -488,12 +506,14 @@ type VisibilityNotifyEventData struct { | |||||
| 488 | State Visibility | 506 | State Visibility | ||
| 489 | } | 507 | } | ||
| 490 | 508 | ||||
| 491 | - | // Put writes the event (code 15, pads and sequence zeroed) into dst. | 509 | + | // Put writes the event (code 15, pads and sequence zeroed) into dst. dst may alias |
| 510 | + | // memory that d's borrowed fields view, such as the Event.Raw they were read from. | |||
| 492 | func (d *VisibilityNotifyEventData) Put(dst *[32]byte) { | 511 | func (d *VisibilityNotifyEventData) Put(dst *[32]byte) { | ||
| 493 | - | clear(dst[:]) | 512 | + | var tmp [32]byte |
| 494 | - | dst[0] = 15 | 513 | + | tmp[0] = 15 |
| 495 | - | binary.LittleEndian.PutUint32(dst[4:], uint32(d.Window)) | 514 | + | binary.LittleEndian.PutUint32(tmp[4:], uint32(d.Window)) |
| 496 | - | dst[8:][0] = byte(d.State) | 515 | + | tmp[8:][0] = byte(d.State) |
| 516 | + | *dst = tmp | |||
| 497 | } | 517 | } | ||
| 498 | 518 | ||||
| 499 | // KindCreateNotify identifies CreateNotify events in xturbo.Event.Kind. | 519 | // KindCreateNotify identifies CreateNotify events in xturbo.Event.Kind. | ||
| @@ -528,22 +548,24 @@ type CreateNotifyEventData struct { | |||||
| 528 | OverrideRedirect bool | 548 | OverrideRedirect bool | ||
| 529 | } | 549 | } | ||
| 530 | 550 | ||||
| 531 | - | // Put writes the event (code 16, pads and sequence zeroed) into dst. | 551 | + | // Put writes the event (code 16, pads and sequence zeroed) into dst. dst may alias |
| 552 | + | // memory that d's borrowed fields view, such as the Event.Raw they were read from. | |||
| 532 | func (d *CreateNotifyEventData) Put(dst *[32]byte) { | 553 | func (d *CreateNotifyEventData) Put(dst *[32]byte) { | ||
| 533 | - | clear(dst[:]) | 554 | + | var tmp [32]byte |
| 534 | - | dst[0] = 16 | 555 | + | tmp[0] = 16 |
| 535 | - | binary.LittleEndian.PutUint32(dst[4:], uint32(d.Parent)) | 556 | + | binary.LittleEndian.PutUint32(tmp[4:], uint32(d.Parent)) |
| 536 | - | binary.LittleEndian.PutUint32(dst[8:], uint32(d.Window)) | 557 | + | binary.LittleEndian.PutUint32(tmp[8:], uint32(d.Window)) |
| 537 | - | binary.LittleEndian.PutUint16(dst[12:], uint16(d.X)) | 558 | + | binary.LittleEndian.PutUint16(tmp[12:], uint16(d.X)) |
| 538 | - | binary.LittleEndian.PutUint16(dst[14:], uint16(d.Y)) | 559 | + | binary.LittleEndian.PutUint16(tmp[14:], uint16(d.Y)) |
| 539 | - | binary.LittleEndian.PutUint16(dst[16:], uint16(d.Width)) | 560 | + | binary.LittleEndian.PutUint16(tmp[16:], uint16(d.Width)) |
| 540 | - | binary.LittleEndian.PutUint16(dst[18:], uint16(d.Height)) | 561 | + | binary.LittleEndian.PutUint16(tmp[18:], uint16(d.Height)) |
| 541 | - | binary.LittleEndian.PutUint16(dst[20:], uint16(d.BorderWidth)) | 562 | + | binary.LittleEndian.PutUint16(tmp[20:], uint16(d.BorderWidth)) |
| 542 | if d.OverrideRedirect { | 563 | if d.OverrideRedirect { | ||
| 543 | - | dst[22:][0] = 1 | 564 | + | tmp[22:][0] = 1 |
| 544 | } else { | 565 | } else { | ||
| 545 | - | dst[22:][0] = 0 | 566 | + | tmp[22:][0] = 0 |
| 546 | } | 567 | } | ||
| 568 | + | *dst = tmp | |||
| 547 | } | 569 | } | ||
| 548 | 570 | ||||
| 549 | // KindDestroyNotify identifies DestroyNotify events in xturbo.Event.Kind. | 571 | // KindDestroyNotify identifies DestroyNotify events in xturbo.Event.Kind. | ||
| @@ -564,12 +586,14 @@ type DestroyNotifyEventData struct { | |||||
| 564 | Window Window | 586 | Window Window | ||
| 565 | } | 587 | } | ||
| 566 | 588 | ||||
| 567 | - | // Put writes the event (code 17, pads and sequence zeroed) into dst. | 589 | + | // Put writes the event (code 17, pads and sequence zeroed) into dst. dst may alias |
| 590 | + | // memory that d's borrowed fields view, such as the Event.Raw they were read from. | |||
| 568 | func (d *DestroyNotifyEventData) Put(dst *[32]byte) { | 591 | func (d *DestroyNotifyEventData) Put(dst *[32]byte) { | ||
| 569 | - | clear(dst[:]) | 592 | + | var tmp [32]byte |
| 570 | - | dst[0] = 17 | 593 | + | tmp[0] = 17 |
| 571 | - | binary.LittleEndian.PutUint32(dst[4:], uint32(d.Event)) | 594 | + | binary.LittleEndian.PutUint32(tmp[4:], uint32(d.Event)) |
| 572 | - | binary.LittleEndian.PutUint32(dst[8:], uint32(d.Window)) | 595 | + | binary.LittleEndian.PutUint32(tmp[8:], uint32(d.Window)) |
| 596 | + | *dst = tmp | |||
| 573 | } | 597 | } | ||
| 574 | 598 | ||||
| 575 | // KindUnmapNotify identifies UnmapNotify events in xturbo.Event.Kind. | 599 | // KindUnmapNotify identifies UnmapNotify events in xturbo.Event.Kind. | ||
| @@ -592,17 +616,19 @@ type UnmapNotifyEventData struct { | |||||
| 592 | FromConfigure bool | 616 | FromConfigure bool | ||
| 593 | } | 617 | } | ||
| 594 | 618 | ||||
| 595 | - | // Put writes the event (code 18, pads and sequence zeroed) into dst. | 619 | + | // Put writes the event (code 18, pads and sequence zeroed) into dst. dst may alias |
| 620 | + | // memory that d's borrowed fields view, such as the Event.Raw they were read from. | |||
| 596 | func (d *UnmapNotifyEventData) Put(dst *[32]byte) { | 621 | func (d *UnmapNotifyEventData) Put(dst *[32]byte) { | ||
| 597 | - | clear(dst[:]) | 622 | + | var tmp [32]byte |
| 598 | - | dst[0] = 18 | 623 | + | tmp[0] = 18 |
| 599 | - | binary.LittleEndian.PutUint32(dst[4:], uint32(d.Event)) | 624 | + | binary.LittleEndian.PutUint32(tmp[4:], uint32(d.Event)) |
| 600 | - | binary.LittleEndian.PutUint32(dst[8:], uint32(d.Window)) | 625 | + | binary.LittleEndian.PutUint32(tmp[8:], uint32(d.Window)) |
| 601 | if d.FromConfigure { | 626 | if d.FromConfigure { | ||
| 602 | - | dst[12:][0] = 1 | 627 | + | tmp[12:][0] = 1 |
| 603 | } else { | 628 | } else { | ||
| 604 | - | dst[12:][0] = 0 | 629 | + | tmp[12:][0] = 0 |
| 605 | } | 630 | } | ||
| 631 | + | *dst = tmp | |||
| 606 | } | 632 | } | ||
| 607 | 633 | ||||
| 608 | // KindMapNotify identifies MapNotify events in xturbo.Event.Kind. | 634 | // KindMapNotify identifies MapNotify events in xturbo.Event.Kind. | ||
| @@ -625,17 +651,19 @@ type MapNotifyEventData struct { | |||||
| 625 | OverrideRedirect bool | 651 | OverrideRedirect bool | ||
| 626 | } | 652 | } | ||
| 627 | 653 | ||||
| 628 | - | // Put writes the event (code 19, pads and sequence zeroed) into dst. | 654 | + | // Put writes the event (code 19, pads and sequence zeroed) into dst. dst may alias |
| 655 | + | // memory that d's borrowed fields view, such as the Event.Raw they were read from. | |||
| 629 | func (d *MapNotifyEventData) Put(dst *[32]byte) { | 656 | func (d *MapNotifyEventData) Put(dst *[32]byte) { | ||
| 630 | - | clear(dst[:]) | 657 | + | var tmp [32]byte |
| 631 | - | dst[0] = 19 | 658 | + | tmp[0] = 19 |
| 632 | - | binary.LittleEndian.PutUint32(dst[4:], uint32(d.Event)) | 659 | + | binary.LittleEndian.PutUint32(tmp[4:], uint32(d.Event)) |
| 633 | - | binary.LittleEndian.PutUint32(dst[8:], uint32(d.Window)) | 660 | + | binary.LittleEndian.PutUint32(tmp[8:], uint32(d.Window)) |
| 634 | if d.OverrideRedirect { | 661 | if d.OverrideRedirect { | ||
| 635 | - | dst[12:][0] = 1 | 662 | + | tmp[12:][0] = 1 |
| 636 | } else { | 663 | } else { | ||
| 637 | - | dst[12:][0] = 0 | 664 | + | tmp[12:][0] = 0 |
| 638 | } | 665 | } | ||
| 666 | + | *dst = tmp | |||
| 639 | } | 667 | } | ||
| 640 | 668 | ||||
| 641 | // KindMapRequest identifies MapRequest events in xturbo.Event.Kind. | 669 | // KindMapRequest identifies MapRequest events in xturbo.Event.Kind. | ||
| @@ -656,12 +684,14 @@ type MapRequestEventData struct { | |||||
| 656 | Window Window | 684 | Window Window | ||
| 657 | } | 685 | } | ||
| 658 | 686 | ||||
| 659 | - | // Put writes the event (code 20, pads and sequence zeroed) into dst. | 687 | + | // Put writes the event (code 20, pads and sequence zeroed) into dst. dst may alias |
| 688 | + | // memory that d's borrowed fields view, such as the Event.Raw they were read from. | |||
| 660 | func (d *MapRequestEventData) Put(dst *[32]byte) { | 689 | func (d *MapRequestEventData) Put(dst *[32]byte) { | ||
| 661 | - | clear(dst[:]) | 690 | + | var tmp [32]byte |
| 662 | - | dst[0] = 20 | 691 | + | tmp[0] = 20 |
| 663 | - | binary.LittleEndian.PutUint32(dst[4:], uint32(d.Parent)) | 692 | + | binary.LittleEndian.PutUint32(tmp[4:], uint32(d.Parent)) |
| 664 | - | binary.LittleEndian.PutUint32(dst[8:], uint32(d.Window)) | 693 | + | binary.LittleEndian.PutUint32(tmp[8:], uint32(d.Window)) |
| 694 | + | *dst = tmp | |||
| 665 | } | 695 | } | ||
| 666 | 696 | ||||
| 667 | // KindReparentNotify identifies ReparentNotify events in xturbo.Event.Kind. | 697 | // KindReparentNotify identifies ReparentNotify events in xturbo.Event.Kind. | ||
| @@ -690,20 +720,22 @@ type ReparentNotifyEventData struct { | |||||
| 690 | OverrideRedirect bool | 720 | OverrideRedirect bool | ||
| 691 | } | 721 | } | ||
| 692 | 722 | ||||
| 693 | - | // Put writes the event (code 21, pads and sequence zeroed) into dst. | 723 | + | // Put writes the event (code 21, pads and sequence zeroed) into dst. dst may alias |
| 724 | + | // memory that d's borrowed fields view, such as the Event.Raw they were read from. | |||
| 694 | func (d *ReparentNotifyEventData) Put(dst *[32]byte) { | 725 | func (d *ReparentNotifyEventData) Put(dst *[32]byte) { | ||
| 695 | - | clear(dst[:]) | 726 | + | var tmp [32]byte |
| 696 | - | dst[0] = 21 | 727 | + | tmp[0] = 21 |
| 697 | - | binary.LittleEndian.PutUint32(dst[4:], uint32(d.Event)) | 728 | + | binary.LittleEndian.PutUint32(tmp[4:], uint32(d.Event)) |
| 698 | - | binary.LittleEndian.PutUint32(dst[8:], uint32(d.Window)) | 729 | + | binary.LittleEndian.PutUint32(tmp[8:], uint32(d.Window)) |
| 699 | - | binary.LittleEndian.PutUint32(dst[12:], uint32(d.Parent)) | 730 | + | binary.LittleEndian.PutUint32(tmp[12:], uint32(d.Parent)) |
| 700 | - | binary.LittleEndian.PutUint16(dst[16:], uint16(d.X)) | 731 | + | binary.LittleEndian.PutUint16(tmp[16:], uint16(d.X)) |
| 701 | - | binary.LittleEndian.PutUint16(dst[18:], uint16(d.Y)) | 732 | + | binary.LittleEndian.PutUint16(tmp[18:], uint16(d.Y)) |
| 702 | if d.OverrideRedirect { | 733 | if d.OverrideRedirect { | ||
| 703 | - | dst[20:][0] = 1 | 734 | + | tmp[20:][0] = 1 |
| 704 | } else { | 735 | } else { | ||
| 705 | - | dst[20:][0] = 0 | 736 | + | tmp[20:][0] = 0 |
| 706 | } | 737 | } | ||
| 738 | + | *dst = tmp | |||
| 707 | } | 739 | } | ||
| 708 | 740 | ||||
| 709 | // KindConfigureNotify identifies ConfigureNotify events in xturbo.Event.Kind. | 741 | // KindConfigureNotify identifies ConfigureNotify events in xturbo.Event.Kind. | ||
| @@ -744,23 +776,25 @@ type ConfigureNotifyEventData struct { | |||||
| 744 | OverrideRedirect bool | 776 | OverrideRedirect bool | ||
| 745 | } | 777 | } | ||
| 746 | 778 | ||||
| 747 | - | // Put writes the event (code 22, pads and sequence zeroed) into dst. | 779 | + | // Put writes the event (code 22, pads and sequence zeroed) into dst. dst may alias |
| 780 | + | // memory that d's borrowed fields view, such as the Event.Raw they were read from. | |||
| 748 | func (d *ConfigureNotifyEventData) Put(dst *[32]byte) { | 781 | func (d *ConfigureNotifyEventData) Put(dst *[32]byte) { | ||
| 749 | - | clear(dst[:]) | 782 | + | var tmp [32]byte |
| 750 | - | dst[0] = 22 | 783 | + | tmp[0] = 22 |
| 751 | - | binary.LittleEndian.PutUint32(dst[4:], uint32(d.Event)) | 784 | + | binary.LittleEndian.PutUint32(tmp[4:], uint32(d.Event)) |
| 752 | - | binary.LittleEndian.PutUint32(dst[8:], uint32(d.Window)) | 785 | + | binary.LittleEndian.PutUint32(tmp[8:], uint32(d.Window)) |
| 753 | - | binary.LittleEndian.PutUint32(dst[12:], uint32(d.AboveSibling)) | 786 | + | binary.LittleEndian.PutUint32(tmp[12:], uint32(d.AboveSibling)) |
| 754 | - | binary.LittleEndian.PutUint16(dst[16:], uint16(d.X)) | 787 | + | binary.LittleEndian.PutUint16(tmp[16:], uint16(d.X)) |
| 755 | - | binary.LittleEndian.PutUint16(dst[18:], uint16(d.Y)) | 788 | + | binary.LittleEndian.PutUint16(tmp[18:], uint16(d.Y)) |
| 756 | - | binary.LittleEndian.PutUint16(dst[20:], uint16(d.Width)) | 789 | + | binary.LittleEndian.PutUint16(tmp[20:], uint16(d.Width)) |
| 757 | - | binary.LittleEndian.PutUint16(dst[22:], uint16(d.Height)) | 790 | + | binary.LittleEndian.PutUint16(tmp[22:], uint16(d.Height)) |
| 758 | - | binary.LittleEndian.PutUint16(dst[24:], uint16(d.BorderWidth)) | 791 | + | binary.LittleEndian.PutUint16(tmp[24:], uint16(d.BorderWidth)) |
| 759 | if d.OverrideRedirect { | 792 | if d.OverrideRedirect { | ||
| 760 | - | dst[26:][0] = 1 | 793 | + | tmp[26:][0] = 1 |
| 761 | } else { | 794 | } else { | ||
| 762 | - | dst[26:][0] = 0 | 795 | + | tmp[26:][0] = 0 |
| 763 | } | 796 | } | ||
| 797 | + | *dst = tmp | |||
| 764 | } | 798 | } | ||
| 765 | 799 | ||||
| 766 | // KindConfigureRequest identifies ConfigureRequest events in xturbo.Event.Kind. | 800 | // KindConfigureRequest identifies ConfigureRequest events in xturbo.Event.Kind. | ||
| @@ -805,20 +839,22 @@ type ConfigureRequestEventData struct { | |||||
| 805 | ValueMask ConfigWindow | 839 | ValueMask ConfigWindow | ||
| 806 | } | 840 | } | ||
| 807 | 841 | ||||
| 808 | - | // Put writes the event (code 23, pads and sequence zeroed) into dst. | 842 | + | // Put writes the event (code 23, pads and sequence zeroed) into dst. dst may alias |
| 843 | + | // memory that d's borrowed fields view, such as the Event.Raw they were read from. | |||
| 809 | func (d *ConfigureRequestEventData) Put(dst *[32]byte) { | 844 | func (d *ConfigureRequestEventData) Put(dst *[32]byte) { | ||
| 810 | - | clear(dst[:]) | 845 | + | var tmp [32]byte |
| 811 | - | dst[0] = 23 | 846 | + | tmp[0] = 23 |
| 812 | - | dst[1:][0] = byte(d.StackMode) | 847 | + | tmp[1:][0] = byte(d.StackMode) |
| 813 | - | binary.LittleEndian.PutUint32(dst[4:], uint32(d.Parent)) | 848 | + | binary.LittleEndian.PutUint32(tmp[4:], uint32(d.Parent)) |
| 814 | - | binary.LittleEndian.PutUint32(dst[8:], uint32(d.Window)) | 849 | + | binary.LittleEndian.PutUint32(tmp[8:], uint32(d.Window)) |
| 815 | - | binary.LittleEndian.PutUint32(dst[12:], uint32(d.Sibling)) | 850 | + | binary.LittleEndian.PutUint32(tmp[12:], uint32(d.Sibling)) |
| 816 | - | binary.LittleEndian.PutUint16(dst[16:], uint16(d.X)) | 851 | + | binary.LittleEndian.PutUint16(tmp[16:], uint16(d.X)) |
| 817 | - | binary.LittleEndian.PutUint16(dst[18:], uint16(d.Y)) | 852 | + | binary.LittleEndian.PutUint16(tmp[18:], uint16(d.Y)) |
| 818 | - | binary.LittleEndian.PutUint16(dst[20:], uint16(d.Width)) | 853 | + | binary.LittleEndian.PutUint16(tmp[20:], uint16(d.Width)) |
| 819 | - | binary.LittleEndian.PutUint16(dst[22:], uint16(d.Height)) | 854 | + | binary.LittleEndian.PutUint16(tmp[22:], uint16(d.Height)) |
| 820 | - | binary.LittleEndian.PutUint16(dst[24:], uint16(d.BorderWidth)) | 855 | + | binary.LittleEndian.PutUint16(tmp[24:], uint16(d.BorderWidth)) |
| 821 | - | binary.LittleEndian.PutUint16(dst[26:], uint16(d.ValueMask)) | 856 | + | binary.LittleEndian.PutUint16(tmp[26:], uint16(d.ValueMask)) |
| 857 | + | *dst = tmp | |||
| 822 | } | 858 | } | ||
| 823 | 859 | ||||
| 824 | // KindGravityNotify identifies GravityNotify events in xturbo.Event.Kind. | 860 | // KindGravityNotify identifies GravityNotify events in xturbo.Event.Kind. | ||
| @@ -843,14 +879,16 @@ type GravityNotifyEventData struct { | |||||
| 843 | Y int16 | 879 | Y int16 | ||
| 844 | } | 880 | } | ||
| 845 | 881 | ||||
| 846 | - | // Put writes the event (code 24, pads and sequence zeroed) into dst. | 882 | + | // Put writes the event (code 24, pads and sequence zeroed) into dst. dst may alias |
| 883 | + | // memory that d's borrowed fields view, such as the Event.Raw they were read from. | |||
| 847 | func (d *GravityNotifyEventData) Put(dst *[32]byte) { | 884 | func (d *GravityNotifyEventData) Put(dst *[32]byte) { | ||
| 848 | - | clear(dst[:]) | 885 | + | var tmp [32]byte |
| 849 | - | dst[0] = 24 | 886 | + | tmp[0] = 24 |
| 850 | - | binary.LittleEndian.PutUint32(dst[4:], uint32(d.Event)) | 887 | + | binary.LittleEndian.PutUint32(tmp[4:], uint32(d.Event)) |
| 851 | - | binary.LittleEndian.PutUint32(dst[8:], uint32(d.Window)) | 888 | + | binary.LittleEndian.PutUint32(tmp[8:], uint32(d.Window)) |
| 852 | - | binary.LittleEndian.PutUint16(dst[12:], uint16(d.X)) | 889 | + | binary.LittleEndian.PutUint16(tmp[12:], uint16(d.X)) |
| 853 | - | binary.LittleEndian.PutUint16(dst[14:], uint16(d.Y)) | 890 | + | binary.LittleEndian.PutUint16(tmp[14:], uint16(d.Y)) |
| 891 | + | *dst = tmp | |||
| 854 | } | 892 | } | ||
| 855 | 893 | ||||
| 856 | // KindResizeRequest identifies ResizeRequest events in xturbo.Event.Kind. | 894 | // KindResizeRequest identifies ResizeRequest events in xturbo.Event.Kind. | ||
| @@ -873,13 +911,15 @@ type ResizeRequestEventData struct { | |||||
| 873 | Height uint16 | 911 | Height uint16 | ||
| 874 | } | 912 | } | ||
| 875 | 913 | ||||
| 876 | - | // Put writes the event (code 25, pads and sequence zeroed) into dst. | 914 | + | // Put writes the event (code 25, pads and sequence zeroed) into dst. dst may alias |
| 915 | + | // memory that d's borrowed fields view, such as the Event.Raw they were read from. | |||
| 877 | func (d *ResizeRequestEventData) Put(dst *[32]byte) { | 916 | func (d *ResizeRequestEventData) Put(dst *[32]byte) { | ||
| 878 | - | clear(dst[:]) | 917 | + | var tmp [32]byte |
| 879 | - | dst[0] = 25 | 918 | + | tmp[0] = 25 |
| 880 | - | binary.LittleEndian.PutUint32(dst[4:], uint32(d.Window)) | 919 | + | binary.LittleEndian.PutUint32(tmp[4:], uint32(d.Window)) |
| 881 | - | binary.LittleEndian.PutUint16(dst[8:], uint16(d.Width)) | 920 | + | binary.LittleEndian.PutUint16(tmp[8:], uint16(d.Width)) |
| 882 | - | binary.LittleEndian.PutUint16(dst[10:], uint16(d.Height)) | 921 | + | binary.LittleEndian.PutUint16(tmp[10:], uint16(d.Height)) |
| 922 | + | *dst = tmp | |||
| 883 | } | 923 | } | ||
| 884 | 924 | ||||
| 885 | // KindCirculateNotify identifies CirculateNotify events in xturbo.Event.Kind. | 925 | // KindCirculateNotify identifies CirculateNotify events in xturbo.Event.Kind. | ||
| @@ -904,13 +944,15 @@ type CirculateNotifyEventData struct { | |||||
| 904 | Place Place | 944 | Place Place | ||
| 905 | } | 945 | } | ||
| 906 | 946 | ||||
| 907 | - | // Put writes the event (code 26, pads and sequence zeroed) into dst. | 947 | + | // Put writes the event (code 26, pads and sequence zeroed) into dst. dst may alias |
| 948 | + | // memory that d's borrowed fields view, such as the Event.Raw they were read from. | |||
| 908 | func (d *CirculateNotifyEventData) Put(dst *[32]byte) { | 949 | func (d *CirculateNotifyEventData) Put(dst *[32]byte) { | ||
| 909 | - | clear(dst[:]) | 950 | + | var tmp [32]byte |
| 910 | - | dst[0] = 26 | 951 | + | tmp[0] = 26 |
| 911 | - | binary.LittleEndian.PutUint32(dst[4:], uint32(d.Event)) | 952 | + | binary.LittleEndian.PutUint32(tmp[4:], uint32(d.Event)) |
| 912 | - | binary.LittleEndian.PutUint32(dst[8:], uint32(d.Window)) | 953 | + | binary.LittleEndian.PutUint32(tmp[8:], uint32(d.Window)) |
| 913 | - | dst[16:][0] = byte(d.Place) | 954 | + | tmp[16:][0] = byte(d.Place) |
| 955 | + | *dst = tmp | |||
| 914 | } | 956 | } | ||
| 915 | 957 | ||||
| 916 | // KindCirculateRequest identifies CirculateRequest events in xturbo.Event.Kind. | 958 | // KindCirculateRequest identifies CirculateRequest events in xturbo.Event.Kind. | ||
| @@ -955,14 +997,16 @@ type PropertyNotifyEventData struct { | |||||
| 955 | State Property | 997 | State Property | ||
| 956 | } | 998 | } | ||
| 957 | 999 | ||||
| 958 | - | // Put writes the event (code 28, pads and sequence zeroed) into dst. | 1000 | + | // Put writes the event (code 28, pads and sequence zeroed) into dst. dst may alias |
| 1001 | + | // memory that d's borrowed fields view, such as the Event.Raw they were read from. | |||
| 959 | func (d *PropertyNotifyEventData) Put(dst *[32]byte) { | 1002 | func (d *PropertyNotifyEventData) Put(dst *[32]byte) { | ||
| 960 | - | clear(dst[:]) | 1003 | + | var tmp [32]byte |
| 961 | - | dst[0] = 28 | 1004 | + | tmp[0] = 28 |
| 962 | - | binary.LittleEndian.PutUint32(dst[4:], uint32(d.Window)) | 1005 | + | binary.LittleEndian.PutUint32(tmp[4:], uint32(d.Window)) |
| 963 | - | binary.LittleEndian.PutUint32(dst[8:], uint32(d.Atom)) | 1006 | + | binary.LittleEndian.PutUint32(tmp[8:], uint32(d.Atom)) |
| 964 | - | binary.LittleEndian.PutUint32(dst[12:], uint32(d.Time)) | 1007 | + | binary.LittleEndian.PutUint32(tmp[12:], uint32(d.Time)) |
| 965 | - | dst[16:][0] = byte(d.State) | 1008 | + | tmp[16:][0] = byte(d.State) |
| 1009 | + | *dst = tmp | |||
| 966 | } | 1010 | } | ||
| 967 | 1011 | ||||
| 968 | // KindSelectionClear identifies SelectionClear events in xturbo.Event.Kind. | 1012 | // KindSelectionClear identifies SelectionClear events in xturbo.Event.Kind. | ||
| @@ -987,13 +1031,15 @@ type SelectionClearEventData struct { | |||||
| 987 | Selection Atom | 1031 | Selection Atom | ||
| 988 | } | 1032 | } | ||
| 989 | 1033 | ||||
| 990 | - | // Put writes the event (code 29, pads and sequence zeroed) into dst. | 1034 | + | // Put writes the event (code 29, pads and sequence zeroed) into dst. dst may alias |
| 1035 | + | // memory that d's borrowed fields view, such as the Event.Raw they were read from. | |||
| 991 | func (d *SelectionClearEventData) Put(dst *[32]byte) { | 1036 | func (d *SelectionClearEventData) Put(dst *[32]byte) { | ||
| 992 | - | clear(dst[:]) | 1037 | + | var tmp [32]byte |
| 993 | - | dst[0] = 29 | 1038 | + | tmp[0] = 29 |
| 994 | - | binary.LittleEndian.PutUint32(dst[4:], uint32(d.Time)) | 1039 | + | binary.LittleEndian.PutUint32(tmp[4:], uint32(d.Time)) |
| 995 | - | binary.LittleEndian.PutUint32(dst[8:], uint32(d.Owner)) | 1040 | + | binary.LittleEndian.PutUint32(tmp[8:], uint32(d.Owner)) |
| 996 | - | binary.LittleEndian.PutUint32(dst[12:], uint32(d.Selection)) | 1041 | + | binary.LittleEndian.PutUint32(tmp[12:], uint32(d.Selection)) |
| 1042 | + | *dst = tmp | |||
| 997 | } | 1043 | } | ||
| 998 | 1044 | ||||
| 999 | // KindSelectionRequest identifies SelectionRequest events in xturbo.Event.Kind. | 1045 | // KindSelectionRequest identifies SelectionRequest events in xturbo.Event.Kind. | ||
| @@ -1028,16 +1074,18 @@ type SelectionRequestEventData struct { | |||||
| 1028 | Property Atom | 1074 | Property Atom | ||
| 1029 | } | 1075 | } | ||
| 1030 | 1076 | ||||
| 1031 | - | // Put writes the event (code 30, pads and sequence zeroed) into dst. | 1077 | + | // Put writes the event (code 30, pads and sequence zeroed) into dst. dst may alias |
| 1078 | + | // memory that d's borrowed fields view, such as the Event.Raw they were read from. | |||
| 1032 | func (d *SelectionRequestEventData) Put(dst *[32]byte) { | 1079 | func (d *SelectionRequestEventData) Put(dst *[32]byte) { | ||
| 1033 | - | clear(dst[:]) | 1080 | + | var tmp [32]byte |
| 1034 | - | dst[0] = 30 | 1081 | + | tmp[0] = 30 |
| 1035 | - | binary.LittleEndian.PutUint32(dst[4:], uint32(d.Time)) | 1082 | + | binary.LittleEndian.PutUint32(tmp[4:], uint32(d.Time)) |
| 1036 | - | binary.LittleEndian.PutUint32(dst[8:], uint32(d.Owner)) | 1083 | + | binary.LittleEndian.PutUint32(tmp[8:], uint32(d.Owner)) |
| 1037 | - | binary.LittleEndian.PutUint32(dst[12:], uint32(d.Requestor)) | 1084 | + | binary.LittleEndian.PutUint32(tmp[12:], uint32(d.Requestor)) |
| 1038 | - | binary.LittleEndian.PutUint32(dst[16:], uint32(d.Selection)) | 1085 | + | binary.LittleEndian.PutUint32(tmp[16:], uint32(d.Selection)) |
| 1039 | - | binary.LittleEndian.PutUint32(dst[20:], uint32(d.Target)) | 1086 | + | binary.LittleEndian.PutUint32(tmp[20:], uint32(d.Target)) |
| 1040 | - | binary.LittleEndian.PutUint32(dst[24:], uint32(d.Property)) | 1087 | + | binary.LittleEndian.PutUint32(tmp[24:], uint32(d.Property)) |
| 1088 | + | *dst = tmp | |||
| 1041 | } | 1089 | } | ||
| 1042 | 1090 | ||||
| 1043 | // KindSelectionNotify identifies SelectionNotify events in xturbo.Event.Kind. | 1091 | // KindSelectionNotify identifies SelectionNotify events in xturbo.Event.Kind. | ||
| @@ -1070,15 +1118,17 @@ type SelectionNotifyEventData struct { | |||||
| 1070 | Property Atom | 1118 | Property Atom | ||
| 1071 | } | 1119 | } | ||
| 1072 | 1120 | ||||
| 1073 | - | // Put writes the event (code 31, pads and sequence zeroed) into dst. | 1121 | + | // Put writes the event (code 31, pads and sequence zeroed) into dst. dst may alias |
| 1122 | + | // memory that d's borrowed fields view, such as the Event.Raw they were read from. | |||
| 1074 | func (d *SelectionNotifyEventData) Put(dst *[32]byte) { | 1123 | func (d *SelectionNotifyEventData) Put(dst *[32]byte) { | ||
| 1075 | - | clear(dst[:]) | 1124 | + | var tmp [32]byte |
| 1076 | - | dst[0] = 31 | 1125 | + | tmp[0] = 31 |
| 1077 | - | binary.LittleEndian.PutUint32(dst[4:], uint32(d.Time)) | 1126 | + | binary.LittleEndian.PutUint32(tmp[4:], uint32(d.Time)) |
| 1078 | - | binary.LittleEndian.PutUint32(dst[8:], uint32(d.Requestor)) | 1127 | + | binary.LittleEndian.PutUint32(tmp[8:], uint32(d.Requestor)) |
| 1079 | - | binary.LittleEndian.PutUint32(dst[12:], uint32(d.Selection)) | 1128 | + | binary.LittleEndian.PutUint32(tmp[12:], uint32(d.Selection)) |
| 1080 | - | binary.LittleEndian.PutUint32(dst[16:], uint32(d.Target)) | 1129 | + | binary.LittleEndian.PutUint32(tmp[16:], uint32(d.Target)) |
| 1081 | - | binary.LittleEndian.PutUint32(dst[20:], uint32(d.Property)) | 1130 | + | binary.LittleEndian.PutUint32(tmp[20:], uint32(d.Property)) |
| 1131 | + | *dst = tmp | |||
| 1082 | } | 1132 | } | ||
| 1083 | 1133 | ||||
| 1084 | // KindColormapNotify identifies ColormapNotify events in xturbo.Event.Kind. | 1134 | // KindColormapNotify identifies ColormapNotify events in xturbo.Event.Kind. | ||
| @@ -1105,18 +1155,20 @@ type ColormapNotifyEventData struct { | |||||
| 1105 | State ColormapState | 1155 | State ColormapState | ||
| 1106 | } | 1156 | } | ||
| 1107 | 1157 | ||||
| 1108 | - | // Put writes the event (code 32, pads and sequence zeroed) into dst. | 1158 | + | // Put writes the event (code 32, pads and sequence zeroed) into dst. dst may alias |
| 1159 | + | // memory that d's borrowed fields view, such as the Event.Raw they were read from. | |||
| 1109 | func (d *ColormapNotifyEventData) Put(dst *[32]byte) { | 1160 | func (d *ColormapNotifyEventData) Put(dst *[32]byte) { | ||
| 1110 | - | clear(dst[:]) | 1161 | + | var tmp [32]byte |
| 1111 | - | dst[0] = 32 | 1162 | + | tmp[0] = 32 |
| 1112 | - | binary.LittleEndian.PutUint32(dst[4:], uint32(d.Window)) | 1163 | + | binary.LittleEndian.PutUint32(tmp[4:], uint32(d.Window)) |
| 1113 | - | binary.LittleEndian.PutUint32(dst[8:], uint32(d.Colormap)) | 1164 | + | binary.LittleEndian.PutUint32(tmp[8:], uint32(d.Colormap)) |
| 1114 | if d.New { | 1165 | if d.New { | ||
| 1115 | - | dst[12:][0] = 1 | 1166 | + | tmp[12:][0] = 1 |
| 1116 | } else { | 1167 | } else { | ||
| 1117 | - | dst[12:][0] = 0 | 1168 | + | tmp[12:][0] = 0 |
| 1118 | } | 1169 | } | ||
| 1119 | - | dst[13:][0] = byte(d.State) | 1170 | + | tmp[13:][0] = byte(d.State) |
| 1171 | + | *dst = tmp | |||
| 1120 | } | 1172 | } | ||
| 1121 | 1173 | ||||
| 1122 | // KindClientMessage identifies ClientMessage events in xturbo.Event.Kind. | 1174 | // KindClientMessage identifies ClientMessage events in xturbo.Event.Kind. | ||
| @@ -1141,14 +1193,16 @@ type ClientMessageEventData struct { | |||||
| 1141 | Data ClientMessageData | 1193 | Data ClientMessageData | ||
| 1142 | } | 1194 | } | ||
| 1143 | 1195 | ||||
| 1144 | - | // Put writes the event (code 33, pads and sequence zeroed) into dst. | 1196 | + | // Put writes the event (code 33, pads and sequence zeroed) into dst. dst may alias |
| 1197 | + | // memory that d's borrowed fields view, such as the Event.Raw they were read from. | |||
| 1145 | func (d *ClientMessageEventData) Put(dst *[32]byte) { | 1198 | func (d *ClientMessageEventData) Put(dst *[32]byte) { | ||
| 1146 | - | clear(dst[:]) | 1199 | + | var tmp [32]byte |
| 1147 | - | dst[0] = 33 | 1200 | + | tmp[0] = 33 |
| 1148 | - | dst[1:][0] = byte(d.Format) | 1201 | + | tmp[1:][0] = byte(d.Format) |
| 1149 | - | binary.LittleEndian.PutUint32(dst[4:], uint32(d.Window)) | 1202 | + | binary.LittleEndian.PutUint32(tmp[4:], uint32(d.Window)) |
| 1150 | - | binary.LittleEndian.PutUint32(dst[8:], uint32(d.Type)) | 1203 | + | binary.LittleEndian.PutUint32(tmp[8:], uint32(d.Type)) |
| 1151 | - | d.Data.Put(dst[12:]) | 1204 | + | d.Data.Put(tmp[12:]) |
| 1205 | + | *dst = tmp | |||
| 1152 | } | 1206 | } | ||
| 1153 | 1207 | ||||
| 1154 | // KindMappingNotify identifies MappingNotify events in xturbo.Event.Kind. | 1208 | // KindMappingNotify identifies MappingNotify events in xturbo.Event.Kind. | ||
| @@ -1171,13 +1225,15 @@ type MappingNotifyEventData struct { | |||||
| 1171 | Count uint8 | 1225 | Count uint8 | ||
| 1172 | } | 1226 | } | ||
| 1173 | 1227 | ||||
| 1174 | - | // Put writes the event (code 34, pads and sequence zeroed) into dst. | 1228 | + | // Put writes the event (code 34, pads and sequence zeroed) into dst. dst may alias |
| 1229 | + | // memory that d's borrowed fields view, such as the Event.Raw they were read from. | |||
| 1175 | func (d *MappingNotifyEventData) Put(dst *[32]byte) { | 1230 | func (d *MappingNotifyEventData) Put(dst *[32]byte) { | ||
| 1176 | - | clear(dst[:]) | 1231 | + | var tmp [32]byte |
| 1177 | - | dst[0] = 34 | 1232 | + | tmp[0] = 34 |
| 1178 | - | dst[4:][0] = byte(d.Request) | 1233 | + | tmp[4:][0] = byte(d.Request) |
| 1179 | - | dst[5:][0] = byte(d.FirstKeycode) | 1234 | + | tmp[5:][0] = byte(d.FirstKeycode) |
| 1180 | - | dst[6:][0] = byte(d.Count) | 1235 | + | tmp[6:][0] = byte(d.Count) |
| 1236 | + | *dst = tmp | |||
| 1181 | } | 1237 | } | ||
| 1182 | 1238 | ||||
| 1183 | // GeGenericEvent is a view over a GeGeneric generic event: the copied Event.Raw plus the borrowed Event.Tail. | 1239 | // GeGenericEvent is a view over a GeGeneric generic event: the copied Event.Raw plus the borrowed Event.Tail. | ||